View Issue Details

IDProjectCategoryView StatusLast Update
0008056ScribusImport / Exportpublic2024-03-17 07:52
Reporterrenm Assigned Toale  
PrioritynormalSeveritymajorReproducibilityalways
Status assignedResolutionopen 
PlatformLinuxOSUbuntu x86_64OS Version9.04
Product Version1.3.5svn 
Target Version1.5.4 
Summary0008056: [WIP PATCH] Import pages with linked text frames breaks the links
DescriptionTry to import the pages from other sla file (create new pages in current sla) and find out the result pages do not look exactly like the original.

After imported, the linked text frames lose the link at the page boundary. The original 'indent' paragraph breaks between pages, and at beginning of the 2nd page, the text will start with 'indent' style text as a new paragraph (the original would be continue text flow).

Workaround is to relink all of them manually. For 1.3.3.x, you have to change the first paragraph on each of the following pages to 'non-indent' style to mimic the original layout since there is no way to relink the filled frame in version 1.3.3.x.
Tags#rottenpatch
PatchYes

Relationships

has duplicate 0008740 closedjghali Text box links lost when importing pages 
has duplicate 0008778 closedchristoph_s importing pages from a scribus document: text frames are not linked properly 
has duplicate 0010316 closedjghali Importing an SLA doc with linked text frames 
has duplicate 0010753 closedjghali Importing pages loses text frame linking 
has duplicate 0011110 closedjghali Import SLA looses links between linked text frames 
has duplicate 0011155 closedjghali Import pages doesn't import link information 
has duplicate 0012128 closedjghali Importing Scribus 1.4 pages with text frames forward linked across pages 
has duplicate 0012764 closed When importing another .sla-file, the textbox-concatenations get lost 
has duplicate 0012981 closedjghali link of textframes through pages broken on import 
has duplicate 0013099 closedjghali Importing linked text frames 
has duplicate 0013208 closedjghali Import features only imports 1 page of .sla document properly on Scribus 1.4.2 
has duplicate 0016228 closedjghali Importing another sla file does not create linked frames when adding pages 
related to 0012018 closedjghali Undo does not behave as expected with linked Text Frames 
related to 0011240 closedcbradney With or without crash; linked textframes unlinked 
related to 0008602 confirmed Master Pages don't respect linked text frames 

Activities

JLuc

2011-10-13 10:34

developer   ~0027015

Last edited: 2014-02-23 13:19

I dont get that 'Indent' problem.

http://bugs.scribus.net/view.php?id=10316 (Fixed) describes in details various faulty SLA Import behaviours. Beside unlinking of text frames, 2 phenomenons happen in some cases : - loss of elements in the masterpage (not imported) - all linked frames are imported twice : once linked but empty, 2nd not linked but with text in first frame.

JLuc

2013-01-27 16:56

developer   ~0029770

Same with 1.4.3 : linked text frames are not linked in the document where they have been imported.

Besides, it seems that masterpages elements are not imported neither.

JLuc

2014-02-09 14:47

developer   ~0031294

Last edited: 2014-02-23 12:44

Same with 1.5

0011408 is also related to restoring links between text frames, but when undoing some page delete.

JLuc

2014-02-23 13:04

developer   ~0031375

Last edited: 2014-02-23 13:04

I upload a sample 2 pages document, with 2 textframes on each page, all of them linked in a 4 frames chain. As a consequence, there is a link on each page and a link that crosses the page boundary.

When imported with "Page(s) > Import" into another document, all frames are imported, the links on each page is imported, but not the link across page boundaries. That's because Scribus150Format::loadPage loads ONE page at a time, with no view of the global job being done.

JLuc

2014-02-23 13:18

developer  

JLuc

2014-02-25 01:18

developer   ~0031380

I upload patch that fixes the issue.
Please test and merge when possible.

JLuc

2014-02-25 11:32

developer   ~0031382

Last edited: 2014-02-25 11:45

I upload improved version of patch.
It shouldnt change now.

Some explanations :

- a new unknownLinks variable is added to Scribus150Format class. This variable of class QMap gather the links where the destination doesnt exist yet when the link is imported.
Later on, when that frame is imported, it is recognised and the link is created.

- when importaing many pages (for "Page Import" menu action) pageLoad is first called with PageNumber set to -1 so as to clear the unknownLinks set.
When the pageLoad action is finished it is called once more with PageNumber set to -1 : it enables to display a warning message when some links that could not be imported are left (because theyr destination has not been imported). And it clears the unknownLinks that are now useless.

How to test :
- create doc1
- import all pages of doc2 having linked links across pages : links should be imported too (that's the fix !)
- import only one page of doc2 : link can not be imported since destination frame is on not imported page. A nice warning is issued.

JLuc

2014-02-25 11:33

developer  

jl_importlinks_2.diff (6,060 bytes)   
Index: scribus/plugins/fileloader/scribus150format/scribus150format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(révision 18833)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(copie de travail)
@@ -66,6 +66,7 @@
 Scribus150Format::~Scribus150Format()
 {
 	unregisterAll();
+    qDebug () << "Scribus150Format::~Scribus150Format DESTRUCTOR"; // never called
 }
 
 void Scribus150Format::languageChange()
@@ -5610,14 +5611,25 @@
 	return !reader.hasError();
 }
 
+// pageNumber can be <0 when begining and ending the loads of a set of pages
 bool Scribus150Format::loadPage(const QString & fileName, int pageNumber, bool Mpage, QString renamedPageName)
 {
 // 	qDebug() << QString("loading page %2 from file '%1' from 1.3.x plugin").arg(fileName).arg(pageNumber);
+
 	if (m_Doc==0 || m_AvailableFonts==0)
+		return false;
+
+	if (pageNumber <0)  // called both for init and end
 	{
-		Q_ASSERT(m_Doc==0 || m_AvailableFonts==0);
-		return false;
+		if (unknownLinks.size())
+			QMessageBox::information (m_ScMW,
+									  CommonStrings::trWarning,
+									  tr("Scribus was unable to import %1 link(s) toward not imported frame(s).").arg(unknownLinks.size()),
+									  CommonStrings::tr_OK);
+		unknownLinks.clear();
+        return true;
 	}
+
 	ParagraphStyle vg;
 	Xp = 0.0;
 	Yp = 0.0;
@@ -5908,8 +5919,22 @@
 				newItem->LayerID = layerTrans.value(newItem->LayerID, newItem->LayerID);
 				if (isNewFormat)
 				{
-					if (itemInfo.nextItem != -1)
+                    int startItemID (unknownLinks.key(itemInfo.itemID,0));
+                    if (startItemID)	// found previously missing destination of an imported link ?
+                    {
+                        PageItem * Its = LinkID[startItemID];
+                        PageItem * Itn = LinkID[itemInfo.itemID];
+                        if (!Its->testLinkCandidate(Itn))
+                            qDebug() << "Scribus150Format::loadPage : Link Corruption Found from " << startItemID << "to "<< itemInfo.itemID;
+                        else
+                        {
+                            Its->link(Itn);
+                            unknownLinks.remove(startItemID);
+                        }
+                    }
+                    if (itemInfo.nextItem != -1) {
 						itemNext[itemInfo.itemID] = itemInfo.nextItem;
+                    };
 					if (itemInfo.item->isTableItem)
 						TableItems.append(itemInfo.item);
 					if (itemInfo.isWeldFlag)
@@ -6044,7 +6069,8 @@
 					PageItem * Itn = LinkID[lc.value()];
 					if (!Its->testLinkCandidate(Itn))
 					{
-						qDebug() << "scribus150format: corruption in linked textframes detected";
+                        qDebug() << "scribus150format: Found link from " << lc.key() << "to yet unloaded frame"<< lc.value();
+                        unknownLinks[lc.key()]=lc.value();
 						continue;
 					}
 					Its->link(Itn);
@@ -6105,7 +6131,7 @@
 						PageItem * Itn = m_Doc->DocItems.at(itemRemap[lc.value()]);
 						if (!Its->testLinkCandidate(Itn))
 						{
-							qDebug() << "scribus150format: corruption in linked textframes detected";
+                            qDebug() << "scribus150format: Found link from " << lc.key() << "to yet unloaded frame"<< lc.value();
 							continue;
 						}
 						Its->link(Itn);
Index: scribus/plugins/fileloader/scribus150format/scribus150format.h
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.h	(révision 18833)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.h	(copie de travail)
@@ -19,6 +19,7 @@
 #include <QMap>
 #include <QProgressBar>
 #include <QString>
+#include <QMessageBox>
 
 class QIODevice;
 
@@ -190,7 +191,8 @@
 		void SetItemProps(ScXmlStreamWriter& docu, PageItem* item, const QString& baseDir, bool newFormat);
 
 		QMap<QString, QString> parStyleMap;
-		
+
+        QMap<int, int> unknownLinks; // in pageLoad only as for now : items that remain unlinked because linked frame is in yet unloaded page
 		QMap<int, int> itemRemap;
 		QMap<int, int> itemNext;
 		QMap<int, int> itemRemapF;
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(révision 18833)
+++ scribus/scribus.cpp	(copie de travail)
@@ -3865,11 +3865,13 @@
 	UndoTransaction* activeTransaction = NULL;
 	if(UndoManager::undoEnabled())
 		activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::ImportPage, Um::IGroup, Um::ImportPage, 0, Um::ILock));
-
 	if (dia->exec())
 	{
 		mainWindowStatusLabel->setText( tr("Importing Pages..."));
 		qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+
+        const QString FromFilename (dia->getFromDoc());
+
 		std::vector<int> pageNs;
 		parsePagesString(dia->getPageNumbers(), &pageNs, dia->getPageCounter());
 		int startPage=0, nrToImport=pageNs.size();
@@ -3877,7 +3879,7 @@
 		if (doc->masterPageMode())
 		{
 			if (nrToImport > 1)
-				loadPage(dia->getFromDoc(), pageNs[0] - 1, false);
+                loadPage(FromFilename, pageNs[0] - 1, false);
 			doIt = false;
 		}
 		else if (dia->getCreatePageChecked())
@@ -3930,16 +3932,18 @@
 				mainWindowProgressBar->reset();
 				mainWindowProgressBar->setMaximum(nrToImport);
 				int counter = startPage;
+                loadPage(FromFilename, -1, false); // init clean unknownLinks
 				for (int i = 0; i < nrToImport; ++i)
 				{
 					view->GotoPa(counter);
-					loadPage(dia->getFromDoc(), pageNs[i] - 1, false);
+                    loadPage(FromFilename, pageNs[i] - 1, false);
 					counter++;
 					mainWindowProgressBar->setValue(i + 1);
 				}
 				view->GotoPa(startPage);
 				mainWindowProgressBar->reset();
 				mainWindowStatusLabel->setText( tr("Import done"));
+                loadPage(FromFilename, -1, false); // end load clean
 			}
 			else
 			{
jl_importlinks_2.diff (6,060 bytes)   

JLuc

2014-02-26 08:56

developer   ~0031404

Last edited: 2014-03-06 10:34

In loadPages, the first call with -1 is meant to be sure to initialise unknownLinks. Since it should be allready empty normally ATM, this "begin" init is not strictly required (but IMO it's not bad to have that "begin" because it balances the "end" -1 call. for example, it might later be usefull for some other loadplugin or some other import page feature to be managed ?).

FirasH

2014-06-28 14:43

reporter   ~0032355

Same here with 1.4.5.svn (19285) and 1.5.0.svn (19288).

JLuc

2014-07-21 19:49

developer   ~0032891

The proposed patch for scribus 1.5 fixes this bug. The proposed patch does not fix the same bug that occur when scribus 1.5 imports some 1.4 document.

IMO This patch should be taken as it is and be merged in trunk as is.

Kunda

2014-09-02 13:04

updater   ~0033457

So the proposal with this patch is to implement it for 1.5svn without backporting. Probably will break backward compatibility functionality, right?

JLuc

2014-09-02 15:31

developer   ~0033460

Last edited: 2014-10-11 16:05

1.5 SLA can not be opened into Scribus 1.4. That's not an issue. There is no backward compatibility issue.

The proposed patch fixes the described issue when importing 1.5 SLA into scribus 1.5. It's not backportable to scribus 1.4 because scribus 1.4 only opens 1.4 SLA and the fix doesnt tackle the import of 1.4 SLA.

Kunda

2014-09-04 23:23

updater   ~0033503

Last edited: 2014-09-04 23:24

fixed typo in bug summary
Question: Will this patch fix 0011240 ?

JLuc

2014-10-11 16:06

developer   ~0033976

Last edited: 2014-10-12 07:47

@kunda : This patch fixes the import bug regarding broken links. That's all. It doesnt improve any not-related crash behaviour.

JLuc

2015-05-30 07:54

developer   ~0035289

Please merge this patch.

ale

2019-11-15 10:46

manager   ~0047084

when reviewing, please make sure that

if (it.key() < m_Doc->Items->count())
    Its = m_Doc->DocItems.at(it.key());

can be converted to

if (it.key() < m_Doc->DocItems->count())
    Its = m_Doc->DocItems.at(it.key());

and please document in scribusdoc.h what's the difference between DocItems and Items...

JLuc

2019-11-15 11:12

developer   ~0047085

ale, have you tested the patch ?
Can you confirm it works well ?

ale

2019-11-15 12:55

manager   ~0047086

no, jluc, i did not test the patch.

i skimmed through it and noticed that it makes things even more complex.

i've now refactored the Scribus150Format::pageLoad() to be easier to read and changed it to support importing multiple page at a time.

i'm now trying to sort out what are the dependencies in scribus.cpp.

you patch was very useful to find out where i should look at, but adding one more list, that persist among calls (i guess...), did not look like the right solution to me...

ale

2019-11-15 12:58

manager   ~0047087

ScribusMainWindow::loadPage() is used by

- ScribusMainWindow::slotPageImport(): we need to add a callback that shows the counter and updates the screen.
- plugins/scriptplugin/cmdpage.cpp: we probably need to have importPage() and importPages()...
- plugins/scriptplugin_py2x/cmdpage.cpp:

ale

2019-11-18 09:45

manager   ~0047100

Last edited: 2019-11-18 09:47

first part of a new patch:

https://gitlab.com/scribus/scribus/merge_requests/17/diffs

please review it, before i go on with the second part.

- this patch does not change scribus behavior.
- there is some refactoring.
- it adds a "loadPage" that accepts a list of pages instead of a single page.
- before accepting the patch, you need to correctly indent the for loop! in the last commit i've reduced the indent to allow a review of the patch (otherwise, all lines are marked as changed...)

it's loosely inspired by jluc patch.

i also attach the diff for the next step:
- it does not correctly work, yet
- THE ATTACHED PATCH IS NOT THE SAME AS THE ONE IN THE MERGE REQUEST LINKED ABOVE
  and needs the first patch to be accepted.

import-textchain-secondstep.diff (12,169 bytes)   
diff --git a/scribus/fileloader.cpp b/scribus/fileloader.cpp
index 50e9c997d..5f1eae3db 100644
--- a/scribus/fileloader.cpp
+++ b/scribus/fileloader.cpp
@@ -173,7 +173,7 @@ int FileLoader::testFile()
 	return ret;
 }
 
-bool FileLoader::loadPage(ScribusDoc* currDoc, int PageToLoad, bool Mpage, const QString& renamedPageName)
+bool FileLoader::loadPage(ScribusDoc* currDoc, std::vector<int> PageToLoad, bool Mpage, std::function<void(int)> updateViewCallabck, const QString& renamedPageName)
 {
 	bool ret = false;
 // 	newReplacement = false;
@@ -192,7 +192,9 @@ bool FileLoader::loadPage(ScribusDoc* currDoc, int PageToLoad, bool Mpage, const
 		if (m_fileType == FORMATID_SLA13XIMPORT || m_fileType == FORMATID_SLA134IMPORT || m_fileType == FORMATID_SLA150IMPORT)
 		{
 			it->plug->setupTargets(currDoc, nullptr, currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager.appPrefs.fontPrefs.AvailFonts));
+			it->plug->setUpdateViewCallback(updateViewCallabck);
 			ret = it->plug->loadPage(m_fileName, PageToLoad, Mpage, renamedPageName);
+			it->plug->setUpdateViewCallback();
 // 			if (ret)
 // 				it->plug->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
 		}
diff --git a/scribus/fileloader.h b/scribus/fileloader.h
index b1210904a..c1f9e3fa9 100644
--- a/scribus/fileloader.h
+++ b/scribus/fileloader.h
@@ -26,6 +26,7 @@ class SCFonts;
 class PrefsManager;
 class FileFormat;
 class multiLine;
+class vector;
 
 class SCRIBUS_API FileLoader : public QObject
 {
@@ -37,7 +38,7 @@ public:
 	int fileType() const { return m_fileType; }
 	int testFile();
 
-	bool loadPage(ScribusDoc* currDoc, int PageToLoad, bool Mpage, const QString& renamedPageName=QString());
+	bool loadPage(ScribusDoc* currDoc, std::vector<int> PageToLoad, bool Mpage, std::function<void(int)> updateViewCallabck, const QString& renamedPageName=QString());
 	bool loadFile(ScribusDoc* currDoc);
 	bool saveFile(const QString& fileName, ScribusDoc *doc, QString *savedFile = nullptr);
 	bool readStyles(ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles);
diff --git a/scribus/loadsaveplugin.cpp b/scribus/loadsaveplugin.cpp
index ae660e5bf..6a0178de2 100644
--- a/scribus/loadsaveplugin.cpp
+++ b/scribus/loadsaveplugin.cpp
@@ -13,6 +13,8 @@ for which a new license (GPL+exception) is in place.
 
 #include "plugins/formatidlist.h"
 
+#include <vector>
+
 #include <QList>
 #include <QMessageBox>
 
@@ -399,6 +401,11 @@ void LoadSavePlugin::getReplacedFontData(bool & /*getNewReplacement*/, QMap<QStr
 {
 }
 
+bool LoadSavePlugin::loadPage(const QString & /*fileName*/, std::vector<int> /*pageNumbers*/, bool /*Mpage*/, const QString& /*renamedPageName*/)
+{
+	return false;
+}
+
 bool LoadSavePlugin::loadPage(const QString& /*fileName*/, int /*pageNumber*/, bool /*Mpage*/, const QString& /*renamedPageName*/)
 {
 	return false;
diff --git a/scribus/loadsaveplugin.h b/scribus/loadsaveplugin.h
index 1bf162898..17db33672 100644
--- a/scribus/loadsaveplugin.h
+++ b/scribus/loadsaveplugin.h
@@ -16,6 +16,9 @@ for which a new license (GPL+exception) is in place.
 #include <QStringList>
 #include <QList>
 
+#include <functional>
+#include <vector>
+
 class FileFormat;
 //TODO REmove includes one day
 class ScribusView;
@@ -108,7 +111,9 @@ class SCRIBUS_API LoadSavePlugin : public ScPlugin
 
 		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, std::vector<int> pageNumbers, bool Mpage, const QString& renamedPageName=QString());
 		virtual bool loadPage(const QString & fileName, int pageNumber, bool Mpage, const QString& renamedPageName=QString());
+		void setUpdateViewCallback(std::function<void(int)> callback = {}) { this->viewUpdateCallback = callback; }
 		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);
@@ -143,6 +148,7 @@ class SCRIBUS_API LoadSavePlugin : public ScPlugin
 		SCFonts*           m_AvailableFonts;
 		QString            m_lastSavedFile;
 		UndoManager * const undoManager;
+		std::function<void(int)> viewUpdateCallback = [](int i) {};
 
 	private:
 		// A list of all supported formats. This is maintained by plugins
diff --git a/scribus/plugins/fileloader/scribus150format/scribus150format.cpp b/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
index ba7c805c2..0e4ecdbb4 100644
--- a/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
+++ b/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
@@ -44,6 +44,8 @@ for which a new license (GPL+exception) is in place.
 #include "pageitem_spiral.h"
 #include "pagestructs.h"
 
+#include <vector>
+
 #include <QApplication>
 #include <QByteArray>
 #include <QCursor>
@@ -5979,7 +5981,7 @@ bool Scribus150Format::readLatexInfo(PageItem_LatexFrame* latexitem, ScXmlStream
 	return !reader.hasError();
 }
 
-bool Scribus150Format::loadPage(const QString & fileName, QList<int> pageNumbers, bool Mpage, const QString& renamedPageName)
+bool Scribus150Format::loadPage(const QString & fileName, std::vector<int> pageNumbers, bool Mpage, const QString& renamedPageName)
 {
 // 	qDebug() << QString("loading page %2 from file '%1' from 1.3.x plugin").arg(fileName).arg(pageNumber);
 	if (m_Doc==nullptr || m_AvailableFonts==nullptr)
@@ -5997,6 +5999,8 @@ bool Scribus150Format::loadPage(const QString & fileName, QList<int> pageNumbers
 
 	for (const int pageNumber: pageNumbers)
 	{
+		if (viewUpdateCallback)
+			viewUpdateCallback(pageNumber);
 		ParagraphStyle vg;
 		Xp = 0.0;
 		Yp = 0.0;
@@ -6541,7 +6545,7 @@ bool Scribus150Format::loadPage(const QString & fileName, QList<int> pageNumbers
 
 bool Scribus150Format::loadPage(const QString & fileName, int pageNumber, bool Mpage, const QString& renamedPageName)
 {
-	QList<int> pageNumbers = {pageNumber};
+	std::vector<int> pageNumbers = {pageNumber};
 	return loadPage(fileName, pageNumbers, Mpage, renamedPageName);
 }
 
diff --git a/scribus/plugins/fileloader/scribus150format/scribus150format.h b/scribus/plugins/fileloader/scribus150format/scribus150format.h
index 7972d5b8f..4b806fd3e 100644
--- a/scribus/plugins/fileloader/scribus150format/scribus150format.h
+++ b/scribus/plugins/fileloader/scribus150format/scribus150format.h
@@ -56,8 +56,8 @@ class PLUGIN_API Scribus150Format : public LoadSavePlugin
 		virtual void addToMainWindowMenu(ScribusMainWindow *) {};
 
 		// Special features - .sla page extraction support
-		virtual bool loadPage(const QString & fileName, QList<int> pageNumbers, bool Mpage, const QString& renamedPageName=QString());
-		virtual bool loadPage(const QString & fileName, int pageNumber, bool Mpage, const QString& renamedPageName=QString());
+		bool loadPage(const QString & fileName, std::vector<int> pageNumbers, bool Mpage, const QString& renamedPageName=QString()) override;
+		bool loadPage(const QString & fileName, int pageNumber, bool Mpage, const QString& renamedPageName=QString()) override;
 		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);
diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
index 239ede923..9b0406261 100644
--- a/scribus/scribus.cpp
+++ b/scribus/scribus.cpp
@@ -3348,13 +3348,15 @@ bool ScribusMainWindow::slotPageImport()
 			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);
+			auto refresh = [this, &counter](int i) {
+				this->view->GotoPa(counter);
 				counter++;
-				mainWindowProgressBar->setValue(i + 1);
-			}
+				this->mainWindowProgressBar->setValue(i + 1);
+				qDebug() << i;
+			};
+
+			loadPage(dia->getFromDoc(), pageNs, false, refresh);
+
 			view->GotoPa(startPage);
 			mainWindowProgressBar->reset();
 			m_mainWindowStatusLabel->setText( tr("Import done"));
@@ -3375,52 +3377,58 @@ bool ScribusMainWindow::slotPageImport()
 
 bool ScribusMainWindow::loadPage(const QString& fileName, int Nr, bool Mpa, const QString& renamedPageName)
 {
-	bool ret = false;
-	if (!fileName.isEmpty())
+	return loadPage(fileName, {Nr}, Mpa, [](int i){}, renamedPageName);
+}
+
+bool ScribusMainWindow::loadPage(const QString& fileName, std::vector<int> pageNumbers, bool Mpa, std::function<void(int)> updateView, const QString& renamedPageName)
+{
+	if (fileName.isEmpty())
+		return false;
+
+	FileLoader *fl = new FileLoader(fileName);
+	if (fl->testFile() == -1)
+	{
+		delete fl;
+		return false;
+	}
+	doc->setLoading(true);
+	int oldItemsCount = doc->Items->count();
+
+	if (!fl->loadPage(doc, pageNumbers, Mpa, updateView, renamedPageName))
 	{
-		FileLoader *fl = new FileLoader(fileName);
-		if (fl->testFile() == -1)
-		{
-			delete fl;
-			return false;
-		}
-		doc->setLoading(true);
-		int oldItemsCount = doc->Items->count();
-		if (!fl->loadPage(doc, Nr, Mpa, renamedPageName))
-		{
-			delete fl;
-			doc->setLoading(false);
-			return false;
-		}
 		delete fl;
-		if (ScCore->haveCMS() && doc->cmsSettings().CMSinUse)
-		{
-			recalcColors();
-			doc->RecalcPictures(&ScCore->InputProfiles, &ScCore->InputProfilesCMYK);
-		}
-		int docItemsCount=doc->Items->count();
-		for (int i = oldItemsCount; i < docItemsCount; ++i)
-		{
-			PageItem *ite = doc->Items->at(i);
-			if ((ite->asTextFrame()) && (ite->isBookmark))
-				AddBookMark(ite);
-		}
-		propertiesPalette->updateColorList();
-		contentPalette->updateColorList();
-		emit UpdateRequest(reqArrowStylesUpdate | reqLineStylesUpdate | reqStyleComboDocUpdate | reqInlinePalUpdate);
-		symbolPalette->updateSymbolList();
-		slotDocCh();
-		rebuildLayersList();
-		updateLayerMenu();
-		layerPalette->rebuildList();
 		doc->setLoading(false);
-		ret = true;
+		return false;
+	}
+	delete fl;
+	if (ScCore->haveCMS() && doc->cmsSettings().CMSinUse)
+	{
+		recalcColors();
+		doc->RecalcPictures(&ScCore->InputProfiles, &ScCore->InputProfilesCMYK);
+	}
+	int docItemsCount=doc->Items->count();
+	for (int i = oldItemsCount; i < docItemsCount; ++i)
+	{
+		PageItem *ite = doc->Items->at(i);
+		if ((ite->asTextFrame()) && (ite->isBookmark))
+			AddBookMark(ite);
 	}
+	propertiesPalette->updateColorList();
+	contentPalette->updateColorList();
+	emit UpdateRequest(reqArrowStylesUpdate | reqLineStylesUpdate | reqStyleComboDocUpdate | reqInlinePalUpdate);
+	symbolPalette->updateSymbolList();
+	slotDocCh();
+	rebuildLayersList();
+	updateLayerMenu();
+	layerPalette->rebuildList();
+	doc->setLoading(false);
+
 	if (!Mpa)
 		pagePalette->Rebuild();
 	view->reformPages();
 	view->DrawNew();
-	return ret;
+
+	return true;
 }
 
 bool ScribusMainWindow::loadDoc(const QString& fileName)
diff --git a/scribus/scribus.h b/scribus/scribus.h
index 6c2015229..96ddd74ed 100644
--- a/scribus/scribus.h
+++ b/scribus/scribus.h
@@ -54,6 +54,8 @@ class QMdiSubWindow;
 class QQuickView;
 
 // application specific includes
+#include <functional>
+
 #include "scribusapi.h"
 #include "scribusdoc.h"
 #include "styleoptions.h"
@@ -321,6 +323,7 @@ public slots:
 	void newFileFromTemplate();
 	bool slotPageImport();
 	bool loadPage(const QString& fileName, int Nr, bool Mpa, const QString& renamedPageName=QString());
+	bool loadPage(const QString& fileName, std::vector<int> pageNumbers, bool Mpa, std::function<void(int)> updateView, const QString& renamedPageName=QString());
 	void GotoLa(int l);
 	void slotGetContent();
 	void slotGetContent2(); // kk2006

ale

2020-08-22 15:42

manager   ~0047987

any review?

people are complaining about the behavior in the internets...

cbradney

2020-08-31 21:05

administrator   ~0048001

I did a quick review.. best if @jghali takes a look now.

AndreasDavour

2020-09-02 13:26

reporter   ~0048020

I opened a issue for importing breaking linked text frames, and it was closed as a duplicate of this one. If there are patched releases built, I'm happy to test my process with them as this is a major blocker for me.

ale

2024-02-06 11:51

manager   ~0050968

https://forums.scribus.net/index.php/topic,4881.msg22594.html

ale

2024-03-17 07:31

manager   ~0051048

Last edited: 2024-03-17 07:52

<strike>stupid</strike> people in the internet keep complaining...

https://forums.scribus.net/index.php/topic,5002.msg23009.html#msg23009

Issue History

Date Modified Username Field Change
2009-05-18 00:34 renm New Issue
2010-01-23 19:08 jghali Relationship added has duplicate 0008740
2010-02-07 00:52 christoph_s Relationship added has duplicate 0008778
2011-10-12 22:24 jghali Relationship added has duplicate 0010316
2011-10-13 10:34 JLuc Note Added: 0027015
2012-06-15 13:15 jghali Relationship added has duplicate 0010753
2012-10-09 18:27 jghali Relationship added has duplicate 0011110
2012-11-06 13:31 jghali Relationship added has duplicate 0011155
2013-01-27 16:56 JLuc Note Added: 0029770
2014-02-09 14:45 JLuc Tag Attached: easyhack
2014-02-09 14:47 JLuc Note Added: 0031294
2014-02-09 21:18 JLuc Note Edited: 0031294
2014-02-09 21:19 JLuc Note Edited: 0031294
2014-02-23 11:24 JLuc Tag Detached: easyhack
2014-02-23 11:26 JLuc Note Edited: 0031294
2014-02-23 11:36 JLuc Note Edited: 0031294
2014-02-23 11:36 JLuc Note Edited: 0031294
2014-02-23 12:44 JLuc Note Edited: 0031294
2014-02-23 13:00 JLuc File Added: page with linked frames import.sla
2014-02-23 13:04 JLuc Note Added: 0031375
2014-02-23 13:04 JLuc Note Edited: 0031375
2014-02-23 13:17 JLuc File Deleted: page with linked frames import.sla
2014-02-23 13:18 JLuc File Added: 2page with linked frames to import.sla
2014-02-23 13:19 JLuc Note Edited: 0027015
2014-02-25 01:17 JLuc File Added: jl_unknownlinks.diff
2014-02-25 01:18 JLuc Note Added: 0031380
2014-02-25 11:32 JLuc Note Added: 0031382
2014-02-25 11:32 JLuc File Deleted: jl_unknownlinks.diff
2014-02-25 11:33 JLuc File Added: jl_importlinks_2.diff
2014-02-25 11:35 JLuc Note Edited: 0031382
2014-02-25 11:45 JLuc Note Edited: 0031382
2014-02-26 08:56 JLuc Note Added: 0031404
2014-03-06 10:34 JLuc Note Edited: 0031404
2014-03-08 21:49 jghali Relationship added has duplicate 0012128
2014-06-28 14:43 FirasH Note Added: 0032355
2014-06-28 14:43 FirasH Status new => confirmed
2014-07-20 23:27 Kunda Relationship added related to 0012018
2014-07-20 23:30 Kunda Summary Import pages with linked text frames will break the link that acrosses the pages => [PATCH] Import pages with linked text frames will break the link that acrosses the pages
2014-07-21 19:49 JLuc Note Added: 0032891
2014-07-22 11:31 Kunda Summary [PATCH] Import pages with linked text frames will break the link that acrosses the pages => [PATCH] Import pages with linked text frames will break the link that across pages
2014-07-22 11:31 Kunda Description Updated
2014-08-21 11:50 Kunda Relationship added related to 0011240
2014-09-02 13:04 Kunda Note Added: 0033457
2014-09-02 15:31 JLuc Note Added: 0033460
2014-09-02 16:55 JLuc Note Edited: 0033460
2014-09-02 16:55 JLuc Note Edited: 0033460
2014-09-04 23:23 Kunda Note Added: 0033503
2014-09-04 23:23 Kunda Summary [PATCH] Import pages with linked text frames will break the link that across pages => [PATCH] Import pages with linked text frames will break the link across pages
2014-09-04 23:24 Kunda Note Edited: 0033503
2014-10-11 16:05 JLuc Note Edited: 0033460
2014-10-11 16:06 JLuc Note Added: 0033976
2014-10-11 16:56 JLuc Relationship added has duplicate 0012764
2014-10-12 07:47 JLuc Note Edited: 0033976
2014-10-24 22:57 Kunda Patch => Yes
2015-04-07 20:53 jghali Relationship added has duplicate 0012981
2015-04-08 19:37 Kunda Target Version => 1.5.1
2015-05-29 17:25 jghali Relationship added has duplicate 0013099
2015-05-30 07:54 JLuc Note Added: 0035289
2015-07-06 21:20 jghali Relationship added has duplicate 0013208
2016-01-23 17:17 cbradney Target Version 1.5.1 => 1.5.3
2016-12-08 22:04 Kunda Target Version 1.5.3 => 1.5.4
2019-11-13 08:44 ale Relationship added related to 0008602
2019-11-13 08:48 ale Assigned To => ale
2019-11-13 08:48 ale Status confirmed => assigned
2019-11-13 08:48 ale Build C-C-T-F-C1.8.6-64bit => C-C-T-F-C1.8.6-64bit
2019-11-13 10:00 JLuc Tag Attached: #rottenpatch
2019-11-13 11:36 JLuc Summary [PATCH] Import pages with linked text frames will break the link across pages => [PATCH] Import pages with linked text frames breaks the links
2019-11-14 20:07 ale Summary [PATCH] Import pages with linked text frames breaks the links => [OLD PATCH] Import pages with linked text frames breaks the links
2019-11-15 10:46 ale Note Added: 0047084
2019-11-15 11:12 JLuc Note Added: 0047085
2019-11-15 12:55 ale Note Added: 0047086
2019-11-15 12:58 ale Note Added: 0047087
2019-11-18 09:41 ale Summary [OLD PATCH] Import pages with linked text frames breaks the links => [WIP PATCH] Import pages with linked text frames breaks the links
2019-11-18 09:45 ale File Added: import-textchain-secondstep.diff
2019-11-18 09:45 ale Note Added: 0047100
2019-11-18 09:46 ale Note Edited: 0047100
2019-11-18 09:47 ale Note Edited: 0047100
2020-08-22 15:42 ale Note Added: 0047987
2020-08-31 21:05 cbradney Note Added: 0048001
2020-09-02 12:25 jghali Relationship added has duplicate 0016228
2020-09-02 13:26 AndreasDavour Note Added: 0048020
2024-02-06 11:51 ale Note Added: 0050968
2024-03-17 07:31 ale Note Added: 0051048
2024-03-17 07:51 ale Note Edited: 0051048
2024-03-17 07:52 ale Note Edited: 0051048