r22783 by jghali - refactor Scribus150Format::saveElements()
scribus-commit
scribus-commit at lists.scribus.net
Mon Dec 10 00:23:12 UTC 2018
Author: jghali
Date: Mon Dec 10 00:23:12 2018
New Revision: 22783
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22783
Log:
refactor Scribus150Format::saveElements()
Modified:
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.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22783&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 Dec 10 00:23:12 2018
@@ -157,7 +157,7 @@
PageItem* pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& attrs, const QString& baseDir, PageItem::ItemKind itemKind, int pagenr = -2 /* currentPage*/);
void writeCheckerProfiles(ScXmlStreamWriter& docu);
- void writeLinestyles(ScXmlStreamWriter& docu);
+ void writeLineStyles(ScXmlStreamWriter& docu);
void writeJavascripts(ScXmlStreamWriter& docu);
void writeBookmarks(ScXmlStreamWriter& docu);
void writeColors(ScXmlStreamWriter& docu, bool part = false);
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22783&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 Dec 10 00:23:12 2018
@@ -47,9 +47,14 @@
QString Scribus150Format::saveElements(double xp, double yp, double wp, double hp, Selection* selection, QByteArray &prevData)
{
+ ResourceCollection lists;
+ QList<PageItem*> emG;
+ QList<PageItem*> emF;
+
QString fileDir = ScPaths::applicationDataDir();
QString documentStr;
documentStr.reserve(524288);
+
ScXmlStreamWriter writer(&documentStr);
writer.setAutoFormatting(true);
// writer.writeStartDocument();
@@ -63,73 +68,53 @@
writer.writeAttribute("previewData", QString(prevData));
writeColors(writer, true);
writeGradients(writer, true);
- ResourceCollection lists;
- QList<PageItem*> emG;
- QList<PageItem*> emF;
-
- for (int cor = 0; cor < selection->count(); ++cor)
- {
- PageItem *currItem = selection->itemAt(cor);
+
+ for (int i = 0; i < selection->count(); ++i)
+ {
+ PageItem *currItem = selection->itemAt(i);
currItem->getNamedResources(lists);
emG.append(currItem);
- if ((currItem->asTextFrame()) || (currItem->asPathText()))
- {
- //for notes frames text should not be saved
- if (currItem->isNoteFrame())
+ if ((!currItem->asTextFrame()) && (!currItem->asPathText()))
+ continue;
+ //for notes frames text should not be saved
+ if (currItem->isNoteFrame())
+ continue;
+ for (int j = currItem->firstInFrame(); j <= currItem->lastInFrame(); ++j)
+ {
+ QChar chr = currItem->itemText.text(j);
+ if (chr != SpecialChars::OBJECT)
continue;
- for (int e = currItem->firstInFrame(); e <= currItem->lastInFrame(); ++e)
- {
- uint chr = currItem->itemText.text(e).unicode();
- if (chr == 25)
- {
- if ((currItem->itemText.hasObject(e)))
- {
- PageItem* pi = currItem->itemText.object(e).getPageItem(currItem->doc());
- if (!emF.contains(pi))
- {
- emF.append(pi);
- }
- }
- }
- }
+ if (!currItem->itemText.hasObject(j))
+ continue;
+ PageItem* pi = currItem->itemText.object(j).getPageItem(currItem->doc());
+ if (!emF.contains(pi))
+ emF.append(pi);
}
}
QList<QString>::Iterator it;
QList<QString> names = lists.styleNames();
QList<int> styleList = m_Doc->getSortedStyleList();
- for (int a = 0; a < styleList.count(); ++a)
- {
- if (names.contains(m_Doc->paragraphStyles()[styleList[a]].name()))
- putPStyle(writer, m_Doc->paragraphStyles()[styleList[a]], "STYLE");
- }
-// for (it = names.begin(); it != names.end(); ++it)
-// {
-// putPStyle(writer, m_Doc->paragraphStyles().get(*it), "STYLE");
-// }
+ for (int i = 0; i < styleList.count(); ++i)
+ {
+ const ParagraphStyle& paragraphStyle = m_Doc->paragraphStyles()[styleList[i]];
+ if (names.contains(paragraphStyle.name()))
+ putPStyle(writer, paragraphStyle, "STYLE");
+ }
+
names = lists.charStyleNames();
styleList = m_Doc->getSortedCharStyleList();
- for (int a = 0; a < styleList.count(); ++a)
- {
- if (names.contains(m_Doc->charStyles()[styleList[a]].name()))
- {
- writer.writeStartElement("CHARSTYLE");
- putNamedCStyle(writer, m_Doc->charStyles()[styleList[a]]);
- writer.writeEndElement();
- }
- }
-// for (it = names.begin(); it != names.end(); ++it)
-// {
-// writer.writeStartElement("CHARSTYLE");
-// putNamedCStyle(writer, m_Doc->charStyles().get(*it));
-// writer.writeEndElement();
-// }
-/* names = lists.lineStyleNames();
- for (it = names.begin(); it != names.end(); ++it)
- {
- writeLinestyles(writer, true, *it);
- } */
- writeLinestyles(writer);
+ for (int i = 0; i < styleList.count(); ++i)
+ {
+ const CharStyle& charStyle = m_Doc->charStyles()[styleList[i]];
+ if (!names.contains(charStyle.name()))
+ continue;
+ writer.writeStartElement("CHARSTYLE");
+ putNamedCStyle(writer, charStyle);
+ writer.writeEndElement();
+ }
+
+ writeLineStyles(writer);
writePatterns(writer, fileDir, true, selection);
if (!emF.isEmpty())
WriteObjects(m_Doc, writer, fileDir, nullptr, 0, ItemSelectionFrame, &emF);
@@ -418,7 +403,7 @@
writeCStyles(docu);
writeTableStyles(docu);
writeCellStyles(docu);
- writeLinestyles(docu);
+ writeLineStyles(docu);
writeLayers(docu);
writePrintOptions(docu);
writePdfOptions(docu);
@@ -495,7 +480,7 @@
}
}
-void Scribus150Format::writeLinestyles(ScXmlStreamWriter& docu)
+void Scribus150Format::writeLineStyles(ScXmlStreamWriter& docu)
{
QHash<QString,multiLine>::Iterator itMU;
for (itMU = m_Doc->MLineStyles.begin(); itMU != m_Doc->MLineStyles.end(); ++itMU)
More information about the scribus-commit
mailing list