r16681 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:33:27 UTC 2011
Author: jghali
Date: Mon Jun 20 20:33:27 2011
New Revision: 16681
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16681
Log:
#10053 : style change not reflected in frames when working on legacy doccs
Modified:
trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
trunk/Scribus/scribus/text/storytext.cpp
trunk/Scribus/scribus/text/storytext.h
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16681&path=/trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp Mon Jun 20 20:33:27 2011
@@ -1263,6 +1263,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)
@@ -1996,6 +2016,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();
@@ -2021,7 +2061,7 @@
m_Doc->BookMarks.append(bok);
}
}
- PAGE=PAGE.nextSibling();
+ PAGE=PAGE.nextSibling();
}
return true;
}
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16681&path=/trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp Mon Jun 20 20:33:27 2011
@@ -1089,6 +1089,26 @@
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())
m_Doc->autoSaveTimer->start(m_Doc->autoSaveTime());
@@ -2331,6 +2351,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: trunk/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16681&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp (original)
+++ trunk/Scribus/scribus/text/storytext.cpp Mon Jun 20 20:33:27 2011
@@ -927,6 +927,51 @@
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: trunk/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16681&path=/trunk/Scribus/scribus/text/storytext.h
==============================================================================
--- trunk/Scribus/scribus/text/storytext.h (original)
+++ trunk/Scribus/scribus/text/storytext.h Mon Jun 20 20:33:27 2011
@@ -169,6 +169,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