View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0018011 | Scribus | Import / Export | public | 2026-10-14 10:44 | 2026-10-14 10:44 |
| Reporter | buttar | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | new | Resolution | open | ||
| Platform | Linux | OS | Fedora Workstation | OS Version | 44 |
| Product Version | 1.7.4.svn | ||||
| Summary | 0018011: [patch] Fix linked text frames during page import | ||||
| Description | Importing pages with linked text frames could break cross-page chains, resulting in missing text or text overflow. ## Fix: - Baseline: Pristine r27881. - Restore cross-page text-frame links using import-scoped ID mapping, independent of import order. - Correct imported page-object positioning and destination margin handling. - Warn when preceding frames of a linked story are not imported. - Harden import failure handling and page-attribute Undo/Redo. | ||||
| Steps To Reproduce | 1. Create a source document with text frames linked across multiple pages. 2. Create another document and use File > Import > Get Pages to import those pages. 3. Observe broken cross-page links and missing or text overflow. | ||||
| Tags | #please_test | ||||
| Attached Files | pil1-page-import-chain-integrity-v1.05.patch (25,126 bytes)
Index: scribus/fileloader.cpp
===================================================================
--- scribus/fileloader.cpp (revision 27881)
+++ scribus/fileloader.cpp (working copy)
@@ -162,7 +162,7 @@
return ret;
}
-bool FileLoader::loadPage(ScribusDoc* currDoc, int PageToLoad, bool Mpage, const QString& renamedPageName)
+bool FileLoader::loadPage(ScribusDoc* currDoc, int PageToLoad, bool Mpage, const QString& renamedPageName, PageImportLinks* links)
{
bool ret = false;
// newReplacement = false;
@@ -171,6 +171,7 @@
QList<FileFormat>::const_iterator it;
if (findFormat(m_fileType, it))
{
+ it->plug->setPageImportLinks(links);
if (m_fileType == FORMATID_SLA12XIMPORT)
{
it->plug->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager.appPrefs.fontPrefs.AvailFonts));
@@ -187,6 +188,7 @@
// if (ret)
// it->plug->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
}
+ it->plug->setPageImportLinks(nullptr);
}
if (ret)
ret = postLoad(currDoc); // FIXME: return false if user doesn't want to replace fonts??
Index: scribus/fileloader.h
===================================================================
--- scribus/fileloader.h (revision 27881)
+++ scribus/fileloader.h (working copy)
@@ -29,6 +29,7 @@
class PrefsManager;
class FileFormat;
class MultiLine;
+struct PageImportLinks;
class SCRIBUS_API FileLoader : public QObject
{
@@ -40,7 +41,7 @@
int fileType() const { return m_fileType; }
int testFile();
- bool loadPage(ScribusDoc* currDoc, int PageToLoad, bool Mpage, const QString& renamedPageName = QString());
+ bool loadPage(ScribusDoc* currDoc, int PageToLoad, bool Mpage, const QString& renamedPageName = QString(), PageImportLinks* links = nullptr);
bool loadFile(ScribusDoc* currDoc);
bool saveFile(const QString& fileName, ScribusDoc *doc, QString *savedFile = nullptr, uint formatID = FORMATID_CURRENTEXPORT);
bool readStyles(ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles);
Index: scribus/loadsaveplugin.h
===================================================================
--- scribus/loadsaveplugin.h (revision 27881)
+++ scribus/loadsaveplugin.h (working copy)
@@ -15,6 +15,7 @@
#include <QStringList>
#include <QList>
+struct PageImportLinks;
class FileFormat;
//TODO REmove includes one day
class ScribusView;
@@ -120,6 +121,7 @@
virtual void setupTargets(ScribusDoc *targetDoc, ScribusView* targetView, ScribusMainWindow* targetMW, QProgressBar* targetMWPRogressBar, SCFonts* targetAvailableFonts);
virtual void getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces);
virtual bool loadPage(const QString& fileName, int pageNumber, bool Mpage, const QString& renamedPageName = QString());
+ void setPageImportLinks(PageImportLinks* links) { m_pageImportLinks = links; }
virtual bool readStyles(const QString& fileName, ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles);
virtual bool readCharStyles(const QString& fileName, ScribusDoc* doc, StyleSet<CharStyle> &docCharStyles);
virtual bool readLineStyles(const QString& fileName, QHash<QString, MultiLine> *Sty);
@@ -130,6 +132,7 @@
virtual QImage readThumbnail(const QString& fileName);
protected:
+ PageImportLinks* m_pageImportLinks {nullptr};
/// Check a loadFlags combination
virtual bool checkFlags(int flags);
Index: scribus/pageimportlinks.h
===================================================================
--- scribus/pageimportlinks.h (nonexistent)
+++ scribus/pageimportlinks.h (working copy)
@@ -0,0 +1,44 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+ to the COPYING file provided with the program. Following this notice may exist
+ a copyright and/or license notice that predates the release of Scribus 1.3.2
+ for which a new license (GPL+exception) is in place.
+*/
+#ifndef SCRIBUS_PAGEIMPORTLINKS_H
+#define SCRIBUS_PAGEIMPORTLINKS_H
+
+#include <QMap>
+#include <QSet>
+
+class PageItem;
+
+// Source frame IDs are local to one import operation; this mapping is not persisted.
+struct PageImportLinks
+{
+ struct Frame
+ {
+ PageItem* item {nullptr};
+ int next {-1};
+ int previous {-1};
+ };
+
+ void add(int id, PageItem* item, int next, int previous)
+ {
+ if (frames.contains(id))
+ duplicateIds.insert(id);
+ else
+ frames.insert(id, { item, next, previous });
+ }
+
+ void merge(const PageImportLinks& other)
+ {
+ for (auto it = other.frames.cbegin(); it != other.frames.cend(); ++it)
+ add(it.key(), it->item, it->next, it->previous);
+ duplicateIds.unite(other.duplicateIds);
+ }
+
+ QMap<int, Frame> frames;
+ QSet<int> duplicateIds;
+};
+
+#endif
Index: scribus/plugins/fileloader/scribus170format/scribus170format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus170format/scribus170format.cpp (revision 27881)
+++ scribus/plugins/fileloader/scribus170format/scribus170format.cpp (working copy)
@@ -5,6 +5,7 @@
for which a new license (GPL+exception) is in place.
*/
#include "scribus170format.h"
+#include "pageimportlinks.h"
#include "scribus170formatimpl.h"
#include <algorithm>
@@ -6812,6 +6813,9 @@
newItem->setLayer(layerTrans.value(newItem->m_layerID, newItem->m_layerID));
if (isNewFormat)
{
+ if (m_pageImportLinks && !Mpage && (tagName == QLatin1String("PAGEOBJECT") || tagName == QLatin1String("PageObject")))
+ m_pageImportLinks->add(itemInfo.itemID, newItem, itemInfo.nextItem,
+ attrs.valueAsInt("BackItem", attrs.valueAsInt("BACKITEM", -1)));
if (itemInfo.nextItem != -1)
itemNext[itemInfo.itemID] = itemInfo.nextItem;
if (itemInfo.item->isTableItem)
@@ -6908,6 +6912,8 @@
setDomParsingError(reader.errorString(), reader.lineNumber(), reader.columnNumber());
return false;
}
+ if (!success)
+ return false;
for (auto it = bookmarks.begin(); it != bookmarks.end(); ++it)
{
@@ -6959,15 +6965,15 @@
}
}
}
- if (itemNext.count() != 0)
+ if (!m_pageImportLinks && itemNext.count() != 0)
{
for (auto lc = itemNext.begin(); lc != itemNext.end(); ++lc)
{
if (lc.value() >= 0)
{
- PageItem * Its = LinkID[lc.key()];
- PageItem * Itn = LinkID[lc.value()];
- if (!Its->canBeLinkedTo(Itn))
+ PageItem* Its = LinkID.value(lc.key(), nullptr);
+ PageItem* Itn = LinkID.value(lc.value(), nullptr);
+ if (!Its || !Its->canBeLinkedTo(Itn))
{
qDebug() << "scribus170format: corruption in linked textframes detected";
continue;
Index: scribus/plugins/fileloader/scribus171format/scribus171format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus171format/scribus171format.cpp (revision 27881)
+++ scribus/plugins/fileloader/scribus171format/scribus171format.cpp (working copy)
@@ -5,6 +5,7 @@
for which a new license (GPL+exception) is in place.
*/
#include "scribus171format.h"
+#include "pageimportlinks.h"
#include "scribus171formatimpl.h"
#include <algorithm>
@@ -8103,6 +8104,15 @@
QMap<int, ScribusDoc::BookMa> bookmarks;
ScPage* newPage = nullptr;
+ bool sourcePageFound = false;
+ // Use the source page layout to resolve physical margins independently of import order.
+ int sourcePagePositioning = 0;
+ int sourceBindingDirection = 0;
+ int sourceColumns = 1;
+ int sourceFirstPage = 0;
+ bool sourceLayoutFound = false;
+ int sourceSetIndex = 0;
+ bool readingPageSets = false;
QMap<int, PageItem*> TableID;
QList<PageItem*> TableItems;
@@ -8119,6 +8129,8 @@
QStack<int> groupStackPI2;
double pageX = 0;
double pageY = 0;
+ double contentShiftX = 0;
+ double contentShiftY = 0;
QMap<int,int> layerTrans;
int maxLayer = 0;
int maxLevel = 0;
@@ -8178,10 +8190,32 @@
while (!reader.atEnd() && !reader.hasError())
{
QXmlStreamReader::TokenType tType = reader.readNext();
+ if (tType == QXmlStreamReader::EndElement && reader.name() == QLatin1String("PageSets"))
+ readingPageSets = false;
if (tType != QXmlStreamReader::StartElement)
continue;
QString tagName(reader.nameAsString());
attrs = reader.scAttributes();
+ if (tagName == QLatin1String("Document"))
+ {
+ sourcePagePositioning = attrs.valueAsInt("PagePositioning", 0);
+ sourceBindingDirection = attrs.valueAsInt("BindingDirection", 0);
+ }
+ else if (tagName == QLatin1String("PageSets"))
+ {
+ readingPageSets = true;
+ sourceSetIndex = 0;
+ }
+ else if (readingPageSets && tagName == QLatin1String("Set"))
+ {
+ if (sourceSetIndex == sourcePagePositioning)
+ {
+ sourceColumns = qMax(1, attrs.valueAsInt("Columns", 1));
+ sourceFirstPage = attrs.valueAsInt("FirstPage", 0);
+ sourceLayoutFound = true;
+ }
+ ++sourceSetIndex;
+ }
if (firstElement)
{
@@ -8314,12 +8348,18 @@
temp.create(tstyle);
m_Doc->redefineCellStyles(temp, false);
}
- if (((tagName == QLatin1String("PAGE")) || (tagName == QLatin1String("MASTERPAGE")) || (tagName == QLatin1String("Page")) || (tagName == QLatin1String("MasterPage"))) && (attrs.valueAsInt("NUM") == pageNumber || attrs.valueAsInt("PageNumber") == pageNumber))
- {
- if (Mpage && (tagName != QLatin1String("MASTERPAGE") && tagName != QLatin1String("MasterPage")))
- continue;
+ const bool isNormalPage = (tagName == QLatin1String("PAGE") || tagName == QLatin1String("Page"));
+ const bool isMasterPage = (tagName == QLatin1String("MASTERPAGE") || tagName == QLatin1String("MasterPage"));
+ // An absent legacy NUM attribute must not match page zero.
+ const int sourcePageNumber = attrs.hasAttribute("NUM") ? attrs.valueAsInt("NUM", -1) : attrs.valueAsInt("PageNumber", -1);
+ if (((Mpage && isMasterPage) || (!Mpage && isNormalPage)) && sourcePageNumber == pageNumber)
+ {
+ sourcePageFound = true;
int pageNr = m_Doc->currentPage()->pageNr();
newPage = m_Doc->Pages->at(pageNr);
+ // Preserve destination margins even when importing source page dimensions.
+ const MarginStruct destinationMargins = newPage->initialMargins;
+ const int destinationMarginPreset = newPage->marginPreset;
SimpleState *ss = nullptr;
if (UndoManager::undoEnabled())
{
@@ -8405,6 +8445,31 @@
pageY = attrs.valueAsDouble("PageYPosition");
}
+ // Translate from source to destination content margins when both layouts are supported.
+ contentShiftX = 0;
+ contentShiftY = 0;
+ if (!Mpage)
+ {
+ const bool translateContent = sourceLayoutFound && sourceBindingDirection == 0 &&
+ m_Doc->bindingDirection() == 0 && sourceColumns <= 2 &&
+ m_Doc->pageSets().at(m_Doc->pagePositioning()).Columns <= 2;
+ double sourceLeftMargin = 0;
+ if (translateContent)
+ {
+ const bool sourceLeft = sourceColumns == 2 && (pageNumber + sourceFirstPage) % 2 == 0;
+ sourceLeftMargin = sourceLeft ? newPage->initialMargins.right() : newPage->initialMargins.left();
+ contentShiftY = destinationMargins.top() - newPage->initialMargins.top();
+ }
+ newPage->initialMargins = destinationMargins;
+ newPage->marginPreset = destinationMarginPreset;
+ newPage->Margins.setTop(destinationMargins.top());
+ newPage->Margins.setBottom(destinationMargins.bottom());
+ if (m_Doc->bindingDirection() == 0)
+ m_Doc->setLocationBasedPageLRMargins(pageNr);
+ if (translateContent)
+ contentShiftX = newPage->Margins.left() - sourceLeftMargin;
+ }
+
// guides reading
//Remove in 1.8
if (attrs.hasAttribute("AGhorizontalAutoGap"))
@@ -8466,6 +8531,11 @@
if ((tagName == QLatin1String("PAGEOBJECT")) || (tagName == QLatin1String("MASTEROBJECT")) || (tagName == QLatin1String("FRAMEOBJECT")) ||
(tagName == QLatin1String("PageObject")) || (tagName == QLatin1String("MasterObject")) || (tagName == QLatin1String("FrameObject")))
{
+ if (!sourcePageFound)
+ {
+ reader.readToElementEnd();
+ continue;
+ }
if ((Mpage && (tagName != QLatin1String("MASTEROBJECT") && tagName != QLatin1String("MasterObject"))) || (!Mpage && (tagName == QLatin1String("MASTEROBJECT") || tagName == QLatin1String("MasterObject"))))
{
// Go to end of node
@@ -8489,15 +8559,20 @@
break;
PageItem* newItem = itemInfo.item;
- newItem->moveBy(-pageX + newPage->xOffset(), - pageY + newPage->yOffset());
+ const bool isPageObject = (tagName == QLatin1String("PAGEOBJECT") || tagName == QLatin1String("PageObject"));
+ newItem->moveBy(-pageX + newPage->xOffset() + (isPageObject ? contentShiftX : 0.0),
+ -pageY + newPage->yOffset() + (isPageObject ? contentShiftY : 0.0));
newItem->setOwnerPage(m_Doc->currentPageNumber());
- if (tagName == QLatin1String("PAGEOBJECT") || tagName == QLatin1String("PageObject"))
+ if (isPageObject)
newItem->setMasterPageName(QString());
else if (Mpage && !renamedPageName.isEmpty())
newItem->setMasterPageName(renamedPageName);
newItem->setLayer(layerTrans.value(newItem->m_layerID, newItem->m_layerID));
if (isNewFormat)
{
+ if (m_pageImportLinks && !Mpage && isPageObject)
+ m_pageImportLinks->add(itemInfo.itemID, newItem, itemInfo.nextItem,
+ attrs.valueAsInt("BackItem", attrs.valueAsInt("BACKITEM", -1)));
if (itemInfo.nextItem != -1)
itemNext[itemInfo.itemID] = itemInfo.nextItem;
if (itemInfo.item->isTableItem)
@@ -8610,6 +8685,8 @@
setDomParsingError(reader.errorString(), reader.lineNumber(), reader.columnNumber());
return false;
}
+ if (!success || !sourcePageFound)
+ return false;
for (auto it = bookmarks.begin(); it != bookmarks.end(); ++it)
{
@@ -8661,15 +8738,15 @@
}
}
}
- if (itemNext.count() != 0)
+ if (!m_pageImportLinks && itemNext.count() != 0)
{
for (auto lc = itemNext.begin(); lc != itemNext.end(); ++lc)
{
if (lc.value() >= 0)
{
- PageItem * Its = LinkID[lc.key()];
- PageItem * Itn = LinkID[lc.value()];
- if (!Its->canBeLinkedTo(Itn))
+ PageItem* Its = LinkID.value(lc.key(), nullptr);
+ PageItem* Itn = LinkID.value(lc.value(), nullptr);
+ if (!Its || !Its->canBeLinkedTo(Itn))
{
qDebug() << "scribus171format: corruption in linked textframes detected";
continue;
Index: scribus/scpage.cpp
===================================================================
--- scribus/scpage.cpp (revision 27881)
+++ scribus/scpage.cpp (working copy)
@@ -352,6 +352,11 @@
this->guides.setHorizontalAutoRefer(horizontal_autorefer);
this->guides.setVerticalAutoRefer(vertical_autorefer);
}
+
+ // Restore effective left/right margins for the page's current layout position.
+ if (m_Doc && m_Doc->bindingDirection() == 0 && m_pageName.isEmpty() &&
+ m_pageNr >= 0 && m_pageNr < m_Doc->DocPages.count() && m_Doc->DocPages.at(m_pageNr) == this)
+ m_Doc->setLocationBasedPageLRMargins(m_pageNr);
}
void ScPage::restorePageItemCreation(ScItemState<PageItem*> *state, bool isUndo)
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp (revision 27881)
+++ scribus/scribus.cpp (working copy)
@@ -113,6 +113,7 @@
#include "documentchecker.h"
#include "documentlogmanager.h"
#include "fileloader.h"
+#include "pageimportlinks.h"
#include "filewatcher.h"
#include "fpoint.h"
#include "fpointarray.h"
@@ -3247,6 +3248,74 @@
return loadDoc(fileNameVersion.first);
}
+// Restore text chains after loading all selected pages, without linking to
+// pre-existing destination frames.
+struct PageImportLinkResult
+{
+ bool missingStoryStart {false};
+ bool invalidLinks {false};
+};
+
+static PageImportLinkResult restorePageImportLinks(const PageImportLinks& links)
+{
+ PageImportLinkResult result;
+ QSet<int> visited;
+
+ for (auto it = links.frames.constBegin(); it != links.frames.constEnd(); ++it)
+ {
+ const int id = it.key();
+ const PageImportLinks::Frame& frame = it.value();
+ if (links.duplicateIds.contains(id))
+ continue;
+
+ if (frame.previous >= 0 && !links.frames.contains(frame.previous))
+ result.missingStoryStart = true;
+ else if (frame.previous >= 0 && !links.duplicateIds.contains(frame.previous))
+ {
+ // Link this frame when traversing its imported predecessor.
+ continue;
+ }
+
+ int currentId = id;
+ while (true)
+ {
+ if (visited.contains(currentId))
+ {
+ result.invalidLinks = true;
+ break;
+ }
+ visited.insert(currentId);
+
+ const auto current = links.frames.constFind(currentId);
+ if (current == links.frames.cend() || current->next < 0)
+ break;
+ const int nextId = current->next;
+ const auto next = links.frames.constFind(nextId);
+ if (next == links.frames.cend())
+ break; // A later page was intentionally not selected.
+ if (links.duplicateIds.contains(nextId) || visited.contains(nextId) ||
+ next->previous != currentId || !current->item || !next->item ||
+ !current->item->canBeLinkedTo(next->item))
+ {
+ result.invalidLinks = true;
+ break;
+ }
+
+ current->item->link(next->item);
+ currentId = nextId;
+ }
+ }
+
+ // An entirely cyclic or otherwise malformed chain may have no root.
+ for (auto it = links.frames.cbegin(); it != links.frames.cend(); ++it)
+ {
+ if (!visited.contains(it.key()) &&
+ (!links.duplicateIds.contains(it.key()) || it->previous >= 0 || it->next >= 0))
+ result.invalidLinks = true;
+ }
+ return result;
+}
+
bool ScribusMainWindow::slotPageImport()
{
Q_ASSERT(!doc->masterPageMode());
@@ -3254,6 +3323,14 @@
QScopedPointer<MergeDoc> dia(new MergeDoc(this, false, doc->DocPages.count(), doc->currentPage()->pageNr() + 1));
if (!dia->exec())
return false;
+
+ // Validate the source before changing the destination document.
+ FileLoader sourceLoader(dia->getFromDoc());
+ if (sourceLoader.testFile() == -1)
+ {
+ ScMessageBox::warning(this, tr("Import Pages"), tr("The selected document cannot be opened for page import."));
+ return false;
+ }
bool ret = false;
UndoTransaction activeTransaction;
@@ -3321,23 +3398,57 @@
QApplication::restoreOverrideCursor();
}
}
+ QString importWarning;
if (doIt)
{
if (nrToImport > 0)
{
+ PageImportLinks importLinks;
+ bool allPagesLoaded = true;
+ int failedSourcePage = -1;
mainWindowProgressBar->reset();
mainWindowProgressBar->setMaximum(nrToImport);
int counter = startPage;
for (int i = 0; i < nrToImport; ++i)
{
view->GotoPa(counter);
- loadPage(dia->getFromDoc(), pageNs[i] - 1, false);
+ PageImportLinks pageLinks;
+ if (!loadPage(dia->getFromDoc(), pageNs[i] - 1, false, QString(), &pageLinks))
+ {
+ allPagesLoaded = false;
+ failedSourcePage = pageNs[i];
+ break;
+ }
+ importLinks.merge(pageLinks);
counter++;
mainWindowProgressBar->setValue(i + 1);
}
+ const PageImportLinkResult linkResult = restorePageImportLinks(importLinks);
+ view->DrawNew();
view->GotoPa(startPage);
mainWindowProgressBar->reset();
- m_mainWindowStatusLabel->setText( tr("Import done"));
+ if (!allPagesLoaded)
+ {
+ m_mainWindowStatusLabel->setText(tr("Page import incomplete"));
+ importWarning = tr("Could not import source page %1. The import was stopped; partially imported pages may remain. Use Undo to revert the import.").arg(failedSourcePage);
+ doIt = false;
+ }
+ else
+ m_mainWindowStatusLabel->setText(linkResult.missingStoryStart || linkResult.invalidLinks ?
+ tr("Import completed with warnings") : tr("Import done"));
+ if (linkResult.missingStoryStart || linkResult.invalidLinks)
+ {
+ if (!importWarning.isEmpty())
+ importWarning += QLatin1String("\n\n");
+ if (linkResult.missingStoryStart)
+ importWarning += tr("Some imported text frames are missing preceding frames, so their text may be incomplete. Import the preceding source pages to preserve the full story.");
+ if (linkResult.invalidLinks)
+ {
+ if (!importWarning.isEmpty())
+ importWarning += QLatin1String("\n\n");
+ importWarning += tr("Some text-frame links could not be restored because source references are ambiguous or invalid.");
+ }
+ }
}
else
{
@@ -3350,10 +3461,12 @@
if (activeTransaction)
activeTransaction.commit();
+ if (!importWarning.isEmpty())
+ ScMessageBox::warning(this, tr("Import Pages"), importWarning);
return ret;
}
-bool ScribusMainWindow::loadPage(const QString& fileName, int Nr, bool Mpa, const QString& renamedPageName)
+bool ScribusMainWindow::loadPage(const QString& fileName, int Nr, bool Mpa, const QString& renamedPageName, PageImportLinks* links)
{
if (fileName.isEmpty())
return false;
@@ -3366,7 +3479,7 @@
}
doc->setLoading(true);
int oldItemsCount = doc->Items->count();
- if (!fl->loadPage(doc, Nr, Mpa, renamedPageName))
+ if (!fl->loadPage(doc, Nr, Mpa, renamedPageName, links))
{
delete fl;
doc->setLoading(false);
Index: scribus/scribus.h
===================================================================
--- scribus/scribus.h (revision 27881)
+++ scribus/scribus.h (working copy)
@@ -106,6 +106,7 @@
class ScribusCore;
class ScribusDoc;
class ScribusMainWindow;
+struct PageImportLinks;
class ScribusQApp;
class ScribusWin;
class SimpleState;
@@ -356,7 +357,7 @@
bool slotFileNew();
void newFileFromTemplate();
bool slotPageImport();
- bool loadPage(const QString& fileName, int Nr, bool Mpa, const QString& renamedPageName = QString());
+ bool loadPage(const QString& fileName, int Nr, bool Mpa, const QString& renamedPageName = QString(), PageImportLinks* links = nullptr);
void gotoLayer(int l);
void slotGetContent();
void slotGetContent2(); // kk2006
Index: scribus/ui/mergedoc.cpp
===================================================================
--- scribus/ui/mergedoc.cpp (revision 27881)
+++ scribus/ui/mergedoc.cpp (working copy)
@@ -13,6 +13,7 @@
#include "prefsmanager.h"
#include "scconfig.h"
#include "ui/customfdialog.h"
+#include "ui/scmessagebox.h"
#include <QApplication>
#include <QCheckBox>
@@ -126,51 +127,57 @@
void MergeDoc::changeFile()
{
- count = 0;
PrefsContext* dirs = PrefsManager::instance().prefsFile->getContext("dirs");
QString wdir = dirs->get("merge", ".");
- CustomFDialog *dia = new CustomFDialog(this, wdir, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
+ CustomFDialog dia(this, wdir, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
if (!fromDocData->text().isEmpty())
- dia->setSelection(fromDocData->text());
- if (dia->exec() == QDialog::Accepted)
- {
- QString fn(dia->selectedFile());
+ dia.setSelection(fromDocData->text());
+ if (dia.exec() == QDialog::Accepted)
+ {
+ QString fn(dia.selectedFile());
if (!fn.isEmpty())
{
dirs->set("merge", fn.left(fn.lastIndexOf("/")));
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
FileLoader fl(fn);
if (fl.testFile() == -1)
- //TODO put in nice user warning
+ {
+ qApp->restoreOverrideCursor();
+ ScMessageBox::warning(this, windowTitle(), tr("The selected file is not a supported Scribus document."));
return;
+ }
QStringList masterPageNames;
bool ret = false;
- int dummy;
+ int dummy = 0;
+ int selectedCount = 0;
if (masterPages)
- ret = fl.readPageCount(&dummy, &count, masterPageNames);
+ ret = fl.readPageCount(&dummy, &selectedCount, masterPageNames);
else
- ret = fl.readPageCount(&count, &dummy, masterPageNames);
+ ret = fl.readPageCount(&selectedCount, &dummy, masterPageNames);
qApp->restoreOverrideCursor();
- if (ret && count > 0)
- {
- fromDocData->setText( QDir::toNativeSeparators(fn) );
- importButton->setEnabled(true);
- importButton->setDefault(true);
- if (masterPages)
- {
- masterPageNameData->clear();
- masterPageNameData->setEnabled(true);
- masterPageNameData->addItems(masterPageNames);
- masterPageNameData->setCurrentRow(0);
- }
- else
- {
- pageNumberData->setEnabled(true);
- pageNumberData->setText("*");
- }
- if (!masterPages)
- fromLabel->setText( tr(" from %1").arg(count));
- }
+ if (!ret || selectedCount <= 0)
+ {
+ ScMessageBox::warning(this, windowTitle(), tr("Could not read pages from the selected document."));
+ return;
+ }
+ count = selectedCount;
+ fromDocData->setText(QDir::toNativeSeparators(fn));
+ importButton->setEnabled(true);
+ importButton->setDefault(true);
+ if (masterPages)
+ {
+ masterPageNameData->clear();
+ masterPageNameData->setEnabled(true);
+ masterPageNameData->addItems(masterPageNames);
+ masterPageNameData->setCurrentRow(0);
+ }
+ else
+ {
+ pageNumberData->setEnabled(true);
+ pageNumberData->setText("*");
+ }
+ if (!masterPages)
+ fromLabel->setText(tr(" from %1").arg(count));
}
}
else
@@ -191,7 +198,6 @@
if (!masterPages)
fromLabel->setText( tr(" from %1").arg(count));
}
- delete dia;
}
void MergeDoc::checkDestPageStatus(int positionComboSelection)
| ||||
| Patch | Yes | ||||