r14473 by fschmid - Added Jain Basil Aliyas IDML importer.

scribus-commit scribus-commit at lists.scribus.net
Tue Jan 5 22:20:27 CET 2010


Revision: 14473
Author: fschmid
Date: 2010-01-05T08:22:29.789792Z
Commit message: Added Jain Basil Aliyas IDML importer.

Changeset: 
M  /trunk/Scribus/scribus/util_formats.cpp
A  /trunk/Scribus/scribus/plugins/import/idml/docpreference.h
A  /trunk/Scribus/scribus/plugins/import/idml/CMakeLists.txt
M  /trunk/Scribus/scribus/util_formats.h
A  /trunk/Scribus/scribus/plugins/import/idml
A  /trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
A  /trunk/Scribus/scribus/plugins/import/idml/importidmlimpl.cpp
A  /trunk/Scribus/scribus/plugins/import/idml/docpreference.cpp
A  /trunk/Scribus/scribus/plugins/import/idml/importidml.h
M  /trunk/Scribus/scribus/plugins/formatidlist.h
M  /trunk/Scribus/scribus/plugins/import/CMakeLists.txt
A  /trunk/Scribus/scribus/plugins/import/idml/importidmlimpl.h

Diffs:
Index: scribus/util_formats.cpp
===================================================================
--- scribus/util_formats.cpp	(revision 14472)
+++ scribus/util_formats.cpp	(revision 14473)
@@ -39,7 +39,7 @@
 	m_fmts.insert(FormatsManager::PCT,  QStringList() << "pct" << "pic" << "pict");
 	m_fmts.insert(FormatsManager::XAR,  QStringList() << "xar");
 	m_fmts.insert(FormatsManager::CGM,  QStringList() << "cgm");
-	m_fmts.insert(FormatsManager::ODT,  QStringList() << "odt");
+	m_fmts.insert(FormatsManager::IDML, QStringList() << "idml");
 	
 	m_fmtNames[FormatsManager::EPS]  = QObject::tr("Encapsulated PostScript \"*.eps\"");
 	m_fmtNames[FormatsManager::GIF]  = QObject::tr("GIF");
@@ -64,7 +64,7 @@
 	m_fmtNames[FormatsManager::PCT]  = QObject::tr("Macinthosh Pict File");
 	m_fmtNames[FormatsManager::XAR]  = QObject::tr("XARA \"*.xar\" File");
 	m_fmtNames[FormatsManager::CGM]  = QObject::tr("CGM File");
-	m_fmtNames[FormatsManager::ODT]  = QObject::tr("ODT File");
+	m_fmtNames[FormatsManager::IDML]  = QObject::tr("IDML File");
 	
 	m_fmtMimeTypes.insert(FormatsManager::EPS,  QStringList() << "application/postscript");
 	m_fmtMimeTypes.insert(FormatsManager::GIF,  QStringList() << "image/gif");
@@ -85,7 +85,7 @@
 	m_fmtMimeTypes.insert(FormatsManager::PCT,  QStringList() << "");
 	m_fmtMimeTypes.insert(FormatsManager::XAR,  QStringList() << "");
 	m_fmtMimeTypes.insert(FormatsManager::CGM,  QStringList() << "");
-	m_fmtMimeTypes.insert(FormatsManager::ODT,  QStringList() << "");
+	m_fmtMimeTypes.insert(FormatsManager::IDML, QStringList() << "");
 			
 	QMapIterator<int, QStringList> i(m_fmts);
 	while (i.hasNext()) 
Index: scribus/util_formats.h
===================================================================
--- scribus/util_formats.h	(revision 14472)
+++ scribus/util_formats.h	(revision 14473)
@@ -68,7 +68,7 @@
 			PCT				= 262144,  // Mac Pict
 			XAR				= 524288,  // Xara
 			CGM				= 1048576, // CGM
-			ODT				= 2097152 // ODT
+			IDML			= 2097152 // IDML
 		};
 	
 /*
Index: scribus/plugins/formatidlist.h
===================================================================
--- scribus/plugins/formatidlist.h	(revision 14472)
+++ scribus/plugins/formatidlist.h	(revision 14473)
@@ -30,7 +30,7 @@
 #define FORMATID_PDFIMPORT 112
 #define FORMATID_XARIMPORT 113
 #define FORMATID_CGMIMPORT 114
-#define FORMATID_ODTIMPORT 115
+#define FORMATID_IDMLIMPORT 115
 
 // EXPORT
 
Index: scribus/plugins/import/idml/importidml.cpp
===================================================================
--- scribus/plugins/import/idml/importidml.cpp	(revision 0)
+++ scribus/plugins/import/idml/importidml.cpp	(revision 14473)
@@ -0,0 +1,142 @@
+/*
+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.
+*/
+#include "importidml.h"
+#include "importidmlimpl.h"
+
+#include "../../formatidlist.h"
+#include "commonstrings.h"
+#include "ui/missing.h"
+#include "hyphenator.h"
+#include "pageitem_latexframe.h"
+#include "prefsfile.h"
+#include "prefsmanager.h"
+#include "prefscontext.h"
+#include "scclocale.h"
+#include "scconfig.h"
+#include "sccolorengine.h"
+#include "scpattern.h"
+#include "scribuscore.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "sctextstream.h"
+#include "scxmlstreamreader.h"
+#include "undomanager.h"
+#include "units.h"
+#include "util.h"
+#include "util_math.h"
+#include "util_color.h"
+
+
+
+ImportIdml::ImportIdml() : LoadSavePlugin()
+{
+	// Set action info in languageChange, so we only have to do
+	// it in one place.
+	languageChange();
+}
+
+ImportIdml::~ImportIdml() 
+{
+	unregisterAll();
+};
+
+void ImportIdml::languageChange()
+{
+	unregisterAll();
+	registerFormats();
+}
+
+const QString ImportIdml::fullTrName() const
+{
+	return QObject::tr("Adobe IDML Importer");
+}
+
+const ScActionPlugin::AboutData* ImportIdml::getAboutData() const
+{
+	AboutData* about = new AboutData;
+	about->authors = "Jain Basil Aliyas<jainbasil at gmail.com>";
+	about->shortDescription = tr("Imports Adobe Idml Packages");
+	about->description = tr("Imports Adobe Indesign's idml packages into Scribus\n converting Indesign objects into scribus pageitems; not all are supported in Scribus, but all those supported are being imported here");
+	about->license = tr("GPL");
+	Q_CHECK_PTR(about);
+	return about;
+}
+
+void ImportIdml::deleteAboutData(const AboutData* about) const
+{
+	Q_ASSERT(about);
+	delete about;
+}
+
+void ImportIdml::registerFormats()
+{
+	FileFormat fmt(this);
+        QString idmlName=tr("Adobe Indesign IDML");
+	fmt.trName = idmlName;
+	fmt.formatId = FORMATID_IDMLIMPORT;
+	fmt.filter =idmlName + "(*.idml *.IDML)"; // QFileDialog filter
+        fmt.nameMatch = QRegExp("\\.(idml|IDML)?", Qt::CaseInsensitive);
+	fmt.load = true;
+	fmt.save = false;
+        fmt.mimeTypes = QStringList();
+        fmt.mimeTypes.append("application/vnd.adobe.indesign-idml-package");
+        fmt.priority = 64; // Priority
+	registerFormat(fmt);
+}
+
+bool ImportIdml::run(ScribusDoc* doc, QString target)
+{
+	if(target.isEmpty())
+	{
+		PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("importidml");
+		QString wdir = prefs->get("wdir", ".");
+		CustomFDialog diaf(ScCore->primaryMainWindow(), wdir, QObject::tr("Open"), tr("All Supported Formats")+" (*.idml *.IDML);;All Files (*)");
+		if(diaf.exec())
+		{
+			target = diaf.selectedFile();
+			prefs->set("wdir", target.left(target.lastIndexOf("/")));
+		}
+		else
+			return true;
+	}
+	m_Doc=ScCore->primaryMainWindow()->doc;
+	ImportIdmlImpl *myPluginImpl = new ImportIdmlImpl();
+	Q_CHECK_PTR(myPluginImpl);
+	bool result = myPluginImpl->run(target, m_Doc);
+	delete myPluginImpl;
+	return result;
+}
+
+bool ImportIdml::fileSupported(QIODevice* /* file */, const QString & fileName) const
+{
+	return true;
+}
+
+bool ImportIdml::loadFile(const QString & fileName, const FileFormat & /* fmt */, int  flags, int /* index */)
+{
+	return run(m_Doc,fileName);
+}
+
+// Low level plugin API
+int importidml_getPluginAPIVersion()
+{
+	return PLUGIN_API_VERSION;
+}
+
+ScPlugin* importidml_getPlugin()
+{
+	ImportIdml* plug = new ImportIdml();
+	Q_CHECK_PTR(plug);
+	return plug;
+}
+
+void importidml_freePlugin(ScPlugin* plugin)
+{
+	ImportIdml* plug = dynamic_cast<ImportIdml*>(plugin);
+	Q_ASSERT(plug);
+	delete plug;
+}
Index: scribus/plugins/import/idml/importidmlimpl.cpp
===================================================================
--- scribus/plugins/import/idml/importidmlimpl.cpp	(revision 0)
+++ scribus/plugins/import/idml/importidmlimpl.cpp	(revision 14473)
@@ -0,0 +1,915 @@
+/*
+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.
+*/
+#include "importidmlimpl.h"
+
+#include <QByteArray>
+#include <QCursor>
+#include <QDrag>
+#include <QFile>
+#include <QMimeData>
+#include <QRegExp>
+#include <QTextCodec>
+#include <QDebug>
+#include <QMessageBox>
+#include <QString>
+#include <QMessageBox>
+#include <QPointF>
+
+#include "commonstrings.h"
+#include "docpreference.h"
+#include "ui/customfdialog.h"
+#include "fileunzip.h"
+#include "importidml.h"
+#include "loadsaveplugin.h"
+#include "ui/missing.h"
+#include "ui/multiprogressdialog.h"
+#include "pageitem_imageframe.h"
+#include "pageitem_polygon.h"
+#include "pageitem_polyline.h"
+#include "pagesize.h"
+#include "prefscontext.h"
+#include "prefsfile.h"
+#include "prefsmanager.h"
+#include "prefstable.h"
+#include "ui/propertiespalette.h"
+#include "rawimage.h"
+#include "scclocale.h"
+#include "sccolorengine.h"
+#include "scconfig.h"
+#include "scmimedata.h"
+#include "scpaths.h"
+#include "scpattern.h"
+#include "scribusdoc.h"
+#include "scribus.h"
+#include "scribusXml.h"
+#include "scribuscore.h"
+#include "sctextstream.h"
+#include "selection.h"
+#include "textwriter.h"
+#include "undomanager.h"
+#include "util.h"
+#include "util_formats.h"
+#include "util_icon.h"
+#include "util_math.h"
+
+
+// Initialize members here, if any
+ImportIdmlImpl::ImportIdmlImpl() : QObject(0)
+{
+}
+
+bool ImportIdmlImpl::run(const QString & target, ScribusDoc* doc)
+{
+	 //Do the bulk of your work here
+	m_Doc=doc;
+	QString fnameIn = target;
+//	bool success = false;
+	bool showProgress;
+	//cancel = false;
+	double x,y,b,h;
+//	bool ret = false;
+	QFileInfo fi = QFileInfo(fnameIn);
+	baseFile = QDir::cleanPath(QDir::toNativeSeparators(fi.absolutePath()+"/"));
+	if(!ScCore->usingGUI())
+		showProgress=false;
+	/* Implement Progress Dialog Later */
+	
+	x = 0.0;
+	y = 0.0;
+	b = 0.0;
+	h = 0.0;
+	
+	/**
+	Here, first we parse the idml document, in the order designmap.xml,preferences.xml, fonts.xml, styles.xml, gradiant.xml, all the stories will be transformed into Story Objects, and finally all the master spreads and spreads.
+	We set the document page width, height etc from preferences.xml, styles are defined and added into the list.
+	
+	QMap are maintained with QString, Object for each item which is referred later in the document using the self attribute. This includes all styles, stories etc.
+	*/
+        FileUnzip* idmlFile = new FileUnzip(target);
+        desmapPath = idmlFile->getFile("designmap.xml");
+        fontPath = idmlFile->getFile("Resources/Fonts.xml");
+        stylePath = idmlFile->getFile("Resources/Styles.xml");
+        graphicPath = idmlFile->getFile("Resources/Graphic.xml");
+        preferPath = idmlFile->getFile("Resources/Preferences.xml");
+	if(!preferPath.isEmpty())
+	{
+		root=loadXmlFile(preferPath);
+		bool success = preference.processFile(root);
+		root.clear();
+		if(!success)
+			return false;
+	}
+	docWidth = preference.preference.PageWidth.toDouble();
+	docHeight = preference.preference.PageHeight.toDouble();
+	double leftMargin = preference.marginPreference.left.toDouble();
+	double rightMargin = preference.marginPreference.right.toDouble();
+	double topMargin = preference.marginPreference.top.toDouble();
+	double bottomMargin = preference.marginPreference.bottom.toDouble();
+	m_Doc=ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, topMargin, leftMargin, rightMargin, bottomMargin, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
+	Elements.clear();
+	m_Doc->GroupCounter = 1;
+	m_Doc->LastAuto = 0;
+	m_Doc->PageColors.clear();
+	m_Doc->Layers.clear();
+	layerMap.clear();
+	layerID = -1;
+
+	if(!desmapPath.isNull())
+        {
+		bool success = processDesignMap();
+		for( int i=0;i<storyList.count();i++ )
+			storyPath.append(idmlFile->getFile(storyList.at(i)));
+		for( int i=0;i<Spreads.count();i++ )
+			spreadPath.append(idmlFile->getFile(Spreads.at(i)));
+		for( int i=0;i<MasterSpreads.count();i++ )
+			mspreadPath.append(idmlFile->getFile(MasterSpreads.at(i)));
+            if(!success)
+                return false;
+        }
+        if(!fontPath.isNull())
+        {
+            bool success = processFont();
+	    root.clear();
+            if(!success)
+                return false;
+        }
+        if(!stylePath.isEmpty())
+	{
+		bool success = processStyles();
+		root.clear();
+		if(!success)
+			return false;
+	}
+	if(!storyPath.isEmpty())
+	{
+		bool success = processStory();
+		root.clear();
+		if(!success)
+			return false;
+	}
+	if(!spreadPath.isEmpty())
+	{
+		bool success = processSpreads();
+		root.clear();
+		if(!success)
+			return false;
+	}
+	return true;
+}
+
+// Function for loading xml file for parsing
+
+QDomElement ImportIdmlImpl::loadXmlFile(QString &filename)
+{
+        QFile file(filename);
+	qDebug()<<"File Name = "<<filename;
+	QDomDocument docu;
+	QDomElement rootElement;
+        file.open(QIODevice::ReadOnly | QIODevice::Text);
+        docu.setContent(&file);
+        rootElement = docu.documentElement();
+	qDebug()<<"root tag = "<<rootElement.tagName();
+        file.close();
+	return rootElement;
+}
+
+bool ImportIdmlImpl::processDesignMap()
+{
+	QDomElement designmapRoot=loadXmlFile(desmapPath);
+        if(designmapRoot.tagName() != "Document")
+              return false;
+        else
+        {
+                /*get the attributes of Document Tag before going into its children */
+                //docAttributes(designmapRoot);
+                node = designmapRoot.firstChild();
+                while(!node.isNull())
+                {
+                        element = node.toElement();
+                        if(!element.isNull())
+                        {
+                                if(element.tagName()=="Layer")
+                                {
+                                        ScLayer newLayer;
+                                        handleLayer(newLayer,element);
+                                        m_Doc->Layers.append(newLayer);
+                                }
+				if(element.tagName()=="Section")
+				{
+					handleSection(m_Doc,element);
+				}
+                                if(element.tagName()=="idPkg:Spread")
+                                        getSpreadSrc(element);
+                                if(element.tagName()=="idPkg:MasterSpread")
+                                        getMSpreadSrc(element);
+                                if(element.tagName()=="idPkg:Story")
+                                        getStorySrc(element);
+                        }
+                        node = node.nextSibling();
+              }
+              return true;
+        }
+}
+
+void docAttributes(QDomElement& element)
+{
+}
+
+/* Function to handle the layers */
+
+void ImportIdmlImpl::handleLayer(ScLayer& layer,QDomElement& element)
+{
+	QString self = element.attribute("Self","");
+        layer.Name=element.attribute("Name","");
+        layer.isEditable=(element.attribute("Locked","")=="true")?true:false;
+        layer.isPrintable=(element.attribute("Printable","")=="true")?true:false;
+        layer.flowControl=(element.attribute("IgnoreWrap","")=="true")?true:false;
+        layer.isViewable=(element.attribute("Visible","")=="true")?true:false;
+        layer.outlineMode=(element.attribute("ShowGuides","")=="true")?true:false;
+        layer.ID = layerID + 1;
+        //descending down to properties of layer
+        QDomNode n = node.firstChild().firstChild();
+        QDomElement lcolor = n.toElement();
+        layer.markerColor=lcolor.text();
+        layerMap.insert(self,layer.ID);
+}
+
+void ImportIdmlImpl::handleSection(ScribusDoc* doc, QDomElement& element)
+{
+}
+
+void ImportIdmlImpl::getMSpreadSrc(QDomElement& element)
+{
+        MasterSpreads.append(element.attribute("src",""));
+}
+
+void ImportIdmlImpl::getSpreadSrc(QDomElement& element)
+{
+        Spreads.append(element.attribute("src",""));
+}
+
+void ImportIdmlImpl::getStorySrc(QDomElement& element)
+{
+        storyList.append(element.attribute("src",""));
+}
+
+bool ImportIdmlImpl::processFont()
+{
+        return true;
+}
+
+bool ImportIdmlImpl::processStyles()
+{
+        QDomElement stylesRoot=loadXmlFile(stylePath);
+        if(stylesRoot.tagName() != "idPkg:Styles")
+              return false;
+        else
+        {
+                node=stylesRoot.firstChild();
+                while(!node.isNull())
+                {
+                        element=node.toElement();
+                        if(!element.isNull())
+                        {
+                                if(element.tagName()=="RootParagraphStyleGroup")
+                                        if(!importPStyles(node))
+                                                return false;
+                                if(element.tagName()=="RootCharacterStyleGroup")
+                                        if(!importCStyles(node))
+                                                return false;
+                        }
+                        node=node.nextSibling();
+                }
+        }
+        return true;
+}
+
+bool ImportIdmlImpl::importPStyles(QDomNode &node)
+{
+        node=node.firstChild();
+        while(!node.isNull())
+        {
+                QDomElement elem = node.toElement();
+                if(!elem.isNull())
+                {
+                        if(elem.tagName()=="ParagraphStyle")
+			{
+				readParagraphStyle(m_Doc, node, vg, *m_AvailableFonts);
+				StyleSet<ParagraphStyle>tmp;
+				tmp.create(vg);
+				m_Doc->redefineStyles(tmp, false);
+			}
+			if(elem.tagName()=="ParagraphStyleGroup")
+			{
+				readParagraphStyle(m_Doc,node.firstChild(),vg,*m_AvailableFonts);
+				StyleSet<ParagraphStyle>tmp;
+				tmp.create(vg);
+				m_Doc->redefineStyles(tmp, false);
+			}
+			if(elem.tagName()=="CharacterStyle")
+			{
+				readCharacterStyle(m_Doc, node, cs);
+				StyleSet<CharStyle> temp;
+				temp.create(cs);
+				m_Doc->redefineCharStyles(temp, false);
+			}
+			if(elem.tagName()=="CharacterStyleGroup")
+			{
+				readCharacterStyle(m_Doc, node.firstChild(), cs);
+				StyleSet<CharStyle> temp;
+				temp.create(cs);
+				m_Doc->redefineCharStyles(temp,false);
+			}
+                }
+                node=node.nextSibling();
+        }
+	return true;
+}
+
+void ImportIdmlImpl::readParagraphStyle(ScribusDoc *doc, QDomNode node,  ParagraphStyle &newStyle, SCFonts &fonts)
+{
+    /* Parsing out the attributes of ParagraphStyle those needed to form a paragraph style of Scribus */
+	QDomElement elem=node.toElement();
+	QStringList features;
+	newStyle.erase();
+	newStyle.setName(elem.attribute("Name",""));
+	newStyle.setDefaultStyle(false);
+	newStyle.setLeftMargin(elem.attribute("LeftIndent","").toDouble());
+	newStyle.setRightMargin(elem.attribute("RightMargin","").toDouble());
+	newStyle.setFirstIndent(elem.attribute("FirstLineIndent","").toDouble());
+	//newStyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(elem.attribute("Justification","")));
+	newStyle.setGapBefore(elem.attribute("SpaceBefore","").toDouble());
+	newStyle.setGapAfter(elem.attribute("SpaceAfter","").toDouble());
+	newStyle.setDropCapLines(elem.attribute("DropCapLines","").toInt());
+	newStyle.setMinWordTracking(elem.attribute("MinimumWordSpacing","").toDouble());
+	newStyle.setMinGlyphExtension(elem.attribute("MinimumGlyphScaling","").toDouble());
+	newStyle.setMaxGlyphExtension(elem.attribute("MaximumGlyphScaling","").toDouble());
+
+	newStyle.charStyle().setFontSize((qRound(elem.attribute("PointSize","").toDouble()) * 10));
+	newStyle.charStyle().setWordTracking(elem.attribute("DesiredWordSpacing","").toDouble());
+	newStyle.charStyle().setTracking(elem.attribute("Tracking","").toDouble());
+
+	if(elem.attribute("Underline","")=="true")
+		features.append(CharStyle::UNDERLINE);
+	if(elem.attribute("StrikeThru","")=="true")
+		features.append(CharStyle::STRIKETHROUGH);
+    /*if(elem.attribute("Capitalization","")=="")
+        features.append(CharStyle::ALLCAPS);
+    if(elem.attribute("Capitalization","")=="")
+        features.append(CharStyle::SMALLCAPS);*/
+	newStyle.charStyle().setFeatures(features);
+
+	QString fontStyle = elem.attribute("FontStyle","");
+	newStyle.charStyle().setScaleH(qRound((elem.attribute("HorizontalScale","").toDouble()) * 10));
+	newStyle.charStyle().setScaleV(qRound((elem.attribute("VerticalScale","").toDouble()) * 10));
+	newStyle.charStyle().setBaselineOffset(qRound( (elem.attribute("BaselineShift","").toDouble()) * 10));
+	newStyle.charStyle().setStrokeColor(elem.attribute("StrokeColor",""));
+	newStyle.charStyle().setFillColor(elem.attribute("FillColor",""));
+	newStyle.charStyle().setFillShade((elem.attribute("FillTint","").toDouble()) * 10);
+	newStyle.charStyle().setStrokeShade((elem.attribute("StrokeTint","").toDouble()) * 10);
+	newStyle.charStyle().setUnderlineOffset(qRound((elem.attribute("UnderlineOffset","").toDouble()) * 10));
+	newStyle.charStyle().setUnderlineWidth(qRound((elem.attribute("UnderlineWidth","").toDouble()) * 10));
+	newStyle.charStyle().setStrikethruOffset(qRound((elem.attribute("StrikeThroughOffset","").toDouble())* 10));
+	newStyle.charStyle().setStrikethruWidth(qRound((elem.attribute("StrikeThroughWidth","").toDouble()) * 10));
+	newStyle.charStyle().setLanguage(elem.attribute("AppliedLanguage",""));
+
+	node = node.firstChild();
+	QList<ParagraphStyle::TabRecord> tbs;
+	newStyle.resetTabValues();
+	while(!node.isNull())
+	{
+		QDomElement e = node.toElement();
+		if(!e.isNull())
+		{
+			if(e.tagName()=="BasedOn")
+			newStyle.setParent(e.text());
+			if(e.tagName()=="AppliedFont")
+			{
+				newStyle.charStyle().setFont(m_AvailableFonts->findFont(e.text()+fontStyle, doc));
+			}
+			if(e.tagName()=="TabList")
+			{
+				ParagraphStyle::TabRecord tb;
+				node = node.firstChild();
+				while(!node.isNull())
+				{
+					QDomElement tabElements = node.toElement();
+					if(!tabElements.isNull())
+					{
+						if(tabElements.tagName()=="Position")
+							tb.tabPosition = tabElements.text().toDouble();
+						if(tabElements.tagName()=="AlignmentCharacter")
+						{
+							QString tbCh   = tabElements.text();
+							if(tbCh.contains("$ID/",Qt::CaseSensitive))
+								tbCh = tbCh.split("$ID/",QString::SkipEmptyParts,Qt::CaseSensitive).at(1);
+							tb.tabFillChar = tbCh.isEmpty() ? QChar() : tbCh[0];
+							tbs.append(tb);
+							if (tbs.count() > 0)
+								newStyle.setTabValues(tbs);
+						}/*
+						tb.tabType     = attrs2.valueAsInt("Type") */
+					}
+					node = node.nextSibling();
+				}
+			}
+		}
+		node = node.nextSibling();
+	}
+	fixLegacyParStyle(newStyle);
+}
+
+void ImportIdmlImpl::readCharacterStyle(ScribusDoc *doc, QDomNode node, CharStyle& newStyle)
+{
+	QDomElement elem = node.toElement();
+	QStringList features;
+	
+	newStyle.erase();
+	newStyle.setDefaultStyle(false);
+	newStyle.setName(elem.attribute("Name",""));
+	newStyle.setFontSize((qRound(elem.attribute("PointSize","").toDouble()) * 10));
+	newStyle.setWordTracking(elem.attribute("DesiredWordSpacing","").toDouble());
+	newStyle.setTracking(elem.attribute("Tracking","").toDouble());
+
+	if(elem.attribute("Underline","")=="true")
+		features.append(CharStyle::UNDERLINE);
+	if(elem.attribute("StrikeThru","")=="true")
+		features.append(CharStyle::STRIKETHROUGH);
+    /*if(elem.attribute("Capitalization","")=="")
+        features.append(CharStyle::ALLCAPS);
+    if(elem.attribute("Capitalization","")=="")
+        features.append(CharStyle::SMALLCAPS);*/
+	newStyle.setFeatures(features);
+    
+	QString fontStyle = elem.attribute("FontStyle","");
+	newStyle.setScaleH(qRound((elem.attribute("HorizontalScale","").toDouble()) * 10));
+	newStyle.setScaleV(qRound((elem.attribute("VerticalScale","").toDouble()) * 10));
+	newStyle.setBaselineOffset(qRound( (elem.attribute("BaselineShift","").toDouble()) * 10));
+	newStyle.setStrokeColor(elem.attribute("StrokeColor",""));
+	newStyle.setFillColor(elem.attribute("FillColor",""));
+	newStyle.setFillShade((elem.attribute("FillTint","").toDouble()) * 10);
+	newStyle.setStrokeShade((elem.attribute("StrokeTint","").toDouble()) * 10);
+	newStyle.setUnderlineOffset(qRound((elem.attribute("UnderlineOffset","").toDouble()) * 10));
+	newStyle.setUnderlineWidth(qRound((elem.attribute("UnderlineWidth","").toDouble()) * 10));
+	newStyle.setStrikethruOffset(qRound((elem.attribute("StrikeThroughOffset","").toDouble())* 10));
+	newStyle.setStrikethruWidth(qRound((elem.attribute("StrikeThroughWidth","").toDouble()) * 10));
+	newStyle.setLanguage(elem.attribute("AppliedLanguage",""));
+	
+	node = node.firstChild();
+	while(!node.isNull())
+	{
+		QDomElement e = node.toElement();
+		if(!e.isNull())
+		{
+			if(e.tagName()=="BasedOn")
+				newStyle.setParent(e.text());
+			if(e.tagName()=="AppliedFont")
+				newStyle.setFont(m_AvailableFonts->findFont(e.text()+fontStyle, doc));
+		}
+		node=node.nextSibling();
+	}
+	fixLegacyCStyle(newStyle);
+}
+
+/*!
+This is a function taken from fileloader of Scribus 150 fileformat. Please check out the file for necessary details
+*/
+
+void ImportIdmlImpl::fixLegacyParStyle(ParagraphStyle& pstyle) 
+{
+	if (pstyle.lineSpacing() <= -16000)
+		pstyle.resetLineSpacing();
+	if (pstyle.leftMargin() <= -16000)
+		pstyle.resetLeftMargin();
+	if (pstyle.rightMargin() <= -16000)
+		pstyle.resetRightMargin();
+	if (pstyle.firstIndent() <= -16000)
+		pstyle.resetFirstIndent();
+	if (pstyle.alignment() < 0)
+		pstyle.resetAlignment();
+	if (pstyle.gapBefore() <= -16000)
+		pstyle.resetGapBefore();
+	if (pstyle.gapAfter() <= -16000)
+		pstyle.resetGapAfter();
+	if (pstyle.dropCapLines() < 0)
+		pstyle.resetDropCapLines();
+	if (pstyle.dropCapOffset() <= -16000)
+		pstyle.resetDropCapOffset();
+	fixLegacyCStyle(pstyle.charStyle());
+}
+
+/*!
+This is a function taken from fileloader of Scribus 150 fileformat. Please check out the file for necessary details
+*/
+
+void fixLegacyCStyle(CharStyle& cstyle) 
+{
+	if (! cstyle.font().usable())
+		cstyle.resetFont();
+	if (cstyle.fontSize() <= -16000 / 10)
+		cstyle.resetFontSize();
+//		if (cstyle.effects() == 65535)
+//			cstyle.resetEffects();
+	if (cstyle.fillColor().isEmpty())
+		cstyle.resetFillColor();
+	if (cstyle.fillShade() <= -16000)
+		cstyle.resetFillShade();
+	if (cstyle.strokeColor().isEmpty())
+		cstyle.resetStrokeColor();
+	if (cstyle.strokeShade() <= -16000)
+		cstyle.resetStrokeShade();
+	if (cstyle.shadowXOffset() <= -16000 / 10)
+		cstyle.resetShadowXOffset();
+	if (cstyle.shadowYOffset() <= -16000 / 10)
+		cstyle.resetShadowYOffset();
+	if (cstyle.outlineWidth() <= -16000 / 10)
+		cstyle.resetOutlineWidth();
+	if (cstyle.underlineOffset() <= -16000 / 10)
+		cstyle.resetUnderlineOffset();
+	if (cstyle.underlineWidth() <= -16000 / 10)
+		cstyle.resetUnderlineWidth();
+	if (cstyle.strikethruOffset() <= -16000 / 10)
+		cstyle.resetStrikethruOffset();
+	if (cstyle.strikethruWidth() <= -16000 / 10)
+		cstyle.resetStrikethruWidth();
+	if (cstyle.scaleH() <= -16000 / 10)
+		cstyle.resetScaleH();
+	if (cstyle.scaleV() <= -16000 / 10)
+		cstyle.resetScaleV();
+	if (cstyle.baselineOffset() <= -16000 / 10)
+		cstyle.resetBaselineOffset();
+	if (cstyle.tracking() <= -16000 / 10)
+		cstyle.resetTracking();
+}
+
+bool ImportIdmlImpl::processSpreads()
+{
+	int count = spreadPath.count();
+	for( int i=0;i<count;i++ )
+	{
+		//loop to load files one by one and process it!
+		QString path = spreadPath.at(i);
+		QDomElement spreadRoot = loadXmlFile(path);
+		if(spreadRoot.tagName()=="idPkg:Spread")
+			continue;
+		else
+		{
+			readSpread(spreadRoot.firstChild());
+		}
+	}
+	return true;
+}
+
+
+bool ImportIdmlImpl::processStory()
+{
+	int count = storyList.count();
+	for(int i=0;i<count;i++)
+	{
+		QString path = storyList.at(i);
+		QDomElement storyRoot = loadXmlFile(path);
+		if(storyRoot.tagName() != "idPkg:Story")
+			continue;
+		else
+		{
+			readStoryObjects(storyRoot.firstChild());
+		}
+	}
+	return true;
+}
+
+bool ImportIdmlImpl::readStoryObjects(QDomNode node)
+{
+	while(!node.isNull())
+	{
+		QDomElement elem = node.toElement();
+		if(!elem.isNull())
+		{
+			if(elem.tagName()=="Story")
+			{
+				Story story;
+				QString Self = elem.attribute("Self","");
+				readComTextProps(node,story.properties); //this will read common text properties represented as attributes/elements in the <story>
+				QDomNode descend = node.firstChild();
+				while(!descend.isNull())
+				{
+					if(descend.toElement().tagName()=="ParagraphStyleRange")
+					{
+						PStyleRange p;
+						readComTextProps(descend,p.properties);
+						if(descend.firstChild().toElement().tagName() == "CharacterStyleRange")
+							p.cstyleRange.append(readCStyleRange(descend.firstChild()));
+					}
+					descend = descend.nextSibling();
+				}
+				storyMap.insert(Self,story);
+			}
+		}
+		node=node.nextSibling();
+	}
+	return true;
+}
+
+void ImportIdmlImpl::readSpread(QDomNode node)
+{
+	/* Reading the attributes first */
+	
+	QTransform ItemTransform;
+	QDomElement elem = node.toElement();
+	bool showMasterItems = (elem.attribute("ShowMasterItems","")=="true")?true:false;
+	int pageCount = elem.attribute("PageCount","").toInt();
+	node=node.firstChild();
+	while( !node.isNull() )
+	{
+		elem = node.toElement();
+		if( !elem.isNull() )
+		{
+			if(elem.tagName()=="Page")
+			{
+				addPage(m_Doc,node);
+			}
+			if( elem.tagName()=="Rectangle")
+			{
+				addRectangle(m_Doc,node);
+			}
+			if( elem.tagName()=="Oval")
+			{
+				
+			}
+			if(elem.tagName()=="Polygon")
+			{
+				addPolygon(m_Doc,node);
+			}
+			if(elem.tagName()=="GraphicLine")
+			{
+				addGraphicLine(m_Doc,node);
+			}
+			if(elem.tagName()=="TextFrame")
+			{
+				addTextFrame(m_Doc,node);
+			}
+			if(elem.tagName()=="Group")
+			{
+			}
+		}
+		node = node.nextSibling();
+	}
+			
+}
+
+void ImportIdmlImpl::addTextFrame(ScribusDoc* doc, QDomNode node)
+{
+	QString Self;
+	Story parentStory;
+	bool Locked = true;
+	QString FillColor, FillTint, StrokeColor, ItemLayer;
+	QTransform itemTransform;
+	QDomElement elem = node.toElement();
+	if( !elem.isNull())
+	{
+		Self = elem.attribute("Self","");
+		Locked = (elem.attribute("Locked","")=="true")?true:false;
+		parentStory = storyMap.value(elem.attribute("ParentStory",""));
+		FillColor = elem.attribute("FillColor","");
+		if(FillColor.isEmpty())
+			FillColor = CommonStrings::None;
+		FillTint = elem.attribute("FillTint","");
+		StrokeColor = elem.attribute("StrokeColor","");
+		if(StrokeColor.isEmpty())
+			StrokeColor = CommonStrings::None;
+		ItemLayer = elem.attribute("ItemLayer","");
+		itemTransform =  applyTransform(elem.attribute("ItemTranform",""));
+		/* Try to add gradiant feature */
+	}
+	//Reading the properties
+	QList<PathPoint> pathPoints;
+	node = node.firstChild().firstChild();
+	while(!node.isNull())
+	{
+		QDomElement e = node.toElement();
+		if(!e.isNull())
+		{
+			if(e.tagName()=="PathGeometry")
+			{
+				if(node.firstChild().toElement().tagName()=="GeometryPathType")
+				{
+					QDomNode path = node.firstChild().firstChild();
+					while(!node.isNull())
+					{
+						QDomElement p = node.toElement();
+						if(!e.isNull())
+						{
+							pathPoints.append(readPathPoint(p));
+						}
+						node = node.nextSibling();
+					}
+				}
+			}
+		}
+	}
+	
+	double x = pathPoints.at(0).Anchor.x();
+	double y = pathPoints.at(0).Anchor.y();
+	double w = findWidth(pathPoints.at(2).Anchor.x(),pathPoints.at(2).Anchor.y(),pathPoints.at(3).Anchor.x(),pathPoints.at(3).Anchor.y());
+	double h = findHeight(pathPoints.at(0).Anchor.x(),pathPoints.at(0).Anchor.y(),pathPoints.at(1).Anchor.x(),pathPoints.at(1).Anchor.y());
+	
+	/** Now we have all the necessary things for defining a textitem in Scribus, here we go!
+	*/
+	
+	int z = doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h,0 , FillColor, StrokeColor, true);
+	currItem = doc->Items->at(z);
+	currItem->setLocked(Locked);
+	currItem->setLayer(layerMap.value(ItemLayer));
+	TextWriter *writer = new TextWriter(m_Doc);
+	writer->open(currItem);
+	/* Appending the text according to the paragraph style range elements */
+	
+	for(int i=0; i<parentStory.pstyleRange.count(); i++)
+	{
+		int count = parentStory.pstyleRange.at(i).cstyleRange.count();
+		for(int j=0; j<count; j++)
+		{
+			if(!(parentStory.pstyleRange.at(i).cstyleRange.at(j).properties.AppliedCStyle.isEmpty()))
+				writer->setCharStyle(parentStory.pstyleRange.at(i).cstyleRange.at(j).properties.AppliedCStyle);
+			if(!(parentStory.pstyleRange.at(i).cstyleRange.at(j).properties.AppliedPStyle.isEmpty()))
+				writer->setStyle(parentStory.pstyleRange.at(i).cstyleRange.at(j).properties.AppliedPStyle);
+			QStringList list = parentStory.pstyleRange.at(i).cstyleRange.at(j).Content.split(QChar(13),QString::KeepEmptyParts);
+			QStringList::Iterator it;
+			for( it=list.begin();it!=list.end();++it)
+			{
+				writer->appendText(*it);
+				writer->appendText(SpecialChars::PARSEP);
+			}
+		}
+	}
+}
+
+PathPoint ImportIdmlImpl::readPathPoint(QDomElement e)
+{
+	PathPoint p;
+	QStringList l = e.attribute("PathPointAnchor","").split(" ");
+	p.Anchor.setX(l.at(0).toDouble());
+	p.Anchor.setY(l.at(1).toDouble());
+	l=e.attribute("LeftDirection","").split(" ");
+	p.Left.setX(l.at(0).toDouble());
+	p.Left.setY(l.at(1).toDouble());
+	l=e.attribute("RightDirection","").split(" ");
+	p.Right.setX(l.at(0).toDouble());
+	p.Right.setY(l.at(1).toDouble());
+	return p;
+}
+/**
+\brief A Funtion to find width 
+\return width as double if successful, else return -1
+*/
+
+double ImportIdmlImpl::findWidth(double x1, double y1, double x2, double y2)
+{
+	if(x1==x2)
+		return (y1>y2)?(y1-y2):(y2-y1);
+	else
+		return -1;
+}
+
+double ImportIdmlImpl::findHeight(double x1, double y1, double x2, double y2)
+{
+	if(y1==y2)
+		return (x1>x2)?(x1-x2):(x2-x1);
+	else
+		return -1;
+}
+
+QTransform itemTransform(QString transform)
+{
+	QStringList list = transform.split(" ");
+	
+	qreal a = list.at(0).toDouble();
+	qreal b = list.at(1).toDouble();
+	qreal c = list.at(3).toDouble();
+	qreal d = list.at(4).toDouble();
+	qreal e = list.at(5).toDouble();
+	qreal f = list.at(6).toDouble();
+	/* Adding the values directly */
+	QTransform transformation(a,b,0,c,d,0,e,f,1);
+	return transformation;
+}
+
+void ImportIdmlImpl::addPage(ScribusDoc *doc, QDomNode node)
+{
+	/** We've set an integer variable to hold the current page number status. Hence when we meet this function, we will increment this variable and pass it to the addPage function of m_Doc
+	*/
+	pageNumber = pageNumber+1;
+	QDomElement elem = node.toElement();
+	QString appliedMaster;
+	Page* newPage;
+	if(!elem.isNull())
+	{
+		appliedMaster = elem.attribute("AppliedMaster","");
+	}
+	if(!appliedMaster.isNull())
+		newPage=doc->addPage(pageNumber,appliedMaster);
+	else
+		newPage=doc->addPage(pageNumber);
+	newPage->setInitialHeight(docHeight);
+	newPage->setInitialWidth(docWidth);
+	if(docWidth > docHeight)
+		newPage->setOrientation(1);
+	else
+		newPage->setOrientation(0);
+	node=node.firstChild();
+	while(!node.isNull())
+	{
+		QDomElement e = node.toElement();
+		if(!e.isNull())
+		{
+			if(e.tagName()=="MarginPreference")
+			{
+				newPage->initialMargins.Left=e.attribute("Left","").toDouble();
+				newPage->initialMargins.Right=e.attribute("Right","").toDouble();
+				newPage->initialMargins.Top=e.attribute("Top","").toDouble();
+				newPage->initialMargins.Bottom=e.attribute("Bottom","").toDouble();
+				newPage->Margins.Top    = newPage->initialMargins.Top;
+				newPage->Margins.Bottom = newPage->initialMargins.Bottom;
+			}
+		}
+		node=node.nextSibling();
+	}
+}
+
+CStyleRange ImportIdmlImpl::readCStyleRange(QDomNode node)
+{
+	CStyleRange c;
+	readComTextProps(node,c.properties);
+	while(!node.isNull())
+	{
+		QDomElement elem = node.toElement();
+		if(!elem.isNull())
+		{
+			if(elem.tagName()=="Content")
+			{
+				c.Content.append(elem.text());
+			}
+			if(elem.tagName()=="Br")
+				c.Content.append(QChar(13));
+		}
+		node=node.nextSibling();
+	}
+	return c;
+}
+
+void ImportIdmlImpl::readComTextProps(QDomNode node, CommonTextProps& property)
+{
+	/**
+	First, read all the properties defined as attributes, then descend to those defined as elements
+	*/
+	QDomElement element = node.toElement();
+	property.AppliedCStyle=element.attribute("AppliedCharacterStyle","");
+	property.AppliedLanguage=element.attribute("AppliedLanguage","");
+	property.AppliedPStyle=element.attribute("AppliedParagraphStyle","");
+	property.BaselineShift=element.attribute("BaselineShift","").toDouble();
+//	property.Capital=element.attribute("Capitalization","");
+	property.DesiredGlyphScale=element.attribute("DesiredGlyphScale","").toDouble();
+	property.DesiredWordSpace=element.attribute("DesiredWordSpacing","").toDouble();
+	property.DropCapChars=element.attribute("DropCapCharacters","").toDouble();
+	property.DropCapLines=element.attribute("DropCapLines","").toDouble();
+	property.FillColor=element.attribute("FillColor","");
+	property.FillTint=element.attribute("FillTint","").toDouble();
+	property.FirstLineIndent=element.attribute("FirstLineIndent","").toDouble();
+	property.FontStyle=element.attribute("FontStyle","");
+	property.GradFillAngle=element.attribute("GradiantFillAngle","").toDouble();
+        property.GradFillLength=element.attribute("GradiantFillLength","").toDouble();
+        property.GradStrokeAngle=element.attribute("GradiantStrokeAngle","").toDouble();
+        property.GradStrokeLength=element.attribute("GradiantStrokeLength","").toDouble();
+	property.HorizontalScale=element.attribute("HorizontalScale","").toDouble();
+//	property.justify=element.attribute("Justification","");
+	property.StrikeThru=(element.attribute("StrikeThrough","")=="true")?true:false;
+	property.StrikeThruOffset=element.attribute("StrikeThroughOffset","").toDouble();
+	property.StrikeThruWeight=element.attribute("StrikeThroughWeight","").toDouble();
+	property.StrokeColor=element.attribute("StrokeColor","");
+	property.StrokeTint=element.attribute("StrokeTint","").toDouble();
+	property.Tracking=element.attribute("Tracking","").toDouble();
+	property.Underline=(element.attribute("Underline","")=="true")?true:false;
+	property.UnderlineOffset=element.attribute("UnderlineOffset","").toDouble();
+	property.UnderlineWeight =element.attribute("UnderlineWeight","").toDouble();
+	
+	/** Properties represented as elements 
+	*/
+	node=node.firstChild();
+	while(!node.isNull())
+	{
+		QDomElement elem = node.toElement();
+		if(!elem.isNull())
+		{
+			if(elem.tagName()=="AppliedFont")
+			{
+				property.AppliedFont=elem.text();
+			}
+		}
+		node=node.nextSibling();
+	}
+}
+
Index: scribus/plugins/import/idml/docpreference.cpp
===================================================================
--- scribus/plugins/import/idml/docpreference.cpp	(revision 0)
+++ scribus/plugins/import/idml/docpreference.cpp	(revision 14473)
@@ -0,0 +1,112 @@
+/*
+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.
+*/
+
+#include "docpreference.h"
+
+/*!
+
+\param root is the root node of the preferences.xml document
+\return true if success
+*/
+
+
+DocPreferences::DocPreferences() : QObject(0)
+{
+}
+
+bool DocPreferences::processFile(QDomElement& root)
+{
+	if( root.tagName() != "idPkg:Preferences" )
+		return false;
+	else
+	{
+		QDomNode node = root.firstChild();
+		while(!node.isNull())
+		{
+			QDomElement elem = node.toElement();
+			if(!elem.isNull())
+			{
+				if( elem.tagName() == "StoryPreference" )
+				{
+					storyPreference.OpticalMarginSize = elem.attribute("OpticalMarginSize","0");
+					storyPreference.StoryDirection = elem.attribute("StoryDirection","");
+					storyPreference.StoryOrientation = elem.attribute("StoryOrientation","");
+				}
+				if(elem.tagName() == "TextDefault" )
+				{
+					textDefault.Self = elem.attribute("Self","");
+					textDefault.AppliedLanguage = elem.attribute("AppliedLanguage","");
+					textDefault.AppliedCStyle = elem.attribute("AppliedCharacterStyle","");
+					textDefault.AppliedPStyle = elem.attribute("AppliedParagraphStyle","");
+					textDefault.BaselineShift = elem.attribute("BaselineShift","");
+					textDefault.Capitalization = elem.attribute("Capitalization","");
+					textDefault.DesWordSpacing = elem.attribute("DesiredWordSpacing","");
+					textDefault.FillColor = elem.attribute("FillColor","");
+					textDefault.FillTint = elem.attribute("FillTint","");
+					textDefault.FirstLineIndent = elem.attribute("FirstLineIndent","");
+					textDefault.FontStyle = elem.attribute("FontStyle","");
+					textDefault.HorizontalScale = elem.attribute("HorizontalScale","");
+					textDefault.Justification = elem.attribute("Justification","");
+					textDefault.LeftIndent = elem.attribute("LeftIndent","");
+					textDefault.MaxGlyphScaling = elem.attribute("MaximumGlyphSpacing","");
+					textDefault.MaxWordSpacing = elem.attribute("MaximumWordSpacing","");
+					textDefault.MinGlyphScaling = elem.attribute("MinimumGlyphScaling","");
+					textDefault.MinWordSpacing = elem.attribute("MinimumWordSpacing","");
+					textDefault.PointSize = elem.attribute("PointSize","");
+					textDefault.RightIndent = elem.attribute("RightIndent","");
+					textDefault.SpaceAfter = elem.attribute("SpaceAfter","");
+					textDefault.SpaceBefore = elem.attribute("SpaceBefore","");
+					textDefault.StrikeThruOffset = elem.attribute("StrikeThroughOffset","");
+					textDefault.StrikeThruWeight = elem.attribute("StrikeThroughWeight","");
+					textDefault.StrokeColor = elem.attribute("StrokeColor","");
+					textDefault.StrokeTint = elem.attribute("StrokeTint","");
+					textDefault.StrokeWeight = elem.attribute("StrokeWeight","");
+					textDefault.Underline = elem.attribute("Underline","");
+					textDefault.UnderlineOffset = elem.attribute("UnderlineOffset","");
+					textDefault.UnderlineWeight = elem.attribute("UnderlineWeight","");
+					textDefault.VerticalScale = elem.attribute("VerticalScale","");
+				}
+				if( elem.tagName() == "DocumentPreference")
+				{
+					preference.ColumnDirection = elem.attribute("ColumnDirection","");
+					preference.DocBleedBotOffset = elem.attribute("DocumentBleedBottomOffset","0");
+					preference.DocBleedLeftOffset = elem.attribute("DocumentBleedLeftOffset","0");
+					preference.DocBleedRightOffset = elem.attribute("DocumentBleedRightOffset","0");
+					preference.DocumentBleedTopOffset = elem.attribute("DocumentBleedTopOffset","0");
+					preference.MasterTextFrame = elem.attribute("MasterTextFrame","");
+					preference.PageHeight = elem.attribute("PageHeight","0");
+					preference.PageWidth = elem.attribute("PageWidth","0");
+					preference.self = elem.attribute("Self","");
+				}
+				if( elem.tagName() == "PageItemDefault")
+				{
+					pageDefault.FillColor = elem.attribute("FillColor","");
+					pageDefault.FillTint = elem.attribute("FillTint","0");
+					pageDefault.GradFillAngle = elem.attribute("GradientFillAngle","0");
+					pageDefault.GradStrokeAngle = elem.attribute("GradientStrokeAngle","0");
+					pageDefault.StrokeColor = elem.attribute("StrokeColor","0");
+					pageDefault.StrokeTint = elem.attribute("StrokeTint","0");
+					pageDefault.StrokeWeight = elem.attribute("StrokeWeight","0");
+				}
+				if( elem.tagName() == "MarginPreference")
+				{
+					marginPreference.bottom = elem.attribute("Bottom","0");
+					marginPreference.left = elem.attribute("Left","0");
+					marginPreference.right = elem.attribute("Right","0");
+					marginPreference.top = elem.attribute("Top","0");
+				}
+			}
+			node=node.nextSibling();
+		}
+	}
+	return true;
+}
+
+
+DocPreferences::~DocPreferences()
+{
+}

Property changes on: scribus/plugins/import/idml/docpreference.cpp
___________________________________________________________________
Added: svn:executable
   + *

Index: scribus/plugins/import/idml/importidml.h
===================================================================
--- scribus/plugins/import/idml/importidml.h	(revision 0)
+++ scribus/plugins/import/idml/importidml.h	(revision 14473)
@@ -0,0 +1,47 @@
+/*
+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 IMPORTIDML_H
+#define IMPORTIDML_H
+
+#include "pluginapi.h"
+#include "loadsaveplugin.h"
+#include "scfonts.h"
+#include "scribusstructs.h"
+#include "styles/styleset.h"
+
+#include <QString>
+#include <QMap>
+#include <QList>
+#include <QProgressBar>
+
+
+class PLUGIN_API ImportIdml : public LoadSavePlugin
+{
+	Q_OBJECT
+
+	public:
+		//! \brief Standard plugin implementation
+		ImportIdml();
+		virtual ~ImportIdml();
+		//! \brief main method to run the plug
+		virtual bool run(ScribusDoc* doc, QString target = QString::null);
+		virtual const QString fullTrName() const;
+		virtual const AboutData* getAboutData() const;
+		virtual void deleteAboutData(const AboutData* about) const;
+		virtual void languageChange();
+		virtual bool fileSupported(QIODevice* file, const QString & fileName=QString::null) const;
+		virtual bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0);
+		virtual void addToMainWindowMenu(ScribusMainWindow *) {};
+//		virtual bool import(QString fileName = QString::null, int flags = lfUseCurrentPage|lfInteractive);
+		void registerFormats();
+};
+
+extern "C" PLUGIN_API int importidml_getPluginAPIVersion();
+extern "C" PLUGIN_API ScPlugin* importidml_getPlugin();
+extern "C" PLUGIN_API void importidml_freePlugin(ScPlugin* plugin);
+
+#endif
Index: scribus/plugins/import/idml/importidmlimpl.h
===================================================================
--- scribus/plugins/import/idml/importidmlimpl.h	(revision 0)
+++ scribus/plugins/import/idml/importidmlimpl.h	(revision 14473)
@@ -0,0 +1,225 @@
+/*
+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 IMPORTIDMLIMPL_H
+#define IMPORTIDMLIMPL_H
+
+
+#include "pageitem.h"
+#include "sccolor.h"
+#include "fpointarray.h"
+#include "docpreference.h"
+
+#include <QObject>
+#include <QList>
+#include <QTransform>
+#include <QMultiMap>
+#include <QtGlobal>
+#include <QObject>
+#include <QString>
+#include <QRect>
+#include <QStack>
+#include <QDomNode>
+#include <QDomElement>
+#include <QPointF>
+
+class QString;
+class ScribusDoc;
+class MultiProgressDialog;
+class Selection;
+class TransactionSettings;
+class ScLayer;
+
+enum Capitalization
+{
+	AllCaps,
+	SmallCaps,
+	Normal
+};
+enum Justification
+{
+	LeftAlign,
+	CenterAlign,
+	RightAlign,
+	FullyJustified
+};
+enum Position
+{
+	NormalP,
+	SuperScript,
+	SubScript
+};
+struct CommonTextProps
+{
+//  CommonTextProperties represented as Attributes
+	QString AppliedCStyle;
+	QString AppliedLanguage;
+	QString AppliedPStyle;
+	double AutoLeading;
+	double BaselineShift;
+	Capitalization Capital;
+	double DesiredGlyphScale;
+	double DesiredWordSpace;
+	double DropCapChars;				//Not supported in Scribus
+	double DropCapLines;
+	QString FillColor;
+	QString FillTint;
+	double FirstLineIndent;
+	QString FontStyle;
+	double GradFillAngle;
+	double GradFillLength;
+	double GradStrokeAngle;
+	double GradStrokeLength;
+	double HorizontalScale;
+	Justification justify;
+	double KerningValue;
+	double LeftIndent;
+	double MaxGlyphScaling;
+	double MaxWordSpacing;
+	double MinGlyphScaling;
+	double MinWordSpacing;
+	double PointSize;
+	Position position;
+	double RightIndent;
+	double SpaceAfter;
+	double SpaceBefore;
+	double StrikeThruWeight;
+	double StrikeThruOffset;
+	bool StrikeThru;
+	QString StrokeColor;
+	double StrokeTint;
+	double Tracking;
+	bool Underline;
+	double UnderlineOffset;
+	double UnderlineWeight;
+//CommonTextProperties represented as elements
+	QString AppliedFont;
+	/* Handle Tablists later */
+};
+
+struct CStyleRange
+{
+	CommonTextProps properties;
+	QString Content;
+};
+
+/*!
+\brief Stuct PStyleRange will hold the values of all those attributes/elements which can occur in the ParagraphStyleRange in a Story. Since it can contain any number of CharacterStyleRange elements as its children, we use a list to store all of them.
+\param properties contain all the common text properties, of which if anyone is skipped, we use the default value for it from the docpreference object.
+\param cstyleRange contain all the CharacterStyleRange elements in the ParagraphStyleRange
+*/
+struct PStyleRange
+{
+	CommonTextProps properties;
+	QList<CStyleRange> cstyleRange;
+};
+
+class Story
+{
+  public:
+	QList<PStyleRange> pstyleRange;
+	CommonTextProps properties;
+};
+
+struct PathPoint
+{
+	QPointF Anchor;
+	QPointF Left;
+	QPoint Right;
+};
+
+class ImportIdmlImpl : public QObject
+{
+	Q_OBJECT
+	public:
+		ImportIdmlImpl();
+		~ImportIdmlImpl() {};
+		bool run(const QString & target, ScribusDoc* doc=0);
+		
+		QString desmapPath, fontPath, stylePath, graphicPath, preferPath, mspreadPath;
+	private:
+		bool processDesignMap();
+		bool processFont();
+		bool processStyles();
+		bool importPStyles(QDomNode&);
+		bool importCStyles(QDomNode&);
+		bool processSpreads();
+		bool processStory();
+		bool readStoryObjects(QDomNode);
+		void readComTextProps(QDomNode, CommonTextProps&);
+		void readSpread(QDomNode);
+		void readMSpread(QDomNode);
+		void docAttributes(QDomElement&);
+		void handleLanguage(QDomElement&);
+		void handleLayer(ScLayer&,QDomElement&);
+		void handleSection(ScribusDoc*, QDomElement&);
+		void handleCRFormat(QDomElement&);
+		void handleBookmarks(QDomElement&);
+		
+		/** PageItem Functions */
+		void handleGroup(QDomNode);
+		void readGradiant(QDomNode);
+		void addTextFrame(ScribusDoc*,QDomNode);
+		void addPage(ScribusDoc*, QDomNode);
+		void addMasterPage(ScribusDoc*,QDomNode);
+		void addRectangle(ScribusDoc*,QDomNode);
+		void addOval(ScribusDoc*,QDomNode);
+		void addPolygon(ScribusDoc*,QDomNode);
+		void addGraphicLine(ScribusDoc*,QDomNode);
+		double findWidth(double,double,double,double);
+		double findHeight(double,double,double,double);
+		QTransform applyTransform(QString);
+		PathPoint readPathPoint(QDomElement);
+		
+		void getMSpreadSrc(QDomElement&);
+		void getSpreadSrc(QDomElement&);
+		void getStorySrc(QDomElement&);
+		void getBStorySrc(QDomElement&);
+		void readParagraphStyle(ScribusDoc *doc, QDomNode node, ParagraphStyle& newStyle, SCFonts &fonts);
+		void readCharacterStyle(ScribusDoc *doc, QDomNode node, CharStyle& newStyle);
+		void fixLegacyParStyle(ParagraphStyle& pstyle);
+		void fixLegacyCStyle(CharStyle& cstyle);
+		CStyleRange readCStyleRange(QDomNode node);
+	
+		QDomElement loadXmlFile(QString &filename);
+		QDomDocument doc;
+		QDomNode node;
+		QDomElement root;
+		QDomElement element;
+		QMap<QString,int> layerMap;
+		QMap<QString,Story> storyMap;
+		QList<QString> storyList;
+		QList<QString> storyPath;
+		QList<QString> Spreads;
+		QList<QString> spreadPath;
+		QList<QString> MasterSpreads;
+		QList<QString> MSpreadPath;
+		QList<PageItem*> Elements;
+		int layerID;
+		int pageNumber;
+		int currentLayer;
+		int importerFlags;
+		int currentPageNr;
+		bool interactive;
+		bool cancel;
+		bool firstLayer;
+		double baseX, baseY;
+		double docWidth;
+		double docHeight;
+		QString baseFile;
+		QString activeLayer;
+		DocPreferences preference;
+		FPointArray coords;
+		MultiProgressDialog *progressDialog;
+		ScribusDoc* m_Doc;
+		SCFonts* m_AvailableFonts;
+		Selection *tmpSel;
+		ParagraphStyle vg;
+		CharStyle cs;
+		PageItem *currItem;
+};
+
+#endif
Index: scribus/plugins/import/idml/docpreference.h
===================================================================
--- scribus/plugins/import/idml/docpreference.h	(revision 0)
+++ scribus/plugins/import/idml/docpreference.h	(revision 14473)
@@ -0,0 +1,114 @@
+/*
+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 DOCPREFERENCE_H
+#define DOCPREFERENCE_H
+
+#include <QObject>
+#include <QDomNode>
+#include <QDomElement>
+#include <QString>
+
+struct docPrefer
+{
+	QString self;
+	QString PageHeight;
+	QString PageWidth;
+	QString DocumentBleedTopOffset;
+	QString DocBleedBotOffset;
+	QString DocBleedLeftOffset;
+	QString DocBleedRightOffset;
+	QString ColumnDirection;
+	QString MasterTextFrame;
+};
+
+struct marginPrefer
+{
+	QString top;
+	QString bottom;
+	QString right;
+	QString left;
+};
+
+struct PageItemDefault
+{
+	QString FillColor;
+	QString FillTint;
+	QString StrokeWeight;
+	QString StrokeColor;
+	QString StrokeTint;
+	QString GradFillAngle;
+	QString GradStrokeAngle;
+};
+
+struct StoryPrefer
+{
+	QString OpticalMarginSize;
+	QString StoryDirection;
+	QString StoryOrientation;
+};
+
+struct TextDefault
+{
+	QString Self;
+	QString FirstLineIndent;
+	QString LeftIndent;
+	QString RightIndent;
+	QString SpaceBefore;
+	QString SpaceAfter;
+	QString Justification;
+	QString MinWordSpacing;
+	QString MaxWordSpacing;
+	QString DesWordSpacing;
+	QString MinGlyphScaling;
+	QString MaxGlyphScaling;
+	QString AppliedPStyle;
+	QString AppliedCStyle;
+	QString FontStyle;
+	QString PointSize;
+	QString Capitalization;
+	QString Underline;
+	QString HorizontalScale;
+	QString VerticalScale;
+	QString BaselineShift;
+	QString FillTint;
+	QString StrokeTint;
+	QString StrokeWeight;
+	QString UnderlineOffset;
+	QString UnderlineWeight;
+	QString StrikeThruOffset;
+	QString StrikeThruWeight;
+	QString FillColor;
+	QString StrokeColor;
+	QString AppliedLanguage;
+	QString BasedOn;
+	QString AppliedFont;
+};
+
+
+
+/*!
+\author Jain Basil Aliyas
+\class DocPreferences
+\brief A class to represent the necessary preferences from Resources/Preferences.xml in the idml package. These values will be used as default if the attribute value returned is null. Hence, every element in the above defined structures are QString type, which will be converted to their natives types while assigning it to the Scribus native objects!.
+*/
+
+class DocPreferences : public QObject
+{
+  Q_OBJECT
+  public:
+	
+	DocPreferences();
+	~DocPreferences();
+	bool processFile(QDomElement& root);
+	docPrefer preference;
+	marginPrefer marginPreference;
+	PageItemDefault pageDefault;
+	StoryPrefer storyPreference;
+	TextDefault textDefault;
+};
+#endif
\ No newline at end of file

Property changes on: scribus/plugins/import/idml/docpreference.h
___________________________________________________________________
Added: svn:executable
   + *

Index: scribus/plugins/import/idml/CMakeLists.txt
===================================================================
--- scribus/plugins/import/idml/CMakeLists.txt	(revision 0)
+++ scribus/plugins/import/idml/CMakeLists.txt	(revision 14473)
@@ -0,0 +1,32 @@
+INCLUDE_DIRECTORIES(
+${CMAKE_SOURCE_DIR}
+${CMAKE_SOURCE_DIR}/scribus
+)
+
+SET(IMPORTIDML_PLUGIN_MOC_CLASSES
+importidml.h
+importidmlimpl.h
+docpreference.h
+)
+
+SET(IMPORTIDML_PLUGIN_SOURCES
+importidml.cpp
+importidmlimpl.cpp
+docpreference.cpp
+)
+
+SET(SCRIBUS_IMPORTIDML_PLUGIN "importidml")
+
+QT4_WRAP_CPP(IMPORTIDML_PLUGIN_MOC_SOURCES ${IMPORTIDML_PLUGIN_MOC_CLASSES})
+
+ADD_LIBRARY(${SCRIBUS_IMPORTIDML_PLUGIN} MODULE ${IMPORTIDML_PLUGIN_SOURCES} ${IMPORTIDML_PLUGIN_MOC_SOURCES})
+
+TARGET_LINK_LIBRARIES(${SCRIBUS_IMPORTIDML_PLUGIN} ${PLUGIN_LIBRARIES})
+
+INSTALL(TARGETS ${SCRIBUS_IMPORTIDML_PLUGIN}
+  LIBRARY
+  DESTINATION ${PLUGINDIR}
+  PERMISSIONS ${PLUGIN_PERMISSIONS}
+)
+
+# SET_TARGET_PROPERTIES(${SCRIBUS_FONTPREVIEW_PLUGIN} PROPERTIES VERSION "0.0.0")
Index: scribus/plugins/import/CMakeLists.txt
===================================================================
--- scribus/plugins/import/CMakeLists.txt	(revision 14472)
+++ scribus/plugins/import/CMakeLists.txt	(revision 14473)
@@ -1,6 +1,7 @@
 ADD_SUBDIRECTORY(ai)
 ADD_SUBDIRECTORY(cgm)
 ADD_SUBDIRECTORY(cvg)
+ADD_SUBDIRECTORY(idml)
 ADD_SUBDIRECTORY(pct)
 ADD_SUBDIRECTORY(ps)
 ADD_SUBDIRECTORY(svg)




More information about the scribus-commit mailing list