r21366 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Sat Jun 4 23:57:01 UTC 2016


Author: jghali
Date: Sat Jun  4 23:57:01 2016
New Revision: 21366

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21366
Log:
#14129: fix reference to deleted styles when loading documents

Modified:
    branches/Version14x/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    branches/Version14x/Scribus/scribus/scribusdoc.cpp
    branches/Version14x/Scribus/scribus/scribusdoc.h
    branches/Version14x/Scribus/scribus/styles/styleset.h

Modified: branches/Version14x/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21366&path=/branches/Version14x/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(original)
+++ branches/Version14x/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp	Sat Jun  4 23:57:01 2016
@@ -1572,6 +1572,11 @@
 	m_Doc->reformPages();
 	m_Doc->refreshGuides();
 
+	// #12282 : some docs have language dependent style names specified in style properties
+	// #14129 : some docs reference deleted character styles
+	m_Doc->fixCharacterStyles();
+	m_Doc->fixParagraphStyles();
+
 	// Some old long doc may have page owner somewhat broken
 	m_Doc->fixItemPageOwner();
 

Modified: branches/Version14x/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21366&path=/branches/Version14x/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusdoc.cpp	(original)
+++ branches/Version14x/Scribus/scribus/scribusdoc.cpp	Sat Jun  4 23:57:01 2016
@@ -4533,6 +4533,38 @@
 	}
 }
 
+void ScribusDoc::fixCharacterStyles()
+{
+	for (int i = 0; i < docCharStyles.count(); ++i)
+	{
+		CharStyle& charStyle = docCharStyles[i];
+		QString parentName = charStyle.parent();
+		if (parentName.isEmpty())
+			continue;
+		if (!docCharStyles.contains(parentName))
+			charStyle.setParent(QString());
+	}
+}
+
+void ScribusDoc::fixParagraphStyles()
+{
+	for (int i = 0; i < docParagraphStyles.count(); ++i)
+	{
+		ParagraphStyle& parStyle = docParagraphStyles[i];
+		QString parentName = parStyle.parent();
+		if (!parentName.isEmpty())
+		{
+			if (!docParagraphStyles.contains(parentName))
+				parStyle.setParent(QString());
+		}
+		QString charStyleName = parStyle.charStyle().parent();
+		if (!charStyleName.isEmpty())
+		{
+			if (!docCharStyles.contains(charStyleName))
+				parStyle.charStyle().setParent(QString());
+		}
+	}
+}
 
 struct oldPageVar
 {

Modified: branches/Version14x/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21366&path=/branches/Version14x/Scribus/scribus/scribusdoc.h
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusdoc.h	(original)
+++ branches/Version14x/Scribus/scribus/scribusdoc.h	Sat Jun  4 23:57:01 2016
@@ -705,6 +705,10 @@
 	void refreshGuides();
 	/** @brief Check and fix if needed PageItem OwnPage member */
 	void fixItemPageOwner();
+	/** @brief Fix paragraph styles */
+	void fixCharacterStyles();
+	/** @brief Fix paragraph styles */
+	void fixParagraphStyles();
 	
 	/**
 	 * @brief Return the x or y offset for a page on the canvas

Modified: branches/Version14x/Scribus/scribus/styles/styleset.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21366&path=/branches/Version14x/Scribus/scribus/styles/styleset.h
==============================================================================
--- branches/Version14x/Scribus/scribus/styles/styleset.h	(original)
+++ branches/Version14x/Scribus/scribus/styles/styleset.h	Sat Jun  4 23:57:01 2016
@@ -27,6 +27,8 @@
 		assert(index < styles.count()); 
 		return * styles[index]; 
 	}
+
+	inline bool contains(const QString& name) const;
 	
 	inline int find(const QString& name) const;
 
@@ -110,6 +112,15 @@
 //	delete (*it);
 //	styles.erase(it);
 	styles.removeAt(index);
+}
+
+template<class STYLE>
+inline bool StyleSet<STYLE>::contains(const QString& name) const
+{
+	for (int i=0; i < styles.count(); ++i)
+		if (styles[i]->name() == name)
+			return true;
+	return false;
 }
 
 template<class STYLE>




More information about the scribus-commit mailing list