r21314 by fschmid -

scribus-commit scribus-commit at lists.scribus.net
Sun May 15 08:34:05 UTC 2016


Author: fschmid
Date: Sun May 15 08:34:05 2016
New Revision: 21314

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21314
Log:
Fixed Bug #7312: Drag/Drop of ODT to text frame outputs gibberish

Modified:
    trunk/Scribus/scribus/gtgettext.cpp
    trunk/Scribus/scribus/gtgettext.h
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribus.h
    trunk/Scribus/scribus/scribusview.cpp

Modified: trunk/Scribus/scribus/gtgettext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21314&path=/trunk/Scribus/scribus/gtgettext.cpp
==============================================================================
--- trunk/Scribus/scribus/gtgettext.cpp	(original)
+++ trunk/Scribus/scribus/gtgettext.cpp	Sun May 15 08:34:05 2016
@@ -150,6 +150,23 @@
 	// Create the Importer Extension to Plugin data qmap.
 	createMap();
 }  // void gtGetText::loadImporterPlugins()
+
+
+QStringList gtGetText::getSupportedTypes()
+{
+	QStringList result;
+	for (uint i = 0; i < m_importers.size(); ++i)
+	{
+		if (m_importers[i].fileEndings.count() != 0)
+		{
+			for (int j = 0; j < m_importers[i].fileEndings.count(); ++j)
+			{
+				result.append(m_importers[i].fileEndings[j].toLower());
+			}
+		}
+	}
+	return result;
+}
 
 // Creates the dialog for the user to import a file based on the supported file formats.
 ImportSetup gtGetText::run()

Modified: trunk/Scribus/scribus/gtgettext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21314&path=/trunk/Scribus/scribus/gtgettext.h
==============================================================================
--- trunk/Scribus/scribus/gtgettext.h	(original)
+++ trunk/Scribus/scribus/gtgettext.h	Sun May 15 08:34:05 2016
@@ -84,6 +84,7 @@
 public:
 	gtGetText(ScribusDoc* doc);					// Constructor
 	~gtGetText();								// Destructor
+	QStringList getSupportedTypes();			// get all Fileextensions we support
 	ImportSetup run();							// Creates the dialog for the user to import a file based on the supported file formats.
 	void launchImporter(int importer, const QString& filename, bool textOnly, const QString& encoding, bool append, bool prefix, PageItem* target=0);
 												// Look at the results of the file selection dialog and figure out if you need to use an importer.

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21314&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Sun May 15 08:34:05 2016
@@ -3931,6 +3931,20 @@
 	}
 }
 
+void ScribusMainWindow::updateFromDrop()
+{
+	m_styleManager->setDoc(doc);
+	marksManager->setDoc(doc);
+	nsEditor->setDoc(doc);
+	inlinePalette->unsetDoc();
+	inlinePalette->setDoc(doc);
+	if (outlinePalette->isVisible())
+		outlinePalette->BuildTree();
+	propertiesPalette->updateColorList();
+	emit UpdateRequest(reqArrowStylesUpdate | reqLineStylesUpdate | reqStyleComboDocUpdate | reqInlinePalUpdate);
+	symbolPalette->updateSymbolList();
+}
+
 void ScribusMainWindow::slotGetContent2() // kk2006
 {
 	if (doc->m_Selection->isEmpty())

Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21314&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h	(original)
+++ trunk/Scribus/scribus/scribus.h	Sun May 15 08:34:05 2016
@@ -190,6 +190,7 @@
 	void restoreAddPage(SimpleState *state, bool isUndo);
 	void restoreDeletePage(SimpleState *state, bool isUndo);
 	void setPreviewToolbar();
+	void updateFromDrop();
 	struct CopyContentsBuffer contentsBuffer;
 	bool internalCopy;
 	QString internalCopyBuffer;

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21314&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp	(original)
+++ trunk/Scribus/scribus/scribusview.cpp	Sun May 15 08:34:05 2016
@@ -1024,21 +1024,51 @@
 		{
 			if ((fi.exists()) && (!img))
 			{
-				QByteArray file;
-				QTextCodec *codec = QTextCodec::codecForLocale();
-				// TODO create a Dialog for selecting the codec
-				if (loadRawText(url.toLocalFile(), file))
+				gtGetText* gt = new gtGetText(Doc);
+				QStringList exts = gt->getSupportedTypes();
+				if (exts.contains(fi.suffix().toLower()))
 				{
-					QString txt = codec->toUnicode( file.data() );
-					txt.replace(QRegExp("\r"), QChar(13));
-					txt.replace(QRegExp("\n"), QChar(13));
-					txt.replace(QRegExp("\t"), QChar(9));
-					b->itemText.insertChars(txt, true);
-					if (Doc->docHyphenator->AutoCheck)
-						Doc->docHyphenator->slotHyphenate(b);
-					b->invalidateLayout();
-					b->update();
+					ImportSetup impsetup;
+					impsetup.runDialog = true;
+					impsetup.encoding = "";
+					impsetup.prefixNames = true;
+					impsetup.textOnly = false;
+					impsetup.importer = -1;
+					impsetup.filename = url.toLocalFile();
+					if (b->itemText.length() != 0)
+					{
+						int t = ScMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your text?"),
+									QMessageBox::Yes | QMessageBox::No,
+									QMessageBox::No,	// GUI default
+									QMessageBox::Yes);	// batch default
+						if (t == QMessageBox::No)
+						{
+							delete gt;
+							return;
+						}
+					}
+					gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, false, impsetup.prefixNames, b);
+					m_ScMW->updateFromDrop();
 				}
+				else
+				{
+					QByteArray file;
+					QTextCodec *codec = QTextCodec::codecForLocale();
+					// TODO create a Dialog for selecting the codec
+					if (loadRawText(url.toLocalFile(), file))
+					{
+						QString txt = codec->toUnicode( file.data() );
+						txt.replace(QRegExp("\r"), QChar(13));
+						txt.replace(QRegExp("\n"), QChar(13));
+						txt.replace(QRegExp("\t"), QChar(9));
+						b->itemText.insertChars(txt, true);
+					}
+				}
+				if (Doc->docHyphenator->AutoCheck)
+					Doc->docHyphenator->slotHyphenate(b);
+				b->invalidateLayout();
+				b->update();
+				delete gt;
 			}
 		}
 		emit DocChanged();




More information about the scribus-commit mailing list