r24417 by jghali - #16431: Page numbers placed in masterpages not displayed correctly when objects are grouped

scribus-commit scribus-commit at lists.scribus.net
Thu Jan 21 22:09:20 UTC 2021


Author: jghali
Date: Thu Jan 21 22:09:20 2021
New Revision: 24417

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24417
Log:
#16431: Page numbers placed in masterpages not displayed correctly when objects are grouped

Modified:
    trunk/Scribus/scribus/canvas.cpp
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pageitem_group.cpp
    trunk/Scribus/scribus/pageitem_group.h
    trunk/Scribus/scribus/pageitem_noteframe.h
    trunk/Scribus/scribus/pageitem_pathtext.h
    trunk/Scribus/scribus/pageitem_table.h
    trunk/Scribus/scribus/pageitem_textframe.h
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/scpageoutput.cpp

Modified: trunk/Scribus/scribus/canvas.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/canvas.cpp
==============================================================================
--- trunk/Scribus/scribus/canvas.cpp	(original)
+++ trunk/Scribus/scribus/canvas.cpp	Thu Jan 21 22:09:20 2021
@@ -27,6 +27,7 @@
 #include "canvasmode.h"
 #include "pageitem_textframe.h"
 #include "pageitem_group.h"
+#include "pageitemiterator.h"
 #include "prefsmanager.h"
 #include "scpage.h"
 #include "scpainter.h"
@@ -1373,7 +1374,7 @@
 	int layerCount = m_doc->layerCount();
 	if ((layerCount > 1) && ((layer.blendMode != 0) || (layer.transparency != 1.0)) && (!layer.outlineMode))
 		painter->beginLayer(layer.transparency, layer.blendMode);
-	int pageFromMasterCount=page->FromMaster.count();
+	int pageFromMasterCount = page->FromMaster.count();
 	for (int a = 0; a < pageFromMasterCount; ++a)
 	{
 		currItem = page->FromMaster.at(a);
@@ -1396,10 +1397,22 @@
 			currItem->BoundingX = oldBX - Mp->xOffset() + page->xOffset();
 			currItem->BoundingY = oldBY - Mp->yOffset() + page->yOffset();
 		}
+		// Save PageItem's OwnPage and set its value to page number
+		// so that page number placed in text frames can work, also modify
+		// OwnPage of items embeded inside groups for same reason
 		currItem->savedOwnPage = currItem->OwnPage;
 		currItem->OwnPage = page->pageNr();
-//FIXME						if (!evSpon || forceRedraw)
-//					currItem->invalid = true;
+		if (currItem->isGroup())
+		{
+			PageItem_Group *groupItem = currItem->asGroupFrame();
+			PageItemIterator itemIt(groupItem->groupItemList, PageItemIterator::IterateInGroups);
+			for ( ; *itemIt; ++itemIt)
+			{
+				PageItem* item = *itemIt;
+				item->savedOwnPage = currItem->OwnPage;
+				item->OwnPage = page->pageNr();
+			}
+		}
 		if (cullingArea.intersects(currItem->getBoundingRect().adjusted(0.0, 0.0, 1.0, 1.0)))
 		{
 			if (!((m_viewMode.operItemMoving) && (currItem->isSelected())))
@@ -1409,8 +1422,19 @@
 				currItem->DrawObj(painter, cullingArea);
 				currItem->DrawObj_Decoration(painter);
 			}
-//							else 
-//								qDebug() << "skip masterpage item (move/resizeEdit/selected)" << m_viewMode.operItemMoving << currItem->isSelected();
+//			else 
+//				qDebug() << "skip masterpage item (move/resizeEdit/selected)" << m_viewMode.operItemMoving << currItem->isSelected();
+		}
+		// Restore items' OwnPage including those of item embedded inside groups 
+		if (currItem->isGroup())
+		{
+			PageItem_Group *groupItem = currItem->asGroupFrame();
+			PageItemIterator itemIt(groupItem->groupItemList, PageItemIterator::IterateInGroups);
+			for ( ; *itemIt; ++itemIt)
+			{
+				PageItem* item = *itemIt;
+				item->OwnPage = item->savedOwnPage;
+			}
 		}
 		currItem->OwnPage = currItem->savedOwnPage;
 		if (!currItem->ChangedMasterItem)

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Thu Jan 21 22:09:20 2021
@@ -734,6 +734,17 @@
 //			unWeldFromMaster(true);
 //		if (isWelded())
 //			unWeldChild();
+}
+
+bool PageItem::isMasterItem() const
+{
+	if (Parent == nullptr)
+		return !OnMasterPage.isEmpty();
+
+	PageItem* parentItem = Parent;
+	while (parentItem && parentItem->Parent)
+		parentItem = parentItem->Parent;
+	return !parentItem->OnMasterPage.isEmpty();
 }
 
 bool PageItem::isGroupChild() const

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h	(original)
+++ trunk/Scribus/scribus/pageitem.h	Thu Jan 21 22:09:20 2021
@@ -270,8 +270,10 @@
 	virtual bool isTable()			const { return false; } ///< Return true if Table item, otherwise false
 	virtual bool isTextFrame()		const { return false; } ///< Return true if Text item, otherwise false
 
+	virtual bool isMasterItem() const; ///< Return true if item is placed on a master page
 	virtual bool isGroupChild() const;
 	virtual bool isTableCell() const;
+	virtual bool isTextContainer() const { return false; } ///< Return true if item is susceptible to display text in a way or another
 
 	PageItem_Group* parentGroup() const { return (Parent ? Parent->asGroupFrame() : nullptr); }
 	PageItem_Table* parentTable() const { return (Parent ? Parent->asTable() : nullptr); }

Modified: trunk/Scribus/scribus/pageitem_group.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pageitem_group.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_group.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_group.cpp	Thu Jan 21 22:09:20 2021
@@ -29,6 +29,7 @@
 
 #include "commonstrings.h"
 #include "pageitem_group.h"
+#include "pageitemiterator.h"
 #include "prefsmanager.h"
 #include "scpainter.h"
 #include "scpage.h"
@@ -57,6 +58,21 @@
 //	{
 //		delete groupItemList.takeFirst();
 //	}
+}
+
+bool PageItem_Group::isTextContainer() const
+{
+	PageItemIterator it(groupItemList, PageItemIterator::IterateInGroups);
+	for (; *it; ++it)
+	{
+		PageItem* item = *it;
+		if (item->isGroup())
+			continue;
+		if (item->isTextContainer())
+			return true;
+	}
+
+	return false;
 }
 
 void PageItem_Group::adjustXYPosition()

Modified: trunk/Scribus/scribus/pageitem_group.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pageitem_group.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_group.h	(original)
+++ trunk/Scribus/scribus/pageitem_group.h	Thu Jan 21 22:09:20 2021
@@ -42,7 +42,9 @@
 
 	PageItem_Group * asGroupFrame() override { return this; }
 	bool isGroup() const override { return true; }
+	bool isTextContainer() const override;
 	ItemType realItemType() const override { return PageItem::Group; }
+
 	void adjustXYPosition();
 	void setLayer(int layerId) override;
 	void setMasterPage(int page, const QString& mpName) override;

Modified: trunk/Scribus/scribus/pageitem_noteframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pageitem_noteframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_noteframe.h	(original)
+++ trunk/Scribus/scribus/pageitem_noteframe.h	Thu Jan 21 22:09:20 2021
@@ -20,6 +20,7 @@
 	PageItem_NoteFrame * asNoteFrame() override { return this; }
 	bool isNoteFrame() const override { return true; }
 	bool isAutoNoteFrame() const override { return m_nstyle->isAutoRemoveEmptyNotesFrames(); }
+	bool isTextContainer() const override { return true; }
 
 	//overloaded text frame layouting
 	void layout() override;

Modified: trunk/Scribus/scribus/pageitem_pathtext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pageitem_pathtext.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_pathtext.h	(original)
+++ trunk/Scribus/scribus/pageitem_pathtext.h	Thu Jan 21 22:09:20 2021
@@ -41,6 +41,7 @@
 	
 	PageItem_PathText * asPathText() override { return this; }
 	bool isPathText() const override { return true; }
+	bool isTextContainer() const override { return true; }
 
 	void layout() override;
 	bool createInfoGroup(QFrame *, QGridLayout *) override;

Modified: trunk/Scribus/scribus/pageitem_table.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pageitem_table.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_table.h	(original)
+++ trunk/Scribus/scribus/pageitem_table.h	Thu Jan 21 22:09:20 2021
@@ -494,6 +494,9 @@
 	/// Returns PageItem::Table.
 	ItemType realItemType() const override { return PageItem::Table; }
 
+	/// Return true if item is susceptible to contain text in a way or another
+	bool isTextContainer() const override { return true; }
+
 	/// Adds the applicable actions for this table to @a actionList.
 	void applicableActions(QStringList& actionList) override;
 

Modified: trunk/Scribus/scribus/pageitem_textframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pageitem_textframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.h	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.h	Thu Jan 21 22:09:20 2021
@@ -55,6 +55,7 @@
 
 	PageItem_TextFrame * asTextFrame() override { return this; }
 	bool isTextFrame() const override { return true; }
+	bool isTextContainer() const override { return true; }
 
 	void clearContents() override;
 	void truncateContents() override;

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Thu Jan 21 22:09:20 2021
@@ -2680,10 +2680,10 @@
 												"/OPM 1\n");
 				PutPage(Pdf::toName(ShName) + " gs\n");
 			}
-/* Bookmarks on Master Pages do not make any sense */
+			/* Bookmarks on Master Pages do not make any sense */
 //			if ((ite->isBookmark) && (Options.Bookmarks))
 //				PDF_Bookmark(ite, pag->height() - (ite->yPos() - pag->yOffset()));
-			if (!ite->printEnabled() || ((ite->itemType() == PageItem::TextFrame) && (!pag->pageNameEmpty())))
+			if (!ite->printEnabled() || (ite->isTextContainer() && !pag->pageNameEmpty()))
 			{
 				PutPage("Q\n");
 				continue;
@@ -3853,43 +3853,43 @@
 
 	if (Options.exportsLayers())
 		PutPage("/OC /" + OCGEntries[layer.Name].Name + " BDC\n");
-	for (int am = 0; am < pag->FromMaster.count() && !abortExport; ++am)
-	{
-		ite = pag->FromMaster.at(am);
+	for (int i = 0; i < pag->FromMaster.count() && !abortExport; ++i)
+	{
+		ite = pag->FromMaster.at(i);
 		if (usingGUI)
 			qApp->processEvents();
 		if ((ite->m_layerID != layer.ID) || (!ite->printEnabled()))
 			continue;
 		if ((!pag->pageNameEmpty()) && (ite->OwnPage != pag->pageNr()) && (ite->OwnPage != -1))
 			continue;
+
 		QByteArray name = QByteArray("/master_page_obj_%1_%2")
 			                            .replace("%1", Pdf::toPdf(mPageIndex))
 			                            .replace("%2", Pdf::toPdf(qHash(ite)));
-		if ((!ite->isTextFrame()) && (!ite->isPathText()) && (!ite->isTable()))
+		if (!ite->isTextContainer())
 		{
 			if (((layer.transparency != 1) || (layer.blendMode != 0)) && Options.supportsTransparency())
 				content += (name + " Do\n");
 			else
 				PutPage(name + " Do\n");
-		}
+			continue;
+		}
+
+		double oldX = ite->xPos();
+		double oldY = ite->yPos();
+		double oldBX = ite->BoundingX;
+		double oldBY = ite->BoundingY;
+		ite->setXPos(ite->xPos() - mPage->xOffset() + pag->xOffset(), true);
+		ite->setYPos(ite->yPos() - mPage->yOffset() + pag->yOffset(), true);
+		if (!PDF_ProcessItem(output, ite, pag, pag->pageNr()))
+			return false;
+		if (((layer.transparency != 1) || (layer.blendMode != 0)) && Options.supportsTransparency())
+			content += output;
 		else
-		{
-			double oldX = ite->xPos();
-			double oldY = ite->yPos();
-			double OldBX = ite->BoundingX;
-			double OldBY = ite->BoundingY;
-			ite->setXPos(ite->xPos() - mPage->xOffset() + pag->xOffset(), true);
-			ite->setYPos(ite->yPos() - mPage->yOffset() + pag->yOffset(), true);
-			if (!PDF_ProcessItem(output, ite, pag, pag->pageNr()))
-				return false;
-			if (((layer.transparency != 1) || (layer.blendMode != 0)) && Options.supportsTransparency())
-				content += output;
-			else
-				PutPage(output);
-			ite->setXYPos(oldX, oldY, true);
-			ite->BoundingX = OldBX;
-			ite->BoundingY = OldBY;
-		}
+			PutPage(output);
+		ite->setXYPos(oldX, oldY, true);
+		ite->BoundingX = oldBX;
+		ite->BoundingY = oldBY;
 	}
 	// Couldn't we use Write_TransparencyGroup() here?
 	if (((layer.transparency != 1) || (layer.blendMode != 0)) && Options.supportsTransparency())

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp	(original)
+++ trunk/Scribus/scribus/pslib.cpp	Thu Jan 21 22:09:20 2021
@@ -1763,7 +1763,7 @@
 				continue;
 			if (!page->masterPageNameEmpty() && !abortExport && !errorOccured)
 			{
-				errorOccured |= !ProcessMasterPageLayer(page, ll, a);
+				errorOccured |= !ProcessMasterPageLayer(page, ll, a + 1);
 			}
 			if (!abortExport && !errorOccured)
 			{
@@ -1979,7 +1979,7 @@
 			PS_scale(1, -1);
 		}
 		if (item->itemText.length() != 0)
-			setTextSt(item, PNr-1, page, master);
+			setTextSt(item, PNr - 1, page, master);
 		if (((item->lineColor() != CommonStrings::None) || (!item->NamedLStyle.isEmpty()) || (!item->strokePattern().isEmpty()) || (item->GrTypeStroke > 0)))
 		{
 			PS_setlinewidth(item->lineWidth());
@@ -2330,6 +2330,8 @@
 		}
 		break;
 	case PageItem::Group:
+		if (master)
+			break;
 		PS_save();
 		if (item->groupClipping())
 			SetPathAndClip(item->PoLine, item->fillRule);
@@ -2612,11 +2614,7 @@
 				ScQApp->processEvents();
 			if (item->m_layerID != ll.ID)
 				continue;
-			if ((!page->pageNameEmpty()) && (item->isTextFrame()))
-				continue;
-			if ((!page->pageNameEmpty()) && (item->isPathText()))
-				continue;
-			if ((!page->pageNameEmpty()) && (item->isTable()))
+			if ((!page->pageNameEmpty()) && (item->isTextContainer()))
 				continue;
 			if ((!page->pageNameEmpty()) && (item->isImageFrame()) && ((Options.outputSeparations) || (!Options.useColor)))
 				continue;
@@ -2660,219 +2658,19 @@
 				ScQApp->processEvents();
 			if ((ite->m_layerID != layer.ID) || (!ite->printEnabled()))
 				continue;
-			if (!(ite->isTextFrame()) && !(ite->isImageFrame()) && !(ite->isPathText()) && !(ite->isTable()))
+			if (!ite->isTextContainer())
 			{
 				int mpIndex = m_Doc->MasterNames[page->masterPageName()];
 				PS_UseTemplate(QString("mp_obj_%1_%2").arg(mpIndex).arg(qHash(ite)));
 			}
-			else if (ite->isImageFrame())
+			else if (!ite->isTextFrame())
 			{
 				PS_save();
 				// JG : replace what seems mostly duplicate code by corresponding function call (#3936)
 				success &= ProcessItem(mPage, ite, PNr, false, false, true);
 				PS_restore();
 			}
-			else if (ite->isTable())
-			{
-				PS_save();
-				PS_translate(ite->xPos() - mPage->xOffset(), mPage->height() - (ite->yPos() - mPage->yOffset()));
-				PS_translate(ite->asTable()->gridOffset().x(), -ite->asTable()->gridOffset().y());
-				// Paint table fill.
-				if (ite->asTable()->fillColor() != CommonStrings::None)
-				{
-					int lastCol = ite->asTable()->columns() - 1;
-					int lastRow = ite->asTable()->rows() - 1;
-					double x = ite->asTable()->columnPosition(0);
-					double y = ite->asTable()->rowPosition(0);
-					double width = ite->asTable()->columnPosition(lastCol) + ite->asTable()->columnWidth(lastCol) - x;
-					double height = ite->asTable()->rowPosition(lastRow) + ite->asTable()->rowHeight(lastRow) - y;
-					putColorNoDraw(ite->asTable()->fillColor(), ite->asTable()->fillShade());
-					PutStream("0 0 " + ToStr(width) + " " + ToStr(-height) + " rectfill\n");
-				}
-				// Pass 1: Paint cell fills.
-				for (int row = 0; row < ite->asTable()->rows(); ++row)
-				{
-					int colSpan = 0;
-					for (int col = 0; col < ite->asTable()->columns(); col += colSpan)
-					{
-						TableCell cell = ite->asTable()->cellAt(row, col);
-						if (row == cell.row())
-						{
-							QString colorName = cell.fillColor();
-							if (colorName != CommonStrings::None)
-							{
-								PS_save();
-								putColorNoDraw(colorName, cell.fillShade());
-								int row = cell.row();
-								int col = cell.column();
-								int lastRow = row + cell.rowSpan() - 1;
-								int lastCol = col + cell.columnSpan() - 1;
-								double x = ite->asTable()->columnPosition(col);
-								double y = ite->asTable()->rowPosition(row);
-								double width = ite->asTable()->columnPosition(lastCol) + ite->asTable()->columnWidth(lastCol) - x;
-								double height = ite->asTable()->rowPosition(lastRow) + ite->asTable()->rowHeight(lastRow) - y;
-								PutStream(ToStr(x) + " " + ToStr(-y) + " " + ToStr(width) + " " + ToStr(-height) + " rectfill\n");
-								PS_restore();
-							}
-						}
-						colSpan = cell.columnSpan();
-					}
-				}
-				// Pass 2: Paint vertical borders.
-				for (int row = 0; row < ite->asTable()->rows(); ++row)
-				{
-					int colSpan = 0;
-					for (int col = 0; col < ite->asTable()->columns(); col += colSpan)
-					{
-						TableCell cell = ite->asTable()->cellAt(row, col);
-						if (row == cell.row())
-						{
-							const int lastRow = cell.row() + cell.rowSpan() - 1;
-							const int lastCol = cell.column() + cell.columnSpan() - 1;
-							const double borderX = ite->asTable()->columnPosition(lastCol) + ite->asTable()->columnWidth(lastCol);
-							QPointF start(borderX, 0.0);
-							QPointF end(borderX, 0.0);
-							QPointF startOffsetFactors, endOffsetFactors;
-							int startRow, endRow;
-							for (int row = cell.row(); row <= lastRow; row += endRow - startRow + 1)
-							{
-								TableCell rightCell = ite->asTable()->cellAt(row, lastCol + 1);
-								startRow = qMax(cell.row(), rightCell.row());
-								endRow = qMin(lastRow, rightCell.isValid() ? rightCell.row() + rightCell.rowSpan() - 1 : lastRow);
-								TableCell topLeftCell = ite->asTable()->cellAt(startRow - 1, lastCol);
-								TableCell topRightCell = ite->asTable()->cellAt(startRow - 1, lastCol + 1);
-								TableCell bottomRightCell = ite->asTable()->cellAt(endRow + 1, lastCol + 1);
-								TableCell bottomLeftCell = ite->asTable()->cellAt(endRow + 1, lastCol);
-								TableBorder topLeft, top, topRight, border, bottomLeft, bottom, bottomRight;
-								resolveBordersVertical(topLeftCell, topRightCell, cell, rightCell, bottomLeftCell, bottomRightCell,
-									&topLeft, &top, &topRight, &border, &bottomLeft, &bottom, &bottomRight, ite->asTable());
-								if (border.isNull())
-									continue; // Quit early if the border to paint is null.
-								start.setY(ite->asTable()->rowPosition(startRow));
-								end.setY((ite->asTable()->rowPosition(endRow) + ite->asTable()->rowHeight(endRow)));
-								joinVertical(border, topLeft, top, topRight, bottomLeft, bottom, bottomRight, &start, &end, &startOffsetFactors, &endOffsetFactors);
-								paintBorder(border, start, end, startOffsetFactors, endOffsetFactors);
-							}
-							if (col == 0)
-							{
-								const int lastRow = cell.row() + cell.rowSpan() - 1;
-								const int firstCol = cell.column();
-								const double borderX = ite->asTable()->columnPosition(firstCol);
-								QPointF start(borderX, 0.0);
-								QPointF end(borderX, 0.0);
-								QPointF startOffsetFactors, endOffsetFactors;
-								int startRow, endRow;
-								for (int row = cell.row(); row <= lastRow; row += endRow - startRow + 1)
-								{
-									TableCell leftCell = ite->asTable()->cellAt(row, firstCol - 1);
-									startRow = qMax(cell.row(), leftCell.row());
-									endRow = qMin(lastRow, leftCell.isValid() ? leftCell.row() + leftCell.rowSpan() - 1 : lastRow);
-									TableCell topLeftCell = ite->asTable()->cellAt(startRow - 1, firstCol - 1);
-									TableCell topRightCell = ite->asTable()->cellAt(startRow - 1, firstCol);
-									TableCell bottomRightCell = ite->asTable()->cellAt(lastRow + 1, firstCol);
-									TableCell bottomLeftCell = ite->asTable()->cellAt(lastRow + 1, firstCol - 1);
-									TableBorder topLeft, top, topRight, border, bottomLeft, bottom, bottomRight;
-									resolveBordersVertical(topLeftCell, topRightCell, leftCell, cell, bottomLeftCell, bottomRightCell,
-										&topLeft, &top, &topRight, &border, &bottomLeft, &bottom, &bottomRight, ite->asTable());
-									if (border.isNull())
-										continue; // Quit early if the border to paint is null.
-									start.setY(ite->asTable()->rowPosition(startRow));
-									end.setY((ite->asTable()->rowPosition(endRow) + ite->asTable()->rowHeight(endRow)));
-									joinVertical(border, topLeft, top, topRight, bottomLeft, bottom, bottomRight, &start, &end, &startOffsetFactors, &endOffsetFactors);
-									paintBorder(border, start, end, startOffsetFactors, endOffsetFactors);
-								}
-							}
-						}
-						colSpan = cell.columnSpan();
-					}
-				}
-				// Pass 3: Paint horizontal borders.
-				for (int row = 0; row < ite->asTable()->rows(); ++row)
-				{
-					int colSpan = 0;
-					for (int col = 0; col < ite->asTable()->columns(); col += colSpan)
-					{
-						TableCell cell = ite->asTable()->cellAt(row, col);
-						if (row == cell.row())
-						{
-							const int lastRow = cell.row() + cell.rowSpan() - 1;
-							const int lastCol = cell.column() + cell.columnSpan() - 1;
-							const double borderY = (ite->asTable()->rowPosition(lastRow) + ite->asTable()->rowHeight(lastRow));
-							QPointF start(0.0, borderY);
-							QPointF end(0.0, borderY);
-							QPointF startOffsetFactors, endOffsetFactors;
-							int startCol, endCol;
-							for (int col = cell.column(); col <= lastCol; col += endCol - startCol + 1)
-							{
-								TableCell bottomCell = ite->asTable()->cellAt(lastRow + 1, col);
-								startCol = qMax(cell.column(), bottomCell.column());
-								endCol = qMin(lastCol, bottomCell.isValid() ? bottomCell.column() + bottomCell.columnSpan() - 1 : lastCol);
-								TableCell topLeftCell = ite->asTable()->cellAt(lastRow, startCol - 1);
-								TableCell topRightCell = ite->asTable()->cellAt(lastRow, endCol + 1);
-								TableCell bottomRightCell = ite->asTable()->cellAt(lastRow + 1, endCol + 1);
-								TableCell bottomLeftCell = ite->asTable()->cellAt(lastRow + 1, startCol - 1);
-								TableBorder topLeft, left, bottomLeft, border, topRight, right, bottomRight;
-								resolveBordersHorizontal(topLeftCell, cell, topRightCell, bottomLeftCell, bottomCell,
-												  bottomRightCell, &topLeft, &left, &bottomLeft, &border, &topRight, &right, &bottomRight, ite->asTable());
-								if (border.isNull())
-									continue; // Quit early if the border is null.
-								start.setX(ite->asTable()->columnPosition(startCol));
-								end.setX(ite->asTable()->columnPosition(endCol) + ite->asTable()->columnWidth(endCol));
-								joinHorizontal(border, topLeft, left, bottomLeft, topRight, right, bottomRight, &start, &end, &startOffsetFactors, &endOffsetFactors);
-								paintBorder(border, start, end, startOffsetFactors, endOffsetFactors);
-							}
-							if (row == 0)
-							{
-								const int firstRow = cell.row();
-								const int lastCol = cell.column() + cell.columnSpan() - 1;
-								const double borderY = ite->asTable()->rowPosition(firstRow);
-								QPointF start(0.0, borderY);
-								QPointF end(0.0, borderY);
-								QPointF startOffsetFactors, endOffsetFactors;
-								int startCol, endCol;
-								for (int col = cell.column(); col <= lastCol; col += endCol - startCol + 1)
-								{
-									TableCell topCell = ite->asTable()->cellAt(firstRow - 1, col);
-									startCol = qMax(cell.column(), topCell.column());
-									endCol = qMin(lastCol, topCell.isValid() ? topCell.column() + topCell.columnSpan() - 1 : lastCol);
-									TableCell topLeftCell = ite->asTable()->cellAt(firstRow - 1, startCol - 1);
-									TableCell topRightCell = ite->asTable()->cellAt(firstRow - 1, endCol + 1);
-									TableCell bottomRightCell = ite->asTable()->cellAt(firstRow, endCol + 1);
-									TableCell bottomLeftCell = ite->asTable()->cellAt(firstRow, startCol - 1);
-									TableBorder topLeft, left, bottomLeft, border, topRight, right, bottomRight;
-									resolveBordersHorizontal(topLeftCell, topCell, topRightCell, bottomLeftCell, cell,
-															 bottomRightCell, &topLeft, &left, &bottomLeft, &border, &topRight, &right, &bottomRight, ite->asTable());
-									if (border.isNull())
-										continue; // Quit early if the border is null.
-									start.setX(ite->asTable()->columnPosition(startCol));
-									end.setX(ite->asTable()->columnPosition(endCol) + ite->asTable()->columnWidth(endCol));
-									joinHorizontal(border, topLeft, left, bottomLeft, topRight, right, bottomRight, &start, &end, &startOffsetFactors, &endOffsetFactors);
-									paintBorder(border, start, end, startOffsetFactors, endOffsetFactors);
-								}
-							}
-						}
-						colSpan = cell.columnSpan();
-					}
-				}
-				// Pass 4: Paint cell content.
-				for (int row = 0; row < ite->asTable()->rows(); ++row)
-				{
-					for (int col = 0; col < ite->asTable()->columns(); col ++)
-					{
-						TableCell cell = ite->asTable()->cellAt(row, col);
-						if (cell.row() == row && cell.column() == col)
-						{
-							PageItem* textFrame = cell.textFrame();
-							PS_save();
-							PS_translate(cell.contentRect().x(), -cell.contentRect().y());
-							ProcessItem(mPage, textFrame, PNr, false, false, true);
-							PS_restore();
-						}
-					}
-				}
-				PS_restore();
-			}
-			else if (ite->isTextFrame())
+			else // if (ite->isTextFrame())
 			{
 				PS_save();
 				if (ite->doOverprint)
@@ -2910,9 +2708,12 @@
 					PS_scale(1, -1);
 				}
 				if (ite->itemText.length() != 0)
-					setTextSt(ite, PNr, mPage, true);
+					setTextSt(ite, PNr - 1, mPage, true);
 				if (((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty()) || (!ite->strokePattern().isEmpty()) || (ite->GrTypeStroke > 0)))
 				{
+					PS_setlinewidth(ite->lineWidth());
+					PS_setcapjoin(ite->PLineEnd, ite->PLineJoin);
+					PS_setdash(ite->PLineArt, ite->DashOffset, ite->DashValues);
 					if (ite->NamedLStyle.isEmpty()) // && (ite->lineWidth() != 0.0))
 					{
 						ScPattern* strokePattern = m_Doc->checkedPattern(ite->strokePattern());
@@ -2923,9 +2724,6 @@
 						}
 						else
 						{
-							PS_setlinewidth(ite->lineWidth());
-							PS_setcapjoin(ite->PLineEnd, ite->PLineJoin);
-							PS_setdash(ite->PLineArt, ite->DashOffset, ite->DashValues);
 							SetClipPath(ite->PoLine);
 							PS_closepath();
 							if (strokePattern)
@@ -2961,58 +2759,6 @@
 				}
 				PS_restore();
 			}
-			else if (ite->asPathText())
-			{
-				PS_save();
-				PS_translate(ite->xPos() - mPage->xOffset(), mPage->height() - (ite->yPos() - mPage->yOffset()));
-				if (ite->PoShow)
-				{
-					if (ite->PoLine.size() > 3)
-					{
-						PS_save();
-						if (ite->NamedLStyle.isEmpty()) //&& (item->lineWidth() != 0.0))
-						{
-							ScPattern* strokePattern = m_Doc->checkedPattern(ite->strokePattern());
-							if (strokePattern && (ite->patternStrokePath))
-							{
-								QPainterPath path = ite->PoLine.toQPainterPath(false);
-								HandleBrushPattern(ite, path, mPage, PNr, true);
-							}
-							else
-							{
-								SetClipPath(ite->PoLine, false);
-								if (strokePattern)
-									HandleStrokePattern(ite);
-								else if (ite->GrTypeStroke > 0)
-									HandleGradientFillStroke(ite);
-								else if (ite->lineColor() != CommonStrings::None)
-									putColor(ite->lineColor(), ite->lineShade(), false);
-							}
-						}
-						else
-						{
-							multiLine ml = m_Doc->docLineStyles[ite->NamedLStyle];
-							for (int it = ml.size() - 1; it > -1; it--)
-							{
-								if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
-								{
-									SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
-									PS_setcmykcolor_stroke(h, s, v, k);
-									PS_setlinewidth(ml[it].Width);
-									PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
-									PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
-									SetClipPath(ite->PoLine, false);
-									putColor(ml[it].Color, ml[it].Shade, false);
-								}
-							}
-						}
-						PS_restore();
-					}
-				}
-				if (ite->itemText.length() != 0)
-					setTextSt(ite, PNr, mPage, true);
-				PS_restore();
-			}
 			if (!success)
 				break;
 		}
@@ -3036,11 +2782,7 @@
 			ScQApp->processEvents();
 		if (item->m_layerID != layer.ID)
 			continue;
-		if ((!page->pageNameEmpty()) && (item->isTextFrame()))
-			continue;
-		if ((!page->pageNameEmpty()) && (item->isPathText()))
-			continue;
-		if ((!page->pageNameEmpty()) && (item->isTable()))
+		if ((!page->pageNameEmpty()) && (item->isTextContainer()))
 			continue;
 		if ((!page->pageNameEmpty()) && (item->isImageFrame()) && ((Options.outputSeparations) || (!Options.useColor)))
 			continue;

Modified: trunk/Scribus/scribus/scpageoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24417&path=/trunk/Scribus/scribus/scpageoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/scpageoutput.cpp	(original)
+++ trunk/Scribus/scribus/scpageoutput.cpp	Thu Jan 21 22:09:20 2021
@@ -141,12 +141,7 @@
 		}
 		QRectF oldR(currItem->getBoundingRect().adjusted(0.0, 0.0, 1.0, 1.0));
 		if (clip.intersects(oldR.toRect()))
-		{
-			// relayout necessary to get page number ok
-			currItem->invalidateLayout();
-			currItem->layout();
 			drawItem(currItem, painter, clip);
-		}
 		currItem->OwnPage = savedOwnPage;
 		if (!currItem->ChangedMasterItem)
 		{
@@ -723,10 +718,13 @@
 		PageItem* embedded = item->groupItemList.at(em);
 		painter->save();
 		painter->translate(embedded->gXpos, embedded->gYpos);
+		embedded->savedOwnPage = embedded->OwnPage;
+		embedded->OwnPage = item->OwnPage;
 		embedded->isEmbedded = true;
 		embedded->invalidateLayout();
 		drawItem(embedded, painter, QRect());
 		embedded->isEmbedded = false;
+		embedded->OwnPage = embedded->savedOwnPage;
 		painter->restore();
 	}
 	//painter->endLayer();
@@ -1505,6 +1503,13 @@
 		if (!item->pixm.qImage().isNull())
 			painter->drawImage(&item->pixm, ScPainterExBase::rgbImages);
 		painter->restore();
+	}
+
+	if (item->isMasterItem())
+	{
+		// relayout necessary to get page number ok
+		item->invalidateLayout();
+		item->layout();
 	}
 
 	ScPageOutputPainter p(item, painter, this);




More information about the scribus-commit mailing list