r22233 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Sun Dec 3 13:03:40 UTC 2017
Author: jghali
Date: Sun Dec 3 13:03:40 2017
New Revision: 22233
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22233
Log:
#15059: Issue with importing master pages that have the same name
Modified:
trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22233&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 Sun Dec 3 13:03:40 2017
@@ -1886,7 +1886,7 @@
return true;
}
-bool Scribus134Format::readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage)
+bool Scribus134Format::readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage, QString renamedPageName)
{
QStringRef tagName = reader.name();
ScXmlStreamAttributes attrs = reader.scAttributes();
@@ -1906,20 +1906,23 @@
itemKind = PageItem::PatternItem;
int pagenr = -1;
- if ((!attrs.value("OnMasterPage").isEmpty()) && (tagName == "MASTEROBJECT"))
- {
- doc->setCurrentPage(doc->MasterPages.at(doc->MasterNames[attrs.valueAsString("OnMasterPage")]));
+ QString masterPageName = attrs.valueAsString("OnMasterPage");
+ if ((!masterPageName.isEmpty()) && (tagName == "MASTEROBJECT"))
+ {
+ if (!renamedPageName.isEmpty())
+ masterPageName = renamedPageName;
+ doc->setCurrentPage(doc->MasterPages.at(doc->MasterNames[masterPageName]));
pagenr = -2;
}
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")
- newItem->OnMasterPage = "";
+ newItem->setMasterPageName(QString());
QString tmpf = attrs.valueAsString("IFONT", doc->itemToolPrefs().textFont);
m_AvailableFonts->findFont(tmpf, doc);
@@ -1936,7 +1939,7 @@
if (tagName == "FRAMEOBJECT")
{
FrameItems.append(doc->Items->takeAt(doc->Items->indexOf(newItem)));
- newItem->LayerID = doc->firstLayerID();
+ newItem->setLayer(doc->firstLayerID());
}
info.item = newItem;
@@ -2162,7 +2165,7 @@
// #11274 : OwnPage is not meaningful for pattern items
itemInfo.item->OwnPage = -1 /*ownPage*/;
- itemInfo.item->OnMasterPage = "";
+ itemInfo.item->OnMasterPage.clear();
if (itemInfo.item->isTableItem)
{
@@ -2625,44 +2628,44 @@
z = doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
//
case PageItem::PathText:
z = doc->itemAdd(PageItem::PathText, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::TextFrame:
z = doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Line:
z = doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Polygon:
z = doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::PolyLine:
z = doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Group:
z = doc->itemAdd(PageItem::Group, PageItem::Unspecified, x, y, w, h, 0, CommonStrings::None, CommonStrings::None, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
currItem->groupWidth = attrs.valueAsDouble("groupWidth", w);
currItem->groupHeight = attrs.valueAsDouble("groupHeight", h);
doc->GroupCounter++;
@@ -2910,7 +2913,7 @@
currItem->Cols = attrs.valueAsInt("COLUMNS", 1);
currItem->ColGap = attrs.valueAsDouble("COLGAP", 0.0);
if (attrs.valueAsInt("LAYER", 0) != -1)
- currItem->LayerID = attrs.valueAsInt("LAYER", 0);
+ currItem->setLayer(attrs.valueAsInt("LAYER", 0));
tmp = "";
QList<ParagraphStyle::TabRecord> tbs;
@@ -3364,15 +3367,18 @@
}
ItemInfo itemInfo;
- success = readObject(m_Doc, reader, itemInfo, fileDir, true);
+ QString masterPageName = Mpage ? renamedPageName : QString();
+ success = readObject(m_Doc, reader, itemInfo, fileDir, true, masterPageName);
if (!success) break;
PageItem* newItem = itemInfo.item;
newItem->moveBy(-pageX + newPage->xOffset(), - pageY + newPage->yOffset());
- newItem->OwnPage = m_Doc->currentPageNumber();
+ newItem->setOwnerPage(m_Doc->currentPageNumber());
if (tagName == "PAGEOBJECT")
- newItem->OnMasterPage = "";
- newItem->LayerID = layerTrans.value(newItem->LayerID, newItem->LayerID);
+ newItem->setMasterPageName(QString());
+ else if (Mpage && !renamedPageName.isEmpty())
+ newItem->setMasterPageName(renamedPageName);
+ newItem->setLayer(layerTrans.value(newItem->LayerID, newItem->LayerID));
if (newItem->isTableItem)
{
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22233&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h Sun Dec 3 13:03:40 2017
@@ -104,7 +104,7 @@
bool readLatexInfo(PageItem_LatexFrame* item, ScXmlStreamReader& reader);
void readLayers(ScLayer& layer, ScXmlStreamAttributes& attrs);
bool readMultiline(multiLine& ml, ScXmlStreamReader& reader);
- bool readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage);
+ bool readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage, QString renamedPageName = QString());
bool readPage(ScribusDoc* doc, ScXmlStreamReader& reader);
bool readPageItemAttributes(PageItem* item, ScXmlStreamReader& reader);
bool readPageSets(ScribusDoc* doc, ScXmlStreamReader& reader);
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22233&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 Sun Dec 3 13:03:40 2017
@@ -3698,7 +3698,7 @@
return true;
}
-bool Scribus150Format::readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage)
+bool Scribus150Format::readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage, QString renamedPageName)
{
QStringRef tagName = reader.name();
ScXmlStreamAttributes attrs = reader.scAttributes();
@@ -3718,9 +3718,12 @@
itemKind = PageItem::PatternItem;
int pagenr = -1;
- if ((!attrs.value("OnMasterPage").isEmpty()) && (tagName == "MASTEROBJECT"))
- {
- doc->setCurrentPage(doc->MasterPages.at(doc->MasterNames[attrs.valueAsString("OnMasterPage")]));
+ QString masterPageName = attrs.valueAsString("OnMasterPage");
+ if ((!masterPageName.isEmpty()) && (tagName == "MASTEROBJECT"))
+ {
+ if (!renamedPageName.isEmpty())
+ masterPageName = renamedPageName;
+ doc->setCurrentPage(doc->MasterPages.at(doc->MasterNames[masterPageName]));
pagenr = -2;
}
layerFound = false;
@@ -3757,7 +3760,7 @@
FrameItems.append(m_Doc->Items->takeAt(m_Doc->Items->indexOf(newItem)));
else
doc->FrameItems.insert(newItem->inlineCharID, doc->Items->takeAt(doc->Items->indexOf(newItem)));
- newItem->LayerID = doc->firstLayerID();
+ newItem->setLayer(doc->firstLayerID());
}
info.item = newItem;
@@ -4811,7 +4814,7 @@
z = doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
//
case PageItem::ImageFrame:
@@ -4820,7 +4823,7 @@
z = doc->itemAdd(pt, PageItem::Unspecified, x, y, w, h, 1, doc->itemToolPrefs().imageFillColor, doc->itemToolPrefs().imageStrokeColor, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
UndoManager::instance()->setUndoEnabled(false);
currItem->ScaleType = attrs.valueAsInt("SCALETYPE", 1);
currItem->AspectRatio = attrs.valueAsInt("RATIO", 0);
@@ -4900,52 +4903,52 @@
z = doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
//
case PageItem::PathText:
z = doc->itemAdd(PageItem::PathText, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::NoteFrame:
case PageItem::TextFrame:
z = doc->itemAdd(pt, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Line:
z = doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Polygon:
z = doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::PolyLine:
z = doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Symbol:
z = doc->itemAdd(PageItem::Symbol, PageItem::Unspecified, x, y, w, h, 0, CommonStrings::None, CommonStrings::None, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
currItem->setPattern( attrs.valueAsString("pattern", "") );
break;
case PageItem::Group:
z = doc->itemAdd(PageItem::Group, PageItem::Unspecified, x, y, w, h, 0, CommonStrings::None, CommonStrings::None, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
currItem->groupWidth = attrs.valueAsDouble("groupWidth", w);
currItem->groupHeight = attrs.valueAsDouble("groupHeight", h);
doc->GroupCounter++;
@@ -4954,25 +4957,25 @@
z = doc->itemAdd(PageItem::RegularPolygon, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Arc:
z = doc->itemAdd(PageItem::Arc, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Spiral:
z = doc->itemAdd(PageItem::Spiral, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Table:
z = doc->itemAdd(PageItem::Table, PageItem::Unspecified, x, y, w, h, 0.0, CommonStrings::None, CommonStrings::None, itemKind);
currItem = doc->Items->at(z);
if (pagenr > -2)
- currItem->OwnPage = pagenr;
+ currItem->setOwnerPage(pagenr);
break;
case PageItem::Multiple:
Q_ASSERT(false);
@@ -5311,7 +5314,7 @@
currItem->ColGap = attrs.valueAsDouble("COLGAP", 0.0);
if (attrs.valueAsInt("LAYER", 0) != -1)
{
- currItem->LayerID = attrs.valueAsInt("LAYER", 0);
+ currItem->setLayer(attrs.valueAsInt("LAYER", 0));
uint layerCount = doc->Layers.count();
bool found = false;
for (uint i = 0; i < layerCount; ++i)
@@ -5323,7 +5326,7 @@
}
}
if (!found)
- currItem->LayerID = doc->firstLayerID();
+ currItem->setLayer(doc->firstLayerID());
}
tmp = "";
if ((attrs.hasAttribute("NUMDASH")) && (attrs.valueAsInt("NUMDASH", 0) != 0))
@@ -6251,15 +6254,18 @@
{
ItemInfo itemInfo;
- success = readObject(m_Doc, reader, itemInfo, fileDir, true);
+ QString masterPageName = Mpage ? renamedPageName : QString();
+ success = readObject(m_Doc, reader, itemInfo, fileDir, true, masterPageName);
if (!success) break;
PageItem* newItem = itemInfo.item;
newItem->moveBy(-pageX + newPage->xOffset(), - pageY + newPage->yOffset());
- newItem->OwnPage = m_Doc->currentPageNumber();
+ newItem->setOwnerPage(m_Doc->currentPageNumber());
if (tagName == "PAGEOBJECT")
- newItem->OnMasterPage = "";
- newItem->LayerID = layerTrans.value(newItem->LayerID, newItem->LayerID);
+ newItem->setMasterPageName(QString());
+ else if (Mpage && !renamedPageName.isEmpty())
+ newItem->setMasterPageName(renamedPageName);
+ newItem->setLayer(layerTrans.value(newItem->LayerID, newItem->LayerID));
if (isNewFormat)
{
if (itemInfo.nextItem != -1)
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22233&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h Sun Dec 3 13:03:40 2017
@@ -119,7 +119,7 @@
bool readLatexInfo(PageItem_LatexFrame* item, ScXmlStreamReader& reader);
void readLayers(ScLayer& layer, ScXmlStreamAttributes& attrs);
bool readMultiline(multiLine& ml, ScXmlStreamReader& reader);
- bool readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage);
+ bool readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage, QString renamedPageName = QString());
bool readPage(ScribusDoc* doc, ScXmlStreamReader& reader);
bool readPageItemAttributes(PageItem* item, ScXmlStreamReader& reader);
bool readPageSets(ScribusDoc* doc, ScXmlStreamReader& reader);
More information about the scribus-commit
mailing list