r13888 by jghali - fix loading of file with broken pattern
scribus-commit
scribus-commit at lists.scribus.net
Wed Aug 26 05:49:09 CEST 2009
Revision: 13888
Author: jghali
Date: 2009-08-20T19:08:14.158575Z
Commit message: fix loading of file with broken pattern
Changeset:
M /trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
M /trunk/Scribus/scribus/pageitem.cpp
M /trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
Diffs:
Index: scribus/pageitem.cpp
===================================================================
--- scribus/pageitem.cpp (revision 13887)
+++ scribus/pageitem.cpp (revision 13888)
@@ -369,7 +369,7 @@
BaseOffs = 0;
textPathType = 0;
textPathFlipped = false;
- OwnPage = m_Doc->currentPage()->pageNr();
+ OwnPage = m_Doc->currentPage() ? m_Doc->currentPage()->pageNr() : -1;
oldOwnPage = OwnPage;
savedOwnPage = OwnPage;
PicArt = true;
@@ -509,7 +509,7 @@
groupsLastItem = 0;
ChangedMasterItem = false;
isEmbedded = false;
- OnMasterPage = m_Doc->currentPage()->pageName();
+ OnMasterPage = m_Doc->currentPage() ? m_Doc->currentPage()->pageName() : QString();
m_startArrowIndex = m_Doc->toolSettings.dStartArrow;
m_endArrowIndex = m_Doc->toolSettings.dEndArrow;
effectsInUse.clear();
Index: scribus/plugins/fileloader/scribus150format/scribus150format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.cpp (revision 13887)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.cpp (revision 13888)
@@ -1654,7 +1654,7 @@
if (!loadPage)
{
- if (tagName == "PAGEOBJECT" || tagName =="FRAMEOBJECT")
+ if (tagName == "PAGEOBJECT" || tagName == "FRAMEOBJECT" || tagName == "PatternItem")
doc->setMasterPageMode(false);
else
doc->setMasterPageMode(true);
@@ -1921,9 +1921,15 @@
{
ScPattern pat;
ScXmlStreamAttributes attrs = reader.scAttributes();
- QString patterName = attrs.valueAsString("Name");
+ QString patternName = attrs.valueAsString("Name");
bool success = true;
+ if (patternName.isEmpty())
+ {
+ reader.readToElementEnd();
+ return true;
+ }
+
QMap<PageItem*, int> groupID2;
QMap<int,int> TableID2;
QList<PageItem*> TableItems2;
@@ -2015,20 +2021,22 @@
}
uint itemCount2 = m_Doc->Items->count();
-
- PageItem* currItem = doc->Items->at(itemCount1), *newItem;
- pat.pattern = currItem->DrawObj_toImage();
- pat.pattern = pat.pattern.copy(-pat.xoffset, -pat.yoffset, pat.width, pat.height);
- for (uint as = itemCount1; as < itemCount2; ++as)
+ if (itemCount2 > itemCount1)
{
- newItem = doc->Items->takeAt(itemCount1);
- newItem->moveBy(pat.xoffset, pat.yoffset, true);
- newItem->gXpos += pat.xoffset;
- newItem->gYpos += pat.yoffset;
- newItem->ItemNr = pat.items.count();
- pat.items.append(newItem);
+ PageItem* currItem = doc->Items->at(itemCount1), *newItem;
+ pat.pattern = currItem->DrawObj_toImage();
+ pat.pattern = pat.pattern.copy(-pat.xoffset, -pat.yoffset, pat.width, pat.height);
+ for (uint as = itemCount1; as < itemCount2; ++as)
+ {
+ newItem = doc->Items->takeAt(itemCount1);
+ newItem->moveBy(pat.xoffset, pat.yoffset, true);
+ newItem->gXpos += pat.xoffset;
+ newItem->gYpos += pat.yoffset;
+ newItem->ItemNr = pat.items.count();
+ pat.items.append(newItem);
+ }
}
- doc->docPatterns.insert(patterName, pat);
+ doc->docPatterns.insert(patternName, pat);
return success;
}
@@ -3388,3 +3396,4 @@
+
Index: scribus/plugins/fileloader/scribus134format/scribus134format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus134format/scribus134format.cpp (revision 13887)
+++ scribus/plugins/fileloader/scribus134format/scribus134format.cpp (revision 13888)
@@ -1685,7 +1685,7 @@
if (!loadPage)
{
- if (tagName == "PAGEOBJECT" || tagName =="FRAMEOBJECT")
+ if (tagName == "PAGEOBJECT" || tagName =="FRAMEOBJECT" || tagName =="PatternItem")
doc->setMasterPageMode(false);
else
doc->setMasterPageMode(true);
@@ -1895,9 +1895,15 @@
{
ScPattern pat;
ScXmlStreamAttributes attrs = reader.scAttributes();
- QString patterName = attrs.valueAsString("Name");
+ QString patternName = attrs.valueAsString("Name");
bool success = true;
+ if (patternName.isEmpty())
+ {
+ reader.readToElementEnd();
+ return true;
+ }
+
QMap<PageItem*, int> groupID2;
QMap<int,int> TableID2;
QList<PageItem*> TableItems2;
@@ -1922,7 +1928,7 @@
reader.readNext();
if (reader.isEndElement() && reader.name() == tagName)
break;
- if (!reader.isStartElement() || reader.name() != "PAGEOBJECT")
+ if (!reader.isStartElement() || reader.name() != "PatternItem")
continue;
QStringRef tName = reader.name();
@@ -1989,20 +1995,22 @@
}
uint itemCount2 = m_Doc->Items->count();
-
- PageItem* currItem = doc->Items->at(itemCount1), *newItem;
- pat.pattern = currItem->DrawObj_toImage();
- pat.pattern = pat.pattern.copy(-pat.xoffset, -pat.yoffset, pat.width, pat.height);
- for (uint as = itemCount1; as < itemCount2; ++as)
+ if (itemCount2 > itemCount1)
{
- newItem = doc->Items->takeAt(itemCount1);
- newItem->moveBy(pat.xoffset, pat.yoffset, true);
- newItem->gXpos += pat.xoffset;
- newItem->gYpos += pat.yoffset;
- newItem->ItemNr = pat.items.count();
- pat.items.append(newItem);
+ PageItem* currItem = doc->Items->at(itemCount1), *newItem;
+ pat.pattern = currItem->DrawObj_toImage();
+ pat.pattern = pat.pattern.copy(-pat.xoffset, -pat.yoffset, pat.width, pat.height);
+ for (uint as = itemCount1; as < itemCount2; ++as)
+ {
+ newItem = doc->Items->takeAt(itemCount1);
+ newItem->moveBy(pat.xoffset, pat.yoffset, true);
+ newItem->gXpos += pat.xoffset;
+ newItem->gYpos += pat.yoffset;
+ newItem->ItemNr = pat.items.count();
+ pat.items.append(newItem);
+ }
}
- doc->docPatterns.insert(patterName, pat);
+ doc->docPatterns.insert(patternName, pat);
return success;
}
@@ -3494,3 +3502,4 @@
+
More information about the scribus-commit
mailing list