r17318 by fschmid - Tables: implemented loading and saving of table and cell styles.

scribus-commit scribus-commit at lists.scribus.net
Mon Feb 20 22:29:28 UTC 2012


Author: fschmid
Date: Mon Feb 20 22:29:28 2012
New Revision: 17318

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17318
Log:
Tables: implemented loading and saving of table and cell styles.

Modified:
    trunk/Scribus/scribus/commonstrings.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/ui/propertiespalette_table.cpp
    trunk/Scribus/scribus/ui/smtablestyle.cpp
    trunk/Scribus/scribus/ui/smtablestyle.h
    trunk/Scribus/scribus/ui/smtablestylewidget.cpp
    trunk/Scribus/scribus/ui/smtablestylewidget.ui

Modified: trunk/Scribus/scribus/commonstrings.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&path=/trunk/Scribus/scribus/commonstrings.cpp
==============================================================================
--- trunk/Scribus/scribus/commonstrings.cpp (original)
+++ trunk/Scribus/scribus/commonstrings.cpp Mon Feb 20 22:29:28 2012
@@ -342,9 +342,13 @@
 	CommonStrings::DefaultParagraphStyle     = "Default Paragraph Style";
 	CommonStrings::DefaultCharacterStyle     = "Default Character Style";
 	CommonStrings::DefaultLineStyle          = "Default Line Style";
+	CommonStrings::DefaultTableStyle         = "Default Table Style";
+	CommonStrings::DefaultCellStyle          = "Default Cell Style";
 	CommonStrings::trDefaultParagraphStyle   = tr("Default Paragraph Style");
 	CommonStrings::trDefaultCharacterStyle   = tr("Default Character Style");
 	CommonStrings::trDefaultLineStyle        = tr("Default Line Style");
+	CommonStrings::trDefaultTableStyle       = tr("Default Table Style");
+	CommonStrings::trDefaultCellStyle        = tr("Default Cell Style");
 
 
 	CommonStrings::monday    = tr("Monday");

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&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 Mon Feb 20 22:29:28 2012
@@ -284,6 +284,22 @@
 			temp.create(vg.charStyle());
 			m_Doc->redefineCharStyles(temp, false);
 		}
+		if (tagName == "TableStyle")
+		{
+			TableStyle tstyle;
+			readTableStyle(m_Doc, reader, tstyle);
+			StyleSet<TableStyle> temp;
+			temp.create(tstyle);
+			m_Doc->redefineTableStyles(temp, false);
+		}
+		if (tagName == "CellStyle")
+		{
+			CellStyle tstyle;
+			readCellStyle(m_Doc, reader, tstyle);
+			StyleSet<CellStyle> temp;
+			temp.create(tstyle);
+			m_Doc->redefineCellStyles(temp, false);
+		}
 		if (tagName == "Arrows")
 		{
 			success = readArrows(m_Doc, attrs);
@@ -1276,6 +1292,22 @@
 			StyleSet<CharStyle> temp;
 			temp.create(cstyle);
 			m_Doc->redefineCharStyles(temp, false);
+		}
+		if (tagName == "TableStyle")
+		{
+			TableStyle tstyle;
+			readTableStyle(m_Doc, reader, tstyle);
+			StyleSet<TableStyle> temp;
+			temp.create(tstyle);
+			m_Doc->redefineTableStyles(temp, false);
+		}
+		if (tagName == "CellStyle")
+		{
+			CellStyle tstyle;
+			readCellStyle(m_Doc, reader, tstyle);
+			StyleSet<CellStyle> temp;
+			temp.create(tstyle);
+			m_Doc->redefineCellStyles(temp, false);
 		}
 		if (tagName == "JAVA")
 		{
@@ -2467,6 +2499,238 @@
 		newStyle.setTabValues(tbs);
 	
 	fixLegacyParStyle(newStyle);
+}
+
+void Scribus150Format::readTableStyle(ScribusDoc *doc, ScXmlStreamReader& reader, TableStyle& newStyle)
+{
+	ScXmlStreamAttributes attrs = reader.scAttributes();
+	newStyle.erase();
+	newStyle.setName(attrs.valueAsString("NAME", ""));
+	// The default style attribute must be correctly set before trying to assign a parent
+	if (attrs.hasAttribute("DefaultStyle"))
+		newStyle.setDefaultStyle(attrs.valueAsInt("DefaultStyle"));
+	else if (newStyle.name() == CommonStrings::DefaultTableStyle || newStyle.name() == CommonStrings::trDefaultTableStyle)
+		newStyle.setDefaultStyle(true);
+	else
+		newStyle.setDefaultStyle(false);
+	QString parentStyle = attrs.valueAsString("PARENT", "");
+	if (!parentStyle.isEmpty() && (parentStyle != newStyle.name()))
+		newStyle.setParent(parentStyle);
+	if (attrs.hasAttribute("FillColor"))
+		newStyle.setFillColor(attrs.valueAsString("FillColor"));
+	if (attrs.hasAttribute("FillShade"))
+		newStyle.setFillShade(attrs.valueAsDouble("FillShade"));
+	QStringRef tagName = reader.name();
+	while (!reader.atEnd() && !reader.hasError())
+	{
+		reader.readNext();
+		if (reader.isEndElement() && reader.name() == tagName)
+			break;
+		if (reader.name() == "TableBorderLeft")
+		{
+			TableBorder border;
+			QStringRef tagName = reader.name();
+			while (!reader.atEnd() && !reader.hasError())
+			{
+				reader.readNext();
+				if (reader.isEndElement() && reader.name() == tagName)
+					break;
+				if (reader.isStartElement() && reader.name() == "TableBorderLine")
+				{
+					ScXmlStreamAttributes tAttB = reader.scAttributes();
+					double width = tAttB.valueAsDouble("Width", 0.0);
+					QString color = tAttB.valueAsString("Color", CommonStrings::None);
+					double shade = tAttB.valueAsDouble("Shade", 100.0);
+					int style = tAttB.valueAsInt("PenStyle", 1);
+					border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), color, shade));
+				}
+			}
+			newStyle.setLeftBorder(border);
+		}
+		else if (reader.name() == "TableBorderRight")
+		{
+			TableBorder border;
+			QStringRef tagName = reader.name();
+			while (!reader.atEnd() && !reader.hasError())
+			{
+				reader.readNext();
+				if (reader.isEndElement() && reader.name() == tagName)
+					break;
+				if (reader.isStartElement() && reader.name() == "TableBorderLine")
+				{
+					ScXmlStreamAttributes tAttB = reader.scAttributes();
+					double width = tAttB.valueAsDouble("Width", 0.0);
+					QString color = tAttB.valueAsString("Color", CommonStrings::None);
+					double shade = tAttB.valueAsDouble("Shade", 100.0);
+					int style = tAttB.valueAsInt("PenStyle", 1);
+					border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), color, shade));
+				}
+			}
+			newStyle.setRightBorder(border);
+		}
+		else if (reader.name() == "TableBorderTop")
+		{
+			TableBorder border;
+			QStringRef tagName = reader.name();
+			while (!reader.atEnd() && !reader.hasError())
+			{
+				reader.readNext();
+				if (reader.isEndElement() && reader.name() == tagName)
+					break;
+				if (reader.isStartElement() && reader.name() == "TableBorderLine")
+				{
+					ScXmlStreamAttributes tAttB = reader.scAttributes();
+					double width = tAttB.valueAsDouble("Width", 0.0);
+					QString color = tAttB.valueAsString("Color", CommonStrings::None);
+					double shade = tAttB.valueAsDouble("Shade", 100.0);
+					int style = tAttB.valueAsInt("PenStyle", 1);
+					border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), color, shade));
+				}
+			}
+			newStyle.setTopBorder(border);
+		}
+		else if (reader.name() == "TableBorderBottom")
+		{
+			TableBorder border;
+			QStringRef tagName = reader.name();
+			while (!reader.atEnd() && !reader.hasError())
+			{
+				reader.readNext();
+				if (reader.isEndElement() && reader.name() == tagName)
+					break;
+				if (reader.isStartElement() && reader.name() == "TableBorderLine")
+				{
+					ScXmlStreamAttributes tAttB = reader.scAttributes();
+					double width = tAttB.valueAsDouble("Width", 0.0);
+					QString color = tAttB.valueAsString("Color", CommonStrings::None);
+					double shade = tAttB.valueAsDouble("Shade", 100.0);
+					int style = tAttB.valueAsInt("PenStyle", 1);
+					border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), color, shade));
+				}
+			}
+			newStyle.setBottomBorder(border);
+		}
+	}
+}
+
+void Scribus150Format::readCellStyle(ScribusDoc *doc, ScXmlStreamReader& reader, CellStyle& newStyle)
+{
+	ScXmlStreamAttributes attrs = reader.scAttributes();
+	newStyle.erase();
+	newStyle.setName(attrs.valueAsString("NAME", ""));
+	// The default style attribute must be correctly set before trying to assign a parent
+	if (attrs.hasAttribute("DefaultStyle"))
+		newStyle.setDefaultStyle(attrs.valueAsInt("DefaultStyle"));
+	else if (newStyle.name() == CommonStrings::DefaultTableStyle || newStyle.name() == CommonStrings::trDefaultTableStyle)
+		newStyle.setDefaultStyle(true);
+	else
+		newStyle.setDefaultStyle(false);
+	QString parentStyle = attrs.valueAsString("PARENT", "");
+	if (!parentStyle.isEmpty() && (parentStyle != newStyle.name()))
+		newStyle.setParent(parentStyle);
+	if (attrs.hasAttribute("FillColor"))
+		newStyle.setFillColor(attrs.valueAsString("FillColor"));
+	if (attrs.hasAttribute("FillShade"))
+		newStyle.setFillShade(attrs.valueAsDouble("FillShade"));
+	if (attrs.hasAttribute("LeftPadding"))
+		newStyle.setLeftPadding(attrs.valueAsDouble("LeftPadding", 0.0));
+	if (attrs.hasAttribute("RightPadding"))
+		newStyle.setRightPadding(attrs.valueAsDouble("RightPadding", 0.0));
+	if (attrs.hasAttribute("TopPadding"))
+		newStyle.setTopPadding(attrs.valueAsDouble("TopPadding", 0.0));
+	if (attrs.hasAttribute("BottomPadding"))
+		newStyle.setBottomPadding(attrs.valueAsDouble("BottomPadding", 0.0));
+	QStringRef tagName = reader.name();
+	while (!reader.atEnd() && !reader.hasError())
+	{
+		reader.readNext();
+		if (reader.isEndElement() && reader.name() == tagName)
+			break;
+		if (reader.name() == "TableBorderLeft")
+		{
+			TableBorder border;
+			QStringRef tagName = reader.name();
+			while (!reader.atEnd() && !reader.hasError())
+			{
+				reader.readNext();
+				if (reader.isEndElement() && reader.name() == tagName)
+					break;
+				if (reader.isStartElement() && reader.name() == "TableBorderLine")
+				{
+					ScXmlStreamAttributes tAttB = reader.scAttributes();
+					double width = tAttB.valueAsDouble("Width", 0.0);
+					QString color = tAttB.valueAsString("Color", CommonStrings::None);
+					double shade = tAttB.valueAsDouble("Shade", 100.0);
+					int style = tAttB.valueAsInt("PenStyle", 1);
+					border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), color, shade));
+				}
+			}
+			newStyle.setLeftBorder(border);
+		}
+		else if (reader.name() == "TableBorderRight")
+		{
+			TableBorder border;
+			QStringRef tagName = reader.name();
+			while (!reader.atEnd() && !reader.hasError())
+			{
+				reader.readNext();
+				if (reader.isEndElement() && reader.name() == tagName)
+					break;
+				if (reader.isStartElement() && reader.name() == "TableBorderLine")
+				{
+					ScXmlStreamAttributes tAttB = reader.scAttributes();
+					double width = tAttB.valueAsDouble("Width", 0.0);
+					QString color = tAttB.valueAsString("Color", CommonStrings::None);
+					double shade = tAttB.valueAsDouble("Shade", 100.0);
+					int style = tAttB.valueAsInt("PenStyle", 1);
+					border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), color, shade));
+				}
+			}
+			newStyle.setRightBorder(border);
+		}
+		else if (reader.name() == "TableBorderTop")
+		{
+			TableBorder border;
+			QStringRef tagName = reader.name();
+			while (!reader.atEnd() && !reader.hasError())
+			{
+				reader.readNext();
+				if (reader.isEndElement() && reader.name() == tagName)
+					break;
+				if (reader.isStartElement() && reader.name() == "TableBorderLine")
+				{
+					ScXmlStreamAttributes tAttB = reader.scAttributes();
+					double width = tAttB.valueAsDouble("Width", 0.0);
+					QString color = tAttB.valueAsString("Color", CommonStrings::None);
+					double shade = tAttB.valueAsDouble("Shade", 100.0);
+					int style = tAttB.valueAsInt("PenStyle", 1);
+					border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), color, shade));
+				}
+			}
+			newStyle.setTopBorder(border);
+		}
+		else if (reader.name() == "TableBorderBottom")
+		{
+			TableBorder border;
+			QStringRef tagName = reader.name();
+			while (!reader.atEnd() && !reader.hasError())
+			{
+				reader.readNext();
+				if (reader.isEndElement() && reader.name() == tagName)
+					break;
+				if (reader.isStartElement() && reader.name() == "TableBorderLine")
+				{
+					ScXmlStreamAttributes tAttB = reader.scAttributes();
+					double width = tAttB.valueAsDouble("Width", 0.0);
+					QString color = tAttB.valueAsString("Color", CommonStrings::None);
+					double shade = tAttB.valueAsDouble("Shade", 100.0);
+					int style = tAttB.valueAsInt("PenStyle", 1);
+					border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), color, shade));
+				}
+			}
+			newStyle.setBottomBorder(border);
+		}
+	}
 }
 
 void Scribus150Format::readLayers(ScLayer& layer, ScXmlStreamAttributes& attrs)
@@ -4479,6 +4743,12 @@
 			int col = tAtt.valueAsInt("Column", -1);
 			if ((row >= 0) && (col >= 0))
 			{
+				if (tAtt.hasAttribute("Style"))
+				{
+					QString Style = attrs.valueAsString("Style");
+					if (!Style.isEmpty())
+						item->cellAt(row, col).setStyle(Style);
+				}
 				QString fColor = tAtt.valueAsString("FillColor");
 				if ((fColor != CommonStrings::None) && (!fColor.isEmpty()))
 					item->cellAt(row, col).setFillColor(fColor);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h Mon Feb 20 22:29:28 2012
@@ -118,6 +118,8 @@
 		bool readPageItemAttributes(PageItem* item, ScXmlStreamReader& reader);
 		bool readPageSets(ScribusDoc* doc, ScXmlStreamReader& reader);
 		void readParagraphStyle(ScribusDoc *doc, ScXmlStreamReader& reader, ParagraphStyle& newStyle);
+		void readTableStyle(ScribusDoc *doc, ScXmlStreamReader& reader, TableStyle& newStyle);
+		void readCellStyle(ScribusDoc *doc, ScXmlStreamReader& reader, CellStyle& newStyle);
 		bool readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, const QString& baseDir);
 		bool readPDFOptions(ScribusDoc* doc, ScXmlStreamReader& reader);
 		bool readPrinterOptions(ScribusDoc* doc, ScXmlStreamReader& reader);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Mon Feb 20 22:29:28 2012
@@ -809,10 +809,130 @@
 
 void Scribus150Format::putTableStyle(ScXmlStreamWriter &docu, const TableStyle &style)
 {
+	if ( ! style.name().isEmpty() )
+		docu.writeAttribute("NAME", style.name());
+	if ( style.hasName() && style.isDefaultStyle())
+		docu.writeAttribute("DefaultStyle", style.isDefaultStyle());
+	if ( ! style.parent().isEmpty() )
+		docu.writeAttribute("PARENT", style.parent());
+	if ( ! style.isInhFillColor())
+		docu.writeAttribute("FillColor", style.fillColor());
+	if ( ! style.isInhFillShade())
+		docu.writeAttribute("FillShade", style.fillShade());
+	TableBorder tbLeft = style.leftBorder();
+	docu.writeStartElement("TableBorderLeft");
+	foreach (TableBorderLine tbl, tbLeft.borderLines())
+	{
+		docu.writeStartElement("TableBorderLine");
+		docu.writeAttribute("Width", tbl.width());
+		docu.writeAttribute("PenStyle", tbl.style());
+		docu.writeAttribute("Color", tbl.color());
+		docu.writeAttribute("Shade", tbl.shade());
+		docu.writeEndElement();
+	}
+	docu.writeEndElement();
+	TableBorder tbRight = style.rightBorder();
+	docu.writeStartElement("TableBorderRight");
+	foreach (TableBorderLine tbl, tbRight.borderLines())
+	{
+		docu.writeStartElement("TableBorderLine");
+		docu.writeAttribute("Width", tbl.width());
+		docu.writeAttribute("PenStyle", tbl.style());
+		docu.writeAttribute("Color", tbl.color());
+		docu.writeAttribute("Shade", tbl.shade());
+		docu.writeEndElement();
+	}
+	docu.writeEndElement();
+	TableBorder tbTop = style.topBorder();
+	docu.writeStartElement("TableBorderTop");
+	foreach (TableBorderLine tbl, tbTop.borderLines())
+	{
+		docu.writeStartElement("TableBorderLine");
+		docu.writeAttribute("Width", tbl.width());
+		docu.writeAttribute("PenStyle", tbl.style());
+		docu.writeAttribute("Color", tbl.color());
+		docu.writeAttribute("Shade", tbl.shade());
+		docu.writeEndElement();
+	}
+	docu.writeEndElement();
+	TableBorder tbBottom = style.bottomBorder();
+	docu.writeStartElement("TableBorderBottom");
+	foreach (TableBorderLine tbl, tbBottom.borderLines())
+	{
+		docu.writeStartElement("TableBorderLine");
+		docu.writeAttribute("Width", tbl.width());
+		docu.writeAttribute("PenStyle", tbl.style());
+		docu.writeAttribute("Color", tbl.color());
+		docu.writeAttribute("Shade", tbl.shade());
+		docu.writeEndElement();
+	}
+	docu.writeEndElement();
 }
 
 void Scribus150Format::putCellStyle(ScXmlStreamWriter &docu, const CellStyle &style)
 {
+	if ( ! style.name().isEmpty() )
+		docu.writeAttribute("NAME", style.name());
+	if ( style.hasName() && style.isDefaultStyle())
+		docu.writeAttribute("DefaultStyle", style.isDefaultStyle());
+	if ( ! style.parent().isEmpty() )
+		docu.writeAttribute("PARENT", style.parent());
+	if ( ! style.isInhFillColor())
+		docu.writeAttribute("FillColor", style.fillColor());
+	if ( ! style.isInhFillShade())
+		docu.writeAttribute("FillShade", style.fillShade());
+	docu.writeAttribute("LeftPadding",style.leftPadding());
+	docu.writeAttribute("RightPadding", style.rightPadding());
+	docu.writeAttribute("TopPadding",style.topPadding());
+	docu.writeAttribute("BottomPadding", style.bottomPadding());
+	TableBorder tbLeft = style.leftBorder();
+	docu.writeStartElement("TableBorderLeft");
+	foreach (TableBorderLine tbl, tbLeft.borderLines())
+	{
+		docu.writeStartElement("TableBorderLine");
+		docu.writeAttribute("Width", tbl.width());
+		docu.writeAttribute("PenStyle", tbl.style());
+		docu.writeAttribute("Color", tbl.color());
+		docu.writeAttribute("Shade", tbl.shade());
+		docu.writeEndElement();
+	}
+	docu.writeEndElement();
+	TableBorder tbRight = style.rightBorder();
+	docu.writeStartElement("TableBorderRight");
+	foreach (TableBorderLine tbl, tbRight.borderLines())
+	{
+		docu.writeStartElement("TableBorderLine");
+		docu.writeAttribute("Width", tbl.width());
+		docu.writeAttribute("PenStyle", tbl.style());
+		docu.writeAttribute("Color", tbl.color());
+		docu.writeAttribute("Shade", tbl.shade());
+		docu.writeEndElement();
+	}
+	docu.writeEndElement();
+	TableBorder tbTop = style.topBorder();
+	docu.writeStartElement("TableBorderTop");
+	foreach (TableBorderLine tbl, tbTop.borderLines())
+	{
+		docu.writeStartElement("TableBorderLine");
+		docu.writeAttribute("Width", tbl.width());
+		docu.writeAttribute("PenStyle", tbl.style());
+		docu.writeAttribute("Color", tbl.color());
+		docu.writeAttribute("Shade", tbl.shade());
+		docu.writeEndElement();
+	}
+	docu.writeEndElement();
+	TableBorder tbBottom = style.bottomBorder();
+	docu.writeStartElement("TableBorderBottom");
+	foreach (TableBorderLine tbl, tbBottom.borderLines())
+	{
+		docu.writeStartElement("TableBorderLine");
+		docu.writeAttribute("Width", tbl.width());
+		docu.writeAttribute("PenStyle", tbl.style());
+		docu.writeAttribute("Color", tbl.color());
+		docu.writeAttribute("Shade", tbl.shade());
+		docu.writeEndElement();
+	}
+	docu.writeEndElement();
 }
 
 void Scribus150Format::writeLayers(ScXmlStreamWriter & docu) 

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Mon Feb 20 22:29:28 2012
@@ -496,6 +496,7 @@
 	// Create default table style.
 	// TODO: We should have preferences for the default values.
 	TableStyle defaultTableStyle;
+	defaultTableStyle.setDefaultStyle(true);
 	defaultTableStyle.setName(CommonStrings::DefaultTableStyle);
 	defaultTableStyle.setFillColor(CommonStrings::None);
 	defaultTableStyle.setFillShade(100);
@@ -509,6 +510,7 @@
 	// Create default table cell style.
 	// TODO: We should have preferences for the default values.
 	CellStyle defaultCellStyle;
+	defaultCellStyle.setDefaultStyle(true);
 	defaultCellStyle.setName(CommonStrings::DefaultCellStyle);
 	defaultCellStyle.setFillColor(CommonStrings::None);
 	defaultCellStyle.setFillShade(100);

Modified: trunk/Scribus/scribus/ui/propertiespalette_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&path=/trunk/Scribus/scribus/ui/propertiespalette_table.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_table.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_table.cpp Mon Feb 20 22:29:28 2012
@@ -229,8 +229,25 @@
 		fillShade->setEnabled(true);
 		fillShadeLabel->setEnabled(true);
 		// Fill in values.
-		setCurrentComboItem(fillColor, table->fillColor());
-		fillShade->setValue(table->fillShade());
+		if (table->selectedCells().count() == 0)
+		{
+			setCurrentComboItem(fillColor, table->fillColor());
+			fillShade->setValue(table->fillShade());
+		}
+		else if (table->selectedCells().count() == 1)
+		{
+			TableCell cell = table->selectedCells().toList().first();
+			setCurrentComboItem(fillColor, cell.fillColor());
+			fillShade->setValue(cell.fillShade());
+		}
+		else
+		{
+			// Disable fill editing controls.
+			fillColor->setEnabled(false);
+			fillColorLabel->setEnabled(false);
+			fillShade->setEnabled(false);
+			fillShadeLabel->setEnabled(false);
+		}
 	}
 	else
 	{
@@ -359,8 +376,18 @@
 		return;
 
 	PageItem_Table* table = m_item->asTable();
-	table->setFillColor(colorName);
-	table->setFillShade(fillShade->value());
+	if (table->selectedCells().count() == 0)
+	{
+		table->setFillColor(colorName);
+		table->setFillShade(fillShade->value());
+	}
+	else if (table->selectedCells().count() == 1)
+	{
+		TableCell cell = table->selectedCells().toList().first();
+		cell.setFillColor(colorName);
+		cell.setFillShade(fillShade->value());
+	}
+
 	table->update();
 }
 
@@ -370,8 +397,17 @@
 		return;
 
 	PageItem_Table* table = m_item->asTable();
-	table->setFillColor(fillColor->currentColor());
-	table->setFillShade(shade);
+	if (table->selectedCells().count() == 0)
+	{
+		table->setFillColor(fillColor->currentColor());
+		table->setFillShade(shade);
+	}
+	else if (table->selectedCells().count() == 1)
+	{
+		TableCell cell = table->selectedCells().toList().first();
+		cell.setFillColor(fillColor->currentColor());
+		cell.setFillShade(shade);
+	}
 	table->update();
 }
 

Modified: trunk/Scribus/scribus/ui/smtablestyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&path=/trunk/Scribus/scribus/ui/smtablestyle.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smtablestyle.cpp (original)
+++ trunk/Scribus/scribus/ui/smtablestyle.cpp Mon Feb 20 22:29:28 2012
@@ -410,25 +410,24 @@
 {
 	if (!m_page)
 		return;
-
-	connect(m_page->fillColor, SIGNAL(activated(const QString&)),
-			this, SLOT(slotFillColor()));
+	connect(m_page->fillColor, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
+	connect(m_page->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
 }
 
 void SMTableStyle::removeConnections()
 {
 	if (!m_page)
 		return;
-
-	disconnect(m_page->fillColor, SIGNAL(activated(const QString&)),
-			this, SLOT(slotFillColor()));
+	disconnect(m_page->fillColor, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
+	disconnect(m_page->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
 }
 
 void SMTableStyle::slotFillColor()
 {
 	// TODO: Handle inheritance as well.
 	QString fillColor(m_page->fillColor->currentText());
-	foreach (TableStyle *tableStyle, m_selection) {
+	foreach (TableStyle *tableStyle, m_selection)
+	{
 		tableStyle->setFillColor(fillColor);
 	}
 
@@ -438,3 +437,19 @@
 		emit selectionDirty();
 	}
 }
+
+void SMTableStyle::slotFillShade()
+{
+	// TODO: Handle inheritance as well.
+	double fillShade = m_page->fillShade_->getValue();
+	foreach (TableStyle *tableStyle, m_selection)
+	{
+		tableStyle->setFillShade(fillShade);
+	}
+
+	if (!m_selectionIsDirty)
+	{
+		m_selectionIsDirty = true;
+		emit selectionDirty();
+	}
+}

Modified: trunk/Scribus/scribus/ui/smtablestyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&path=/trunk/Scribus/scribus/ui/smtablestyle.h
==============================================================================
--- trunk/Scribus/scribus/ui/smtablestyle.h (original)
+++ trunk/Scribus/scribus/ui/smtablestyle.h Mon Feb 20 22:29:28 2012
@@ -92,6 +92,7 @@
 
 private slots:
 	void slotFillColor();
+	void slotFillShade();
 };
 
 #endif // SMTABLESTYLES_H

Modified: trunk/Scribus/scribus/ui/smtablestylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&path=/trunk/Scribus/scribus/ui/smtablestylewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smtablestylewidget.cpp (original)
+++ trunk/Scribus/scribus/ui/smtablestylewidget.cpp Mon Feb 20 22:29:28 2012
@@ -16,6 +16,7 @@
 
 	fillColorIcon->setPixmap(loadIcon("16/color-fill.png"));
 	fillColor->addItem(CommonStrings::tr_NoneColor);
+	fillShadeLabel->setPixmap( loadIcon("shade.png") );
 }
 
 SMTableStyleWidget::~SMTableStyleWidget()
@@ -32,6 +33,7 @@
 	// TODO: Handle parent styles (and language?)
 
 	fillColor->setCurrentText(tableStyle->fillColor());
+	fillShade_->setValue(qRound(tableStyle->fillShade()));
 }
 
 void SMTableStyleWidget::show(QList<TableStyle*> &tableStyles, QList<TableStyle> &tableStylesAll, const QString &defaultLanguage, int unitIndex)
@@ -45,7 +47,8 @@
 
 void SMTableStyleWidget::languageChange()
 {
-	fillColor->setToolTip(tr("Fill Color"));
+	fillColor->setToolTip( tr("Fill Color"));
+	fillShade_->setToolTip( tr("Fill Shade"));
 }
 
 void SMTableStyleWidget::fillFillColorCombo(ColorList &colors)

Modified: trunk/Scribus/scribus/ui/smtablestylewidget.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17318&path=/trunk/Scribus/scribus/ui/smtablestylewidget.ui
==============================================================================
--- trunk/Scribus/scribus/ui/smtablestylewidget.ui (original)
+++ trunk/Scribus/scribus/ui/smtablestylewidget.ui Mon Feb 20 22:29:28 2012
@@ -16,9 +16,9 @@
      <property name="title">
       <string>Colors</string>
      </property>
-     <layout class="QVBoxLayout">
+     <layout class="QVBoxLayout" name="verticalLayout">
       <item>
-       <layout class="QHBoxLayout">
+       <layout class="QHBoxLayout" name="horizontalLayout">
         <item>
          <widget class="QLabel" name="fillColorIcon">
           <property name="maximumSize">
@@ -37,6 +37,20 @@
         </item>
         <item>
          <widget class="SMColorCombo" name="fillColor"/>
+        </item>
+        <item>
+         <widget class="QLabel" name="fillShadeLabel">
+          <property name="text">
+           <string>Text</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="SMShadeButton" name="fillShade_">
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
         </item>
         <item>
          <spacer>
@@ -81,6 +95,11 @@
    <extends>QComboBox</extends>
    <header>ui/smcolorcombo.h</header>
   </customwidget>
+  <customwidget>
+   <class>SMShadeButton</class>
+   <extends>QPushButton</extends>
+   <header>ui/smshadebutton.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>




More information about the scribus-commit mailing list