r18840 by jghali - #11874, second part: first line offset in tables is not saved

scribus-commit scribus-commit at lists.scribus.net
Tue Feb 25 21:07:48 UTC 2014


Author: jghali
Date: Tue Feb 25 21:07:47 2014
New Revision: 18840

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18840
Log:
#11874, second part: first line offset in tables is not saved

Modified:
    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

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18840&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 Tue Feb 25 21:07:47 2014
@@ -2283,7 +2283,7 @@
 	{
 		reader.readNext();
 		QStringRef tagName = reader.name();
-		if(reader.isStartElement())
+		if (reader.isStartElement())
 			attrs = reader.attributes();
 		if (reader.isEndElement() && tagName == "PageSets")
 			break;
@@ -4289,6 +4289,168 @@
 	doc->docPatterns.insert(patternName, pat);
 
 	return success;
+}
+
+bool Scribus150Format::readStoryText(ScribusDoc *doc, ScXmlStreamReader& reader, PageItem* item)
+{
+	QStringRef tagName = reader.name();
+	ScXmlStreamAttributes attrs = reader.scAttributes();
+
+	QList<ParagraphStyle::TabRecord> tabValues;
+
+	LastStyles * lastStyle = new LastStyles();
+	while(!reader.atEnd() && !reader.hasError())
+	{
+		ScXmlStreamReader::TokenType tType = reader.readNext();
+		if (reader.isEndElement() && tagName == reader.name())
+			break;
+		if (tType != ScXmlStreamReader::StartElement)
+			continue;
+		QStringRef tName = reader.name();
+		ScXmlStreamAttributes tAtt = reader.scAttributes();
+
+		if (tName == "DefaultStyle")
+		{
+			ParagraphStyle newStyle;
+			readParagraphStyle(doc, reader, newStyle);
+			item->itemText.setDefaultStyle(newStyle);
+		}
+
+		if (tName == "ITEXT")
+			readItemText(item, tAtt, lastStyle);
+		else if (tName == "para")
+		{
+			item->itemText.insertChars(item->itemText.length(), SpecialChars::PARSEP);
+			ParagraphStyle newStyle;
+			readParagraphStyle(doc, reader, newStyle);
+			item->itemText.setStyle(item->itemText.length()-1, newStyle);
+			item->itemText.setCharStyle(item->itemText.length()-1, 1, lastStyle->Style);
+		}
+		else if (tName == "trail")
+		{
+			ParagraphStyle newStyle;
+			readParagraphStyle(doc, reader, newStyle);
+			item->itemText.setStyle(item->itemText.length(), newStyle);
+		}
+		else if (tName == "tab")
+		{
+			CharStyle newStyle;
+			item->itemText.insertChars(item->itemText.length(), SpecialChars::TAB);
+			readCharacterStyleAttrs(doc, tAtt, newStyle);
+			item->itemText.setCharStyle(item->itemText.length()-1, 1, newStyle);
+			lastStyle->StyleStart = item->itemText.length()-1;
+			lastStyle->Style = newStyle;
+		}
+		else if (tName == "breakline")
+			item->itemText.insertChars(item->itemText.length(), SpecialChars::LINEBREAK);
+		else if (tName == "breakcol")
+			item->itemText.insertChars(item->itemText.length(), SpecialChars::COLBREAK);
+		else if (tName == "breakframe")
+			item->itemText.insertChars(item->itemText.length(), SpecialChars::FRAMEBREAK);
+		else if (tName == "nbhyphen")
+		{
+			CharStyle newStyle;
+			item->itemText.insertChars(item->itemText.length(), SpecialChars::NBHYPHEN);
+			readCharacterStyleAttrs(doc, tAtt, newStyle);
+			item->itemText.setCharStyle(item->itemText.length()-1, 1, newStyle);
+			lastStyle->StyleStart = item->itemText.length()-1;
+			lastStyle->Style = newStyle;
+		}
+		else if (tName == "nbspace")
+		{
+			CharStyle newStyle;
+			item->itemText.insertChars(item->itemText.length(), SpecialChars::NBSPACE);
+			readCharacterStyleAttrs(doc, tAtt, newStyle);
+			item->itemText.setCharStyle(item->itemText.length()-1, 1, newStyle);
+			lastStyle->StyleStart = item->itemText.length()-1;
+			lastStyle->Style = newStyle;
+		}
+		else if (tName == "zwnbspace")
+		{
+			CharStyle newStyle;
+			item->itemText.insertChars(item->itemText.length(), SpecialChars::ZWNBSPACE);
+			readCharacterStyleAttrs(doc, tAtt, newStyle);
+			item->itemText.setCharStyle(item->itemText.length()-1, 1, newStyle);
+			lastStyle->StyleStart = item->itemText.length()-1;
+			lastStyle->Style = newStyle;
+		}
+		else if (tName == "zwspace")
+		{
+			CharStyle newStyle;
+			item->itemText.insertChars(item->itemText.length(), SpecialChars::ZWSPACE);
+			readCharacterStyleAttrs(doc, tAtt, newStyle);
+			item->itemText.setCharStyle(item->itemText.length()-1, 1, newStyle);
+			lastStyle->StyleStart = item->itemText.length()-1;
+			lastStyle->Style = newStyle;
+		}
+		else if (tName == "var")
+		{
+			CharStyle newStyle;
+			if (tAtt.value("name") == "pgno")
+				item->itemText.insertChars(item->itemText.length(), SpecialChars::PAGENUMBER);
+			else
+				item->itemText.insertChars(item->itemText.length(), SpecialChars::PAGECOUNT);
+			readCharacterStyleAttrs(doc, tAtt, newStyle);
+			item->itemText.setCharStyle(item->itemText.length()-1, 1, newStyle);
+			lastStyle->StyleStart = item->itemText.length()-1;
+			lastStyle->Style = newStyle;
+		}
+
+		if (tName == "MARK")
+		{
+			QString l = tAtt.valueAsString("label");
+			MarkType t = (MarkType) tAtt.valueAsInt("type");
+			Mark* mark = NULL;
+			if (m_Doc->isLoading())
+			{
+				mark = m_Doc->getMarkDefinied(l, t);
+			}
+			else
+			{	//doc is not loading so it is copy/paste task
+				if (t == MARKVariableTextType)
+					mark = m_Doc->getMarkDefinied(l, t);
+				else
+				{
+					//create copy of mark
+					Mark* oldMark = m_Doc->getMarkDefinied(l, t);
+					if (oldMark == NULL)
+					{
+						qWarning() << "wrong copy of oldMark";
+						mark = m_Doc->newMark();
+						mark->setType(t);
+					}
+					else
+					{
+						mark = m_Doc->newMark(oldMark);
+						getUniqueName(l,doc->marksLabelsList(t), "_");
+					}
+					mark->label = l;
+					if (t == MARKNoteMasterType)
+					{  //create copy of note
+						TextNote* old = mark->getNotePtr();
+						TextNote* note = m_Doc->newNote(old->notesStyle());
+						mark->setNotePtr(note);
+						note->setMasterMark(mark);
+						note->setSaxedText(old->saxedText());
+						m_Doc->setNotesChanged(true);
+					}
+				}
+			}
+			if (mark == NULL)
+				qDebug() << "Undefinied mark label ["<< l << "] type " << t;
+			else
+			{
+				//set pointer to item holds mark in his text
+				if (t == MARKAnchorType)
+					mark->setItemPtr(item);
+				mark->OwnPage = item->OwnPage;
+				item->itemText.insertMark(mark, item->itemText.length());
+			}
+		}
+	}
+	delete lastStyle;
+
+	return !reader.hasError();
 }
 
 bool Scribus150Format::readItemText(PageItem *obj, ScXmlStreamAttributes& attrs, LastStyles* last)
@@ -5293,201 +5455,14 @@
 		reader.readNext();
 		if (reader.isEndElement() && reader.name() == tagName)
 			break;
-		if (reader.isStartElement() && reader.name() == "Cell")
-		{
-			ScXmlStreamAttributes tAtt = reader.scAttributes();
-			int row = tAtt.valueAsInt("Row", -1);
-			int col = tAtt.valueAsInt("Column", -1);
-			lastStyle = LastStyles();
-			if ((row >= 0) && (col >= 0))
-			{
-				if (tAtt.hasAttribute("Style"))
-				{
-					QString Style = tAtt.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);
-				item->cellAt(row, col).setFillShade(tAtt.valueAsInt("FillShade", 100));
-				item->cellAt(row, col).setLeftPadding(tAtt.valueAsDouble("LeftPadding", 0.0));
-				item->cellAt(row, col).setRightPadding(tAtt.valueAsDouble("RightPadding", 0.0));
-				item->cellAt(row, col).setTopPadding(tAtt.valueAsDouble("TopPadding", 0.0));
-				item->cellAt(row, col).setBottomPadding(tAtt.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));
-						}
-					}
-					item->cellAt(row, col).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));
-						}
-					}
-					item->cellAt(row, col).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));
-						}
-					}
-					item->cellAt(row, col).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));
-						}
-					}
-					item->cellAt(row, col).setBottomBorder(border);
-				}
-				else if (reader.name() == "ITEXT")
-				{
-					ScXmlStreamAttributes tAttT = reader.scAttributes();
-					readItemText(item->cellAt(row, col).textFrame(), tAttT, &lastStyle);
-				}
-				else if (reader.name() == "para")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::PARSEP);
-					ParagraphStyle newStyle;
-					readParagraphStyle(doc, reader, newStyle);
-					newItem->itemText.setStyle(newItem->itemText.length()-1, newStyle);
-					newItem->itemText.setCharStyle(newItem->itemText.length()-1, 1, lastStyle.Style);
-				}
-				else if (reader.name() == "trail")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					ParagraphStyle newStyle;
-					readParagraphStyle(doc, reader, newStyle);
-					newItem->itemText.setStyle(newItem->itemText.length(), newStyle);
-				}
-				else if (reader.name() == "tab")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					CharStyle newStyle;
-					newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::TAB);
-					readCharacterStyleAttrs(doc, tAtt, newStyle);
-					newItem->itemText.setCharStyle(newItem->itemText.length()-1, 1, newStyle);
-					lastStyle.StyleStart = newItem->itemText.length()-1;
-					lastStyle.Style = newStyle;
-				}
-				else if (reader.name() == "breakline")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::LINEBREAK);
-				}
-				else if (reader.name() == "breakcol")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::COLBREAK);
-				}
-				else if (reader.name() == "breakframe")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::FRAMEBREAK);
-				}
-				else if (reader.name() == "nbhyphen")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::NBHYPHEN);
-				}
-				else if (reader.name() == "nbspace")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::NBSPACE);
-				}
-				else if (reader.name() == "zwnbspace")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::ZWNBSPACE);
-				}
-				else if (reader.name() == "zwspace")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::ZWSPACE);
-				}
-				else if (reader.name() == "var")
-				{
-					PageItem* newItem = item->cellAt(row, col).textFrame();
-					CharStyle newStyle;
-					if (tAtt.value("name") == "pgno")
-						newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::PAGENUMBER);
-					else
-						newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::PAGECOUNT);
-					readCharacterStyleAttrs(doc, tAtt, newStyle);
-					newItem->itemText.setCharStyle(newItem->itemText.length()-1, 1, newStyle);
-					lastStyle.StyleStart = newItem->itemText.length()-1;
-					lastStyle.Style = newStyle;
-				}
-			}
-		}
-		else if (reader.isStartElement() && reader.name() == "TableBorderLeft")
+		if (!reader.isStartElement())
+			continue;
+			
+		if (reader.name() == "Cell")
+		{
+			readItemTableCell(item, reader, doc);
+		}
+		else if (reader.name() == "TableBorderLeft")
 		{
 			TableBorder border;
 			QStringRef tagName = reader.name();
@@ -5508,7 +5483,7 @@
 			}
 			item->setLeftBorder(border);
 		}
-		else if (reader.isStartElement() && reader.name() == "TableBorderRight")
+		else if (reader.name() == "TableBorderRight")
 		{
 			TableBorder border;
 			QStringRef tagName = reader.name();
@@ -5529,7 +5504,7 @@
 			}
 			item->setRightBorder(border);
 		}
-		else if (reader.isStartElement() && reader.name() == "TableBorderTop")
+		else if (reader.name() == "TableBorderTop")
 		{
 			TableBorder border;
 			QStringRef tagName = reader.name();
@@ -5550,7 +5525,7 @@
 			}
 			item->setTopBorder(border);
 		}
-		else if (reader.isStartElement() && reader.name() == "TableBorderBottom")
+		else if (reader.name() == "TableBorderBottom")
 		{
 			TableBorder border;
 			QStringRef tagName = reader.name();
@@ -5571,10 +5546,230 @@
 			}
 			item->setBottomBorder(border);
 		}
+		else
+		{
+			reader.skipCurrentElement();
+		}
 	}
 	item->adjustTableToFrame();
 	item->adjustFrameToTable();
 	doc->dontResize = false;
+	return !reader.hasError();
+}
+
+bool Scribus150Format::readItemTableCell(PageItem_Table* item, ScXmlStreamReader& reader, ScribusDoc *doc)
+{
+	QStringRef tagName = reader.name();
+	ScXmlStreamAttributes tAtt = reader.scAttributes();
+	
+	int row = tAtt.valueAsInt("Row", -1);
+	int col = tAtt.valueAsInt("Column", -1);
+	if ((row >= 0) && (col >= 0))
+	{
+		if (tAtt.hasAttribute("Style"))
+		{
+			QString Style = tAtt.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);
+		item->cellAt(row, col).setFillShade(tAtt.valueAsInt("FillShade", 100));
+		item->cellAt(row, col).setLeftPadding(tAtt.valueAsDouble("LeftPadding", 0.0));
+		item->cellAt(row, col).setRightPadding(tAtt.valueAsDouble("RightPadding", 0.0));
+		item->cellAt(row, col).setTopPadding(tAtt.valueAsDouble("TopPadding", 0.0));
+		item->cellAt(row, col).setBottomPadding(tAtt.valueAsDouble("BottomPadding", 0.0));
+
+		PageItem* newItem = item->cellAt(row, col).textFrame();
+		newItem->Cols   = tAtt.valueAsInt("TextColums", 1);
+		newItem->ColGap = tAtt.valueAsDouble("TextColGap", 0.0);
+		newItem->setTextToFrameDist(tAtt.valueAsDouble("TextDistLeft", 0.0),
+							tAtt.valueAsDouble("TextDistTop", 0.0),
+							tAtt.valueAsDouble("TextDistBottom", 0.0),
+							tAtt.valueAsDouble("TextDistRight", 0.0));
+		newItem->setFirstLineOffset(static_cast<FirstLineOffsetPolicy>(tAtt.valueAsInt("Flop")));
+	}
+
+	LastStyles lastStyle;
+	while (!reader.atEnd() && !reader.hasError())
+	{
+		reader.readNext();
+		if (reader.isEndElement() && reader.name() == tagName)
+			break;
+		if (!reader.isStartElement())
+			continue;
+
+		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));
+				}
+			}
+			item->cellAt(row, col).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));
+				}
+			}
+			item->cellAt(row, col).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));
+				}
+			}
+			item->cellAt(row, col).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));
+				}
+			}
+			item->cellAt(row, col).setBottomBorder(border);
+		}
+		else if (reader.name() == "StoryText")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			readStoryText(doc, reader, newItem);
+		}
+		else if (reader.name() == "ITEXT")
+		{
+			ScXmlStreamAttributes tAttT = reader.scAttributes();
+			readItemText(item->cellAt(row, col).textFrame(), tAttT, &lastStyle);
+		}
+		else if (reader.name() == "para")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::PARSEP);
+			ParagraphStyle newStyle;
+			readParagraphStyle(doc, reader, newStyle);
+			newItem->itemText.setStyle(newItem->itemText.length()-1, newStyle);
+			newItem->itemText.setCharStyle(newItem->itemText.length()-1, 1, lastStyle.Style);
+		}
+		else if (reader.name() == "trail")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			ParagraphStyle newStyle;
+			readParagraphStyle(doc, reader, newStyle);
+			newItem->itemText.setStyle(newItem->itemText.length(), newStyle);
+		}
+		else if (reader.name() == "tab")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			CharStyle newStyle;
+			newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::TAB);
+			readCharacterStyleAttrs(doc, tAtt, newStyle);
+			newItem->itemText.setCharStyle(newItem->itemText.length()-1, 1, newStyle);
+			lastStyle.StyleStart = newItem->itemText.length()-1;
+			lastStyle.Style = newStyle;
+		}
+		else if (reader.name() == "breakline")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::LINEBREAK);
+		}
+		else if (reader.name() == "breakcol")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::COLBREAK);
+		}
+		else if (reader.name() == "breakframe")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::FRAMEBREAK);
+		}
+		else if (reader.name() == "nbhyphen")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::NBHYPHEN);
+		}
+		else if (reader.name() == "nbspace")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::NBSPACE);
+		}
+		else if (reader.name() == "zwnbspace")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::ZWNBSPACE);
+		}
+		else if (reader.name() == "zwspace")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::ZWSPACE);
+		}
+		else if (reader.name() == "var")
+		{
+			PageItem* newItem = item->cellAt(row, col).textFrame();
+			CharStyle newStyle;
+			if (tAtt.value("name") == "pgno")
+				newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::PAGENUMBER);
+			else
+				newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::PAGECOUNT);
+			readCharacterStyleAttrs(doc, tAtt, newStyle);
+			newItem->itemText.setCharStyle(newItem->itemText.length()-1, 1, newStyle);
+			lastStyle.StyleStart = newItem->itemText.length()-1;
+			lastStyle.Style = newStyle;
+		}
+	}
+
 	return !reader.hasError();
 }
 

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18840&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 Tue Feb 25 21:07:47 2014
@@ -30,6 +30,7 @@
 class  ScXmlStreamAttributes;
 class  ScXmlStreamReader;
 class  ScXmlStreamWriter;
+class  StoryText;
 
 class PLUGIN_API Scribus150Format : public LoadSavePlugin
 {
@@ -111,8 +112,10 @@
 		void readNamedCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle);
 		bool readDocItemAttributes(ScribusDoc *doc, ScXmlStreamReader& reader);
 		bool readHyphen(ScribusDoc *doc, ScXmlStreamReader& reader);
+		bool readStoryText(ScribusDoc *doc, ScXmlStreamReader& reader, PageItem* item);
 		bool readItemText(PageItem* item, ScXmlStreamAttributes& attrs, LastStyles* last);
 		bool readItemTableData(PageItem_Table* item, ScXmlStreamReader& reader, ScribusDoc *doc);
+		bool readItemTableCell(PageItem_Table* item, ScXmlStreamReader& reader, ScribusDoc *doc);
 		bool readLatexInfo(PageItem_LatexFrame* item, ScXmlStreamReader& reader);
 		void readLayers(ScLayer& layer, ScXmlStreamAttributes& attrs);
 		bool readMultiline(multiLine& ml, ScXmlStreamReader& reader);
@@ -165,11 +168,11 @@
 		void writeTableStyles(ScXmlStreamWriter& docu);
 		void writeCellStyles(ScXmlStreamWriter& docu);
 		void putPStyle(ScXmlStreamWriter& docu, const ParagraphStyle & style, const QString &nodeName);
-		void putCStylePT(ScXmlStreamWriter& docu, const CharStyle & style);
 		void putCStyle(ScXmlStreamWriter& docu, const CharStyle & style);
 		void putNamedCStyle(ScXmlStreamWriter& docu, const CharStyle & style);
 		void putTableStyle(ScXmlStreamWriter& docu, const TableStyle & style);
 		void putCellStyle(ScXmlStreamWriter& docu, const CellStyle & style);
+		void writeStoryText(ScribusDoc *doc, ScXmlStreamWriter&, PageItem* item);
 		void writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter&, PageItem* item);
 		void writeLayers(ScXmlStreamWriter& docu);
 		void writePrintOptions(ScXmlStreamWriter& docu);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18840&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 Tue Feb 25 21:07:47 2014
@@ -743,33 +743,6 @@
 //	}
 }
 
-void Scribus150Format::putCStylePT(ScXmlStreamWriter & docu, const CharStyle & style)
-{
-	docu.writeAttribute("CNAME", style.name());
-	docu.writeAttribute("CPARENT", style.parent());
-	docu.writeAttribute("FONT", style.font().scName());
-	docu.writeAttribute("FONTSIZE", style.fontSize() / 10.0);
-	docu.writeAttribute("FEATURES", style.features().join(" "));
-	docu.writeAttribute("FCOLOR", style.fillColor());
-	docu.writeAttribute("FSHADE", style.fillShade());
-	docu.writeAttribute("SCOLOR", style.strokeColor());
-	docu.writeAttribute("SSHADE", style.strokeShade());
-	docu.writeAttribute("TXTSHX", style.shadowXOffset() / 10.0);
-	docu.writeAttribute("TXTSHY", style.shadowYOffset() / 10.0);
-	docu.writeAttribute("TXTOUT", style.outlineWidth() / 10.0);
-	docu.writeAttribute("TXTULP", style.underlineOffset() / 10.0);
-	docu.writeAttribute("TXTULW", style.underlineWidth() / 10.0);
-	docu.writeAttribute("TXTSTP", style.strikethruOffset() / 10.0);
-	docu.writeAttribute("TXTSTW", style.strikethruWidth() / 10.0);
-	docu.writeAttribute("SCALEH", style.scaleH() / 10.0);
-	docu.writeAttribute("SCALEV", style.scaleV() / 10.0);
-	docu.writeAttribute("BASEO", style.baselineOffset() / 10.0);
-	docu.writeAttribute("KERN", style.tracking() / 10.0);
-	docu.writeAttribute("wordTrack", style.wordTracking());
-	docu.writeAttribute("LANGUAGE", style.language());
-	docu.writeAttribute("SHORTCUT", style.shortcut()); // shortcuts won't be inherited
-}
-
 void Scribus150Format::putCStyle(ScXmlStreamWriter & docu, const CharStyle & style)
 {
 	if ( ! style.parent().isEmpty() )
@@ -1539,6 +1512,17 @@
 	}
 } // namespace anon
 
+void Scribus150Format::writeStoryText(ScribusDoc *doc, ScXmlStreamWriter& docu, PageItem* item)
+{
+	docu.writeStartElement("StoryText");
+
+	const ParagraphStyle& defaultStyle = item->itemText.defaultStyle();
+	putPStyle(docu, defaultStyle, "DefaultStyle");
+
+	writeITEXTs(doc, docu, item);
+
+	docu.writeEndElement();
+}
 
 void Scribus150Format::writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter &docu, PageItem* item)
 {
@@ -1665,10 +1649,7 @@
 	if ( item->itemText.length() - lastPos > 0)
 	{
 		docu.writeEmptyElement("ITEXT");
-		/*if (item->asPathText())
-			putCStylePT(docu, lastStyle);
-		else*/
-			putCStyle(docu, lastStyle);
+		putCStyle(docu, lastStyle);
 		docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, item->itemText.length()));
 	}
 	// paragraphstyle for trailing chars
@@ -2261,96 +2242,106 @@
 				for (int col = 0; col < tableItem->columns(); col ++)
 				{
 					TableCell cell = tableItem->cellAt(row, col);
-					if (cell.row() == row && cell.column() == col)
+					if (cell.row() != row || cell.column() != col)
+						continue;
+					PageItem* textFrame = cell.textFrame();
+					docu.writeStartElement("Cell");
+					docu.writeAttribute("Row", cell.row());
+					docu.writeAttribute("Column",cell.column());
+					docu.writeAttribute("Style",cell.style());
+					docu.writeAttribute("TextColumns", textFrame->columns());
+					docu.writeAttribute("TextColGap", textFrame->columnGap());
+					docu.writeAttribute("TextDistLeft", textFrame->textToFrameDistLeft());
+					docu.writeAttribute("TextDistTop", textFrame->textToFrameDistTop());
+					docu.writeAttribute("TextDistBottom", textFrame->textToFrameDistBottom());
+					docu.writeAttribute("TextDistRight", textFrame->textToFrameDistRight());
+					docu.writeAttribute("Flop", textFrame->firstLineOffset());
+
+					QString cstyle = cell.style();
+					CellStyle cs;
+					if (!cell.style().isEmpty())
+						cs = m_Doc->cellStyle(cell.style());
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhFillColor())))
+						docu.writeAttribute("FillColor", cell.fillColor());
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhFillShade())))
+						docu.writeAttribute("FillShade", cell.fillShade());
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhLeftPadding())))
+						docu.writeAttribute("LeftPadding",cell.leftPadding());
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhRightPadding())))
+						docu.writeAttribute("RightPadding", cell.rightPadding());
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhTopPadding())))
+						docu.writeAttribute("TopPadding",cell.topPadding());
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhBottomPadding())))
+						docu.writeAttribute("BottomPadding", cell.bottomPadding());
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhLeftBorder())))
 					{
-						docu.writeStartElement("Cell");
-						docu.writeAttribute("Row", cell.row());
-						docu.writeAttribute("Column",cell.column());
-						docu.writeAttribute("Style",cell.style());
-						QString cstyle = cell.style();
-						CellStyle cs;
-						if (!cell.style().isEmpty())
-							cs = m_Doc->cellStyle(cell.style());
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhFillColor())))
-							docu.writeAttribute("FillColor", cell.fillColor());
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhFillShade())))
-							docu.writeAttribute("FillShade", cell.fillShade());
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhLeftPadding())))
-							docu.writeAttribute("LeftPadding",cell.leftPadding());
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhRightPadding())))
-							docu.writeAttribute("RightPadding", cell.rightPadding());
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhTopPadding())))
-							docu.writeAttribute("TopPadding",cell.topPadding());
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhBottomPadding())))
-							docu.writeAttribute("BottomPadding", cell.bottomPadding());
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhLeftBorder())))
+						TableBorder tbLeft = cell.leftBorder();
+						docu.writeStartElement("TableBorderLeft");
+						docu.writeAttribute("Width", tbLeft.width());
+						foreach (TableBorderLine tbl, tbLeft.borderLines())
 						{
-							TableBorder tbLeft = cell.leftBorder();
-							docu.writeStartElement("TableBorderLeft");
-							docu.writeAttribute("Width", tbLeft.width());
-							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.writeStartElement("TableBorderLine");
+							docu.writeAttribute("Width", tbl.width());
+							docu.writeAttribute("PenStyle", tbl.style());
+							docu.writeAttribute("Color", tbl.color());
+							docu.writeAttribute("Shade", tbl.shade());
 							docu.writeEndElement();
 						}
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhRightBorder())))
+						docu.writeEndElement();
+					}
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhRightBorder())))
+					{
+						TableBorder tbRight = cell.rightBorder();
+						docu.writeStartElement("TableBorderRight");
+						docu.writeAttribute("Width", tbRight.width());
+						foreach (TableBorderLine tbl, tbRight.borderLines())
 						{
-							TableBorder tbRight = cell.rightBorder();
-							docu.writeStartElement("TableBorderRight");
-							docu.writeAttribute("Width", tbRight.width());
-							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.writeStartElement("TableBorderLine");
+							docu.writeAttribute("Width", tbl.width());
+							docu.writeAttribute("PenStyle", tbl.style());
+							docu.writeAttribute("Color", tbl.color());
+							docu.writeAttribute("Shade", tbl.shade());
 							docu.writeEndElement();
 						}
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhTopBorder())))
+						docu.writeEndElement();
+					}
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhTopBorder())))
+					{
+						TableBorder tbTop = cell.topBorder();
+						docu.writeStartElement("TableBorderTop");
+						docu.writeAttribute("Width", tbTop.width());
+						foreach (TableBorderLine tbl, tbTop.borderLines())
 						{
-							TableBorder tbTop = cell.topBorder();
-							docu.writeStartElement("TableBorderTop");
-							docu.writeAttribute("Width", tbTop.width());
-							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.writeStartElement("TableBorderLine");
+							docu.writeAttribute("Width", tbl.width());
+							docu.writeAttribute("PenStyle", tbl.style());
+							docu.writeAttribute("Color", tbl.color());
+							docu.writeAttribute("Shade", tbl.shade());
 							docu.writeEndElement();
 						}
-						if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhBottomBorder())))
+						docu.writeEndElement();
+					}
+					if ((cstyle.isEmpty()) || ((!cstyle.isEmpty()) && ( !cs.isInhBottomBorder())))
+					{
+						TableBorder tbBottom = cell.bottomBorder();
+						docu.writeStartElement("TableBorderBottom");
+						docu.writeAttribute("Width", tbBottom.width());
+						foreach (TableBorderLine tbl, tbBottom.borderLines())
 						{
-							TableBorder tbBottom = cell.bottomBorder();
-							docu.writeStartElement("TableBorderBottom");
-							docu.writeAttribute("Width", tbBottom.width());
-							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.writeStartElement("TableBorderLine");
+							docu.writeAttribute("Width", tbl.width());
+							docu.writeAttribute("PenStyle", tbl.style());
+							docu.writeAttribute("Color", tbl.color());
+							docu.writeAttribute("Shade", tbl.shade());
 							docu.writeEndElement();
 						}
-						//End Cell
-						writeITEXTs(doc, docu, cell.textFrame());
 						docu.writeEndElement();
 					}
+					//End Cell
+					
+
+					writeStoryText(doc, docu, cell.textFrame());
+					docu.writeEndElement();
 				}
 			}
 			docu.writeEndElement();




More information about the scribus-commit mailing list