r15239 by jghali - #9190: copying page fails to copy tab settings for text frame

scribus-commit scribus-commit at lists.scribus.net
Sun Jun 20 03:10:44 CEST 2010


Revision: 15239
Author: jghali
Date: 2010-06-20T01:06:04.340000Z
Commit message: #9190: copying page fails to copy tab settings for text frame

Changeset: 
M  /trunk/Scribus/scribus/scribusdoc.cpp

Diffs:
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 15238)
+++ scribus/scribusdoc.cpp	(revision 15239)
@@ -23,6 +23,7 @@
 
 #include <memory>
 #include <utility>
+#include <sstream>
 
 #include <QByteArray>
  #include <QDebug>
@@ -37,12 +38,12 @@
 #include "canvas.h"
 #include "colorblind.h"
 #include "commonstrings.h"
+#include "desaxe/digester.h"
+#include "desaxe/saxXML.h"
 #include "fileloader.h"
 #include "filewatcher.h"
 #include "ui/guidemanager.h"
-#include "ui/hruler.h"
 #include "hyphenator.h"
-#include "ui/layers.h"
 #include "page.h"
 #include "pageitem.h"
 #include "pageitem_imageframe.h"
@@ -77,6 +78,8 @@
 #include "scribuswin.h"
 #include "selection.h"
 #include "serializer.h"
+#include "ui/hruler.h"
+#include "ui/layers.h"
 #include "ui/storyeditor.h"
 #include "text/nlsconfig.h"
 #include "undomanager.h"
@@ -5547,7 +5550,7 @@
 	Page* lastDest = NULL;
 
 	uint oldItems = Items->count();
-	QStringList itemBuffer;
+	QList<QByteArray> itemBuffer;
 	m_Selection->clear();
 	m_Selection->delaySignalsOn();
 	if (oldItems>0)
@@ -5567,14 +5570,16 @@
 				}
 				if (m_Selection->count() != 0)
 				{
-					ScriXmlDoc *ss = new ScriXmlDoc();
-					itemBuffer.append(ss->WriteElem(this, m_Selection));
+					std::ostringstream xmlString;
+					SaxXML xmlStream(xmlString);
+					Serializer::serializeObjects(*m_Selection, xmlStream);
+					std::string xml(xmlString.str());
+					itemBuffer.append( QByteArray(xml.c_str(), xml.size()) );
 					m_Selection->clear();
-					delete ss;
 				}
 				else
 				{
-					itemBuffer.append(QString());
+					itemBuffer.append(QByteArray());
 				}
 			}
 			setActiveLayer(currActiveLayer);
@@ -5641,16 +5646,27 @@
 			if (Layers.count()!= 0)
 			{
 				int currActiveLayer = activeLayer();
+				bool savedAlignGrid   = this->useRaster;
+				bool savedAlignGuides = this->SnapGuides;
+				this->useRaster  = false;
+				this->SnapGuides = false;
 				for (it = Layers.begin(); it != Layers.end(); ++it)
 				{
 					if ((lcount < itemBuffer.count()) && !itemBuffer[lcount].isEmpty())
 					{
-						ScriXmlDoc *ss = new ScriXmlDoc();
-						ss->ReadElemToLayer(itemBuffer[lcount], appPrefsData.fontPrefs.AvailFonts, this, destination->xOffset(), destination->yOffset(), false, true, appPrefsData.fontPrefs.GFontSub,(*it).ID);
-						delete ss;
+						QByteArray fragment = itemBuffer[lcount];
+						Selection pastedObjects = Serializer(*this).deserializeObjects(fragment);
+						for (int i=0; i < pastedObjects.count(); ++i)
+							pastedObjects.itemAt(i)->LayerID = it->ID;
+						// We do not need moveGroup undo actions
+						UndoManager::instance()->setUndoEnabled(false);
+						moveGroup(destination->xOffset() - from->xOffset(), destination->yOffset() - from->yOffset(), false, &pastedObjects);
+						UndoManager::instance()->setUndoEnabled(true);
 					}
 					lcount++;
 				}
+				this->useRaster  = savedAlignGrid;
+				this->SnapGuides = savedAlignGuides;
 				setActiveLayer(currActiveLayer);
 			}
 		}




More information about the scribus-commit mailing list