r16697 by jghali - - #9969: Table of Contents generates incorrect page numbers
scribus-commit
scribus-commit at lists.scribus.net
Mon Jun 27 21:57:40 UTC 2011
Author: jghali
Date: Mon Jun 27 21:57:40 2011
New Revision: 16697
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16697
Log:
- #9969: Table of Contents generates incorrect page numbers
- fix also a crash when layouting page numbers in < 1.5.0 docs
Modified:
trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/scribusdoc.h
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16697&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Mon Jun 27 21:57:40 2011
@@ -574,6 +574,9 @@
m_Doc->setMasterPageMode(false);
m_Doc->reformPages();
+
+ // #9969 : Some old long doc may have page owner somewhat broken
+ m_Doc->fixItemPageOwner();
handleOldLayerBehavior(m_Doc);
if (m_Doc->Layers.count() == 0)
@@ -1703,6 +1706,7 @@
newSection.sectionstartindex = attrs.valueAsInt("Start");
newSection.reversed = attrs.valueAsBool("Reversed");
newSection.active = attrs.valueAsBool("Active");
+ newSection.pageNumberWidth = 0;
doc->sections().insert(newSection.number, newSection);
}
}
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16697&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 27 21:57:40 2011
@@ -764,6 +764,7 @@
newSection.sectionstartindex=sectionElem.attribute("Start").toInt();
newSection.reversed=static_cast<bool>(sectionElem.attribute("Reversed").toInt());
newSection.active=static_cast<bool>(sectionElem.attribute("Active").toInt());
+ newSection.pageNumberWidth = 0;
m_Doc->sections().insert(newSection.number, newSection);
}
Section = Section.nextSibling();
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16697&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Mon Jun 27 21:57:40 2011
@@ -4846,6 +4846,47 @@
}
}
+void ScribusDoc::fixItemPageOwner()
+{
+ int pageNr;
+ Page* page;
+ PageItem* currItem;
+ MarginStruct pageBleeds;
+
+ for (int i = 0; i < Items->count(); ++i)
+ {
+ currItem = Items->at(i);
+ pageNr = currItem->OwnPage;
+
+ // TODO check group owner
+ if (currItem->getItemList().count() > 0)
+ continue;
+
+ // If item has a valid page, check that
+ // specified page effectively contain the item
+ if (pageNr >= 0 && pageNr < Pages->count())
+ {
+ page = Pages->at(pageNr);
+ getBleeds(page, pageBleeds);
+ double x1 = page->xOffset() - pageBleeds.Left;
+ double y1 = page->yOffset() - pageBleeds.Top;
+ double w1 = page->width() + pageBleeds.Left + pageBleeds.Right;
+ double h1 = page->height() + pageBleeds.Bottom + pageBleeds.Top;
+ double x2 = currItem->BoundingX;
+ double y2 = currItem->BoundingY;
+ double w2 = currItem->BoundingW;
+ double h2 = currItem->BoundingH;
+ if (( qMax(x1, x2) <= qMin(x1 + w1, x2 + w2) && qMax(y1, y2) <= qMin(y1 + h1, y2 + h2)))
+ {
+ continue;
+ }
+ }
+
+ // If no or page owner is incorrect, recompute page owner
+ currItem->OwnPage = OnPage(currItem);
+ }
+}
+
struct oldPageVar
{
Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16697&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Mon Jun 27 21:57:40 2011
@@ -780,11 +780,11 @@
*/
void canvasMinMax(FPoint&, FPoint&);
- int OnPage(double x2, double y2);
- int OnPage(PageItem *currItem);
+ int OnPage(double x2, double y2);
+ int OnPage(PageItem *currItem);
void GroupOnPage(PageItem *currItem);
- //void reformPages(double& maxX, double& maxY, bool moveObjects = true);
void reformPages(bool moveObjects = true);
+ void fixItemPageOwner();
/**
* @brief Return the x or y offset for a page on the canvas
More information about the scribus-commit
mailing list