r17304 by fschmid - Start of printing support for tables: drawing table background and cell background.

scribus-commit scribus-commit at lists.scribus.net
Wed Feb 15 21:59:40 UTC 2012


Author: fschmid
Date: Wed Feb 15 21:59:40 2012
New Revision: 17304

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17304
Log:
Start of printing support for tables: drawing table background and cell background.

Modified:
    trunk/Scribus/scribus/pslib.cpp

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17304&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Wed Feb 15 21:59:40 2012
@@ -41,6 +41,7 @@
 #include "pluginapi.h"
 #include "pageitem_latexframe.h"
 #include "pageitem_pathtext.h"
+#include "pageitem_table.h"
 #include "prefsmanager.h"
 #include "scclocale.h"
 #include "sccolorengine.h"
@@ -2641,6 +2642,57 @@
 				ProcessItem(m_Doc, a, embed, PNr, sep, farb, ic, gcr, master, true);
 				PS_restore();
 			}
+			PS_restore();
+			break;
+		case PageItem::Table:
+			PS_save();
+			SetClipPath(&c->PoLine);
+			PS_closepath();
+			PS_clip(c->fillRule);
+			PS_save();
+			PS_translate(c->asTable()->gridOffset().x(), c->asTable()->gridOffset().y());
+			// Paint table fill.
+			if (c->asTable()->fillColor() != CommonStrings::None)
+			{
+				int lastCol = c->asTable()->columns() - 1;
+				int lastRow = c->asTable()->rows() - 1;
+				double x = c->asTable()->columnPosition(0);
+				double y = c->asTable()->rowPosition(0);
+				double width = c->asTable()->columnPosition(lastCol) + c->asTable()->columnWidth(lastCol) - x;
+				double height = c->asTable()->rowPosition(lastRow) + c->asTable()->rowHeight(lastRow) - y;
+				putColorNoDraw(c->asTable()->fillColor(), c->asTable()->fillShade(), gcr);
+				PutStream("0 0 "+ToStr(width)+" "+ToStr(-height)+" rectfill\n");
+			}
+			// Pass 1: Paint cell fills.
+			for (int row = 0; row < c->asTable()->rows(); ++row)
+			{
+				int colSpan = 0;
+				for (int col = 0; col < c->asTable()->columns(); col += colSpan)
+				{
+					TableCell cell = c->asTable()->cellAt(row, col);
+					if (row == cell.row())
+					{
+						QString colorName = cell.fillColor();
+						if (colorName != CommonStrings::None)
+						{
+							PS_save();
+							putColorNoDraw(colorName, 100, gcr);
+							int row = cell.row();
+							int col = cell.column();
+							int lastRow = row + cell.rowSpan() - 1;
+							int lastCol = col + cell.columnSpan() - 1;
+							double x = c->asTable()->columnPosition(col);
+							double y = c->asTable()->rowPosition(row);
+							double width = c->asTable()->columnPosition(lastCol) + c->asTable()->columnWidth(lastCol) - x;
+							double height = c->asTable()->rowPosition(lastRow) + c->asTable()->rowHeight(lastRow) - y;
+							PutStream(ToStr(x)+" "+ToStr(c->asTable()->tableHeight() - y)+" "+ToStr(width)+" "+ToStr(-height)+" rectfill\n");
+							PS_restore();
+						}
+					}
+					colSpan = cell.columnSpan();
+				}
+			}
+			PS_restore();
 			PS_restore();
 			break;
 		default:




More information about the scribus-commit mailing list