r16859 by craig - Start to add in the basics for writing table data to an SLA file.
scribus-commit
scribus-commit at lists.scribus.net
Wed Sep 28 19:01:38 UTC 2011
Author: craig
Date: Wed Sep 28 19:01:38 2011
New Revision: 16859
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16859
Log:
Start to add in the basics for writing table data to an SLA file.
Modified:
trunk/Scribus/scribus/pageitem_table.h
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/scribusdoc.h
Modified: trunk/Scribus/scribus/pageitem_table.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16859&path=/trunk/Scribus/scribus/pageitem_table.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_table.h (original)
+++ trunk/Scribus/scribus/pageitem_table.h Wed Sep 28 19:01:38 2011
@@ -454,6 +454,9 @@
/// Returns a textual description of this item.
virtual QString infoDescription() { return QString(); }
+ // Returns the Cell Areas from this table
+ QList<CellArea> cellAreas() const { return m_cellAreas; }
+
signals:
/// This signal is emitted whenever the table changes.
void changed();
@@ -535,6 +538,7 @@
void assertValid() const;
private:
+ //<<Data we need to save
/// List of rows of cells in the table.
QList<QList<TableCell> > m_cellRows;
@@ -556,11 +560,13 @@
/// List of areas of merged cells.
QList<CellArea> m_cellAreas;
+ /// Style of the table.
+ TableStyle m_style;
+ //>>End of data we need to save
+ //-----------------------------
+ //<<Live working variables/data
/// Set of selected cells.
QSet<TableCell> m_selection;
-
- /// Style of the table.
- TableStyle m_style;
/// The table painter to paint the table with.
TablePainter* m_tablePainter;
@@ -595,6 +601,7 @@
/// The logical active column.
int m_activeColumn;
+ //>>End of live working variables/data
};
#endif // PAGEITEM_TABLE_H
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16859&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 Wed Sep 28 19:01:38 2011
@@ -130,10 +130,14 @@
void writeHyphenatorLists(ScXmlStreamWriter& docu);
void writePStyles(ScXmlStreamWriter& docu);
void writeCStyles(ScXmlStreamWriter& docu);
+ 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 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=16859&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 Wed Sep 28 19:01:38 2011
@@ -27,6 +27,7 @@
#include "pageitem_regularpolygon.h"
#include "pageitem_arc.h"
#include "pageitem_spiral.h"
+#include "pageitem_table.h"
#include "units.h"
#include "util.h"
@@ -353,6 +354,8 @@
writeHyphenatorLists(docu);
writePStyles(docu);
writeCStyles(docu);
+ writeTableStyles(docu);
+ writeCellStyles(docu);
writeLinestyles(docu);
writeLayers(docu);
writePrintOptions(docu);
@@ -562,7 +565,7 @@
docu.writeEndElement();
}
-void Scribus150Format::writePStyles(ScXmlStreamWriter & docu)
+void Scribus150Format::writePStyles(ScXmlStreamWriter & docu)
{
QList<int> styleList = m_Doc->getSortedStyleList();
for (int a = 0; a < styleList.count(); ++a)
@@ -751,6 +754,36 @@
if ( style.hasName() && style.isDefaultStyle())
docu.writeAttribute("DefaultStyle", style.isDefaultStyle());
putCStyle(docu, style);
+}
+
+void Scribus150Format::writeTableStyles(ScXmlStreamWriter& docu)
+{
+ QList<int> styleList = m_Doc->getSortedTableStyleList();
+ for (int i = 0; i < styleList.count(); ++i)
+ {
+ docu.writeStartElement("TableStyle");
+ putTableStyle(docu, m_Doc->tableStyles()[styleList[i]]);
+ docu.writeEndElement();
+ }
+}
+
+void Scribus150Format::writeCellStyles(ScXmlStreamWriter& docu)
+{
+ QList<int> styleList = m_Doc->getSortedCellStyleList();
+ for (int i = 0; i < styleList.count(); ++i)
+ {
+ docu.writeStartElement("CellStyle");
+ putCellStyle(docu, m_Doc->cellStyles()[styleList[i]]);
+ docu.writeEndElement();
+ }
+}
+
+void Scribus150Format::putTableStyle(ScXmlStreamWriter &docu, const TableStyle &style)
+{
+}
+
+void Scribus150Format::putCellStyle(ScXmlStreamWriter &docu, const CellStyle &style)
+{
}
void Scribus150Format::writeLayers(ScXmlStreamWriter & docu)
@@ -2045,6 +2078,43 @@
docu.writeAttribute("BottomLINK", -1);
docu.writeAttribute("OwnLINK", item->ItemNr);
}
+
+ if (item->isTable())
+ {
+ //PTYPE == PageItem::Table or 16 (pageitem.h)
+ PageItem_Table* tableItem=item->asTable();
+ docu.writeAttribute("Rows", tableItem->rows());
+ docu.writeAttribute("Columns",tableItem->columns());
+
+ QString outputData;
+ //Row Positions
+ foreach(qreal value, tableItem->rowPositions())
+ outputData += tmp.setNum(value) + " ";
+ docu.writeAttribute("RowPositions", outputData.simplified());
+ outputData.clear();
+
+ //Row Heights
+ foreach(qreal value, tableItem->rowHeights())
+ outputData += tmp.setNum(value) + " ";
+ docu.writeAttribute("RowHeights", outputData.simplified());
+ outputData.clear();
+ //Column Positions
+ foreach(qreal value, tableItem->columnPositions())
+ outputData += tmp.setNum(value) + " ";
+ docu.writeAttribute("ColumnPositions", outputData.simplified());
+ outputData.clear();
+ //Column Widths
+ foreach(qreal value, tableItem->columnWidths())
+ outputData += tmp.setNum(value) + " ";
+ docu.writeAttribute("ColumnWidths", outputData.simplified());
+ outputData.clear();
+ //Cell Areas
+ foreach(CellArea ca, tableItem->cellAreas())
+ outputData += tmp.setNum(ca.row()) + " " + tmp.setNum(ca.column()) + " " + tmp.setNum(ca.height()) + " " + tmp.setNum(ca.width()) + " ";
+ docu.writeAttribute("CellAreas", outputData.simplified());
+ outputData.clear();
+ }
+
if (item->isGroup())
{
docu.writeAttribute("groupWidth", item->groupWidth);
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16859&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Wed Sep 28 19:01:38 2011
@@ -1118,6 +1118,70 @@
if ((pp >= 0) && (!retList2.contains(pp)))
retList2.prepend(pp);
par = (pp >= 0) ? docCharStyles[pp].parent() : QString();
+ }
+ for (int r = 0; r < retList2.count(); ++r)
+ {
+ if (!retList.contains(retList2[r]))
+ retList.append(retList2[r]);
+ }
+ }
+ return retList;
+}
+
+QList<int> ScribusDoc::getSortedTableStyleList()
+{
+ QList<int> retList;
+ for (int ff = 0; ff < docTableStyles.count(); ++ff)
+ {
+ if (docTableStyles[ff].parent().isEmpty())
+ {
+ if (!retList.contains(ff))
+ retList.append(ff);
+ continue;
+ }
+
+ QList<int> retList2;
+ QString name = docTableStyles[ff].name();
+ QString par = docTableStyles[ff].parent();
+ retList2.prepend(ff);
+ while ((!par.isEmpty()) && (par != name))
+ {
+ int pp = docTableStyles.find(par);
+ if ((pp >= 0) && (!retList2.contains(pp)))
+ retList2.prepend(pp);
+ par = (pp >= 0) ? docTableStyles[pp].parent() : QString();
+ }
+ for (int r = 0; r < retList2.count(); ++r)
+ {
+ if (!retList.contains(retList2[r]))
+ retList.append(retList2[r]);
+ }
+ }
+ return retList;
+}
+
+QList<int> ScribusDoc::getSortedCellStyleList()
+{
+ QList<int> retList;
+ for (int ff = 0; ff < docCellStyles.count(); ++ff)
+ {
+ if (docCellStyles[ff].parent().isEmpty())
+ {
+ if (!retList.contains(ff))
+ retList.append(ff);
+ continue;
+ }
+
+ QList<int> retList2;
+ QString name = docCellStyles[ff].name();
+ QString par = docCellStyles[ff].parent();
+ retList2.prepend(ff);
+ while ((!par.isEmpty()) && (par != name))
+ {
+ int pp = docCellStyles.find(par);
+ if ((pp >= 0) && (!retList2.contains(pp)))
+ retList2.prepend(pp);
+ par = (pp >= 0) ? docCellStyles[pp].parent() : QString();
}
for (int r = 0; r < retList2.count(); ++r)
{
Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16859&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Wed Sep 28 19:01:38 2011
@@ -577,6 +577,8 @@
QList<int> getSortedStyleList();
QList<int> getSortedCharStyleList();
+ QList<int> getSortedTableStyleList();
+ QList<int> getSortedCellStyleList();
void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
/**
More information about the scribus-commit
mailing list