r17417 by fschmid - Convert old tables to new tables upon loading and importing.

scribus-commit scribus-commit at lists.scribus.net
Wed Apr 4 21:29:31 UTC 2012


Author: fschmid
Date: Wed Apr  4 21:29:31 2012
New Revision: 17417

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17417
Log:
Convert old tables to new tables upon loading and importing.

Modified:
    trunk/Scribus/scribus/collapsedtablepainter.cpp
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/ui/propertiespalette_table.cpp
    trunk/Scribus/scribus/util.cpp
    trunk/Scribus/scribus/util.h

Modified: trunk/Scribus/scribus/collapsedtablepainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/collapsedtablepainter.cpp
==============================================================================
--- trunk/Scribus/scribus/collapsedtablepainter.cpp (original)
+++ trunk/Scribus/scribus/collapsedtablepainter.cpp Wed Apr  4 21:29:31 2012
@@ -496,6 +496,8 @@
 		lineEnd.setX(end.x() + line.width() * endOffsetFactors.x());
 		lineEnd.setY(end.y() + line.width() * endOffsetFactors.y());
 		// Set line color.
+		if (line.color() == CommonStrings::None)
+			continue;
 		table()->SetQColor(&lineColor, line.color(), line.shade());
 		// Draw line.
 		p->setPen(lineColor, line.width(), line.style(), Qt::FlatCap, Qt::MiterJoin);

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Wed Apr  4 21:29:31 2012
@@ -4643,14 +4643,15 @@
 	QVector<double> DashValues;
 	foreach (const TableBorderLine& line, border.borderLines())
 	{
+		if (line.color() == CommonStrings::None)
+			continue;
 		lineStart.setX(start.x() + line.width() * startOffsetFactors.x());
 		lineStart.setY(start.y() + line.width() * startOffsetFactors.y());
 		lineEnd.setX(end.x() + line.width() * endOffsetFactors.x());
 		lineEnd.setY(end.y() + line.width() * endOffsetFactors.y());
 		tmp += FToStr(lineStart.x())+" "+FToStr(-lineStart.y())+" m\n";
 		tmp += FToStr(lineEnd.x())+" "+FToStr(-lineEnd.y())+" l\n";
-		if (line.color() != CommonStrings::None)
-			tmp += putColor(line.color(), line.shade(), false);
+		tmp += putColor(line.color(), line.shade(), false);
 		tmp += FToStr(fabs(line.width()))+" w\n";
 		getDashArray(line.style(), qMax(line.width(), 1.0), DashValues);
 		if (DashValues.count() != 0)

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp Wed Apr  4 21:29:31 2012
@@ -12,6 +12,7 @@
 #include "ui/missing.h"
 #include "prefsmanager.h"
 #include "pageitem_latexframe.h"
+#include "pageitem_group.h"
 #include "scconfig.h"
 #include "scclocale.h"
 #include "scribusdoc.h"
@@ -1293,6 +1294,54 @@
 		if (item->prevInChain() == 0 && item->itemText.length() > 0)
 			item->itemText.fixLegacyFormatting();
 	}
+	for (int i = 0; i < m_Doc->DocItems.count(); ++i)
+	{
+		QList<PageItem*> allItems;
+		PageItem* item = m_Doc->DocItems.at(i);
+		if (item->isGroup())
+			allItems = item->asGroupFrame()->getItemList();
+		else
+			allItems.append(item);
+		for (int ii = 0; ii < allItems.count(); ii++)
+		{
+			PageItem* gItem = allItems[ii];
+			if (gItem->isGroup())
+			{
+				if (gItem->groupItemList[0]->isTableItem)
+				{
+					if (gItem->Parent == NULL)
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &m_Doc->DocItems);
+					else
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &(gItem->asGroupFrame()->groupItemList));
+				}
+			}
+		}
+		allItems.clear();
+	}
+	for (int i = 0; i < m_Doc->MasterItems.count(); ++i)
+	{
+		QList<PageItem*> allItems;
+		PageItem* item = m_Doc->MasterItems.at(i);
+		if (item->isGroup())
+			allItems = item->asGroupFrame()->getItemList();
+		else
+			allItems.append(item);
+		for (int ii = 0; ii < allItems.count(); ii++)
+		{
+			PageItem* gItem = allItems[ii];
+			if (gItem->isGroup())
+			{
+				if (gItem->groupItemList[0]->isTableItem)
+				{
+					if (gItem->Parent == NULL)
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &m_Doc->MasterItems);
+					else
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &(gItem->asGroupFrame()->groupItemList));
+				}
+			}
+		}
+		allItems.clear();
+	}
 	
 	setCurrentComboItem(m_View->unitSwitcher, unitGetStrFromIndex(m_Doc->unitIndex()));
 	if (m_mwProgressBar!=0)
@@ -2047,6 +2096,54 @@
 					if (item->prevInChain() == 0 && item->itemText.length() > 0)
 						item->itemText.fixLegacyFormatting();
 				}
+				for (int i = 0; i < m_Doc->DocItems.count(); ++i)
+				{
+					QList<PageItem*> allItems;
+					PageItem* item = m_Doc->DocItems.at(i);
+					if (item->isGroup())
+						allItems = item->asGroupFrame()->getItemList();
+					else
+						allItems.append(item);
+					for (int ii = 0; ii < allItems.count(); ii++)
+					{
+						PageItem* gItem = allItems[ii];
+						if (gItem->isGroup())
+						{
+							if (gItem->groupItemList[0]->isTableItem)
+							{
+								if (gItem->Parent == NULL)
+									convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &m_Doc->DocItems);
+								else
+									convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &(gItem->asGroupFrame()->groupItemList));
+							}
+						}
+					}
+					allItems.clear();
+				}
+				for (int i = 0; i < m_Doc->MasterItems.count(); ++i)
+				{
+					QList<PageItem*> allItems;
+					PageItem* item = m_Doc->MasterItems.at(i);
+					if (item->isGroup())
+						allItems = item->asGroupFrame()->getItemList();
+					else
+						allItems.append(item);
+					for (int ii = 0; ii < allItems.count(); ii++)
+					{
+						PageItem* gItem = allItems[ii];
+						if (gItem->isGroup())
+						{
+							if (gItem->groupItemList[0]->isTableItem)
+							{
+								if (gItem->Parent == NULL)
+									convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &m_Doc->MasterItems);
+								else
+									convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &(gItem->asGroupFrame()->groupItemList));
+							}
+						}
+					}
+					allItems.clear();
+				}
 				
 				if (!Mpage)
 					m_View->reformPages();

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Wed Apr  4 21:29:31 2012
@@ -12,6 +12,7 @@
 #include "ui/missing.h"
 #include "hyphenator.h"
 #include "pageitem_latexframe.h"
+#include "pageitem_table.h"
 #include "prefsmanager.h"
 #include "scclocale.h"
 #include "scconfig.h"
@@ -628,11 +629,13 @@
 	{
 		while (groupStackP.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackP.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -647,18 +650,23 @@
 				}
 				m_Doc->DocItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackP, &m_Doc->DocItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	if (groupStackF.count() > 0)
 	{
 		while (groupStackF.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackF.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -673,18 +681,23 @@
 				}
 				m_Doc->FrameItems.remove(m_Doc->FrameItems.key(cItem));
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackF, NULL);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	if (groupStackM.count() > 0)
 	{
 		while (groupStackM.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackM.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -699,7 +712,10 @@
 				}
 				m_Doc->MasterItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackM, &m_Doc->MasterItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	
@@ -2143,11 +2159,13 @@
 	{
 		while (groupStackP.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackP.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -2162,7 +2180,10 @@
 				}
 				m_Doc->DocItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackP, &m_Doc->DocItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp Wed Apr  4 21:29:31 2012
@@ -10,6 +10,7 @@
 #include "../../formatidlist.h"
 #include "commonstrings.h"
 #include "ui/missing.h"
+#include "pageitem_group.h"
 #include "prefsmanager.h"
 #include "scconfig.h"
 #include "scribusdoc.h"
@@ -1115,6 +1116,54 @@
 		if (item->prevInChain() == 0 && item->itemText.length() > 0)
 			item->itemText.fixLegacyFormatting();
 	}
+	for (int i = 0; i < m_Doc->DocItems.count(); ++i)
+	{
+		QList<PageItem*> allItems;
+		PageItem* item = m_Doc->DocItems.at(i);
+		if (item->isGroup())
+			allItems = item->asGroupFrame()->getItemList();
+		else
+			allItems.append(item);
+		for (int ii = 0; ii < allItems.count(); ii++)
+		{
+			PageItem* gItem = allItems[ii];
+			if (gItem->isGroup())
+			{
+				if (gItem->groupItemList[0]->isTableItem)
+				{
+					if (gItem->Parent == NULL)
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &m_Doc->DocItems);
+					else
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &(gItem->asGroupFrame()->groupItemList));
+				}
+			}
+		}
+		allItems.clear();
+	}
+	for (int i = 0; i < m_Doc->MasterItems.count(); ++i)
+	{
+		QList<PageItem*> allItems;
+		PageItem* item = m_Doc->MasterItems.at(i);
+		if (item->isGroup())
+			allItems = item->asGroupFrame()->getItemList();
+		else
+			allItems.append(item);
+		for (int ii = 0; ii < allItems.count(); ii++)
+		{
+			PageItem* gItem = allItems[ii];
+			if (gItem->isGroup())
+			{
+				if (gItem->groupItemList[0]->isTableItem)
+				{
+					if (gItem->Parent == NULL)
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &m_Doc->MasterItems);
+					else
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &(gItem->asGroupFrame()->groupItemList));
+				}
+			}
+		}
+		allItems.clear();
+	}
 
 	// start auto save timer if needed
 	if (m_Doc->autoSave() && ScCore->usingGUI())
@@ -2382,6 +2431,54 @@
 		if (item->prevInChain() == 0 && item->itemText.length() > 0)
 			item->itemText.fixLegacyFormatting();
 	}
+	for (int i = 0; i < m_Doc->DocItems.count(); ++i)
+	{
+		QList<PageItem*> allItems;
+		PageItem* item = m_Doc->DocItems.at(i);
+		if (item->isGroup())
+			allItems = item->asGroupFrame()->getItemList();
+		else
+			allItems.append(item);
+		for (int ii = 0; ii < allItems.count(); ii++)
+		{
+			PageItem* gItem = allItems[ii];
+			if (gItem->isGroup())
+			{
+				if (gItem->groupItemList[0]->isTableItem)
+				{
+					if (gItem->Parent == NULL)
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &m_Doc->DocItems);
+					else
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &(gItem->asGroupFrame()->groupItemList));
+				}
+			}
+		}
+		allItems.clear();
+	}
+	for (int i = 0; i < m_Doc->MasterItems.count(); ++i)
+	{
+		QList<PageItem*> allItems;
+		PageItem* item = m_Doc->MasterItems.at(i);
+		if (item->isGroup())
+			allItems = item->asGroupFrame()->getItemList();
+		else
+			allItems.append(item);
+		for (int ii = 0; ii < allItems.count(); ii++)
+		{
+			PageItem* gItem = allItems[ii];
+			if (gItem->isGroup())
+			{
+				if (gItem->groupItemList[0]->isTableItem)
+				{
+					if (gItem->Parent == NULL)
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &m_Doc->MasterItems);
+					else
+						convertOldTable(m_Doc, gItem, gItem->groupItemList, NULL, &(gItem->asGroupFrame()->groupItemList));
+				}
+			}
+		}
+		allItems.clear();
+	}
 	
 	return true;
 }

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Wed Apr  4 21:29:31 2012
@@ -554,11 +554,13 @@
 	{
 		while (groupStackP.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackP.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -573,18 +575,23 @@
 				}
 				m_Doc->DocItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackP, &m_Doc->DocItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	if (groupStackF.count() > 0)
 	{
 		while (groupStackF.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackF.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -599,18 +606,23 @@
 				}
 				m_Doc->FrameItems.remove(m_Doc->FrameItems.key(cItem));
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackF, NULL);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	if (groupStackM.count() > 0)
 	{
 		while (groupStackM.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackM.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -625,7 +637,10 @@
 				}
 				m_Doc->MasterItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackM, &m_Doc->MasterItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	return true;
@@ -1033,11 +1048,13 @@
 	{
 		while (groupStackP.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackP.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -1052,18 +1069,23 @@
 				}
 				m_Doc->DocItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackP, &m_Doc->DocItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	if (groupStackF.count() > 0)
 	{
 		while (groupStackF.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackF.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -1078,18 +1100,23 @@
 				}
 				m_Doc->FrameItems.remove(m_Doc->FrameItems.key(cItem));
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackF, NULL);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	if (groupStackM.count() > 0)
 	{
 		while (groupStackM.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackM.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -1104,7 +1131,10 @@
 				}
 				m_Doc->MasterItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackM, &m_Doc->MasterItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 
@@ -1683,11 +1713,13 @@
 	{
 		while (groupStackP.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackP.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -1702,18 +1734,23 @@
 				}
 				m_Doc->DocItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackP, &m_Doc->DocItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	if (groupStackF.count() > 0)
 	{
 		while (groupStackF.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackF.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -1728,18 +1765,23 @@
 				}
 				m_Doc->FrameItems.remove(m_Doc->FrameItems.key(cItem));
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackF, NULL);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	if (groupStackM.count() > 0)
 	{
 		while (groupStackM.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackM.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -1754,7 +1796,10 @@
 				}
 				m_Doc->MasterItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackM, &m_Doc->MasterItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	
@@ -3757,11 +3802,13 @@
 	{
 		while (groupStackP.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackP.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -3776,7 +3823,10 @@
 				}
 				m_Doc->DocItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackP, &m_Doc->DocItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 
@@ -5540,11 +5590,13 @@
 	{
 		while (groupStackP.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackP.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -5559,18 +5611,23 @@
 				}
 				m_Doc->DocItems.removeOne(cItem);
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackP, &m_Doc->DocItems);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	if (groupStackF.count() > 0)
 	{
 		while (groupStackF.count() > 0)
 		{
+			bool isTableIt = false;
 			QList<PageItem*> gpL = groupStackF.pop();
 			PageItem* gItem = gpL.takeFirst();
 			for (int id = 0; id < gpL.count(); id++)
 			{
 				PageItem* cItem = gpL.at(id);
+				isTableIt = cItem->isTableItem;
 				cItem->gXpos = cItem->xPos() - gItem->xPos();
 				cItem->gYpos = cItem->yPos() - gItem->yPos();
 				cItem->Parent = gItem;
@@ -5585,7 +5642,10 @@
 				}
 				m_Doc->FrameItems.remove(m_Doc->FrameItems.key(cItem));
 			}
-			gItem->groupItemList = gpL;
+			if (isTableIt)
+				convertOldTable(m_Doc, gItem, gpL, &groupStackF, NULL);
+			else
+				gItem->groupItemList = gpL;
 		}
 	}
 	

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Wed Apr  4 21:29:31 2012
@@ -2868,6 +2868,8 @@
 	QVector<double> DashValues;
 	foreach (const TableBorderLine& line, border.borderLines())
 	{
+		if (line.color() == CommonStrings::None)
+			continue;
 		lineStart.setX(start.x() + line.width() * startOffsetFactors.x());
 		lineStart.setY(start.y() + line.width() * startOffsetFactors.y());
 		lineEnd.setX(end.x() + line.width() * endOffsetFactors.x());
@@ -2878,11 +2880,8 @@
 		getDashArray(line.style(), qMax(line.width(), 1.0), DashValues);
 		PS_setdash(line.style(), 0, DashValues);
 		int h, s, v, k;
-		if (line.color() != CommonStrings::None)
-		{
-			SetColor(line.color(), line.shade(), &h, &s, &v, &k, gcr);
-			PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
-		}
+		SetColor(line.color(), line.shade(), &h, &s, &v, &k, gcr);
+		PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
 		PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
 		putColor(line.color(), line.shade(), false);
 	}

Modified: trunk/Scribus/scribus/ui/propertiespalette_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/ui/propertiespalette_table.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_table.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_table.cpp Wed Apr  4 21:29:31 2012
@@ -285,12 +285,14 @@
 	borderLineList->clear();
 	foreach (const TableBorderLine& borderLine, m_currentBorder.borderLines())
 	{
-		QPixmap *icon = getWidePixmap(getColor(borderLine.color(), borderLine.shade()));
-		QString text = QString(" %1%2 %3")
-			.arg(borderLine.width())
-			.arg(borderLineWidth->suffix())
-			.arg(CommonStrings::translatePenStyleName(borderLine.style()));
-		borderLineList->addItem(new QListWidgetItem(*icon, text, borderLineList));
+		QString text = QString(" %1%2 %3").arg(borderLine.width()).arg(borderLineWidth->suffix()).arg(CommonStrings::translatePenStyleName(borderLine.style()));
+		if (borderLine.color() != CommonStrings::None)
+		{
+			QPixmap *icon = getWidePixmap(getColor(borderLine.color(), borderLine.shade()));
+			borderLineList->addItem(new QListWidgetItem(*icon, text, borderLineList));
+		}
+		else
+			borderLineList->addItem(new QListWidgetItem(text, borderLineList));
 	}
 	removeBorderLineButton->setEnabled(borderLineList->count() > 1);
 }
@@ -298,16 +300,12 @@
 void PropertiesPalette_Table::updateBorderLineListItem()
 {
 	QListWidgetItem* item = borderLineList->currentItem();
-	QString color = borderLineColor->currentColor();
-	if (color == CommonStrings::tr_NoneColor)
-		color = CommonStrings::None;
-	QPixmap *icon = getWidePixmap(getColor(color, borderLineShade->value()));
-	QString text = QString(" %1%2 %3")
-		.arg(borderLineWidth->getValue())
-		.arg(borderLineWidth->suffix())
-		.arg(CommonStrings::translatePenStyleName(static_cast<Qt::PenStyle>(borderLineStyle->currentIndex() + 1)));
-
-	item->setIcon(*icon);
+	QString text = QString(" %1%2 %3").arg(borderLineWidth->getValue()).arg(borderLineWidth->suffix()).arg(CommonStrings::translatePenStyleName(static_cast<Qt::PenStyle>(borderLineStyle->currentIndex() + 1)));
+	if (borderLineColor->currentColor() != CommonStrings::None)
+	{
+		QPixmap *icon = getWidePixmap(getColor(borderLineColor->currentColor(), borderLineShade->value()));
+		item->setIcon(*icon);
+	}
 	item->setText(text);
 }
 

Modified: trunk/Scribus/scribus/util.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/util.cpp
==============================================================================
--- trunk/Scribus/scribus/util.cpp (original)
+++ trunk/Scribus/scribus/util.cpp Wed Apr  4 21:29:31 2012
@@ -29,6 +29,7 @@
 #include <QDomElement>
 #include <QProcess>
 #include "pageitem.h"
+#include "pageitem_table.h"
 #include "ui/scmessagebox.h"
 #include "scribus.h"
 #include "scribusdoc.h"
@@ -1008,3 +1009,118 @@
 #endif
 }
 
+
+void convertOldTable(ScribusDoc *m_Doc, PageItem* gItem, QList<PageItem*> &gpL, QStack<QList<PageItem *> > *groupStackT, QList<PageItem *> *target)
+{
+	QList<double> colWidths;
+	QList<double> rowHeights;
+	PageItem *topLeft = NULL;
+	for (int a = 0; a < gpL.count(); a++)
+	{
+		PageItem* it = gpL[a];
+		if ((it->TopLink == NULL) && (it->LeftLink == NULL))	// we got the topleft item
+		{
+			topLeft = it;
+			PageItem *tl = it;
+			while (tl->RightLink != NULL)
+			{
+				colWidths.append(tl->width());
+				tl = tl->RightLink;
+			}
+			colWidths.append(tl->width());
+			while (tl->BottomLink != NULL)
+			{
+				rowHeights.append(tl->height());
+				tl = tl->BottomLink;
+			}
+			rowHeights.append(tl->height());
+			break;
+		}
+	}
+	m_Doc->dontResize = true;
+	int z = m_Doc->itemAdd(PageItem::Table, PageItem::Unspecified, gItem->xPos(), gItem->yPos(), gItem->width(), gItem->height(), 0.0, CommonStrings::None, CommonStrings::None, true);
+	PageItem_Table* currItem = m_Doc->Items->takeAt(z)->asTable();
+	currItem->insertRows(0, rowHeights.count()-1);
+	m_Doc->dontResize = true;
+	currItem->insertColumns(0, colWidths.count()-1);
+	m_Doc->dontResize = true;
+	for (int i = 0; i < rowHeights.count(); i++)
+	{
+		currItem->resizeRow(i, rowHeights[i]);
+	}
+	m_Doc->dontResize = true;
+	for (int i = 0; i < colWidths.count(); i++)
+	{
+		currItem->resizeColumn(i, colWidths[i]);
+	}
+	TableBorder border(0.0, Qt::SolidLine, CommonStrings::None, 100);
+	currItem->setLeftBorder(border);
+	currItem->setTopBorder(border);
+	currItem->setRightBorder(border);
+	currItem->setBottomBorder(border);
+	m_Doc->dontResize = true;
+	PageItem *tr = topLeft;
+	int rowCount = 0;
+	int colCount = 0;
+	while (rowCount < rowHeights.count())
+	{
+		PageItem *tl = tr;
+		while (colCount < colWidths.count())
+		{
+			currItem->cellAt(rowCount, colCount).textFrame()->itemText = tl->itemText.copy();
+			currItem->cellAt(rowCount, colCount).setFillColor(tl->fillColor());
+			currItem->cellAt(rowCount, colCount).setFillShade(tl->fillShade());
+			currItem->cellAt(rowCount, colCount).setLeftBorder(border);
+			currItem->cellAt(rowCount, colCount).setTopBorder(border);
+			currItem->cellAt(rowCount, colCount).setRightBorder(border);
+			currItem->cellAt(rowCount, colCount).setBottomBorder(border);
+			if ((tl->lineColor() != CommonStrings::None) && (tl->lineWidth() != 0.0))
+			{
+				TableBorder bb(tl->lineWidth(), tl->lineStyle(), tl->lineColor(), tl->lineShade());
+				if (tl->LeftLine)
+					currItem->cellAt(rowCount, colCount).setLeftBorder(bb);
+				if (tl->TopLine)
+					currItem->cellAt(rowCount, colCount).setTopBorder(bb);
+				if (tl->RightLine)
+					currItem->cellAt(rowCount, colCount).setRightBorder(bb);
+				if (tl->BottomLine)
+					currItem->cellAt(rowCount, colCount).setBottomBorder(bb);
+			}
+			if (colCount == colWidths.count()-1)
+				break;
+			colCount++;
+			tl = tl->RightLink;
+		}
+		if (rowCount == rowHeights.count()-1)
+			break;
+		colCount = 0;
+		rowCount++;
+		tr = tr->BottomLink;
+	}
+	m_Doc->dontResize = true;
+	currItem->adjustFrameToTable();
+	if (target != NULL)
+	{
+		int ind = target->indexOf(gItem);
+		target->replace(ind, currItem);
+	}
+	else
+	{
+		int ind = m_Doc->FrameItems.key(gItem);
+		m_Doc->FrameItems.remove(ind);
+		m_Doc->FrameItems.insert(ind, currItem);
+	}
+	if (groupStackT != NULL)
+	{
+		if (groupStackT->count() > 0)
+		{
+			int ii = groupStackT->top().indexOf(gItem);
+			groupStackT->top().replace(ii, currItem);
+		}
+	}
+	while (!gpL.isEmpty())
+	{
+		delete gpL.takeFirst();
+	}
+	delete gItem;
+}

Modified: trunk/Scribus/scribus/util.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17417&path=/trunk/Scribus/scribus/util.h
==============================================================================
--- trunk/Scribus/scribus/util.h (original)
+++ trunk/Scribus/scribus/util.h Wed Apr  4 21:29:31 2012
@@ -18,6 +18,7 @@
 #include <QPainterPath>
 #include <QPair>
 #include <QPixmap>
+#include <QStack>
 #include <QString>
 #include <QStringList>
 #include <QVector>
@@ -149,5 +150,6 @@
 void    SCRIBUS_API getDashArray(int dashtype, double linewidth, QVector<float> &m_array);
 
 void SCRIBUS_API printBacktrace(int nFrames);
+void SCRIBUS_API convertOldTable(ScribusDoc *m_Doc, PageItem* gItem, QList<PageItem*> &gpL, QStack< QList<PageItem*> > *groupStackT = NULL, QList<PageItem *> *target = NULL);
 
 #endif




More information about the scribus-commit mailing list