r23535 by jghali - Fix chicken and egg issue between numbered lists updates and text layout updates

scribus-commit scribus-commit at lists.scribus.net
Tue Mar 24 15:58:55 UTC 2020


Author: jghali
Date: Tue Mar 24 15:58:55 2020
New Revision: 23535

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23535
Log:
Fix chicken and egg issue between numbered lists updates and text layout updates

This patch enforces the ability to update numbers in numbered lists without prior knowledge of text layout. For this we have however to remove several existing numeration ranges: section, page, frame. Only document and story remain.

Modified:
    trunk/Scribus/scribus/gtaction.cpp
    trunk/Scribus/scribus/numeration.h
    trunk/Scribus/scribus/pageitem_noteframe.cpp
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/pageitem_textframe.h
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/ui/notesstyleseditor.cpp
    trunk/Scribus/scribus/ui/propertywidget_pareffect.cpp
    trunk/Scribus/scribus/ui/smpstylewidget.cpp
    trunk/Scribus/scribus/ui/smtextstyles.cpp

Modified: trunk/Scribus/scribus/gtaction.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/gtaction.cpp
==============================================================================
--- trunk/Scribus/scribus/gtaction.cpp	(original)
+++ trunk/Scribus/scribus/gtaction.cpp	Tue Mar 24 15:58:55 2020
@@ -138,14 +138,8 @@
 		{
 			NotesStyle* nStyle = m_note->notesStyle();
 			QString label = "NoteMark_" + nStyle->name();
-			if (nStyle->range() == NSRsection)
-				label += " in section " + m_it->m_Doc->getSectionNameForPageIndex(m_it->OwnPage) + " page " + QString::number(m_it->OwnPage +1);
-			else if (nStyle->range() == NSRpage)
-				label += " on page " + QString::number(m_it->OwnPage +1);
-			else if (nStyle->range() == NSRstory)
+			if (nStyle->range() == NSRstory)
 				label += " in " + m_it->firstInChain()->itemName();
-			else if (nStyle->range() == NSRframe)
-				label += " in frame" + m_it->itemName();
 			if (m_it->m_Doc->getMark(label + "_1", MARKNoteMasterType) != nullptr)
 				getUniqueName(label,m_it->m_Doc->marksLabelsList(MARKNoteMasterType), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
 			else
@@ -293,14 +287,8 @@
 		{
 			NotesStyle* nStyle = m_note->notesStyle();
 			QString label = "NoteMark_" + nStyle->name();
-			if (nStyle->range() == NSRsection)
-				label += " in section " + m_it->m_Doc->getSectionNameForPageIndex(m_it->OwnPage) + " page " + QString::number(m_it->OwnPage +1);
-			else if (nStyle->range() == NSRpage)
-				label += " on page " + QString::number(m_it->OwnPage +1);
-			else if (nStyle->range() == NSRstory)
+			if (nStyle->range() == NSRstory)
 				label += " in " + m_it->firstInChain()->itemName();
-			else if (nStyle->range() == NSRframe)
-				label += " in frame" + m_it->itemName();
 			if (m_it->m_Doc->getMark(label + "_1", MARKNoteMasterType) != nullptr)
 				getUniqueName(label,m_it->m_Doc->marksLabelsList(MARKNoteMasterType), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
 			else

Modified: trunk/Scribus/scribus/numeration.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/numeration.h
==============================================================================
--- trunk/Scribus/scribus/numeration.h	(original)
+++ trunk/Scribus/scribus/numeration.h	Tue Mar 24 15:58:55 2020
@@ -24,17 +24,16 @@
 enum NumerationRange
 {
 	NSRdocument,
-	NSRsection,
+	NSRsection, // deprecated, kept only to allow loading old documents
 	NSRstory,
-	NSRpage,
-	NSRframe
-//	NSRblock //used for contignous numeration eg. paragraphs - paragraph without numbering reset counter
+	NSRpage, // deprecated, kept only to allow loading old documents
+	NSRframe // deprecated, kept only to allow loading old documents
 };
 
 class Numeration
 {
 public:
-	Numeration() : numFormat(Type_1_2_3), asterix(QString()), lead('0'), len(0), range(NSRdocument), prefix(QString()), suffix(QString()), start(1) {}
+	Numeration() : numFormat(Type_1_2_3), asterix(QString()), lead('0'), range(NSRdocument) {}
 	Numeration(NumFormat f) : numFormat(f), asterix("*") {}
 	
 	QString numString(int num) const;
@@ -42,11 +41,11 @@
 	NumFormat numFormat;
 	QString asterix;
 	QChar lead;
-	int len;
+	int len { 0 };
 	NumerationRange range;
 	QString prefix;
 	QString suffix;
-	int start;
+	int start { 1 };
 };
 
 struct NumFormatPair

Modified: trunk/Scribus/scribus/pageitem_noteframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/pageitem_noteframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_noteframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_noteframe.cpp	Tue Mar 24 15:58:55 2020
@@ -249,14 +249,8 @@
 		mrk = m_Doc->newMark();
 		mrk->setType(MARKNoteFrameType);
 		QString label = "NoteFrameMark_" + notesStyle()->name();
-		if (notesStyle()->range() == NSRsection)
-			label += " in section " + m_Doc->getSectionNameForPageIndex(note->masterMark()->OwnPage) + " page " + QString::number(note->masterMark()->OwnPage +1);
-		else if (notesStyle()->range() == NSRpage)
-			label += " on page " + QString::number(note->masterMark()->OwnPage +1);
-		else if (notesStyle()->range() == NSRstory)
+		if (notesStyle()->range() == NSRstory)
 			label += " in " + note->masterMark()->getItemPtr()->firstInChain()->itemName();
-		else if (notesStyle()->range() == NSRframe)
-			label += " in frame " + note->masterMark()->getItemName();
 		mrk->label = label + "_" + note->numString();
 		mrk->setNotePtr(note);
 		getUniqueName(mrk->label, m_Doc->marksLabelsList(MARKNoteFrameType), "_");

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Tue Mar 24 15:58:55 2020
@@ -3034,7 +3034,13 @@
 	}
 }
 
-void PageItem_TextFrame::slotInvalidateLayout(int firstItem, int endItem)
+void PageItem_TextFrame::invalidateLayout(int firstChar)
+{
+	int storyLen = itemText.length();
+	slotInvalidateLayout(firstChar, storyLen);
+}
+
+void PageItem_TextFrame::slotInvalidateLayout(int firstItem, int /*endItem*/)
 {
 	PageItem* firstFrame = firstInChain();
 	firstItem = itemText.prevParagraph(firstItem);
@@ -4831,8 +4837,8 @@
 		}
 
 	}
+
 	m_Doc->updateNumbers();
-
 }
 
 
@@ -5661,17 +5667,11 @@
 						case NSRdocument:
 							m_Doc->setEndNoteFrame(nF, (void*) nullptr);
 							break;
-						case NSRsection:
-							m_Doc->setEndNoteFrame(nF, m_Doc->getSectionKeyForPageIndex(OwnPage));
-							break;
 						case NSRstory:
 							m_Doc->setEndNoteFrame(nF, (void*) firstInChain());
 							break;
-						case NSRpage:
-							m_Doc->setEndNoteFrame(nF, (void*) m_Doc->DocPages.at(OwnPage));
-							break;
-						case NSRframe:
-							qDebug() << "Frame range is prohibited for end-notes";
+						default:
+							qDebug() << "Deprecated range prohibited for end-notes";
 							Q_ASSERT(false);
 							break;
 					}

Modified: trunk/Scribus/scribus/pageitem_textframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/pageitem_textframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.h	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.h	Tue Mar 24 15:58:55 2020
@@ -71,8 +71,10 @@
 
 	//for speed up updates when changed was only one frame from chain
 	virtual void invalidateLayout(bool wholeChain);
+	virtual void invalidateLayout(int firstChar);
 	using PageItem::invalidateLayout;
 	void layout() override;
+
 	//return true if all previouse frames from chain are valid (including that one)
 	bool isValidChainFromBegin();
 	void setTextAnnotationOpen(bool open);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	Tue Mar 24 15:58:55 2020
@@ -3511,7 +3511,11 @@
 				NS.setType(Type_CJK);
 			else //if (type == "Type_None")
 				NS.setType(Type_None);
-			NS.setRange((NumerationRange) attrs.valueAsInt("Range"));
+			// Fix deprecated numeration ranges
+			NumerationRange numRange = (NumerationRange) attrs.valueAsInt("Range");
+			if (numRange != NSRdocument && numRange != NSRstory)
+				numRange = NSRstory;
+			NS.setRange(numRange);
 			NS.setPrefix(attrs.valueAsString("Prefix"));
 			NS.setSuffix(attrs.valueAsString("Suffix"));
 			NS.setAutoNotesHeight(attrs.valueAsBool("AutoHeight"));
@@ -3555,6 +3559,9 @@
 			{
 				eF.index = attrs.valueAsInt("index");
 				eF.NSrange = (NumerationRange) attrs.valueAsInt("range");
+				 // Fix deprecated numeration ranges
+				if (eF.NSrange != NSRdocument && eF.NSrange != NSRstory)
+					eF.NSrange = NSRstory;
 				eF.itemID = attrs.valueAsInt("ItemID");
 			}
 			if (reader.name() == "FOOTNOTEFRAME")
@@ -5240,7 +5247,13 @@
 	if (attrs.hasAttribute("NumerationSuffix"))
 		pstyle.setNumSuffix(attrs.valueAsString("NumerationSuffix"));
 	if (attrs.hasAttribute("NumerationRestart"))
-		pstyle.setNumRestart(attrs.valueAsInt("NumerationRestart"));
+	{
+		NumerationRange numRange = (NumerationRange) attrs.valueAsInt("NumerationRestart");
+		// Fix deprecated numeration ranges
+		if (numRange != NSRdocument && numRange != NSRstory)
+			numRange = NSRstory;
+		pstyle.setNumRestart(static_cast<int>(numRange));
+	}
 	if (attrs.hasAttribute("NumeartionOther"))
 		pstyle.setNumOther(static_cast<bool>(attrs.valueAsInt("NumeartionOther")));
 	if (attrs.hasAttribute("NumerationHigher"))
@@ -7086,10 +7099,6 @@
 					{
 						if (eF.NSrange == NSRdocument)
 							m_Doc->setEndNoteFrame(item->asNoteFrame(), (void*) nullptr);
-						else if (eF.NSrange == NSRpage)
-							m_Doc->setEndNoteFrame(item->asNoteFrame(), (void*) m_Doc->DocPages.at(eF.index));
-						else if (eF.NSrange == NSRsection)
-							m_Doc->setEndNoteFrame(item->asNoteFrame(), m_Doc->getSectionKeyForPageIndex(eF.index));
 						else if (eF.NSrange == NSRstory)
 							m_Doc->setEndNoteFrame(item->asNoteFrame(), (void*) LinkID.value(eF.itemID));
 					}

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp	Tue Mar 24 15:58:55 2020
@@ -1417,11 +1417,7 @@
 			//docu.writeAttribute("name", nF->itemName());
 			
 			rangeItem rI = m_Doc->m_docEndNotesFramesMap.value(nF);
-			if (NS->range() == NSRsection)
-				docu.writeAttribute("index", rI.sectionIndex);
-			else if (NS->range() == NSRpage)
-				docu.writeAttribute("index", rI.page->pageNr());
-			else if (NS->range() == NSRstory)
+			if (NS->range() == NSRstory)
 				docu.writeAttribute("ItemID", qHash(rI.firstStoryFrame) & 0x7FFFFFFF);
 				//docu.writeAttribute("item", rI.firstStoryFrame->itemName());
 		}

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Tue Mar 24 15:58:55 2020
@@ -3769,6 +3769,7 @@
 		/*QTime t;
 		t.start();*/
 		doc->flag_Renumber = false;
+		doc->updateNumbers(true);
 		for (auto iti = doc->Items->begin(); iti != doc->Items->end(); ++iti)
 		{
 			PageItem* ite = *iti;
@@ -3814,7 +3815,6 @@
 		// Seems to fix crash on loading
 		ActWin = nullptr;
 		newActWin(w->getSubWin());
-		doc->updateNumbers(true);
 		emit UpdateRequest(reqNumUpdate);
 		doc->setCurrentPage(doc->DocPages.at(0));
 		scrActions["viewToggleCMS"]->setChecked(doc->HasCMS);
@@ -9494,14 +9494,8 @@
 		}
 		NotesStyle* nStyle = doc->m_docNotesStylesList.at(0);
 		QString label = "NoteMark_" + nStyle->name();
-		if (nStyle->range() == NSRsection)
-			label += " in section " + doc->getSectionNameForPageIndex(currItem->OwnPage) + " page " + QString::number(currItem->OwnPage +1);
-		else if (nStyle->range() == NSRpage)
-			label += " on page " + QString::number(currItem->OwnPage +1);
-		else if (nStyle->range() == NSRstory)
+		if (nStyle->range() == NSRstory)
 			label += " in " + currItem->firstInChain()->itemName();
-		else if (nStyle->range() == NSRframe)
-			label += " in frame" + currItem->itemName();
 		if (doc->getMark(label + "_1", MARKNoteMasterType) != nullptr)
 			getUniqueName(label,doc->marksLabelsList(MARKNoteMasterType), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
 		else
@@ -9633,14 +9627,8 @@
 
 			markdata.notePtr = doc->newNote(NStyle);
 			label = "NoteMark_" + NStyle->name();
-			if (NStyle->range() == NSRsection)
-				label += " in section " + doc->getSectionNameForPageIndex(currItem->OwnPage) + " page " + QString::number(currItem->OwnPage +1);
-			else if (NStyle->range() == NSRpage)
-				label += " on page " + QString::number(currItem->OwnPage +1);
-			else if (NStyle->range() == NSRstory)
+			if (NStyle->range() == NSRstory)
 				label += " in " + currItem->firstInChain()->itemName();
-			else if (NStyle->range() == NSRframe)
-				label += " in frame" + currItem->itemName();
 			break;
 		case MARKIndexType:
 				return false;

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Tue Mar 24 15:58:55 2020
@@ -16718,7 +16718,7 @@
 	
 	Numeration num;
 	NumStruct * numS = nullptr;
-	for (int i=0; i < m_docParagraphStyles.count(); ++i)
+	for (int i = 0; i < m_docParagraphStyles.count(); ++i)
 	{
 		ParagraphStyle &style = m_docParagraphStyles[i];
 		if (!style.hasNum())
@@ -16735,13 +16735,14 @@
 		num.numFormat = (NumFormat) style.numFormat();
 		num.prefix = style.numPrefix();
 		num.suffix = style.numSuffix();
+		num.range = (NumerationRange) style.numRestart();
 		num.start = style.numStart();
 		int level = style.numLevel();
 		if (level >= numS->m_counters.count())
 		{
-			for (int i=numS->m_counters.count(); i <= level; ++i)
-			{
-				numS->m_nums.insert(i,num);
+			for (int i = numS->m_counters.count(); i <= level; ++i)
+			{
+				numS->m_nums.insert(i, num);
 				numS->m_counters.insert(i, 0);
 			}
 		}
@@ -16818,214 +16819,239 @@
 		numS->m_counters.replace(level, number);
 }
 
-bool ScribusDoc::updateLocalNums(StoryText& itemText)
-{
-	QVector<Numeration> m_nums;
-	QList<int> m_counters;
-	bool needUpdate = false;
+int ScribusDoc::updateLocalNums(StoryText& itemText)
+{
+	int firstInvalidChar = -1;
+	QVector<Numeration> nums;
+	QList<int> counters;
+
 	for (int pos = 0; pos < itemText.length(); ++pos)
 	{
-		if (pos != 0 && itemText.text(pos-1) != SpecialChars::PARSEP)
+		if (pos != 0 && itemText.text(pos - 1) != SpecialChars::PARSEP)
 			continue;
 		Mark* mark = itemText.mark(pos);
-		if (mark != nullptr && mark->isType(MARKBullNumType) && itemText.paragraphStyle(pos).hasNum())
-		{
-			const ParagraphStyle& style = itemText.paragraphStyle(pos);
-			if (style.numName() == "<local block>")
-			{
-				int level = style.numLevel();
-				while (m_counters.count() < (level + 1))
-				{
-					m_counters.append(0);
-					Numeration num((NumFormat) style.numFormat());
-					m_nums.append(num);
-				}
-				Numeration num = m_nums.at(level);
-				num.prefix = style.numPrefix();
-				num.suffix = style.numSuffix();
-				num.start = style.numStart();
-				num.numFormat = (NumFormat) style.numFormat();
-				m_nums.replace(level, num);
-				int count = m_counters.at(level);
-				bool reset = false;
-				if (pos == 0)
-					reset = true;
-				else if (pos > 0)
-				{
-					ParagraphStyle prevStyle;
-					prevStyle = itemText.paragraphStyle(pos -1);
-					reset = !prevStyle.hasNum()
-							|| prevStyle.numName() != "<local block>"
-							|| prevStyle.numLevel() < level
-							|| prevStyle.numFormat() != style.numFormat();
-				}
-				if ((level == 0) && (style.numFormat() != (int) num.numFormat))
-				{
-					reset = true;
-					m_counters.clear();
-					m_counters.append(0);
-					m_nums.clear();
-					m_nums.append(num);
-				}
-				if (reset)
-					count = style.numStart();
-				else
-					count++;
-				m_counters.replace(level, count);
-				//m_nums.insert(level, num);
-				QString result;
-				for (int i=0; i <= level; ++i)
-				{
-					result.append(m_nums.at(i).prefix);
-					result.append(getStringFromNum(m_nums.at(i).numFormat, m_counters.at(i)));
-					result.append(m_nums.at(i).suffix);
-				}
-				if (mark->getString() != result)
-				{
-					mark->setString(result);
-					needUpdate = true;
-				}
-			}
-		}
-	}
-	return needUpdate;
+		if (mark == nullptr)
+			continue;
+		if (!mark->isType(MARKBullNumType) || !itemText.paragraphStyle(pos).hasNum())
+			continue;
+
+		const ParagraphStyle& style = itemText.paragraphStyle(pos);
+		if (style.numName() != "<local block>")
+			continue;
+
+		int level = style.numLevel();
+		while (counters.count() < (level + 1))
+		{
+			counters.append(0);
+			Numeration num((NumFormat) style.numFormat());
+			num.prefix = style.numPrefix();
+			num.suffix = style.numSuffix();
+			num.start = style.numStart();
+			nums.append(num);
+		}
+		Numeration num = nums.at(level);
+		num.prefix = style.numPrefix();
+		num.suffix = style.numSuffix();
+		// num.range = NSRstory; Shouldn't we add this or num.range = (NumerationRange) style.numRestart() ?
+		num.start = style.numStart();
+		num.numFormat = (NumFormat) style.numFormat();
+		nums.replace(level, num);
+		int count = counters.at(level);
+		bool reset = false;
+		if (pos == 0)
+			reset = true;
+		else if (pos > 0)
+		{
+			ParagraphStyle prevStyle;
+			prevStyle = itemText.paragraphStyle(pos -1);
+			reset = !prevStyle.hasNum()
+					|| prevStyle.numName() != "<local block>"
+					|| prevStyle.numLevel() < level
+					|| prevStyle.numFormat() != style.numFormat();
+		}
+		if ((level == 0) && (style.numFormat() != (int) num.numFormat))
+		{
+			reset = true;
+			counters.clear();
+			counters.append(0);
+			nums.clear();
+			nums.append(num);
+		}
+		if (reset)
+			count = style.numStart();
+		else
+			count++;
+		counters.replace(level, count);
+		//nums.insert(level, num);
+		QString result;
+		for (int i = 0; i <= level; ++i)
+		{
+			result.append(nums.at(i).prefix);
+			result.append(getStringFromNum(nums.at(i).numFormat, counters.at(i)));
+			result.append(nums.at(i).suffix);
+		}
+		if (mark->getString() != result)
+		{
+			mark->setString(result);
+			firstInvalidChar = pos;
+		}
+	}
+	return firstInvalidChar;
 }
 
 void ScribusDoc::updateNumbers(bool updateNumerations)
 {
+	struct ItemPosInfo
+	{
+		PageItem* item;
+		double xPos; // Absolute x position in document
+		double yPos; // Absolute y position in document
+	};
+
 	if (updateNumerations)
 		//after styles change reset all numerations settings
 		setupNumerations();
 
-	//reset ALL counters
+	// Collect all text frames including those placed inside groups;
+	QVector<ItemPosInfo> allTextFramePos;
+	allTextFramePos.reserve(100);
+
+	QStack<QList<PageItem*> > itemsStack;
+	itemsStack.push(DocItems);
+
+	while (!itemsStack.isEmpty())
+	{
+		QList<PageItem*> itemList = itemsStack.pop();
+		for (int i = 0; i < itemList.count(); ++i)
+		{
+			PageItem* item = itemList.at(i);
+			if (item->isGroup())
+			{
+				itemsStack.push(item->asGroupFrame()->groupItemList);
+				continue;
+			}
+			if (!item->isTextFrame())
+				continue;
+			if (item->prevInChain() != nullptr)
+				continue;
+			
+			ItemPosInfo itemPos { item, item->xPos(), item->yPos() };
+			if (item->Parent)
+			{
+				QTransform itemTrans = item->getTransform();
+				QPointF itemPoint = itemTrans.map(QPointF(0.0, 0.0));
+				itemPos.xPos = itemPoint.x();
+				itemPos.yPos = itemPoint.y();
+			}
+			allTextFramePos.append(itemPos);
+		}
+	}
+
+	// Start items by y position, x ascending
+	// Note : this will have to be changed once we support document binding on the right
+	std::stable_sort(allTextFramePos.begin(), allTextFramePos.end(), [](const ItemPosInfo & pos1, const ItemPosInfo & pos2) -> bool
+	{
+		if (pos1.yPos < pos2.yPos)
+			return true;
+		if (pos1.yPos == pos2.yPos)
+			return (pos1.xPos < pos2.xPos);
+		return false;
+	});
+
+	// Reset ALL counters
 	QList<NumStruct*> numerationValues = numerations.values();
 	for (NumStruct * numS : numerationValues)
 		for (int l = 0; l < numS->m_nums.count(); ++l)
-			numS->m_counters[l] = numS->m_nums[l].start -1;
-
-	flag_Renumber = false;
-	//renumbering for doc, sections, page and frame range
-	for (int sec = 0; sec < sections().count(); ++sec)
-	{
-		//reset section range counters
+			numS->m_counters[l] = numS->m_nums[l].start - 1;
+
+	// Renumbering for doc range
+	for (int i = 0; i < allTextFramePos.count(); ++i)
+	{
+		PageItem* item = allTextFramePos.at(i).item;
+
+		// Reset stories range counters
 		for (NumStruct * numS : numerationValues)
 			for (int l = 0; l < numS->m_nums.count(); ++l)
-				if (numS->m_nums[l].range == NSRsection)
-					numS->m_counters[l] = numS->m_nums[l].start -1;
-
-		int start = sections().value(sec).fromindex;
-		int stop = sections().value(sec).toindex;
-		for (int page = start; page <= stop; ++page)
-		{
-			//reset page range counters
-			for (NumStruct * numS : numerationValues)
-				for (int l = 0; l < numS->m_nums.count(); ++l)
-					if (numS->m_nums[l].range == NSRpage)
-						numS->m_counters[l] = numS->m_nums[l].start -1;
-
-			for (int i = 0; i < DocItems.count(); ++i)
-			{
-				PageItem* item = DocItems.at(i);
-				if (item->OwnPage != page)
-					continue;
-				if (!item->isTextFrame())
-					continue;
-				if (item->invalid)
-					continue;
-
-				//reset items and stories range counters
-				for (NumStruct * numS : numerationValues)
-					for (int l = 0; l < numS->m_nums.count(); ++l)
-						if ((numS->m_nums[l].range == NSRframe) || ((numS->m_nums[l].range == NSRstory) && (item->prevInChain() == nullptr)))
-							numS->m_counters[l] = numS->m_nums[l].start -1;
-
-				int pos = item->firstInFrame();
-				int last = item->lastInFrame();
-				if (pos > last)
-					continue;
-
-				if ((pos != 0) && (item->itemText.text(pos - 1) != SpecialChars::PARSEP))
-					pos = item->itemText.nextParagraph(pos) + 1;
-				int len = item->itemText.length();
-				while (pos <= last)
+				if (numS->m_nums[l].range == NSRstory)
+					numS->m_counters[l] = numS->m_nums[l].start - 1;
+
+		int pos = 0;
+		if (item->itemText.length() <= 0)
+			continue;
+		int firstInvalidChar1 = -1;
+
+		while (pos < item->itemText.length())
+		{
+			if ((pos == 0) || (item->itemText.text(pos - 1) == SpecialChars::PARSEP))
+			{
+				const ParagraphStyle& style = item->itemText.paragraphStyle(pos);
+				if (style.hasNum() && style.numName() != "<local block>")
 				{
-					if ((pos == 0) || (item->itemText.text(pos - 1) == SpecialChars::PARSEP))
+					if (!numerations.contains(style.numName()))
 					{
-						const ParagraphStyle& style = item->itemText.paragraphStyle(pos);
-						if (style.hasNum() && style.numName() != "<local block>")
-						{
-							if (!numerations.contains(style.numName()))
-							{
-								ParagraphStyle newStyle;
-								newStyle.setNumName("<local block>");
-								Selection tempSelection(this, false);
-								tempSelection.addItem(item, true);
-								itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
-								continue;
-							}
-							Mark* mark = item->itemText.mark(pos);
-							NumStruct* numStyle = numerations.value(style.numName());
-							bool resetNums = false;
-							if (numStyle->m_lastlevel == -1)
-								resetNums = true;
-							else if (style.numOther())
-							{
-								ParagraphStyle preStyle = item->itemText.paragraphStyle(pos -1);
-								//reset counter if prev style hasn't numeration or has other numeration
-								if (!preStyle.hasNum() || (preStyle.numName() != style.numName()))
-									resetNums = true;
-							}
-							else if (style.numHigher() && (style.numLevel() > numStyle->m_lastlevel))
-								resetNums = true;
+						ParagraphStyle newStyle;
+						newStyle.setNumName("<local block>");
+						Selection tempSelection(this, false);
+						tempSelection.addItem(item, true);
+						itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
+						continue;
+					}
+					Mark* mark = item->itemText.mark(pos);
+					NumStruct* numStyle = numerations.value(style.numName());
+					bool resetNums = false;
+					if (numStyle->m_lastlevel == -1)
+						resetNums = true;
+					else if (style.numOther())
+					{
+						ParagraphStyle preStyle = item->itemText.paragraphStyle(pos -1);
+						//reset counter if prev style hasn't numeration or has other numeration
+						if (!preStyle.hasNum() || (preStyle.numName() != style.numName()))
+							resetNums = true;
+					}
+					else if (style.numHigher() && (style.numLevel() > numStyle->m_lastlevel))
+						resetNums = true;
 							
-							QString prefixStr = getNumberStr(style.numName(), style.numLevel(), resetNums, style);
-							numStyle->m_lastlevel = style.numLevel();
-							if (mark == nullptr)
-							{
-								BulNumMark* bnMark = new BulNumMark;
-								item->itemText.insertMark(bnMark,pos);
-								CharStyle emptyCS;
-								item->itemText.setCharStyle(pos, 1, emptyCS);
-							}
-							if (mark && mark->getString() != prefixStr)
-							{
-								mark->setString(prefixStr);
-								item->invalid = true;
-								flag_Renumber = true;
-							}
-						}
-						if (pos == last)
-							break;
-						if (item->itemText.text(pos) == SpecialChars::PARSEP)
-							++pos;
-						else
-						{
-							pos = item->itemText.nextParagraph(pos)+1;
-							if (pos == len)
-								break;
-						}
+					QString prefixStr = getNumberStr(style.numName(), style.numLevel(), resetNums, style);
+					numStyle->m_lastlevel = style.numLevel();
+					if (mark == nullptr)
+					{
+						BulNumMark* bnMark = new BulNumMark;
+						item->itemText.insertMark(bnMark, pos);
+						CharStyle emptyCS;
+						item->itemText.setCharStyle(pos, 1, emptyCS);
+					}
+					if (mark && mark->getString() != prefixStr)
+					{
+						mark->setString(prefixStr);
+						firstInvalidChar1 = pos;
 					}
 				}
-			}
-		}
-	}
-
-	//update local numbering
-	for (PageItem* item : DocItems)
-	{
-		if (item->itemText.length() <= 0)
-			continue;
-
-		PageItem* itemFirst = item->firstInChain();
-		if (!updateLocalNums(itemFirst->itemText))
-			continue;
-
-		if (itemFirst->isTextFrame())
-			itemFirst->asTextFrame()->invalidateLayout(true);
+				if (item->itemText.text(pos) == SpecialChars::PARSEP)
+					++pos;
+				else
+					pos = item->itemText.nextParagraph(pos) + 1;
+			}
+		}
+
+		// Update local numbering
+		int firstInvalidChar2 = updateLocalNums(item->itemText);
+
+		int firstInvalidChar = -1;
+		if (firstInvalidChar1 >= 0 && firstInvalidChar2 >=0)
+			firstInvalidChar = qMin(firstInvalidChar1, firstInvalidChar2);
 		else
-			itemFirst->invalidateLayout();
-	}
-
+			firstInvalidChar = (firstInvalidChar1 >= 0) ? firstInvalidChar1 : firstInvalidChar2;
+
+		if (firstInvalidChar >= 0)
+		{
+			if (item->isTextFrame())
+				item->asTextFrame()->invalidateLayout(firstInvalidChar);
+			else
+				item->invalidateLayout();
+		}
+	}
+	
+	flag_Renumber = false;
 }
 
 QStringList ScribusDoc::marksLabelsList(MarkType type)
@@ -17647,17 +17673,8 @@
 					doUpdate = true;
 					mark->setString(numStr);
 					label = "NoteMark_" + nStyle->name();
-					if (nStyle->range() != NSRdocument)
-					{
-						if (nStyle->range() == NSRsection)
-							label += " in section " + getSectionNameForPageIndex(frame->OwnPage) + " page " + QString::number(frame->OwnPage +1);
-						else if (nStyle->range() == NSRpage)
-							label += " on page " + QString::number(frame->OwnPage +1);
-						else if (nStyle->range() == NSRstory)
-							label += " in " + frame->firstInChain()->itemName();
-						else if (nStyle->range() == NSRframe)
-							label += " in frame " + frame->itemName();
-					}
+					if (nStyle->range() == NSRstory)
+						label += " in " + frame->firstInChain()->itemName();
 					label += "_" + QString::number(noteNum);
 					mark->label = label;
 				}
@@ -17712,7 +17729,7 @@
 	flag_layoutNotesFrames = false;  //do not layout notes frames while counting notes
 	int num, i;
 	int itemsCount = Items->count();
-	if ((nStyle->range() == NSRdocument) || ((nStyle->range() == NSRsection) && m_docPrefsData.docSectionMap.isEmpty()))
+	if (nStyle->range() == NSRdocument)
 	{
 		//FIX ME: how to change frames order on page? and what about reverse page order?
 		num = nStyle->start();
@@ -17758,65 +17775,7 @@
 				nF->deleteIt = true;
 		}
 	}
-	else if (nStyle->range() == NSRsection)
-	{
-		Q_ASSERT(!m_docPrefsData.docSectionMap.isEmpty());
-		foreach (DocumentSection section, m_docPrefsData.docSectionMap.values())
-		{
-			num = nStyle->start();
-			for (int page = section.fromindex; page <= (int) section.toindex ; ++page)
-			{
-				if (nStyle->isEndNotes())
-				{
-					endNF = endNoteFrame(nStyle, getSectionKeyForPageIndex(page));
-					if (endNF != nullptr)
-						clearNotesInFrameList(endNF);
-				}
-				for (i = 0; i < itemsCount; ++i)
-				{
-					PageItem* currItem = Items->at(i);
-					if (currItem == nullptr)
-						continue;
-					if ((currItem->OwnPage == page) && currItem->isTextFrame() && !currItem->isNoteFrame() && (currItem->itemText.length() > 0))
-					{
-						if (!currItem->asTextFrame()->isValidChainFromBegin())
-						{
-							currItem->layout();
-							if (flag_restartMarksRenumbering)
-							{
-								//restart whole update as items was changed
-								if (endNF != nullptr)
-									clearNotesInFrameList(endNF);
-								page = section.fromindex -1;
-								i = -1;
-								itemsCount = Items->count();
-								num = nStyle->start();
-								docWasChanged = true;
-								flag_restartMarksRenumbering = false;
-								break;
-							}
-						}
-						if (nStyle->isEndNotes() || currItem->asTextFrame()->hasNoteFrame(nStyle, false))
-							updateItemNotesNums(currItem->asTextFrame(), nStyle, num);
-						if (currItem->asTextFrame()->hasNoteFrame(nStyle, false) && currItem->asTextFrame()->itemNoteFrame(nStyle)->invalid)
-							docWasChanged = true;
-						if (currItem->invalid)
-						{
-							currItem->layout();
-							docWasChanged = true;
-						}
-					}
-				}
-				if ((i != -1) && (num == nStyle->start()) && nStyle->isEndNotes())
-				{
-					PageItem_NoteFrame* nF = endNoteFrame(nStyle);
-					if (nF != nullptr && nF->isAutoNoteFrame())
-						nF->deleteIt = true;
-				}
-			}
-		}
-	}
-	else if (nStyle->range() == NSRstory || nStyle->range() == NSRframe)
+	else if (nStyle->range() == NSRstory)
 	{
 		for (i = 0; i < itemsCount; ++i)
 		{
@@ -17825,7 +17784,7 @@
 				continue;
 			if (currItem->isTextFrame() && !currItem->isNoteFrame() && (currItem->itemText.length() > 0))
 			{
-				if (nStyle->isEndNotes() && nStyle->range() == NSRstory)
+				if (nStyle->isEndNotes())
 				{
 					endNF = endNoteFrame(nStyle, (void*) currItem);
 					if (endNF != nullptr)
@@ -17846,26 +17805,17 @@
 						continue;
 					}
 				}
-				if (nStyle->range() == NSRstory)
-				{
-					//restart numeration for all first frames of story chain
-					if (currItem->prevInChain() == nullptr)
-					{
-						num = nStyle->start();
-						PageItem* nextItem = currItem;
-						while (nextItem != nullptr)
-						{
-							if (nStyle->isEndNotes() || nextItem->asTextFrame()->hasNoteFrame(nStyle, false))
-								updateItemNotesNums(nextItem->asTextFrame(), nStyle, num);
-							nextItem = nextItem->nextInChain();
-						}
-					}
-				}
-				else	//restart numeration for each frame
+				//restart numeration for all first frames of story chain
+				if (currItem->prevInChain() == nullptr)
 				{
 					num = nStyle->start();
-					if (nStyle->isEndNotes() || currItem->asTextFrame()->hasNoteFrame(nStyle, false))
-						updateItemNotesNums(currItem->asTextFrame(), nStyle, num);
+					PageItem* nextItem = currItem;
+					while (nextItem != nullptr)
+					{
+						if (nStyle->isEndNotes() || nextItem->asTextFrame()->hasNoteFrame(nStyle, false))
+							updateItemNotesNums(nextItem->asTextFrame(), nStyle, num);
+						nextItem = nextItem->nextInChain();
+					}
 				}
 				if (currItem->asTextFrame()->hasNoteFrame(nStyle, false) && currItem->asTextFrame()->itemNoteFrame(nStyle)->invalid)
 					docWasChanged = true;
@@ -17874,62 +17824,6 @@
 					currItem->layout();
 					docWasChanged = true;
 				}
-			}
-		}
-	}
-	else if (nStyle->range() == NSRpage)
-	{
-		for (int page = 0; page < Pages->count(); ++page)
-		{
-			if (nStyle->isEndNotes() && nStyle->range() == NSRpage)
-			{
-				endNF = endNoteFrame(nStyle, (void*) DocPages.at(page));
-				if (endNF != nullptr)
-					clearNotesInFrameList(endNF);
-			}
-			//restart numeration for each page
-			num = nStyle->start();
-
-			for (i = 0; i < itemsCount; ++i)
-			{
-				PageItem* currItem = Items->at(i);
-				if (currItem == nullptr)
-					continue;
-				if ((currItem->OwnPage == page) && currItem->isTextFrame() && !currItem->isNoteFrame() && (currItem->itemText.length() > 0))
-				{
-					if (!currItem->asTextFrame()->isValidChainFromBegin())
-					{
-						currItem->layout();
-						if (flag_restartMarksRenumbering)
-						{
-							//restart whole update as items was changed
-							if (endNF != nullptr)
-								clearNotesInFrameList(endNF);
-							page = -1;
-							i = -1;
-							itemsCount = Items->count();
-							num = nStyle->start();
-							docWasChanged = true;
-							flag_restartMarksRenumbering = false;
-							break;
-						}
-					}
-					if (nStyle->isEndNotes() || currItem->asTextFrame()->hasNoteFrame(nStyle, false))
-						updateItemNotesNums(currItem->asTextFrame(), nStyle, num);
-					if (currItem->asTextFrame()->hasNoteFrame(nStyle, false) && currItem->asTextFrame()->itemNoteFrame(nStyle)->invalid)
-						docWasChanged = true;
-					if (currItem->invalid)
-					{
-						currItem->layout();
-						docWasChanged = true;
-					}
-				}
-			}
-			if ((i != -1) && (num == nStyle->start()) && nStyle->isEndNotes())
-			{
-				PageItem_NoteFrame* nF = endNoteFrame(nStyle);
-				if (nF != nullptr && nF->isAutoNoteFrame())
-					nF->deleteIt = true;
 			}
 		}
 	}
@@ -18023,19 +17917,11 @@
 const ScPage *ScribusDoc::page4EndNotes(NotesStyle *NS, PageItem* item)
 {
 	ScPage* scP = nullptr;
-	if ((NS->range() == NSRdocument) || ((NS->range() == NSRsection) && m_docPrefsData.docSectionMap.isEmpty()))
+	if (NS->range() == NSRdocument)
 		scP = DocPages.last();
 	else if (item != nullptr)
 	{
-		if (NS->range() == NSRpage)
-			scP = DocPages.at(item->OwnPage);
-		else if (NS->range() == NSRsection)
-		{
-			int section = getSectionKeyForPageIndex(item->OwnPage);
-			DocumentSection sec = sections().find(section).value();
-			scP = DocPages.at(sec.toindex);
-		}
-		else if (NS->range() == NSRstory)
+		if (NS->range() == NSRstory)
 			scP = DocPages.at(item->lastInChain()->OwnPage);
 	}
 
@@ -18362,35 +18248,8 @@
 {
 	if (nStyle->range() == NSRdocument)
 		return endNoteFrame(nStyle);
-	if (nStyle->range() == NSRsection)
-		return endNoteFrame(nStyle, getSectionKeyForPageIndex(master->OwnPage));
-	if (nStyle->range() == NSRpage)
-		return endNoteFrame(nStyle, (void*) DocPages.at(master->OwnPage));
 	if (nStyle->range() == NSRstory)
 		return endNoteFrame(nStyle, master->firstInChain());
-	return nullptr;
-}
-
-PageItem_NoteFrame* ScribusDoc::endNoteFrame(NotesStyle *nStyle, int sectIndex)
-{
-	if (nStyle->range() != NSRsection)
-		return nullptr;
-	if (m_docEndNotesFramesMap.isEmpty())
-		return nullptr;
-
-	QMap<PageItem_NoteFrame*, rangeItem>::Iterator it = m_docEndNotesFramesMap.begin();
-	QMap<PageItem_NoteFrame*, rangeItem>::Iterator end = m_docEndNotesFramesMap.end();
-	while (it != end)
-	{
-		PageItem_NoteFrame* nF = it.key();
-		if (nF->notesStyle() == nStyle)
-		{
-			rangeItem rItem = it.value();
-			if (rItem.sectionIndex == sectIndex)
-				return nF;
-		}
-		++it;
-	}
 	return nullptr;
 }
 

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h	(original)
+++ trunk/Scribus/scribus/scribusdoc.h	Tue Mar 24 15:58:55 2020
@@ -1802,7 +1802,6 @@
 
 	//search for endnotesframe for given notes style and item holding master mark or section number
 	PageItem_NoteFrame* endNoteFrame(NotesStyle* nStyle, void* item = nullptr);
-	PageItem_NoteFrame* endNoteFrame(NotesStyle* nStyle, int sectIndex);
 	//clear list of notes for given notesframe
 	void clearNotesInFrameList(PageItem_NoteFrame* nF) { m_docNotesInFrameMap.insert(nF, QList<TextNote*>()); }
 	//renumber notes with given notes style for given frame starting from number num
@@ -1839,7 +1838,7 @@
 	bool flag_Renumber {false};
 	bool flag_NumUpdateRequest {false};
 	// for local numeration of paragraphs
-	bool updateLocalNums(StoryText& itemText); //return true if any num strings were updated and item need s invalidation
+	int  updateLocalNums(StoryText& itemText); //return first invalidated char
 	void updateNumbers(bool updateNumerations = false);
 	void itemSelection_ClearBulNumStrings(Selection *customSelection);
 /* Functions for PDF Form Actions */

Modified: trunk/Scribus/scribus/ui/notesstyleseditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/ui/notesstyleseditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/notesstyleseditor.cpp	(original)
+++ trunk/Scribus/scribus/ui/notesstyleseditor.cpp	Tue Mar 24 15:58:55 2020
@@ -25,11 +25,8 @@
 	setDoc(nullptr);
 	NSlistBox->setInsertPolicy(QComboBox::InsertAlphabetically);
 
-	RangeBox->addItem(tr("Document"));
-	RangeBox->addItem(tr("Section"));
-	RangeBox->addItem(tr("Story"));
-	RangeBox->addItem(tr("Page"));
-	RangeBox->addItem(tr("Frame"));
+	RangeBox->addItem(tr("Document"), static_cast<int>(NSRdocument));
+	RangeBox->addItem(tr("Story"), static_cast<int>(NSRstory));
 
 	languageChange();
 
@@ -93,12 +90,8 @@
 
 	bool rangeBlocked = RangeBox->blockSignals(true);
 	int  rangeIndex = RangeBox->currentIndex();
-	RangeBox->clear();
-	RangeBox->addItem(tr("Document"));
-	RangeBox->addItem(tr("Section"));
-	RangeBox->addItem(tr("Story"));
-	RangeBox->addItem(tr("Page"));
-	RangeBox->addItem(tr("Frame"));
+	RangeBox->addItem(tr("Document"), static_cast<int>(NSRdocument));
+	RangeBox->addItem(tr("Story"), static_cast<int>(NSRstory));
 	if (rangeIndex >= 0)
 		RangeBox->setCurrentIndex(rangeIndex);
 	RangeBox->blockSignals(rangeBlocked);
@@ -195,13 +188,11 @@
 	else
 		NewNameEdit->setEnabled(true);
 	FootRadio->setChecked(!NS->isEndNotes());
-	if (NS->range() == NSRframe)
-		EndRadio->setEnabled(false);
-	else
-		EndRadio->setEnabled(true);
+	EndRadio->setEnabled(true);
 	EndRadio->setChecked(NS->isEndNotes());
 	NumberingBox->setCurrentFormat(NS->getType());
-	RangeBox->setCurrentIndex((int) NS->range());
+	int rangeIndex = RangeBox->findData((int) NS->range());
+	RangeBox->setCurrentIndex((rangeIndex >= 0) ? rangeIndex : 0);
 	StartSpinBox->setValue(NS->start());
 	PrefixEdit->setText(NS->prefix());
 	SuffixEdit->setText(NS->suffix());
@@ -214,22 +205,16 @@
 	AutoH->setChecked(NS->isAutoNotesHeight());
 	AutoW->setChecked(NS->isAutoNotesWidth());
 	AutoWeld->setChecked(NS->isAutoWeldNotesFrames());
-	//for endnotes remove FRAME range (same effect as footnotes for frame)
-	//and disable autofixing size of notes frames
-	int rangeFrameIndex = RangeBox->findText(tr("Frame"));
+	//for endnotes disable autofixing size of notes frames
 	if (NS->isEndNotes())
 	{
 		AutoW->setEnabled(false);
 		AutoWeld->setEnabled(false);
-		if (rangeFrameIndex >= 0)
-			RangeBox->removeItem(rangeFrameIndex);
-}
+	}
 	else
 	{
 		AutoW->setEnabled(true);
 		AutoWeld->setEnabled(true);
-		if (rangeFrameIndex == -1)
-			RangeBox->addItem(tr("Frame"));
 	}
 	AutoRemove->setChecked(NS->isAutoRemoveEmptyNotesFrames());
 
@@ -507,7 +492,7 @@
 void NotesStylesEditor::on_RangeBox_currentIndexChanged(int index)
 {
 	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setRange((NumerationRange) index);
+	ns.setRange((NumerationRange) RangeBox->itemData(index).toInt());
 
 	changesMap.insert(NSlistBox->currentText(), ns);
 	ApplyButton->setEnabled(true);

Modified: trunk/Scribus/scribus/ui/propertywidget_pareffect.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/ui/propertywidget_pareffect.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_pareffect.cpp	(original)
+++ trunk/Scribus/scribus/ui/propertywidget_pareffect.cpp	Tue Mar 24 15:58:55 2020
@@ -134,7 +134,11 @@
 	{
 		const auto numerationKeys = m_doc->numerations.keys();
 		for (const QString& numName : numerationKeys)
+		{
+			if (numName.isEmpty())
+				continue;
 			numNames.append(numName);
+		}
 		numNames.sort();
 	}
 	numNames.prepend("<local block>");
@@ -282,10 +286,10 @@
 	numComboBox->setCurrentIndex(numComboBox->findText(numName));
 	NumStruct * numS = m_doc->numerations.value(numName);
 	if (numS)
-		numLevelSpin->setMaximum(numS->m_counters.count()+1);
+		numLevelSpin->setMaximum(numS->m_counters.count() + 1);
 	else
 		numLevelSpin->setMaximum(3);
-	numLevelSpin->setValue(newPStyle.numLevel() +1);
+	numLevelSpin->setValue(newPStyle.numLevel() + 1);
 	numPrefix->setText(newPStyle.numPrefix());
 	numSuffix->setText(newPStyle.numSuffix());
 	numStart->setValue(newPStyle.numStart());
@@ -409,7 +413,7 @@
 		newStyle.setHasNum(true);
 		newStyle.setNumName(numComboBox->currentText());
 		newStyle.setNumFormat(numFormatCombo->currentFormat());
-		newStyle.setNumLevel(numLevelSpin->value() -1);
+		newStyle.setNumLevel(numLevelSpin->value() - 1);
 		newStyle.setNumStart(numStart->value());
 		newStyle.setNumPrefix(numPrefix->text());
 		newStyle.setNumSuffix(numSuffix->text());
@@ -468,8 +472,8 @@
 	{
 		NumStruct * numS = m_doc->numerations.value(numName);
 		Q_ASSERT(numS);
-		int level = qMin(numLevelSpin->value(), numS->m_counters.count()) -1;
-		numLevelSpin->setValue(level +1);
+		int level = qMin(numLevelSpin->value(), numS->m_counters.count()) - 1;
+		numLevelSpin->setValue(level + 1);
 		newStyle.setNumLevel(level);
 		Numeration num = numS->m_nums[level];
 		numFormatCombo->setCurrentFormat(num.numFormat);

Modified: trunk/Scribus/scribus/ui/smpstylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/ui/smpstylewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smpstylewidget.cpp	(original)
+++ trunk/Scribus/scribus/ui/smpstylewidget.cpp	Tue Mar 24 15:58:55 2020
@@ -207,8 +207,12 @@
 {
 	QStringList numNames;
 	const auto numerationKeys = m_Doc->numerations.keys();
-	foreach (const QString& numName, numerationKeys)
+	for (const QString& numName : numerationKeys)
+	{
+		if (numName.isEmpty())
+			continue;
 		numNames.append(numName);
+	}
 	numNames.sort();
 	numComboBox->clear();
 	numComboBox->insertItems(0, numNames);
@@ -218,11 +222,8 @@
 void SMPStyleWidget::fillNumRestartCombo()
 {
 	numRestartCombo->clear();
-	numRestartCombo->addItem(tr("Document"));
-	numRestartCombo->addItem(tr("Section"));
-	numRestartCombo->addItem(tr("Story"));
-	numRestartCombo->addItem(tr("Page"));
-	numRestartCombo->addItem(tr("Frame"));
+	numRestartCombo->addItem(tr("Document"), static_cast<int>(NSRdocument));
+	numRestartCombo->addItem(tr("Story") , static_cast<int>(NSRstory));
 }
 
 void SMPStyleWidget::checkParEffectState()
@@ -389,8 +390,9 @@
 		setWidgetBoldFont(numSuffixLabel, !pstyle->isInhNumSuffix());
 		numStartSpin->setValue(pstyle->numStart(), pstyle->isInhNumStart());
 		numStartSpin->setParentValue(parent->numStart());
-		numRestartCombo->setCurrentItem(pstyle->numRestart(), pstyle->isInhNumRestart());
-		numRestartCombo->setParentItem(parent->numRestart());
+		int numRestartIndex = numRestartCombo->findData(pstyle->numRestart());
+		numRestartCombo->setCurrentItem(numRestartIndex, pstyle->isInhNumRestart());
+		numRestartCombo->setParentItem(numRestartIndex);
 		numRestartOtherBox->setChecked(pstyle->numOther(), pstyle->isInhNumOther());
 		numRestartOtherBox->setParentValue(parent->numOther());
 		numRestartHigherBox->setChecked(pstyle->numHigher(), pstyle->isInhNumHigher());
@@ -444,7 +446,8 @@
 		numSuffix->setText(pstyle->numSuffix());
 		setWidgetBoldFont(numSuffixLabel, false);
 		numStartSpin->setValue(pstyle->numStart());
-		numRestartCombo->setCurrentItem(pstyle->numRestart());
+		int numRestartIndex = numRestartCombo->findData(pstyle->numRestart());
+		numRestartCombo->setCurrentItem((numRestartIndex >= 0) ? numRestartIndex : 0);
 		numRestartOtherBox->setChecked(pstyle->numOther());
 		numRestartHigherBox->setChecked(pstyle->numHigher());
 

Modified: trunk/Scribus/scribus/ui/smtextstyles.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23535&path=/trunk/Scribus/scribus/ui/smtextstyles.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smtextstyles.cpp	(original)
+++ trunk/Scribus/scribus/ui/smtextstyles.cpp	Tue Mar 24 15:58:55 2020
@@ -1231,12 +1231,14 @@
 
 void SMParagraphStyle::slotNumRestart(int restart)
 {
+	int restartRange = m_pwidget->numRestartCombo->itemData(restart).toInt();
+
 	if (m_pwidget->numRestartCombo->useParentValue())
 		for (int i = 0; i < m_selection.count(); ++i)
 			m_selection[i]->resetNumRestart();
 	else
 		for (int i = 0; i < m_selection.count(); ++i)
-			m_selection[i]->setNumRestart(restart);
+			m_selection[i]->setNumRestart(restartRange);
 
 	if (!m_selectionIsDirty)
 	{
@@ -1746,9 +1748,9 @@
 	}
 	else
 	{
-		QString la=LanguageManager::instance()->getAbbrevFromLang(m_pwidget->cpage->language_->currentText(), false);
+		QString la = LanguageManager::instance()->getAbbrevFromLang(m_pwidget->cpage->language_->currentText(), false);
 		if (!la.isEmpty())
-			language=la;
+			language = la;
 		for (int i = 0; i < m_selection.count(); ++i)
 			m_selection[i]->charStyle().setLanguage(language);
 	}




More information about the scribus-commit mailing list