r22222 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Wed Nov 22 18:00:23 UTC 2017


Author: jghali
Date: Wed Nov 22 18:00:22 2017
New Revision: 22222

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22222
Log:
#15045: Editing table cells is not reliable

Modified:
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pageitem_group.cpp
    trunk/Scribus/scribus/pageitem_group.h
    trunk/Scribus/scribus/pageitem_table.cpp
    trunk/Scribus/scribus/pageitem_table.h
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/tablecell.cpp
    trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
    trunk/Scribus/scribus/util.cpp

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h	(original)
+++ trunk/Scribus/scribus/pageitem.h	Wed Nov 22 18:00:22 2017
@@ -776,7 +776,27 @@
 	 */
 	void setItemName(const QString& newName);
 
-	/** @brief Get the name of the gradient of the object */
+	/**
+	* @brief Set the masterpage the object is on
+	* @param mpName name of the master page
+	*/
+	virtual void setMasterPage(int page, const QString& mpName) { OwnPage = page; OnMasterPage = mpName; }
+
+	/**
+	 * @brief Set the masterpage the object is on
+	 * @param mpName name of the master page
+	 */
+	virtual void setMasterPageName(const QString& mpName) { OnMasterPage = mpName; }
+
+	/**
+	* @brief Set the page "owning" the object
+	* @param page index of the page
+	*/
+	virtual void setOwnerPage(int page) { OwnPage = page; }
+
+	/** 
+	 * @brief Get the name of the gradient of the object
+	 */
 	QString gradient() const { return gradientVal; }
 
 	/**
@@ -1099,9 +1119,9 @@
 	void convertTo(ItemType newType);
 
 	/**
-	* Set the layer for the item
-	* @param layerId layer where this item is moved
-	*/
+	 * Set the layer for the item
+	 * @param layerId layer where this item is moved
+	 */
 	virtual void setLayer(int layerId);
 
 	/**

Modified: trunk/Scribus/scribus/pageitem_group.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&path=/trunk/Scribus/scribus/pageitem_group.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_group.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_group.cpp	Wed Nov 22 18:00:22 2017
@@ -100,6 +100,28 @@
 		embedded->setLayer(newLayerID);
 	}
 	LayerID = newLayerID;
+}
+
+void PageItem_Group::setMasterPage(int page, const QString& mpName)
+{
+	PageItem::setMasterPage(page, mpName);
+
+	for (int em = 0; em < groupItemList.count(); ++em)
+	{
+		PageItem* embedded = groupItemList.at(em);
+		embedded->setMasterPage(page, mpName);
+	}
+}
+
+void PageItem_Group::setMasterPageName(const QString& mpName)
+{
+	PageItem::setMasterPageName(mpName);
+
+	for (int em = 0; em < groupItemList.count(); ++em)
+	{
+		PageItem* embedded = groupItemList.at(em);
+		embedded->setMasterPageName(mpName);
+	}
 }
 
 void PageItem_Group::replaceNamedResources(ResourceCollection& newNames)

Modified: trunk/Scribus/scribus/pageitem_group.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&path=/trunk/Scribus/scribus/pageitem_group.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_group.h	(original)
+++ trunk/Scribus/scribus/pageitem_group.h	Wed Nov 22 18:00:22 2017
@@ -45,7 +45,9 @@
 	virtual ItemType realItemType() const { return PageItem::Group; }
 	void adjustXYPosition();
 	virtual QList<PageItem*> getItemList() const;
-	virtual void setLayer(int layerId);
+	virtual void setLayer(int layerId);
+	virtual void setMasterPage(int page, const QString& mpName);
+	virtual void setMasterPageName(const QString& mpName);
 	virtual void getNamedResources(ResourceCollection& lists) const;
 	virtual void replaceNamedResources(ResourceCollection& newNames);
 	virtual void applicableActions(QStringList& actionList);

Modified: trunk/Scribus/scribus/pageitem_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&path=/trunk/Scribus/scribus/pageitem_table.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_table.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_table.cpp	Wed Nov 22 18:00:22 2017
@@ -210,6 +210,91 @@
 			{
 				PageItem* textFrame = cell.textFrame();
 				textFrame->layout();
+			}
+		}
+	}
+}
+
+void PageItem_Table::setLayer(int newLayerID)
+{
+	LayerID = newLayerID;
+
+	int rowCount = rows();
+	int columnCount = columns();
+
+	for (int row = 0; row < rowCount; ++row)
+	{
+		for (int col = 0; col < columnCount; col++)
+		{
+			TableCell cell = cellAt(row, col);
+			if (cell.row() == row && cell.column() == col)
+			{
+				PageItem* textFrame = cell.textFrame();
+				textFrame->LayerID = newLayerID;
+			}
+		}
+	}
+}
+
+void PageItem_Table::setMasterPage(int page, const QString& mpName)
+{
+	PageItem::setMasterPage(page, mpName);
+
+	int rowCount = rows();
+	int columnCount = columns();
+
+	for (int row = 0; row < rowCount; ++row)
+	{
+		for (int col = 0; col < columnCount; col++)
+		{
+			TableCell cell = cellAt(row, col);
+			if (cell.row() == row && cell.column() == col)
+			{
+				PageItem* textFrame = cell.textFrame();
+				textFrame->OwnPage = page;
+				textFrame->OnMasterPage = mpName;
+			}
+		}
+	}
+}
+
+void PageItem_Table::setMasterPageName(const QString& mpName)
+{
+	PageItem::setMasterPageName(mpName);
+
+	int rowCount = rows();
+	int columnCount = columns();
+
+	for (int row = 0; row < rowCount; ++row)
+	{
+		for (int col = 0; col < columnCount; col++)
+		{
+			TableCell cell = cellAt(row, col);
+			if (cell.row() == row && cell.column() == col)
+			{
+				PageItem* textFrame = cell.textFrame();
+				textFrame->OnMasterPage = mpName;
+			}
+		}
+	}
+}
+
+void PageItem_Table::setOwnerPage(int page)
+{
+	PageItem::setOwnerPage(page);
+
+	int rowCount = rows();
+	int columnCount = columns();
+
+	for (int row = 0; row < rowCount; ++row)
+	{
+		for (int col = 0; col < columnCount; col++)
+		{
+			TableCell cell = cellAt(row, col);
+			if (cell.row() == row && cell.column() == col)
+			{
+				PageItem* textFrame = cell.textFrame();
+				textFrame->OwnPage = page;
 			}
 		}
 	}

Modified: trunk/Scribus/scribus/pageitem_table.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&path=/trunk/Scribus/scribus/pageitem_table.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_table.h	(original)
+++ trunk/Scribus/scribus/pageitem_table.h	Wed Nov 22 18:00:22 2017
@@ -485,6 +485,18 @@
 	/// Returns the rows of the table for writing to SLA
 	QList<QList<TableCell> > cellRows() const { return m_cellRows; }
 
+	/// Set the layer for the item
+	virtual void setLayer(int layerId);
+
+	/// Set the masterpage the object is on
+	virtual void setMasterPage(int page, const QString& mpName);
+
+	/// Set the masterpage the object is on
+	virtual void setMasterPageName(const QString& mpName);
+
+	/// Set the page "owning" the object
+	virtual void setOwnerPage(int page);
+
 	/// Collect named resource of table and its cells
 	virtual void getNamedResources(ResourceCollection& lists) const;
 

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&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	Wed Nov 22 18:00:22 2017
@@ -3728,16 +3728,15 @@
 	PageItem* newItem = pasteItem(doc, attrs, baseDir, itemKind, pagenr);
 	newItem->setRedrawBounding();
 	if (tagName == "MASTEROBJECT")
-		newItem->OwnPage = doc->OnPage(newItem);
+		newItem->setOwnerPage(doc->OnPage(newItem));
 	else
-		newItem->OwnPage = attrs.valueAsInt("OwnPage");
+		newItem->setOwnerPage(attrs.valueAsInt("OwnPage"));
 	if ((tagName == "PAGEOBJECT") || (tagName == "ITEM"))
-		newItem->OnMasterPage = "";
+		newItem->setMasterPageName(QString());
 	if (tagName == "ITEM")
 	{
-		newItem->LayerID = LayerToPaste;
-		newItem->OwnPage = doc->OnPage(newItem);
-		newItem->OnMasterPage = doc->currentPage()->pageName();
+		newItem->setLayer(LayerToPaste);
+		newItem->setMasterPage(doc->OnPage(newItem), doc->currentPage()->pageName());
 	}
 	QString tmpf = attrs.valueAsString("IFONT", doc->itemToolPrefs().textFont);
 	m_AvailableFonts->findFont(tmpf, doc);

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Wed Nov 22 18:00:22 2017
@@ -2697,7 +2697,7 @@
 	for (int i = 0; i < masterItemsCount; ++i)
 	{
 		if (MasterItems.at(i)->OnMasterPage == oldPageName)
-			MasterItems.at(i)->OnMasterPage = newPageName;
+			MasterItems.at(i)->setMasterPageName(newPageName);
 	}
 	changed();
 	if (UndoManager::undoEnabled())
@@ -5323,8 +5323,7 @@
 	for (int a = end2; a < end3; ++a)
 	{
 		PageItem *newItem = MasterItems.at(a);
-		newItem->OnMasterPage = masterPageName;
-		newItem->OwnPage = MasterNames[masterPageName];
+		newItem->setMasterPage(MasterNames[masterPageName], masterPageName);
 	}
 	targetPage->MPageNam = "";
 	setLoading(false);
@@ -6051,7 +6050,7 @@
 		}
 
 		// If no or page owner is incorrect, recompute page owner
-		currItem->OwnPage = OnPage(currItem);
+		currItem->setOwnerPage(OnPage(currItem));
  	}
 
 	// #10379: Scribus crash when opening .sla document

Modified: trunk/Scribus/scribus/tablecell.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&path=/trunk/Scribus/scribus/tablecell.cpp
==============================================================================
--- trunk/Scribus/scribus/tablecell.cpp	(original)
+++ trunk/Scribus/scribus/tablecell.cpp	Wed Nov 22 18:00:22 2017
@@ -34,6 +34,9 @@
 	d->textFrame = new PageItem_TextFrame(d->table->m_Doc,
 		0, 0, 0, 0, 0, CommonStrings::None, CommonStrings::None);
 	d->textFrame->Parent = table;
+	d->textFrame->OwnPage = table->OwnPage;
+	d->textFrame->OnMasterPage = table->OnMasterPage;
+	d->textFrame->LayerID = table->LayerID;
 
 	setValid(true);
 	setRow(row);

Modified: trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&path=/trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp	(original)
+++ trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp	Wed Nov 22 18:00:22 2017
@@ -312,22 +312,8 @@
 	for (uint a = end2; a < end3; ++a)
 	{
 		PageItem *newItem = m_doc->MasterItems.at(a);
-		newItem->OnMasterPage = masterPageName;
-		newItem->OwnPage = m_doc->MasterNames[masterPageName];
-		if (!newItem->isGroup())
-			continue;
-
 		int masterPageIndex = m_doc->MasterNames[masterPageName];
-		PageItem_Group* group = newItem->asGroupFrame();
-		QList<PageItem*> groupList = group->groupItemList;
-		while (!groupList.isEmpty())
-		{
-			newItem = groupList.takeFirst();
-			newItem->OnMasterPage = masterPageName;
-			newItem->OwnPage = masterPageIndex;
-			if (newItem->isGroup())
-				groupList = newItem->asGroupFrame()->groupItemList + groupList;
-		}
+		newItem->setMasterPage(masterPageIndex, masterPageName);
 	}
 	from->guides.copy(&destination->guides);
 	m_doc->GroupCounter = GrMax + 1;

Modified: trunk/Scribus/scribus/util.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22222&path=/trunk/Scribus/scribus/util.cpp
==============================================================================
--- trunk/Scribus/scribus/util.cpp	(original)
+++ trunk/Scribus/scribus/util.cpp	Wed Nov 22 18:00:22 2017
@@ -1130,6 +1130,8 @@
 		tr = tr->BottomLink;
 	}
 	m_Doc->dontResize = true;
+	currItem->setLayer(gItem->LayerID);
+	currItem->setMasterPage(gItem->OwnPage, gItem->OnMasterPage);
 	currItem->adjustFrameToTable();
 	if (target != NULL)
 	{




More information about the scribus-commit mailing list