r16660 by jghali - #10052 : incorrect style hierarchy caused by use of forward references on save
scribus-commit
scribus-commit at lists.scribus.net
Wed Jun 15 21:04:15 UTC 2011
Author: jghali
Date: Wed Jun 15 21:04:15 2011
New Revision: 16660
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16660
Log:
#10052 : incorrect style hierarchy caused by use of forward references on save
Modified:
branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
branches/Version135/Scribus/scribus/scribusdoc.cpp
branches/Version135/Scribus/scribus/scribusdoc.h
Modified: branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16660&path=/branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp (original)
+++ branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp Wed Jun 15 21:04:15 2011
@@ -418,11 +418,9 @@
void Scribus134Format::writePStyles(ScXmlStreamWriter & docu)
{
- // if (m_Doc->docParagraphStyles.count() > 5)
- {
- for (int ff = 0; ff < m_Doc->paragraphStyles().count(); ++ff)
- putPStyle(docu, m_Doc->paragraphStyles()[ff], "STYLE");
- }
+ QList<int> styleList = m_Doc->getSortedStyleList();
+ for (int a = 0; a < styleList.count(); ++a)
+ putPStyle(docu, m_Doc->paragraphStyles()[styleList[a]], "STYLE");
}
void Scribus134Format::putPStyle(ScXmlStreamWriter & docu, const ParagraphStyle & style, const QString &nodeName)
@@ -498,10 +496,11 @@
void Scribus134Format::writeCStyles(ScXmlStreamWriter & docu)
{
- for (int ff = 0; ff < m_Doc->charStyles().count(); ++ff)
+ QList<int> styleList = m_Doc->getSortedCharStyleList();
+ for (int a = 0; a < styleList.count(); ++a)
{
docu.writeStartElement("CHARSTYLE");
- putNamedCStyle(docu, m_Doc->charStyles()[ff]);
+ putNamedCStyle(docu, m_Doc->charStyles()[styleList[a]]);
docu.writeEndElement();
}
}
Modified: branches/Version135/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16660&path=/branches/Version135/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version135/Scribus/scribus/scribusdoc.cpp Wed Jun 15 21:04:15 2011
@@ -920,6 +920,67 @@
return false;
}
+QList<int> ScribusDoc::getSortedStyleList()
+{
+ QList<int> retList;
+ for (int ff = 0; ff < docParagraphStyles.count(); ++ff)
+ {
+ if (docParagraphStyles[ff].parent().isEmpty())
+ {
+ if (!retList.contains(ff))
+ retList.append(ff);
+ continue;
+ }
+
+ QList<int> retList2;
+ QString par = docParagraphStyles[ff].parent();
+ retList2.prepend(ff);
+ while (!par.isEmpty())
+ {
+ int pp = docParagraphStyles.find(par);
+ if ((pp >= 0) && (!retList2.contains(pp)))
+ retList2.prepend(pp);
+ par = (pp >= 0) ? docParagraphStyles[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::getSortedCharStyleList()
+{
+ QList<int> retList;
+ for (int ff = 0; ff < docCharStyles.count(); ++ff)
+ {
+ if (docCharStyles[ff].parent().isEmpty())
+ {
+ if (!retList.contains(ff))
+ retList.append(ff);
+ continue;
+ }
+
+ QList<int> retList2;
+ QString par = docCharStyles[ff].parent();
+ retList2.prepend(ff);
+ while (!par.isEmpty())
+ {
+ int pp = docCharStyles.find(par);
+ 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;
+}
void ScribusDoc::replaceStyles(const QMap<QString,QString>& newNameForOld)
{
Modified: branches/Version135/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16660&path=/branches/Version135/Scribus/scribus/scribusdoc.h
==============================================================================
--- branches/Version135/Scribus/scribus/scribusdoc.h (original)
+++ branches/Version135/Scribus/scribus/scribusdoc.h Wed Jun 15 21:04:15 2011
@@ -441,6 +441,9 @@
void getNamedResources(ResourceCollection& lists) const;
void replaceNamedResources(ResourceCollection& newNames);
bool styleExists(QString styleName);
+
+ QList<int> getSortedStyleList();
+ QList<int> getSortedCharStyleList();
void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
/**
More information about the scribus-commit
mailing list