r24685 by jghali - Reduce indentation in ScribusDoc's loadStylesFromFile() by returning early when possible

scribus-commit scribus-commit at lists.scribus.net
Tue Aug 3 15:58:47 UTC 2021


Author: jghali
Date: Tue Aug  3 15:58:47 2021
New Revision: 24685

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24685
Log:
Reduce indentation in ScribusDoc's loadStylesFromFile() by returning early when possible

Modified:
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24685&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Tue Aug  3 15:58:47 2021
@@ -1498,68 +1498,68 @@
 	StyleSet<CharStyle> *wrkCharStyles      = tempCharStyles;
 	QHash<QString, multiLine> *wrkLineStyles = tempLineStyles;
 	
-	if (!fileName.isEmpty())
-	{
-		FileLoader fl(fileName);
-		if (fl.testFile() == -1)
+	if (fileName.isEmpty())
+		return;
+
+	FileLoader fl(fileName);
+	if (fl.testFile() == -1)
+	//TODO put in nice user warning
+		return;
+
+	if (!fl.readStyles(this, *wrkStyles))
+	{
 		//TODO put in nice user warning
-			return;
-
-		if (!fl.readStyles(this, *wrkStyles))
-		{
-			//TODO put in nice user warning
-		}
-
-		if (!fl.readCharStyles(this, *wrkCharStyles))
-		{
-			//TODO put in nice user warning
-		}
-
-		if (!fl.readLineStyles(wrkLineStyles))
-		{
-			//TODO put in nice user warning
-		}
+	}
+
+	if (!fl.readCharStyles(this, *wrkCharStyles))
+	{
+		//TODO put in nice user warning
+	}
+
+	if (!fl.readLineStyles(wrkLineStyles))
+	{
+		//TODO put in nice user warning
+	}
 		
-		// Which are the default styles 
-		// Sadly StyleSet is not updated at import
-		// and it might break something to do so. 
-		// We need to loop then - pm
+	// Which are the default styles 
+	// Sadly StyleSet is not updated at import
+	// and it might break something to do so. 
+	// We need to loop then - pm
 				
-		QFileInfo fi(fileName);
-		QString importPrefix(tr("Imported ","Prefix of imported default style"));
-		QString importSuffix(" (" +  fi.baseName() + ")");
+	QFileInfo fi(fileName);
+	QString importPrefix(tr("Imported ", "Prefix of imported default style"));
+	QString importSuffix(" (" +  fi.baseName() + ")");
 		
-		for (int j(0) ; j < wrkStyles->count() ; ++j)
-		{
-			if ((*wrkStyles)[j].isDefaultStyle())
-			{
-				ParagraphStyle& parDefault((*wrkStyles)[j]);
-				parDefault.setDefaultStyle(false);
-				QMap<QString, QString> namesMap;
-				namesMap[parDefault.name()] = importPrefix + parDefault.name() + importSuffix;
-				for (int i(0) ; i < wrkStyles->count() ; ++i)
-				{
-					if ((*wrkStyles)[i] != parDefault)
-						namesMap[(*wrkStyles)[i].name()] = (*wrkStyles)[i].name();
-				}
-				wrkStyles->rename(namesMap);
-			}
-		}
-		for (int j(0) ; j < wrkCharStyles->count() ; ++j)
-		{
-			if ((*wrkCharStyles)[j].isDefaultStyle())
-			{
-				CharStyle& charDefault((*wrkCharStyles)[j]);
-				charDefault.setDefaultStyle(false);
-				QMap<QString, QString> namesMap;
-				namesMap[charDefault.name()] = importPrefix + charDefault.name() + importSuffix;
-				for (int i(0) ; i < wrkCharStyles->count() ; ++i)
-				{
-					if ((*wrkCharStyles)[i] != charDefault)
-						namesMap[(*wrkCharStyles)[i].name()] = (*wrkCharStyles)[i].name();
-				}
-				wrkCharStyles->rename(namesMap);
-			}
+	for (int j(0) ; j < wrkStyles->count() ; ++j)
+	{
+		if ((*wrkStyles)[j].isDefaultStyle())
+		{
+			ParagraphStyle& parDefault((*wrkStyles)[j]);
+			parDefault.setDefaultStyle(false);
+			QMap<QString, QString> namesMap;
+			namesMap[parDefault.name()] = importPrefix + parDefault.name() + importSuffix;
+			for (int i(0) ; i < wrkStyles->count() ; ++i)
+			{
+				if ((*wrkStyles)[i] != parDefault)
+					namesMap[(*wrkStyles)[i].name()] = (*wrkStyles)[i].name();
+			}
+			wrkStyles->rename(namesMap);
+		}
+	}
+	for (int j(0) ; j < wrkCharStyles->count() ; ++j)
+	{
+		if ((*wrkCharStyles)[j].isDefaultStyle())
+		{
+			CharStyle& charDefault((*wrkCharStyles)[j]);
+			charDefault.setDefaultStyle(false);
+			QMap<QString, QString> namesMap;
+			namesMap[charDefault.name()] = importPrefix + charDefault.name() + importSuffix;
+			for (int i(0) ; i < wrkCharStyles->count() ; ++i)
+			{
+				if ((*wrkCharStyles)[i] != charDefault)
+					namesMap[(*wrkCharStyles)[i].name()] = (*wrkCharStyles)[i].name();
+			}
+			wrkCharStyles->rename(namesMap);
 		}
 	}
 }




More information about the scribus-commit mailing list