r16680 by jghali - #10053 : style change not reflected in frames when working on legacy doccs

scribus-commit scribus-commit at lists.scribus.net
Mon Jun 20 20:31:06 UTC 2011


Author: jghali
Date: Mon Jun 20 20:31:05 2011
New Revision: 16680

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16680
Log:
#10053 : style change not reflected in frames when working on legacy doccs

Modified:
    branches/Version135/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
    branches/Version135/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
    branches/Version135/Scribus/scribus/text/storytext.cpp
    branches/Version135/Scribus/scribus/text/storytext.h

Modified: branches/Version135/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16680&path=/branches/Version135/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp (original)
+++ branches/Version135/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp Mon Jun 20 20:31:05 2011
@@ -762,6 +762,26 @@
 		while (m_Doc->FirstAuto->prevInChain())
 			m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain();
 	}
+
+	// fix legacy char formatting
+	for (int i = 0; i < m_Doc->DocItems.count(); ++i)
+	{
+		PageItem* item = m_Doc->DocItems.at(i);
+		if (item->prevInChain() == 0 && item->itemText.length() > 0)
+			item->itemText.fixLegacyFormatting();
+	}
+	for (int i = 0; i < m_Doc->MasterItems.count(); ++i)
+	{
+		PageItem* item = m_Doc->MasterItems.at(i);
+		if (item->prevInChain() == 0 && item->itemText.length() > 0)
+			item->itemText.fixLegacyFormatting();
+	}
+	for (int i = 0; i < m_Doc->FrameItems.count(); ++i)
+	{
+		PageItem* item = m_Doc->FrameItems.at(i);
+		if (item->prevInChain() == 0 && item->itemText.length() > 0)
+			item->itemText.fixLegacyFormatting();
+	}
 	
 	setCurrentComboItem(m_View->unitSwitcher, unitGetStrFromIndex(m_Doc->unitIndex()));
 	if (m_mwProgressBar!=0)
@@ -1478,6 +1498,26 @@
 						Its->link(Itn);
 					}
 				}
+
+				// fix legacy char formatting
+				for (int i = 0; i < m_Doc->DocItems.count(); ++i)
+				{
+					PageItem* item = m_Doc->DocItems.at(i);
+					if (item->prevInChain() == 0 && item->itemText.length() > 0)
+						item->itemText.fixLegacyFormatting();
+				}
+				for (int i = 0; i < m_Doc->MasterItems.count(); ++i)
+				{
+					PageItem* item = m_Doc->MasterItems.at(i);
+					if (item->prevInChain() == 0 && item->itemText.length() > 0)
+						item->itemText.fixLegacyFormatting();
+				}
+				for (int i = 0; i < m_Doc->FrameItems.count(); ++i)
+				{
+					PageItem* item = m_Doc->FrameItems.at(i);
+					if (item->prevInChain() == 0 && item->itemText.length() > 0)
+						item->itemText.fixLegacyFormatting();
+				}
 				
 				if (!Mpage)
 					m_View->reformPages();
@@ -1503,7 +1543,7 @@
 							m_Doc->BookMarks.append(bok);
 						}
 					}
-				PAGE=PAGE.nextSibling();
+					PAGE=PAGE.nextSibling();
 				}
 				return true;
 			}

Modified: branches/Version135/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16680&path=/branches/Version135/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp (original)
+++ branches/Version135/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp Mon Jun 20 20:31:05 2011
@@ -1150,6 +1150,26 @@
 		while (m_Doc->FirstAuto->prevInChain())
 			m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain();
 	}
+	
+	// fix legacy char formatting
+	for (int i = 0; i < m_Doc->DocItems.count(); ++i)
+	{
+		PageItem* item = m_Doc->DocItems.at(i);
+		if (item->prevInChain() == 0 && item->itemText.length() > 0)
+			item->itemText.fixLegacyFormatting();
+	}
+	for (int i = 0; i < m_Doc->MasterItems.count(); ++i)
+	{
+		PageItem* item = m_Doc->MasterItems.at(i);
+		if (item->prevInChain() == 0 && item->itemText.length() > 0)
+			item->itemText.fixLegacyFormatting();
+	}
+	for (int i = 0; i < m_Doc->FrameItems.count(); ++i)
+	{
+		PageItem* item = m_Doc->FrameItems.at(i);
+		if (item->prevInChain() == 0 && item->itemText.length() > 0)
+			item->itemText.fixLegacyFormatting();
+	}
 
 	// start auto save timer if needed
 	if (m_Doc->AutoSave  && ScCore->usingGUI())
@@ -1845,7 +1865,6 @@
 	if (it->hasAttribute("CULW"))
 		newStyle.setUnderlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("CULW"), -0.1) * 10));
 
-	
 	if (it->hasAttribute("CSTP"))
 		newStyle.setStrikethruOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSTP"), -0.1) * 10));
 	
@@ -2966,6 +2985,26 @@
 		while (m_Doc->FirstAuto->prevInChain())
 			m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain();
 	}
+
+	// fix legacy char formatting
+	for (int i = 0; i < m_Doc->DocItems.count(); ++i)
+	{
+		PageItem* item = m_Doc->DocItems.at(i);
+		if (item->prevInChain() == 0 && item->itemText.length() > 0)
+			item->itemText.fixLegacyFormatting();
+	}
+	for (int i = 0; i < m_Doc->MasterItems.count(); ++i)
+	{
+		PageItem* item = m_Doc->MasterItems.at(i);
+		if (item->prevInChain() == 0 && item->itemText.length() > 0)
+			item->itemText.fixLegacyFormatting();
+	}
+	for (int i = 0; i < m_Doc->FrameItems.count(); ++i)
+	{
+		PageItem* item = m_Doc->FrameItems.at(i);
+		if (item->prevInChain() == 0 && item->itemText.length() > 0)
+			item->itemText.fixLegacyFormatting();
+	}
 	
 	return true;
 }

Modified: branches/Version135/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16680&path=/branches/Version135/Scribus/scribus/text/storytext.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/text/storytext.cpp (original)
+++ branches/Version135/Scribus/scribus/text/storytext.cpp Mon Jun 20 20:31:05 2011
@@ -922,12 +922,56 @@
 	invalidate(0, len);	
 }
 
-
 void StoryText::replaceCharStyles(QMap<QString,QString> newNameForOld)
 {
 	ResourceCollection newnames;
 	newnames.mapCharStyles(newNameForOld);
 	replaceNamedResources(newnames);
+}
+
+void StoryText::fixLegacyFormatting()
+{
+	if (length() == 0)
+		return;
+
+	for (int i = 0; i < length(); ++ i)
+	{
+		if (d->at(i)->ch == SpecialChars::PARSEP)
+			fixLegacyFormatting(i);
+	}
+	fixLegacyFormatting( length() );
+}
+
+void StoryText::fixLegacyFormatting(int pos)
+{
+	if (length() == 0)
+		return;
+
+	if (pos < 0)
+		pos += length();
+
+	assert(pos >= 0);
+	assert(pos <= length());
+
+	int i = pos;
+	while (i > 0 && d->at(i - 1)->ch != SpecialChars::PARSEP) {
+		--i;
+	}
+
+	const ParagraphStyle& parStyle = this->paragraphStyle(pos);
+	parStyle.validate();
+
+	if (parStyle.hasParent())
+	{
+		int start = i;
+		while ((i < length()) && (d->at(i)->ch != SpecialChars::PARSEP))
+		{
+			d->at(i)->validate();
+			d->at(i)->eraseCharStyle( parStyle.charStyle() );
+			++i;
+		}
+		invalidate(start, qMin(i + 1, length()));
+	}
 }
 
 uint StoryText::nrOfParagraph() const

Modified: branches/Version135/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16680&path=/branches/Version135/Scribus/scribus/text/storytext.h
==============================================================================
--- branches/Version135/Scribus/scribus/text/storytext.h (original)
+++ branches/Version135/Scribus/scribus/text/storytext.h Mon Jun 20 20:31:05 2011
@@ -167,6 +167,13 @@
  	void eraseStyle(int pos, const ParagraphStyle& style);
 	void replaceStyles(QMap<QString,QString> newNameForOld);
 	void replaceCharStyles(QMap<QString,QString> newNameForOld);
+
+	// Cleanup legacy formatting for whole story, ie remove direct
+	// formatting for parameters already set at paragraph level
+	void fixLegacyFormatting();
+	
+	// Cleanup legacy formatting for paragraph at position pos
+	void fixLegacyFormatting(int pos);
 	
 	void getNamedResources(ResourceCollection& lists) const;
 	void replaceNamedResources(ResourceCollection& newNames);




More information about the scribus-commit mailing list