r19222 by fschmid - Bug #12327: Update the relevant plug-in interfaces and the plug-ins to use librevenge

scribus-commit scribus-commit at lists.scribus.net
Sat Jun 14 16:48:07 UTC 2014


Author: fschmid
Date: Sat Jun 14 16:48:07 2014
New Revision: 19222

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19222
Log:
Bug #12327: Update the relevant plug-in interfaces and the plug-ins to use librevenge
Part 1: ported the MS-Publisher import plugin

Modified:
    trunk/Scribus/CMakeLists.txt
    trunk/Scribus/config.h.cmake
    trunk/Scribus/scribus/plugins/import/pub/CMakeLists.txt
    trunk/Scribus/scribus/plugins/import/pub/importpub.cpp
    trunk/Scribus/scribus/plugins/import/pub/importpub.h

Modified: trunk/Scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19222&path=/trunk/Scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/CMakeLists.txt (original)
+++ trunk/Scribus/CMakeLists.txt Sat Jun 14 16:48:07 2014
@@ -134,9 +134,9 @@
 ENDIF (_machine_sparc64)
 
 #convert any 64 bit build into generic 64 tag for below
-IF (ARCH_X86_64 OR ARCH_SPARC_64 OR ARCH_MIPS_64 OR ARCH_PPC_64) 
+IF (ARCH_X86_64 OR ARCH_SPARC_64 OR ARCH_MIPS_64 OR ARCH_PPC_64)
   SET(ARCH64BIT 1)
-ENDIF (ARCH_X86_64 OR ARCH_SPARC_64 OR ARCH_MIPS_64 OR ARCH_PPC_64) 
+ENDIF (ARCH_X86_64 OR ARCH_SPARC_64 OR ARCH_MIPS_64 OR ARCH_PPC_64)
 
 MESSAGE(STATUS "Building for target ${MACHINE}")
 
@@ -391,12 +391,12 @@
     # vanilla gcc
     SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -Wall -fstrict-aliasing")
     SET(CMAKE_C_FLAGS_DEBUG "-O0 -g3 -Wall -fstrict-aliasing")
-    
+
     IF (_machine_x86 OR _machine_x86_64)
       SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC")
       SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fPIC")
     ENDIF (_machine_x86 OR _machine_x86_64)
-    
+
   ENDIF(${CMAKE_GENERATOR} MATCHES "^(Visual Studio|NMake).*")
 ENDIF(APPLE)
 
@@ -502,7 +502,7 @@
 #<< ZLIB, PNG
 IF (WIN32)
   # On win32 we can use Qt's zlib and libpng, so we use some
-  # custom cmake includes. This permits us to honour the 
+  # custom cmake includes. This permits us to honour the
   # USE_QT_ZLIB_PNGLIB flag if passed.
   SET(PNG_DIR ${CMAKE_MODULE_PATH})
   SET(ZLIB_DIR ${CMAKE_MODULE_PATH})
@@ -709,12 +709,23 @@
 ENDIF (POPPLER_FOUND)
 #>>Poppler for PDF import
 
+# librevenge for MsPub import
+pkg_check_modules(LIBREVENGE librevenge-0.0)
+IF (LIBREVENGE_FOUND)
+	pkg_check_modules(LIBREVENGE_STREAM librevenge-stream-0.0)
+	IF (LIBREVENGE_STREAM_FOUND)
+		pkg_check_modules(LIBREVENGE_GENERATORS librevenge-generators-0.0)
+		IF (LIBREVENGE_GENERATORS_FOUND)
+			SET(HAVE_REVENGE 1)
+		ENDIF (LIBREVENGE_GENERATORS_FOUND)
+	ENDIF (LIBREVENGE_STREAM_FOUND)
+ENDIF (LIBREVENGE_FOUND)
 
 ##############################################################################################################
 ########## Include Setup                                                                            ##########
 
 TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
-  
+
 CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
 IF(HAVE_DLFCN_H)
   ADD_DEFINITIONS(-DHAVE_DLFCN_H)
@@ -784,8 +795,8 @@
 
 ADD_CUSTOM_TARGET(uninstall
   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
-  
-  
+
+
 ##############################################################################################################
 ########## Add our subdirs                                                                          ##########
 

Modified: trunk/Scribus/config.h.cmake
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19222&path=/trunk/Scribus/config.h.cmake
==============================================================================
--- trunk/Scribus/config.h.cmake (original)
+++ trunk/Scribus/config.h.cmake Sat Jun 14 16:48:07 2014
@@ -37,3 +37,4 @@
 #cmakedefine WORDS_BIGENDIAN 1
 #cmakedefine GMAGICK_FOUND 1
 #cmakedefine WITH_TESTS 1
+#cmakedefine HAVE_REVENGE 1

Modified: trunk/Scribus/scribus/plugins/import/pub/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19222&path=/trunk/Scribus/scribus/plugins/import/pub/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pub/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/plugins/import/pub/CMakeLists.txt Sat Jun 14 16:48:07 2014
@@ -1,22 +1,39 @@
 INCLUDE(FindPkgConfig)
-pkg_check_modules(LIBWPG libwpg-0.2)
-IF (LIBWPG_FOUND)
-	pkg_check_modules(LIBWPD libwpd-0.9)
-	IF (LIBWPD_FOUND)
-		pkg_check_modules(LIBWPD_STREAM libwpd-stream-0.9)
-		IF (LIBWPD_STREAM_FOUND)
-			pkg_check_modules(LIBMSPUB libmspub-0.0)
-			IF (LIBMSPUB_FOUND)
-				INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/scribus ${LIBWPG_INCLUDE_DIRS} ${LIBWPD_INCLUDE_DIRS} ${LIBWPD_STREAM_INCLUDE_DIRS} ${LIBMSPUB_INCLUDE_DIRS})
-				SET(IMPORTPUB_PLUGIN_MOC_CLASSES importpub.h importpubplugin.h)
-				SET(IMPORTPUB_PLUGIN_SOURCES importpub.cpp importpubplugin.cpp)
-				SET(SCRIBUS_IMPORTPUB_PLUGIN "importpub")
-				QT5_WRAP_CPP(IMPORTPUB_PLUGIN_MOC_SOURCES ${IMPORTPUB_PLUGIN_MOC_CLASSES})
-				ADD_LIBRARY(${SCRIBUS_IMPORTPUB_PLUGIN} MODULE ${IMPORTPUB_PLUGIN_SOURCES} ${IMPORTPUB_PLUGIN_MOC_SOURCES})
-				TARGET_LINK_LIBRARIES(${SCRIBUS_IMPORTPUB_PLUGIN} ${PLUGIN_LIBRARIES} ${LIBWPG_LDFLAGS} ${LIBWPD_LDFLAGS} ${LIBWPD_STREAM_LDFLAGS} ${LIBMSPUB_LDFLAGS})
-				INSTALL(TARGETS ${SCRIBUS_IMPORTPUB_PLUGIN} LIBRARY DESTINATION ${PLUGINDIR} PERMISSIONS ${PLUGIN_PERMISSIONS})
-				ADD_DEPENDENCIES(${SCRIBUS_IMPORTPUB_PLUGIN} ${EXE_NAME})
-			ENDIF (LIBMSPUB_FOUND)
-		ENDIF (LIBWPD_STREAM_FOUND)
-	ENDIF (LIBWPD_FOUND)
-ENDIF (LIBWPG_FOUND)
+IF (HAVE_REVENGE)
+	pkg_check_modules(LIBMSPUB libmspub-0.1)
+	IF (LIBMSPUB_FOUND)
+		MESSAGE("Building MS-Publisher Importer with librevenge")
+		INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/scribus ${LIBREVENGE_INCLUDE_DIRS} ${LIBREVENGE_GENERATORS_INCLUDE_DIRS} ${LIBREVENGE_STREAM_INCLUDE_DIRS} ${LIBMSPUB_INCLUDE_DIRS})
+		SET(IMPORTPUB_PLUGIN_MOC_CLASSES importpub.h importpubplugin.h)
+		SET(IMPORTPUB_PLUGIN_SOURCES importpub.cpp importpubplugin.cpp)
+		SET(SCRIBUS_IMPORTPUB_PLUGIN "importpub")
+		QT5_WRAP_CPP(IMPORTPUB_PLUGIN_MOC_SOURCES ${IMPORTPUB_PLUGIN_MOC_CLASSES})
+		ADD_LIBRARY(${SCRIBUS_IMPORTPUB_PLUGIN} MODULE ${IMPORTPUB_PLUGIN_SOURCES} ${IMPORTPUB_PLUGIN_MOC_SOURCES})
+		TARGET_LINK_LIBRARIES(${SCRIBUS_IMPORTPUB_PLUGIN} ${PLUGIN_LIBRARIES} ${LIBREVENGE_LDFLAGS} ${LIBREVENGE_GENERATORS_LDFLAGS} ${LIBREVENGE_STREAM_LDFLAGS} ${LIBMSPUB_LDFLAGS})
+		INSTALL(TARGETS ${SCRIBUS_IMPORTPUB_PLUGIN} LIBRARY DESTINATION ${PLUGINDIR} PERMISSIONS ${PLUGIN_PERMISSIONS})
+		ADD_DEPENDENCIES(${SCRIBUS_IMPORTPUB_PLUGIN} ${EXE_NAME})
+	ENDIF (LIBMSPUB_FOUND)
+ELSE (HAVE_REVENGE)
+	pkg_check_modules(LIBMSPUB libmspub-0.0)
+	IF (LIBMSPUB_FOUND)
+		pkg_check_modules(LIBWPG libwpg-0.2)
+		IF (LIBWPG_FOUND)
+			pkg_check_modules(LIBWPD libwpd-0.9)
+			IF (LIBWPD_FOUND)
+				pkg_check_modules(LIBWPD_STREAM libwpd-stream-0.9)
+				IF (LIBWPD_STREAM_FOUND)
+					MESSAGE("Building MS-Publisher Importer without librevenge")
+					INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/scribus ${LIBWPG_INCLUDE_DIRS} ${LIBWPD_INCLUDE_DIRS} ${LIBWPD_STREAM_INCLUDE_DIRS} ${LIBMSPUB_INCLUDE_DIRS})
+					SET(IMPORTPUB_PLUGIN_MOC_CLASSES importpub.h importpubplugin.h)
+					SET(IMPORTPUB_PLUGIN_SOURCES importpub.cpp importpubplugin.cpp)
+					SET(SCRIBUS_IMPORTPUB_PLUGIN "importpub")
+					QT5_WRAP_CPP(IMPORTPUB_PLUGIN_MOC_SOURCES ${IMPORTPUB_PLUGIN_MOC_CLASSES})
+					ADD_LIBRARY(${SCRIBUS_IMPORTPUB_PLUGIN} MODULE ${IMPORTPUB_PLUGIN_SOURCES} ${IMPORTPUB_PLUGIN_MOC_SOURCES})
+					TARGET_LINK_LIBRARIES(${SCRIBUS_IMPORTPUB_PLUGIN} ${PLUGIN_LIBRARIES} ${LIBWPG_LDFLAGS} ${LIBWPD_LDFLAGS} ${LIBWPD_STREAM_LDFLAGS} ${LIBMSPUB_LDFLAGS})
+					INSTALL(TARGETS ${SCRIBUS_IMPORTPUB_PLUGIN} LIBRARY DESTINATION ${PLUGINDIR} PERMISSIONS ${PLUGIN_PERMISSIONS})
+					ADD_DEPENDENCIES(${SCRIBUS_IMPORTPUB_PLUGIN} ${EXE_NAME})
+				ENDIF (LIBWPD_STREAM_FOUND)
+			ENDIF (LIBWPD_FOUND)
+		ENDIF (LIBWPG_FOUND)
+	ENDIF (LIBMSPUB_FOUND)
+ENDIF (HAVE_REVENGE)

Modified: trunk/Scribus/scribus/plugins/import/pub/importpub.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19222&path=/trunk/Scribus/scribus/plugins/import/pub/importpub.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pub/importpub.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pub/importpub.cpp Sat Jun 14 16:48:07 2014
@@ -56,8 +56,1432 @@
 
 extern SCRIBUS_API ScribusQApp * ScQApp;
 
-RawPainter::RawPainter(): libwpg::WPGPaintInterface()
-{
+#if HAVE_REVENGE
+
+struct RawPainterPrivate
+{
+	RawPainterPrivate();
+};
+
+RawPainterPrivate::RawPainterPrivate()
+{
+}
+
+RawPainter::RawPainter(ScribusDoc* Doc, double x, double y, double w, double h, int iflags, QList<PageItem*> *Elem, QStringList *iColors, QStringList *iPatterns, Selection* tSel) : m_pImpl(new RawPainterPrivate())
+{
+	m_Doc = Doc;
+	baseX = x;
+	baseY = y;
+	docWidth = w;
+	docHeight = h;
+	importerFlags = iflags;
+	Elements = Elem;
+	importedColors = iColors;
+	importedPatterns = iPatterns;
+	tmpSel = tSel;
+	doProcessing = true;
+	CurrColorFill = "Black";
+	CurrFillShade = 100.0;
+	CurrColorStroke = "Black";
+	CurrStrokeShade = 100.0;
+	CurrStrokeTrans = 0.0;
+	CurrFillTrans = 0.0;
+	Coords.resize(0);
+	Coords.svgInit();
+	LineW = 1.0;
+	lineJoin = Qt::MiterJoin;
+	lineEnd = Qt::FlatCap;
+	fillrule = true;
+	gradientAngle = 0.0;
+	isGradient = false;
+	lineSpSet = false;
+	currentGradient = VGradient(VGradient::linear);
+	currentGradient.clearStops();
+	currentGradient.setRepeatMethod( VGradient::none );
+	dashArray.clear();
+	firstPage = true;
+	actPage = 0;
+	actTextItem = NULL;
+}
+
+RawPainter::~RawPainter()
+{
+	delete m_pImpl;
+}
+
+void RawPainter::startDocument(const librevenge::RVNGPropertyList &propList)
+{
+}
+
+void RawPainter::endDocument()
+{
+}
+
+void RawPainter::setDocumentMetaData(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "setDocumentMetaData";
+}
+
+void RawPainter::defineEmbeddedFont(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "defineEmbeddedFont";
+}
+
+void RawPainter::startPage(const librevenge::RVNGPropertyList &propList)
+{
+	if (propList["svg:width"])
+		docWidth = valueAsPoint(propList["svg:width"]);
+	if (propList["svg:height"])
+		docHeight = valueAsPoint(propList["svg:height"]);
+	if (importerFlags & LoadSavePlugin::lfCreateDoc)
+	{
+		if (!firstPage)
+		{
+			m_Doc->addPage(actPage);
+			m_Doc->setActiveLayer(baseLayer);
+		}
+		else
+			baseLayer = m_Doc->activeLayerName();
+		m_Doc->setPageSize("Custom");
+		m_Doc->currentPage()->setInitialWidth(docWidth);
+		m_Doc->currentPage()->setInitialHeight(docHeight);
+		m_Doc->currentPage()->setWidth(docWidth);
+		m_Doc->currentPage()->setHeight(docHeight);
+		m_Doc->currentPage()->MPageNam = CommonStrings::trMasterPageNormal;
+		m_Doc->currentPage()->m_pageSize = "Custom";
+		m_Doc->reformPages(true);
+		baseX = m_Doc->currentPage()->xOffset();
+		baseY = m_Doc->currentPage()->yOffset();
+	}
+	firstPage = false;
+	actPage++;
+}
+
+void RawPainter::endPage()
+{
+	if (importerFlags & LoadSavePlugin::lfCreateThumbnail)
+		doProcessing = false;
+}
+
+void RawPainter::startMasterPage(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "startMasterPage";
+}
+
+void RawPainter::endMasterPage()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "endMasterPage";
+}
+
+void RawPainter::startLayer(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	FPointArray clip;
+	if (propList["svg:clip-path"])
+	{
+		QString svgString = QString(propList["svg:clip-path"]->getStr().cstr());
+		clip.resize(0);
+		clip.svgInit();
+		svgString.replace(",", ".");
+		clip.parseSVG(svgString);
+		QTransform m;
+		m.scale(72.0, 72.0);
+		clip.map(m);
+	}
+	QList<PageItem*> gElements;
+	groupEntry gr;
+	gr.clip = clip.copy();
+	gr.Items = gElements;
+	groupStack.push(gr);
+}
+
+void RawPainter::endLayer()
+{
+	if (!doProcessing)
+		return;
+	if (groupStack.count() != 0)
+	{
+		PageItem *ite;
+		groupEntry gr = groupStack.pop();
+		QList<PageItem*> gElements = gr.Items;
+		tmpSel->clear();
+		if (gElements.count() > 0)
+		{
+			bool groupClip = true;
+			for (int dre = 0; dre < gElements.count(); ++dre)
+			{
+				tmpSel->addItem(gElements.at(dre), true);
+				Elements->removeAll(gElements.at(dre));
+				if (gElements.at(dre)->hasSoftShadow())
+					groupClip = false;
+			}
+			ite = m_Doc->groupObjectsSelection(tmpSel);
+			ite->setGroupClipping(groupClip);
+			ite->setTextFlowMode(PageItem::TextFlowUsesBoundingBox);
+			if (!gr.clip.isEmpty())
+			{
+				double oldX = ite->xPos();
+				double oldY = ite->yPos();
+				double oldW = ite->width();
+				double oldH = ite->height();
+				double oldgW = ite->groupWidth;
+				double oldgH = ite->groupHeight;
+				ite->PoLine = gr.clip.copy();
+				ite->PoLine.translate(baseX, baseY);
+				FPoint xy = getMinClipF(&ite->PoLine);
+				ite->setXYPos(xy.x(), xy.y(), true);
+				ite->PoLine.translate(-xy.x(), -xy.y());
+				FPoint wh = getMaxClipF(&ite->PoLine);
+				ite->setWidthHeight(wh.x(),wh.y());
+				ite->groupWidth = oldgW * (ite->width() / oldW);
+				ite->groupHeight = oldgH * (ite->height() / oldH);
+				double dx = (ite->xPos() - oldX) / (ite->width() / ite->groupWidth);
+				double dy = (ite->yPos() - oldY) / (ite->height() / ite->groupHeight);
+				for (int em = 0; em < ite->groupItemList.count(); ++em)
+				{
+					PageItem* embedded = ite->groupItemList.at(em);
+					embedded->moveBy(-dx, -dy, true);
+					m_Doc->setRedrawBounding(embedded);
+					embedded->OwnPage = m_Doc->OnPage(embedded);
+				}
+				ite->ClipEdited = true;
+				ite->OldB2 = ite->width();
+				ite->OldH2 = ite->height();
+				ite->Clip = FlattenPath(ite->PoLine, ite->Segments);
+				ite->updateGradientVectors();
+			}
+			Elements->append(ite);
+			if (groupStack.count() != 0)
+				groupStack.top().Items.append(ite);
+		}
+		tmpSel->clear();
+	}
+}
+
+void RawPainter::startEmbeddedGraphics(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "startEmbeddedGraphics";
+}
+
+void RawPainter::endEmbeddedGraphics()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "endEmbeddedGraphics";
+}
+
+void RawPainter::openGroup(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "openGroup";
+}
+
+void RawPainter::closeGroup()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "closeGroup";
+}
+
+void RawPainter::setStyle(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	m_style.clear();
+	m_style = propList;
+	isGradient = false;
+	if(propList["draw:fill"] && propList["draw:fill"]->getStr() == "none")
+		CurrColorFill = CommonStrings::None;
+	else if(propList["draw:fill"] && propList["draw:fill"]->getStr() == "solid")
+	{
+		if (propList["draw:fill-color"])
+		{
+			CurrColorFill = parseColor(QString(propList["draw:fill-color"]->getStr().cstr()));
+			if(propList["draw:opacity"])
+				CurrFillTrans = 1.0 - qMin(1.0, qMax(fromPercentage(QString(propList["draw:opacity"]->getStr().cstr())), 0.0));
+		}
+	}
+	if(propList["draw:fill"] && propList["draw:fill"]->getStr() == "gradient")
+	{
+		double angle = 0;
+		if (propList["draw:angle"])
+			angle = propList["draw:angle"]->getDouble();
+		double opacity = 1.0;
+		librevenge::RVNGPropertyListVector gradient;
+		if (propList.child("svg:linearGradient"))
+		{
+			currentGradient = VGradient(VGradient::linear);
+			gradient = *propList.child("svg:linearGradient");
+		}
+		else if (propList.child("svg:radialGradient"))
+		{
+			currentGradient = VGradient(VGradient::radial);
+			gradient = *propList.child("svg:radialGradient");
+		}
+		if (gradient.count() > 1)
+		{
+			currentGradient.clearStops();
+			currentGradient.setRepeatMethod( VGradient::pad );
+			double dr = 1.0 / static_cast<double>(gradient.count());
+			for (unsigned c = 0; c < gradient.count(); c++)
+			{
+				librevenge::RVNGPropertyList grad = gradient[c];
+				if (grad["svg:stop-color"])
+				{
+					QString stopName = parseColor(QString(grad["svg:stop-color"]->getStr().cstr()));
+					double rampPoint = dr * c;
+					if(grad["svg:offset"])
+						rampPoint = fromPercentage(QString(grad["svg:offset"]->getStr().cstr()));
+					const ScColor& gradC = m_Doc->PageColors[stopName];
+					if(grad["svg:stop-opacity"])
+						opacity = qMin(1.0, qMax(fromPercentage(QString(grad["svg:stop-opacity"]->getStr().cstr())), 0.0));
+					currentGradient.addStop( ScColorEngine::getRGBColor(gradC, m_Doc), rampPoint, 0.5, opacity, stopName, 100 );
+					if (c == 0)
+					{
+						gradColor1Str = stopName;
+						gradColor1 = ScColorEngine::getRGBColor(gradC, m_Doc);
+						gradColor1Trans = opacity;
+					}
+					else
+					{
+						gradColor2Str = stopName;
+						gradColor2 = ScColorEngine::getRGBColor(gradC, m_Doc);
+						gradColor2Trans = opacity;
+					}
+				}
+			}
+			if (currentGradient.Stops() > 1)
+				isGradient = true;
+		}
+	}
+	if(propList["svg:fill-rule"])
+	{
+		if (QString(propList["svg:fill-rule"]->getStr().cstr()) == "nonzero")
+			fillrule = false;
+		else
+			fillrule = true;
+	}
+	if (propList["svg:stroke-width"])
+		LineW = valueAsPoint(propList["svg:stroke-width"]);
+	if (propList["draw:stroke"])
+	{
+		if (propList["draw:stroke"]->getStr() == "none")
+			CurrColorStroke = CommonStrings::None;
+		else if ((propList["draw:stroke"]->getStr() == "solid") || (propList["draw:stroke"]->getStr() == "dash"))
+		{
+			if (propList["svg:stroke-color"])
+			{
+				CurrColorStroke = parseColor(QString(propList["svg:stroke-color"]->getStr().cstr()));
+				if(propList["svg:stroke-opacity"])
+					CurrStrokeTrans = 1.0 - qMin(1.0, qMax(fromPercentage(QString(propList["svg:stroke-opacity"]->getStr().cstr())), 0.0));
+			}
+			if (propList["draw:stroke"]->getStr() == "dash")
+			{
+				dashArray.clear();
+				double gap = LineW;
+				if (propList["draw:distance"])
+					gap = valueAsPoint(propList["draw:distance"]);
+				int dots1 = 0;
+				if (propList["draw:dots1"])
+					dots1 = propList["draw:dots1"]->getInt();
+				double dots1len = LineW;
+				if (propList["draw:dots1-length"])
+					dots1len = valueAsPoint(propList["draw:dots1-length"]);
+				int dots2 = 0;
+				if (propList["draw:dots2"])
+					dots2 = propList["draw:dots2"]->getInt();
+				double dots2len = LineW;
+				if (propList["draw:dots2-length"])
+					dots2len = valueAsPoint(propList["draw:dots2-length"]);
+				for (int i = 0; i < dots1; i++)
+				{
+					dashArray << qMax(dots1len, 0.1) << qMax(gap, 0.1);
+				}
+				for (int j = 0; j < dots2; j++)
+				{
+					dashArray << qMax(dots2len, 0.1) << qMax(gap, 0.1);
+				}
+			}
+			else
+				dashArray.clear();
+		}
+	}
+	if (propList["svg:stroke-linecap"])
+	{
+		QString params = QString(propList["svg:stroke-linecap"]->getStr().cstr());
+		if( params == "butt" )
+			lineEnd = Qt::FlatCap;
+		else if( params == "round" )
+			lineEnd = Qt::RoundCap;
+		else if( params == "square" )
+			lineEnd = Qt::SquareCap;
+		else
+			lineEnd = Qt::FlatCap;
+	}
+	if (propList["svg:stroke-linejoin"])
+	{
+		QString params = QString(propList["svg:stroke-linejoin"]->getStr().cstr());
+		if( params == "miter" )
+			lineJoin = Qt::MiterJoin;
+		else if( params == "round" )
+			lineJoin = Qt::RoundJoin;
+		else if( params == "bevel" )
+			lineJoin = Qt::BevelJoin;
+		else
+			lineJoin = Qt::MiterJoin;
+	}
+}
+
+void RawPainter::drawRectangle(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"])
+	{
+		double x = valueAsPoint(propList["svg:x"]);
+		double y = valueAsPoint(propList["svg:y"]);
+		double w = valueAsPoint(propList["svg:width"]);
+		double h = valueAsPoint(propList["svg:height"]);
+		int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, baseX + x, baseY + y, w, h, LineW, CurrColorFill, CurrColorStroke, true);
+		PageItem *ite = m_Doc->Items->at(z);
+		finishItem(ite);
+		applyFill(ite);
+		if (CurrColorFill != CommonStrings::None)
+			applyShadow(ite);
+	}
+}
+
+void RawPainter::drawEllipse(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"])
+	{
+		double x = valueAsPoint(propList["svg:x"]);
+		double y = valueAsPoint(propList["svg:y"]);
+		double w = valueAsPoint(propList["svg:width"]);
+		double h = valueAsPoint(propList["svg:height"]);
+		int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, baseX + x, baseY + y, w, h, LineW, CurrColorFill, CurrColorStroke, true);
+		PageItem *ite = m_Doc->Items->at(z);
+		finishItem(ite);
+		applyFill(ite);
+		if (CurrColorFill != CommonStrings::None)
+			applyShadow(ite);
+	}
+}
+
+void RawPainter::drawPolyline(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	librevenge::RVNGPropertyListVector vertices = *propList.child("svg:points");
+	if(vertices.count() < 2)
+		return;
+	Coords.resize(0);
+	Coords.svgInit();
+	PageItem *ite;
+	Coords.svgMoveTo(valueAsPoint(vertices[0]["svg:x"]), valueAsPoint(vertices[0]["svg:y"]));
+	for(unsigned i = 1; i < vertices.count(); i++)
+	{
+		Coords.svgLineTo(valueAsPoint(vertices[i]["svg:x"]), valueAsPoint(vertices[i]["svg:y"]));
+	}
+	if (Coords.size() > 0)
+	{
+		int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CommonStrings::None, CurrColorStroke, true);
+		ite = m_Doc->Items->at(z);
+		ite->PoLine = Coords.copy();
+		finishItem(ite);
+	}
+}
+
+void RawPainter::drawPolygon(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	librevenge::RVNGPropertyListVector vertices = *propList.child("svg:points");
+	if(vertices.count() < 2)
+		return;
+	Coords.resize(0);
+	Coords.svgInit();
+	PageItem *ite;
+	int z;
+	Coords.svgMoveTo(valueAsPoint(vertices[0]["svg:x"]), valueAsPoint(vertices[0]["svg:y"]));
+	for(unsigned i = 1; i < vertices.count(); i++)
+	{
+		Coords.svgLineTo(valueAsPoint(vertices[i]["svg:x"]), valueAsPoint(vertices[i]["svg:y"]));
+	}
+	Coords.svgClosePath();
+	if (Coords.size() > 0)
+	{
+		if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap" && m_style["style:repeat"] && m_style["style:repeat"]->getStr() == "stretch")
+		{
+		  if (m_style["draw:fill-image"] && m_style["librevenge:mime-type"])
+		  {
+			  QByteArray ba(m_style["draw:fill-image"]->getStr().cstr());
+			  QByteArray imageData = QByteArray::fromBase64(ba);
+			  QString imgExt = "";
+			  if (m_style["librevenge:mime-type"]->getStr() == "image/png")
+				  imgExt = "png";
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/jpeg")
+				  imgExt = "jpg";
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/bmp")
+				  imgExt = "bmp";
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/pict")
+				  imgExt = "pict";
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/tiff")
+				  imgExt = "tif";
+			  if (!imgExt.isEmpty())
+			  {
+				  z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CurrColorStroke, true);
+				  ite = m_Doc->Items->at(z);
+				  ite->PoLine = Coords.copy();
+				  finishItem(ite);
+				  insertImage(ite, imgExt, imageData);
+			  }
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/wmf")
+			  {
+				  imgExt = "wmf";
+				  QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pub_XXXXXX." + imgExt);
+				  if (tempFile->open())
+				  {
+					  tempFile->write(imageData);
+					  QString fileName = getLongPathName(tempFile->fileName());
+					  tempFile->close();
+					  FileLoader *fileLoader = new FileLoader(fileName);
+					  int testResult = fileLoader->testFile();
+					  delete fileLoader;
+					  if (testResult != -1)
+					  {
+						  const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
+						  if( fmt )
+						  {
+							  fmt->setupTargets(m_Doc, 0, 0, 0, &(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts));
+							  fmt->loadFile(fileName, LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
+							  if (m_Doc->m_Selection->count() > 0)
+							  {
+								  ite = m_Doc->groupObjectsSelection();
+								  double rot = 0;
+								  if (m_style["librevenge:rotate"])
+									  rot = m_style["librevenge:rotate"]->getDouble();
+								  QPainterPath ba = Coords.toQPainterPath(true);
+								  QRectF baR = ba.boundingRect();
+								  if (rot != 0)
+								  {
+									  QTransform mm;
+									  mm.translate(baR.x(), baR.y());
+									  mm.translate(baR.width() / 2.0, baR.height() / 2.0);
+									  mm.rotate(rot);
+									  mm.translate(-baR.width() / 2.0, -baR.height() / 2.0);
+									  mm.translate(-baR.x(), -baR.y());
+									  ba = mm.map(ba);
+									  baR = ba.boundingRect();
+									  ite->setXYPos(baseX + baR.x(), baseY + baR.y(), true);
+									  ite->setWidthHeight(baR.width(), baR.height(), true);
+									  Coords.fromQPainterPath(ba, true);
+									  FPoint tp2(getMinClipF(&Coords));
+									  Coords.translate(-tp2.x(), -tp2.y());
+									  ite->PoLine = Coords.copy();
+									  int rm = m_Doc->RotMode();
+									  m_Doc->RotMode(2);
+									  m_Doc->RotateItem(-rot, ite);
+									  m_Doc->RotMode(rm);
+								  }
+								  else
+								  {
+									  ite->setXYPos(baseX + baR.x(), baseY + baR.y(), true);
+									  ite->setWidthHeight(baR.width(), baR.height(), true);
+									  FPoint tp2(getMinClipF(&Coords));
+									  Coords.translate(-tp2.x(), -tp2.y());
+									  ite->PoLine = Coords.copy();
+								  }
+								  finishItem(ite);
+								  if (m_style["draw:red"] && m_style["draw:green"] && m_style["draw:blue"])
+								  {
+									  int r = qRound(m_style["draw:red"]->getDouble() * 255);
+									  int g = qRound(m_style["draw:green"]->getDouble() * 255);
+									  int b = qRound(m_style["draw:blue"]->getDouble() * 255);
+									  QString colVal = QString("#%1%2%3").arg(r, 2, 16, QLatin1Char('0')).arg(g, 2, 16, QLatin1Char('0')).arg(b, 2, 16, QLatin1Char('0'));
+									  QString efVal = parseColor(colVal);
+									  recolorItem(ite, efVal);
+								  }
+							  }
+						  }
+					  }
+				  }
+				  delete tempFile;
+			  }
+		  }
+		}
+		else
+		{
+			z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CurrColorStroke, true);
+			ite = m_Doc->Items->at(z);
+			ite->PoLine = Coords.copy();
+			finishItem(ite);
+			applyFill(ite);
+		}
+		applyFlip(ite);
+		if (CurrColorFill != CommonStrings::None)
+			applyShadow(ite);
+	}
+}
+
+void RawPainter::drawPath(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	librevenge::RVNGPropertyListVector path = *propList.child("svg:d");
+	bool isClosed = false;
+	QString svgString = "";
+	for(unsigned i=0; i < path.count(); i++)
+	{
+		librevenge::RVNGPropertyList pList = path[i];
+		if (pList["librevenge:path-action"] && pList["librevenge:path-action"]->getStr() == "M")
+			svgString += QString("M %1 %2 ").arg(valueAsPoint(pList["svg:x"])).arg(valueAsPoint(pList["svg:y"]));
+		else if (pList["librevenge:path-action"] && pList["librevenge:path-action"]->getStr() == "L")
+			svgString += QString("L %1 %2 ").arg(valueAsPoint(pList["svg:x"])).arg(valueAsPoint(pList["svg:y"]));
+		else if (pList["librevenge:path-action"] && pList["librevenge:path-action"]->getStr() == "C")
+			svgString += QString("C %1 %2 %3 %4 %5 %6 ").arg(valueAsPoint(pList["svg:x1"])).arg(valueAsPoint(pList["svg:y1"])).arg(valueAsPoint(pList["svg:x2"])).arg(valueAsPoint(pList["svg:y2"])).arg(valueAsPoint(pList["svg:x"])).arg(valueAsPoint(pList["svg:y"]));
+		else if (propList["librevenge:path-action"] && propList["librevenge:path-action"]->getStr() == "Q")
+			svgString += QString("Q %1 %2 %3 %4 ").arg(valueAsPoint(pList["svg:x1"])).arg(valueAsPoint(pList["svg:y1"])).arg(valueAsPoint(pList["svg:x"])).arg(valueAsPoint(pList["svg:y"]));
+		else if (pList["librevenge:path-action"] && pList["librevenge:path-action"]->getStr() == "A")
+			svgString += QString("A %1 %2 %3 %4 %5 %6 %7") .arg(valueAsPoint(pList["svg:rx"])) .arg(valueAsPoint(pList["svg:ry"])).arg(pList["librevenge:rotate"] ? pList["librevenge:rotate"]->getDouble() : 0).arg(pList["librevenge:large-arc"] ? pList["librevenge:large-arc"]->getInt() : 1).arg(pList["librevenge:sweep"] ? pList["librevenge:sweep"]->getInt() : 1).arg(valueAsPoint(pList["svg:x"])).arg(valueAsPoint(pList["svg:y"]));
+		else if ((i >= path.count()-1 && i > 2) && pList["librevenge:path-action"] && pList["librevenge:path-action"]->getStr() == "Z" )
+		{
+			isClosed = true;
+			svgString += "Z";
+		}
+	}
+	Coords.resize(0);
+	Coords.svgInit();
+	Coords.parseSVG(svgString);
+	PageItem *ite;
+	int z;
+	if (isClosed)
+	{
+		if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap" && m_style["style:repeat"] && m_style["style:repeat"]->getStr() == "stretch")
+		{
+		  if (m_style["draw:fill-image"] && m_style["librevenge:mime-type"])
+		  {
+			  QByteArray ba(m_style["draw:fill-image"]->getStr().cstr());
+			  QByteArray imageData = QByteArray::fromBase64(ba);
+			  QString imgExt = "";
+			  if (m_style["librevenge:mime-type"]->getStr() == "image/png")
+				  imgExt = "png";
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/jpeg")
+				  imgExt = "jpg";
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/bmp")
+				  imgExt = "bmp";
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/pict")
+				  imgExt = "pict";
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/tiff")
+				  imgExt = "tif";
+			  if (!imgExt.isEmpty())
+			  {
+				  z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CurrColorStroke, true);
+				  ite = m_Doc->Items->at(z);
+				  ite->PoLine = Coords.copy();
+				  finishItem(ite);
+				  insertImage(ite, imgExt, imageData);
+			  }
+			  else if (m_style["librevenge:mime-type"]->getStr() == "image/wmf")
+			  {
+				  imgExt = "wmf";
+				  QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pub_XXXXXX." + imgExt);
+				  if (tempFile->open())
+				  {
+					  tempFile->write(imageData);
+					  QString fileName = getLongPathName(tempFile->fileName());
+					  tempFile->close();
+					  FileLoader *fileLoader = new FileLoader(fileName);
+					  int testResult = fileLoader->testFile();
+					  delete fileLoader;
+					  if (testResult != -1)
+					  {
+						  const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
+						  if( fmt )
+						  {
+							  fmt->setupTargets(m_Doc, 0, 0, 0, &(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts));
+							  fmt->loadFile(fileName, LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
+							  if (m_Doc->m_Selection->count() > 0)
+							  {
+								  ite = m_Doc->groupObjectsSelection();
+								  double rot = 0;
+								  if (m_style["librevenge:rotate"])
+									  rot = m_style["librevenge:rotate"]->getDouble();
+								  QPainterPath ba = Coords.toQPainterPath(true);
+								  QRectF baR = ba.boundingRect();
+								  if (rot != 0)
+								  {
+									  QTransform mm;
+									  mm.translate(baR.x(), baR.y());
+									  mm.translate(baR.width() / 2.0, baR.height() / 2.0);
+									  mm.rotate(rot);
+									  mm.translate(-baR.width() / 2.0, -baR.height() / 2.0);
+									  mm.translate(-baR.x(), -baR.y());
+									  ba = mm.map(ba);
+									  baR = ba.boundingRect();
+									  ite->setXYPos(baseX + baR.x(), baseY + baR.y(), true);
+									  ite->setWidthHeight(baR.width(), baR.height(), true);
+									  Coords.fromQPainterPath(ba, true);
+									  FPoint tp2(getMinClipF(&Coords));
+									  Coords.translate(-tp2.x(), -tp2.y());
+									  ite->PoLine = Coords.copy();
+									  int rm = m_Doc->RotMode();
+									  m_Doc->RotMode(2);
+									  m_Doc->RotateItem(-rot, ite);
+									  m_Doc->RotMode(rm);
+								  }
+								  else
+								  {
+									  ite->setXYPos(baseX + baR.x(), baseY + baR.y(), true);
+									  ite->setWidthHeight(baR.width(), baR.height(), true);
+									  FPoint tp2(getMinClipF(&Coords));
+									  Coords.translate(-tp2.x(), -tp2.y());
+									  ite->PoLine = Coords.copy();
+								  }
+								  finishItem(ite);
+								  if (m_style["draw:red"] && m_style["draw:green"] && m_style["draw:blue"])
+								  {
+									  int r = qRound(m_style["draw:red"]->getDouble() * 255);
+									  int g = qRound(m_style["draw:green"]->getDouble() * 255);
+									  int b = qRound(m_style["draw:blue"]->getDouble() * 255);
+									  QString colVal = QString("#%1%2%3").arg(r, 2, 16, QLatin1Char('0')).arg(g, 2, 16, QLatin1Char('0')).arg(b, 2, 16, QLatin1Char('0'));
+									  QString efVal = parseColor(colVal);
+									  recolorItem(ite, efVal);
+								  }
+							  }
+						  }
+					  }
+				  }
+				  delete tempFile;
+			  }
+		  }
+		}
+		else
+		{
+			z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CurrColorStroke, true);
+			ite = m_Doc->Items->at(z);
+			ite->PoLine = Coords.copy();
+			finishItem(ite);
+			applyFill(ite);
+		}
+		applyFlip(ite);
+		if (CurrColorFill != CommonStrings::None)
+			applyShadow(ite);
+	}
+	else
+	{
+		z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CommonStrings::None, CurrColorStroke, true);
+		ite = m_Doc->Items->at(z);
+		ite->PoLine = Coords.copy();
+		finishItem(ite);
+	}
+}
+
+void RawPainter::drawGraphicObject(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	if (!propList["librevenge:mime-type"] || propList["librevenge:mime-type"]->getStr().len() <= 0)
+		return;
+	if (!propList["office:binary-data"])
+		return;
+	if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"])
+	{
+		PageItem *ite;
+		double x = valueAsPoint(propList["svg:x"]);
+		double y = valueAsPoint(propList["svg:y"]);
+		double w = valueAsPoint(propList["svg:width"]);
+		double h = valueAsPoint(propList["svg:height"]);
+		QByteArray ba(propList["office:binary-data"]->getStr().cstr());
+		QByteArray imageData = QByteArray::fromBase64(ba);
+		QString imgExt = "";
+		if (propList["librevenge:mime-type"]->getStr() == "image/png")
+			imgExt = "png";
+		else if (propList["librevenge:mime-type"]->getStr() == "image/jpeg")
+			imgExt = "jpg";
+		else if (propList["librevenge:mime-type"]->getStr() == "image/bmp")
+			imgExt = "bmp";
+		else if (propList["librevenge:mime-type"]->getStr() == "image/pict")
+			imgExt = "pict";
+		else if (propList["librevenge:mime-type"]->getStr() == "image/tiff")
+			imgExt = "tif";
+		if (!imgExt.isEmpty())
+		{
+			int z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Rectangle, baseX + x, baseY + y, w, h, 0, CurrColorFill, CurrColorStroke, true);
+			ite = m_Doc->Items->at(z);
+			finishItem(ite);
+			insertImage(ite, imgExt, imageData);
+		}
+		else
+		{
+			if (propList["librevenge:mime-type"]->getStr() == "image/wmf")
+			{
+				imgExt = "wmf";
+				QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pub_XXXXXX." + imgExt);
+				if (tempFile->open())
+				{
+					tempFile->write(imageData);
+					QString fileName = getLongPathName(tempFile->fileName());
+					tempFile->close();
+					FileLoader *fileLoader = new FileLoader(fileName);
+					int testResult = fileLoader->testFile();
+					delete fileLoader;
+					if (testResult != -1)
+					{
+						const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
+						if( fmt )
+						{
+							fmt->setupTargets(m_Doc, 0, 0, 0, &(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts));
+							fmt->loadFile(fileName, LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
+							if (m_Doc->m_Selection->count() > 0)
+							{
+								ite = m_Doc->groupObjectsSelection();
+								double rot = 0;
+								if (m_style["librevenge:rotate"])
+									rot = m_style["librevenge:rotate"]->getDouble();
+								QPainterPath ba;
+								ba.addRect(QRectF(x, y, w, h));
+								QRectF baR = QRectF(x, y, w, h);
+								if (rot != 0)
+								{
+									QTransform mm;
+									mm.translate(baR.x(), baR.y());
+									mm.translate(baR.width() / 2.0, baR.height() / 2.0);
+									mm.rotate(rot);
+									mm.translate(-baR.width() / 2.0, -baR.height() / 2.0);
+									mm.translate(-baR.x(), -baR.y());
+									ba = mm.map(ba);
+									baR = ba.boundingRect();
+									ite->setXYPos(baseX + baR.x(), baseY + baR.y(), true);
+									ite->setWidthHeight(baR.width(), baR.height(), true);
+									ite->updateClip();
+									int rm = m_Doc->RotMode();
+									m_Doc->RotMode(2);
+									m_Doc->RotateItem(-rot, ite);
+									m_Doc->RotMode(rm);
+								}
+								else
+								{
+									ite->setXYPos(baseX + baR.x(), baseY + baR.y(), true);
+									ite->setWidthHeight(baR.width(), baR.height(), true);
+									ite->updateClip();
+								}
+								finishItem(ite);
+								if (m_style["draw:red"] && m_style["draw:green"] && m_style["draw:blue"])
+								{
+									int r = qRound(m_style["draw:red"]->getDouble() * 255);
+									int g = qRound(m_style["draw:green"]->getDouble() * 255);
+									int b = qRound(m_style["draw:blue"]->getDouble() * 255);
+									QString colVal = QString("#%1%2%3").arg(r, 2, 16, QLatin1Char('0')).arg(g, 2, 16, QLatin1Char('0')).arg(b, 2, 16, QLatin1Char('0'));
+									QString efVal = parseColor(colVal);
+									recolorItem(ite, efVal);
+								}
+							}
+						}
+					}
+				}
+				delete tempFile;
+			}
+		}
+		applyFlip(ite);
+		if (CurrColorFill != CommonStrings::None)
+			applyShadow(ite);
+	}
+}
+
+void RawPainter::drawConnector(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "drawConnector";
+}
+
+void RawPainter::startTextObject(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	if (!doProcessing)
+		return;
+	actTextItem = NULL;
+	lineSpSet = false;
+	lineSpIsPT = false;
+	if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"])
+	{
+		double x = valueAsPoint(propList["svg:x"]);
+		double y = valueAsPoint(propList["svg:y"]);
+		double w = valueAsPoint(propList["svg:width"]);
+		double h = valueAsPoint(propList["svg:height"]);
+		double rot = 0;
+		if (propList["librevenge:rotate"])
+			rot = propList["librevenge:rotate"]->getDouble();
+		int z = m_Doc->itemAdd(PageItem::TextFrame, PageItem::Rectangle, baseX + x, baseY + y, w, h, 0, CurrColorFill, CurrColorStroke, true);
+		PageItem *ite = m_Doc->Items->at(z);
+		finishItem(ite);
+		applyShadow(ite);
+		if (rot != 0)
+		{
+			int rm = m_Doc->RotMode();
+			m_Doc->RotMode(2);
+			m_Doc->RotateItem(rot, ite);
+			m_Doc->RotMode(rm);
+		}
+		if (propList["draw-mirror-horizontal"])
+			ite->flipImageH();
+		if (propList["draw-mirror-vertical"])
+			ite->flipImageV();
+		if (propList["fo:padding-left"])
+			ite->setTextToFrameDistLeft(valueAsPoint(propList["fo:padding-left"]));
+		if (propList["fo:padding-right"])
+			ite->setTextToFrameDistRight(valueAsPoint(propList["fo:padding-right"]));
+		if (propList["fo:padding-top"])
+			ite->setTextToFrameDistTop(valueAsPoint(propList["fo:padding-top"]));
+		if (propList["fo:padding-bottom"])
+			ite->setTextToFrameDistBottom(valueAsPoint(propList["fo:padding-bottom"]));
+		if (propList["fo:column-count"])
+			ite->setColumns(propList["fo:column-count"]->getInt());
+		if (propList["fo:column-gap"])
+			ite->setColumnGap(valueAsPoint(propList["fo:column-gap"]));
+		ite->setFirstLineOffset(FLOPFontAscent);
+		actTextItem = ite;
+		QString pStyle = CommonStrings::DefaultParagraphStyle;
+		ParagraphStyle newStyle;
+		newStyle.setParent(pStyle);
+		textStyle = newStyle;
+	}
+}
+
+void RawPainter::endTextObject()
+{
+	if (!doProcessing)
+		return;
+	if (actTextItem)
+		actTextItem->itemText.trim();
+	actTextItem = NULL;
+	lineSpSet = false;
+	lineSpIsPT = false;
+}
+
+void RawPainter::startTableObject(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "startTableObject";
+}
+
+void RawPainter::openTableRow(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "openTableRow";
+}
+
+void RawPainter::closeTableRow()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "closeTableRow";
+}
+
+void RawPainter::openTableCell(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "openTableCell";
+}
+
+void RawPainter::closeTableCell()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "closeTableCell";
+}
+
+void RawPainter::insertCoveredTableCell(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "insertCoveredTableCell";
+}
+
+void RawPainter::endTableObject()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "endTableObject";
+}
+
+void RawPainter::openOrderedListLevel(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "openOrderedListLevel";
+}
+
+void RawPainter::closeOrderedListLevel()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "closeOrderedListLevel";
+}
+
+void RawPainter::openUnorderedListLevel(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "openUnorderedListLevel";
+}
+
+void RawPainter::closeUnorderedListLevel()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "closeUnorderedListLevel";
+}
+
+void RawPainter::openListElement(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "openListElement";
+}
+
+void RawPainter::closeListElement()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "closeListElement";
+}
+
+void RawPainter::defineParagraphStyle(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "defineParagraphStyle";
+}
+
+void RawPainter::openParagraph(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	QString pStyle = CommonStrings::DefaultParagraphStyle;
+	ParagraphStyle newStyle;
+	newStyle.setParent(pStyle);
+	textStyle = newStyle;
+	if (propList["fo:text-align"])
+	{
+		QString align = QString(propList["fo:text-align"]->getStr().cstr());
+		if (align == "left")
+			textStyle.setAlignment(ParagraphStyle::Leftaligned);
+		else if (align == "center")
+			textStyle.setAlignment(ParagraphStyle::Centered);
+		else if (align == "right")
+			textStyle.setAlignment(ParagraphStyle::Rightaligned);
+		else if (align == "justify")
+			textStyle.setAlignment(ParagraphStyle::Justified);
+	}
+	if (propList["fo:margin-left"])
+		textStyle.setLeftMargin(valueAsPoint(propList["fo:margin-left"]));
+	if (propList["fo:margin-right"])
+		textStyle.setRightMargin(valueAsPoint(propList["fo:margin-right"]));
+	if (propList["fo:text-indent"])
+		textStyle.setFirstIndent(valueAsPoint(propList["fo:text-indent"]));
+	if (propList["style:drop-cap"])
+	{
+		textStyle.setDropCapLines(propList["style:drop-cap"]->getInt());
+		textStyle.setHasDropCap(true);
+	}
+	if (propList["fo:margin-bottom"])
+		textStyle.setGapAfter(valueAsPoint(propList["fo:margin-bottom"]));
+	if (propList["fo:margin-top"])
+		textStyle.setGapBefore(valueAsPoint(propList["fo:margin-top"]));
+//	m_maxFontSize = textStyle.charStyle().fontSize() / 10.0;
+	m_maxFontSize = 1.0;
+	if (propList["fo:line-height"])
+	{
+		m_linespace = propList["fo:line-height"]->getDouble();
+		QString lsp = QString(propList["fo:line-height"]->getStr().cstr());
+		lineSpIsPT = lsp.endsWith("pt");
+		lineSpSet = true;
+	}
+}
+
+void RawPainter::closeParagraph()
+{
+	if (!doProcessing)
+		return;
+	int posT = actTextItem->itemText.length();
+	if (posT > 0)
+	{
+		if ((actTextItem->itemText.text(posT - 1) != SpecialChars::PARSEP))
+		{
+			actTextItem->itemText.insertChars(posT, SpecialChars::PARSEP);
+			actTextItem->itemText.applyStyle(posT, textStyle);
+		}
+	}
+}
+
+void RawPainter::defineCharacterStyle(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "defineCharacterStyle";
+}
+
+void RawPainter::openSpan(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	textCharStyle = textStyle.charStyle();
+	if (propList["fo:font-size"])
+	{
+		textCharStyle.setFontSize(valueAsPoint(propList["fo:font-size"]) * 10.0);
+		m_maxFontSize = qMax(m_maxFontSize, valueAsPoint(propList["fo:font-size"]));
+	}
+	if (propList["fo:color"])
+		textCharStyle.setFillColor(parseColor(QString(propList["fo:color"]->getStr().cstr())));
+	if (propList["style:font-name"])
+	{
+		QString fontVari = "";
+		if (propList["fo:font-weight"])
+			fontVari = QString(propList["fo:font-weight"]->getStr().cstr());
+		QString fontName = QString(propList["style:font-name"]->getStr().cstr());
+		QString realFontName = constructFontName(fontName, fontVari);
+		textCharStyle.setFont((*m_Doc->AllFonts)[realFontName]);
+	}
+	StyleFlag styleEffects = textCharStyle.effects();
+	if (propList["style:text-underline-type"])
+		styleEffects |= ScStyle_Underline;
+	if (propList["style:text-position"])
+	{
+		if (propList["style:text-position"]->getStr() == "50% 67%")
+			styleEffects |= ScStyle_Superscript;
+		else
+			styleEffects |= ScStyle_Subscript;
+	}
+	textCharStyle.setFeatures(styleEffects.featureList());
+}
+
+void RawPainter::closeSpan()
+{
+}
+
+void RawPainter::openLink(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "openLink";
+}
+
+void RawPainter::closeLink()
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "closeLink";
+}
+
+void RawPainter::insertTab()
+{
+	if (!doProcessing)
+		return;
+	int posT = actTextItem->itemText.length();
+	actTextItem->itemText.insertChars(posT, SpecialChars::TAB);
+	actTextItem->itemText.applyStyle(posT, textStyle);
+}
+
+void RawPainter::insertSpace()
+{
+	if (!doProcessing)
+		return;
+	int posT = actTextItem->itemText.length();
+	actTextItem->itemText.insertChars(posT, SpecialChars::BLANK);
+	actTextItem->itemText.applyStyle(posT, textStyle);
+}
+
+void RawPainter::insertText(const librevenge::RVNGString &text)
+{
+	if (!doProcessing)
+		return;
+	if (lineSpSet)
+	{
+		textStyle.setLineSpacingMode(ParagraphStyle::FixedLineSpacing);
+		if (lineSpIsPT)
+			textStyle.setLineSpacing(m_linespace);
+		else
+			textStyle.setLineSpacing(m_maxFontSize * m_linespace);
+	}
+	else
+		textStyle.setLineSpacingMode(ParagraphStyle::AutomaticLineSpacing);
+	librevenge::RVNGString tempUTF8(text);
+	QString actText = QString(tempUTF8.cstr());
+	if (actTextItem)
+	{
+		int posC = actTextItem->itemText.length();
+		if (actText.count() > 0)
+		{
+			actText.replace(QChar(10), SpecialChars::LINEBREAK);
+			actText.replace(QChar(12), SpecialChars::FRAMEBREAK);
+			actText.replace(QChar(30), SpecialChars::NBHYPHEN);
+			actText.replace(QChar(160), SpecialChars::NBSPACE);
+			QTextDocument texDoc;
+			texDoc.setHtml(actText);
+			actText = texDoc.toPlainText();
+			actText = actText.trimmed();
+			actTextItem->itemText.insertChars(posC, actText);
+			actTextItem->itemText.applyStyle(posC, textStyle);
+			actTextItem->itemText.applyCharStyle(posC, actText.length(), textCharStyle);
+		}
+	}
+}
+
+void RawPainter::insertLineBreak()
+{
+	if (!doProcessing)
+		return;
+	int posT = actTextItem->itemText.length();
+	actTextItem->itemText.insertChars(posT, SpecialChars::LINEBREAK);
+	actTextItem->itemText.applyStyle(posT, textStyle);
+}
+
+void RawPainter::insertField(const librevenge::RVNGPropertyList &propList)
+{
+	if (!doProcessing)
+		return;
+	qDebug() << "insertField";
+}
+
+double RawPainter::valueAsPoint(const librevenge::RVNGProperty *prop)
+{
+	double value = 0.0;
+	QString str = QString(prop->getStr().cstr()).toLower();
+	if (str.endsWith("in"))
+		value = prop->getDouble() * 72.0;
+	else
+		value = prop->getDouble();
+	return value;
+}
+
+void RawPainter::applyFill(PageItem* ite)
+{
+	if(isGradient)
+	{
+		QString gradMode = "normal";
+		if (m_style["libmspub:shade"])
+			gradMode = QString(m_style["libmspub:shade"]->getStr().cstr());
+		else if (m_style["draw:style"])
+			gradMode = QString(m_style["draw:style"]->getStr().cstr());
+		if ((gradMode == "normal") || (gradMode == "linear"))
+		{
+			int angle = 0;
+			if (m_style["draw:angle"])
+				angle = qRound(m_style["draw:angle"]->getDouble());
+			double h = ite->height();
+			double w = ite->width();
+			if (angle == 0)
+				ite->setGradientVector(w / 2.0, h, w / 2.0, 0, 0, 0, 1, 0);
+			else if (angle == -225)
+				ite->setGradientVector(w, 0, 0, h, 0, 0, 1, 0);
+			else if (angle == 45)
+				ite->setGradientVector(w, h, 0, 0, 0, 0, 1, 0);
+			else if (angle == 90)
+				ite->setGradientVector(w, h / 2.0, 0, h / 2.0, 0, 0, 1, 0);
+			else if (angle == 180)
+				ite->setGradientVector(w / 2.0, 0, w / 2.0, h, 0, 0, 1, 0);
+			else if (angle == 270)
+				ite->setGradientVector(0, h / 2.0, w, h / 2.0, 0, 0, 1, 0);
+			ite->fill_gradient = currentGradient;
+			ite->GrType = 6;
+		}
+		else if (gradMode == "radial")
+		{
+			double h = ite->height();
+			double w = ite->width();
+			double cx = 0.0;
+			double cy = 0.0;
+			if (m_style["svg:cx"])
+				cx = m_style["svg:cx"]->getDouble();
+			if (m_style["svg:cy"])
+				cy = m_style["svg:cy"]->getDouble();
+			ite->setGradientVector(cx, cy, w, h / 2.0, cx, cy, 1, 0);
+			ite->fill_gradient = currentGradient;
+			ite->GrType = 7;
+		}
+		else if (gradMode == "square")
+		{
+			double cx = 0.0;
+			double cy = 0.0;
+			if (m_style["svg:cx"])
+				cx = m_style["svg:cx"]->getDouble();
+			if (m_style["svg:cy"])
+				cy = m_style["svg:cy"]->getDouble();
+			FPoint cp = FPoint(cx, cy);
+			ite->setDiamondGeometry(FPoint(0, 0), FPoint(ite->width(), 0), FPoint(ite->width(), ite->height()), FPoint(0, ite->height()), cp);
+			ite->fill_gradient.clearStops();
+			QList<VColorStop*> colorStops = currentGradient.colorStops();
+			for( int a = 0; a < colorStops.count() ; a++ )
+			{
+				ite->fill_gradient.addStop(colorStops[a]->color, 1.0 - colorStops[a]->rampPoint, colorStops[a]->midPoint, colorStops[a]->opacity, colorStops[a]->name, colorStops[a]->shade);
+			}
+			ite->GrType = 10;
+		}
+		else if (gradMode == "center")
+		{
+			QString center = "top-left";
+			FPoint cp = FPoint(0, 0);
+			if (m_style["libmspub:shade-ref-point"])
+				center = QString(m_style["libmspub:shade-ref-point"]->getStr().cstr());
+			if (center == "top-left")
+				cp = FPoint(0, 0);
+			else if (center == "top-right")
+				cp = FPoint(ite->width(), 0);
+			else if (center == "bottom-left")
+				cp = FPoint(0, ite->height());
+			else if (center == "bottom-right")
+				cp = FPoint(ite->width(), ite->height());
+			ite->setDiamondGeometry(FPoint(0, 0), FPoint(ite->width(), 0), FPoint(ite->width(), ite->height()), FPoint(0, ite->height()), cp);
+			ite->fill_gradient.clearStops();
+			QList<VColorStop*> colorStops = currentGradient.colorStops();
+			for( int a = 0; a < colorStops.count() ; a++ )
+			{
+				ite->fill_gradient.addStop(colorStops[a]->color, 1.0 - colorStops[a]->rampPoint, colorStops[a]->midPoint, colorStops[a]->opacity, colorStops[a]->name, colorStops[a]->shade);
+			}
+			ite->GrType = 10;
+		}
+		else if (gradMode == "shape")
+		{
+			ite->meshGradientPatches.clear();
+			FPoint center = FPoint(ite->width() / 2.0, ite->height() / 2.0);
+			meshPoint cP;
+			cP.resetTo(center);
+			cP.transparency = gradColor2Trans;
+			cP.shade = 100;
+			cP.colorName = gradColor2Str;
+			cP.color = gradColor2;
+			for (int poi = 0; poi < ite->PoLine.size()-3; poi += 4)
+			{
+				meshGradientPatch patch;
+				patch.BL = cP;
+				patch.BR = cP;
+				if (ite->PoLine.isMarker(poi))
+					continue;
+				meshPoint tL;
+				tL.resetTo(ite->PoLine.point(poi));
+				tL.controlRight = ite->PoLine.point(poi + 1);
+				tL.transparency = gradColor1Trans;
+				tL.shade = 100;
+				tL.colorName = gradColor1Str;
+				tL.color = gradColor1;
+				meshPoint tR;
+				tR.resetTo(ite->PoLine.point(poi + 2));
+				tR.controlLeft = ite->PoLine.point(poi + 3);
+				tR.transparency = gradColor1Trans;
+				tR.shade = 100;
+				tR.colorName = gradColor1Str;
+				tR.color = gradColor1;
+				patch.TL = tL;
+				patch.TR = tR;
+				ite->meshGradientPatches.append(patch);
+			}
+			ite->GrType = 12;
+		}
+	}
+	if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap")
+	{
+		QByteArray ba(m_style["draw:fill-image"]->getStr().cstr());
+		QByteArray imageData = QByteArray::fromBase64(ba);
+		QString imgExt = "";
+		if (m_style["librevenge:mime-type"]->getStr() == "image/png")
+			imgExt = "png";
+		else if (m_style["librevenge:mime-type"]->getStr() == "image/jpeg")
+			imgExt = "jpg";
+		else if (m_style["librevenge:mime-type"]->getStr() == "image/bmp")
+			imgExt = "bmp";
+		else if (m_style["librevenge:mime-type"]->getStr() == "image/pict")
+			imgExt = "pict";
+		else if (m_style["librevenge:mime-type"]->getStr() == "image/tiff")
+			imgExt = "tif";
+		if (!imgExt.isEmpty())
+		{
+			QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pub_XXXXXX." + imgExt);
+			tempFile->setAutoRemove(false);
+			if (tempFile->open())
+			{
+				tempFile->write(imageData);
+				QString fileName = getLongPathName(tempFile->fileName());
+				tempFile->close();
+				ScPattern pat = ScPattern();
+				pat.setDoc(m_Doc);
+				int z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, 0, 0, 1, 1, 0, CommonStrings::None, CommonStrings::None, true);
+				PageItem* newItem = m_Doc->Items->at(z);
+				if (m_style["draw:red"] && m_style["draw:green"] && m_style["draw:blue"])
+				{
+					int r = qRound(m_style["draw:red"]->getDouble() * 255);
+					int g = qRound(m_style["draw:green"]->getDouble() * 255);
+					int b = qRound(m_style["draw:blue"]->getDouble() * 255);
+					QString colVal = QString("#%1%2%3").arg(r, 2, 16, QLatin1Char('0')).arg(g, 2, 16, QLatin1Char('0')).arg(b, 2, 16, QLatin1Char('0'));
+					QString efVal = parseColor(colVal);
+					efVal += "\n";
+					struct ImageEffect ef;
+					efVal += "100";
+					ef.effectCode = ScImage::EF_COLORIZE;
+					ef.effectParameters = efVal;
+					ite->effectsInUse.append(ef);
+				}
+				m_Doc->loadPict(fileName, newItem);
+				m_Doc->Items->takeAt(z);
+				newItem->isInlineImage = true;
+				newItem->isTempFile = true;
+				pat.width = newItem->pixm.qImage().width();
+				pat.height = newItem->pixm.qImage().height();
+				pat.scaleX = (72.0 / newItem->pixm.imgInfo.xres) * newItem->pixm.imgInfo.lowResScale;
+				pat.scaleY = (72.0 / newItem->pixm.imgInfo.xres) * newItem->pixm.imgInfo.lowResScale;
+				pat.pattern = newItem->pixm.qImage().copy();
+				newItem->setWidth(pat.pattern.width());
+				newItem->setHeight(pat.pattern.height());
+				newItem->SetRectFrame();
+				newItem->gXpos = 0.0;
+				newItem->gYpos = 0.0;
+				newItem->gWidth = pat.pattern.width();
+				newItem->gHeight = pat.pattern.height();
+				pat.items.append(newItem);
+				QString patternName = "Pattern_"+ite->itemName();
+				patternName = patternName.trimmed().simplified().replace(" ", "_");
+				m_Doc->addPattern(patternName, pat);
+				importedPatterns->append(patternName);
+				ite->setPattern(patternName);
+				ite->GrType = 8;
+			}
+			delete tempFile;
+		}
+	}
+}
+
+#else
+RawPainter::RawPainter(ScribusDoc* Doc, double x, double y, double w, double h, int iflags, QList<PageItem*> *Elem, QStringList *iColors, QStringList *iPatterns, Selection* tSel): libwpg::WPGPaintInterface()
+{
+	m_Doc = Doc;
+	baseX = x;
+	baseY = y;
+	docWidth = w;
+	docHeight = h;
+	importerFlags = iflags;
+	Elements = Elem;
+	importedColors = iColors;
+	importedPatterns = iPatterns;
+	tmpSel = tSel;
 	CurrColorFill = "Black";
 	CurrFillShade = 100.0;
 	CurrColorStroke = "Black";
@@ -1025,73 +2449,6 @@
 	}
 }
 
-QString RawPainter::constructFontName(QString fontBaseName, QString fontStyle)
-{
-	QString fontName = "";
-	bool found = false;
-	SCFontsIterator it(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts);
-	for ( ; it.hasNext(); it.next())
-	{
-		if (fontBaseName.toLower() == it.current().family().toLower())
-		{
-			// found the font family, now go for the style
-			QStringList slist = PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts.fontMap[it.current().family()];
-			slist.sort();
-			if (slist.count() > 0)
-			{
-				for (int a = 0; a < slist.count(); a++)
-				{
-					if (fontStyle.toLower() == slist[a].toLower())
-					{
-						found = true;
-						fontName = it.current().family() + " " + slist[a];
-						break;
-					}
-				}
-				if (!found)
-				{
-					int reInd = slist.indexOf("Regular");
-					if (reInd < 0)
-						fontName = it.current().family() + " " + slist[0];
-					else
-						fontName = it.current().family() + " " + slist[reInd];
-					found = true;
-				}
-			}
-			else
-			{
-				fontName = it.current().family();
-				found = true;
-			}
-			break;
-		}
-	}
-	if (!found)
-	{
-		if (importerFlags & LoadSavePlugin::lfCreateThumbnail)
-			fontName = PrefsManager::instance()->appPrefs.itemToolPrefs.textFont;
-		else
-		{
-			QString family = fontBaseName;
-			if (!fontStyle.isEmpty())
-				family += " " + fontStyle;
-			if (!PrefsManager::instance()->appPrefs.fontPrefs.GFontSub.contains(family))
-			{
-				qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-				MissingFont *dia = new MissingFont(0, family, m_Doc);
-				dia->exec();
-				fontName = dia->getReplacementFont();
-				delete dia;
-				qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
-				PrefsManager::instance()->appPrefs.fontPrefs.GFontSub[family] = fontName;
-			}
-			else
-				fontName = PrefsManager::instance()->appPrefs.fontPrefs.GFontSub[family];
-		}
-	}
-	return fontName;
-}
-
 double RawPainter::valueAsPoint(const WPXProperty *prop)
 {
 	double value = 0.0;
@@ -1101,122 +2458,6 @@
 	else
 		value = prop->getDouble();
 	return value;
-}
-
-double RawPainter::fromPercentage( const QString &s )
-{
-	QString s1 = s;
-	if (s1.endsWith( ";" ))
-		s1.chop(1);
-	if (s1.endsWith( "%" ))
-	{
-		s1.chop(1);
-		return ScCLocale::toDoubleC(s1) / 100.0;
-	}
-	else
-		return ScCLocale::toDoubleC(s1);
-}
-
-QColor RawPainter::parseColorN( const QString &rgbColor )
-{
-	int r, g, b;
-	keywordToRGB( rgbColor.toLower(), r, g, b );
-	return QColor( r, g, b );
-}
-
-QString RawPainter::parseColor( const QString &s )
-{
-	QColor c;
-	QString ret = CommonStrings::None;
-	if (s.startsWith( "rgb(" ) )
-	{
-		QString parse = s.trimmed();
-		QStringList colors = parse.split(',', QString::SkipEmptyParts);
-		QString r = colors[0].right( ( colors[0].length() - 4 ) );
-		QString g = colors[1];
-		QString b = colors[2].left( ( colors[2].length() - 1 ) );
-		if (r.contains( "%" ))
-		{
-			r.chop(1);
-			r = QString::number( static_cast<int>( ( static_cast<double>( 255 * ScCLocale::toDoubleC(r) ) / 100.0 ) ) );
-		}
-		if (g.contains( "%" ))
-		{
-			g.chop(1);
-			g = QString::number( static_cast<int>( ( static_cast<double>( 255 * ScCLocale::toDoubleC(g) ) / 100.0 ) ) );
-		}
-		if (b.contains( "%" ))
-		{
-			b.chop(1);
-			b = QString::number( static_cast<int>( ( static_cast<double>( 255 * ScCLocale::toDoubleC(b) ) / 100.0 ) ) );
-		}
-		c = QColor(r.toInt(), g.toInt(), b.toInt());
-	}
-	else
-	{
-		QString rgbColor = s.trimmed();
-		if (rgbColor.startsWith( "#" ))
-		{
-			rgbColor = rgbColor.left(7);
-			c.setNamedColor( rgbColor );
-		}
-		else
-			c = parseColorN( rgbColor );
-	}
-	ScColor tmp;
-	tmp.fromQColor(c);
-	tmp.setSpotColor(false);
-	tmp.setRegistrationColor(false);
-	QString newColorName = "FromPUB"+c.name();
-	QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
-	if (fNam == newColorName)
-		importedColors->append(newColorName);
-	ret = fNam;
-	return ret;
-}
-
-void RawPainter::insertImage(PageItem* ite, QString imgExt, QByteArray &imageData)
-{
-	QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pub_XXXXXX." + imgExt);
-	tempFile->setAutoRemove(false);
-	if (tempFile->open())
-	{
-		tempFile->write(imageData);
-		QString fileName = getLongPathName(tempFile->fileName());
-		tempFile->close();
-		ite->isTempFile = true;
-		ite->isInlineImage = true;
-		if (m_style["draw:red"] && m_style["draw:green"] && m_style["draw:blue"])
-		{
-			int r = qRound(m_style["draw:red"]->getDouble() * 255);
-			int g = qRound(m_style["draw:green"]->getDouble() * 255);
-			int b = qRound(m_style["draw:blue"]->getDouble() * 255);
-			QString colVal = QString("#%1%2%3").arg(r, 2, 16, QLatin1Char('0')).arg(g, 2, 16, QLatin1Char('0')).arg(b, 2, 16, QLatin1Char('0'));
-			QString efVal = parseColor(colVal);
-			efVal += "\n";
-			struct ImageEffect ef;
-			efVal += "100";
-			ef.effectCode = ScImage::EF_COLORIZE;
-			ef.effectParameters = efVal;
-			ite->effectsInUse.append(ef);
-		}
-		if (m_style["draw:luminance"])
-		{
-			double per = m_style["draw:luminance"]->getDouble();
-			struct ImageEffect ef;
-			ef.effectCode = ScImage::EF_BRIGHTNESS;
-			ef.effectParameters = QString("%1").arg(qRound((per - 0.5) * 255));
-			ite->effectsInUse.append(ef);
-		}
-		m_Doc->loadPict(fileName, ite);
-		if (m_style["libwpg:rotate"])
-		{
-			int rot = QString(m_style["libwpg:rotate"]->getStr().cstr()).toInt();
-			ite->setImageRotation(rot);
-			ite->AdjustPictScale();
-		}
-	}
-	delete tempFile;
 }
 
 void RawPainter::applyFill(PageItem* ite)
@@ -1413,6 +2654,199 @@
 		}
 	}
 }
+#endif
+
+QString RawPainter::constructFontName(QString fontBaseName, QString fontStyle)
+{
+	QString fontName = "";
+	bool found = false;
+	SCFontsIterator it(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts);
+	for ( ; it.hasNext(); it.next())
+	{
+		if (fontBaseName.toLower() == it.current().family().toLower())
+		{
+			// found the font family, now go for the style
+			QStringList slist = PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts.fontMap[it.current().family()];
+			slist.sort();
+			if (slist.count() > 0)
+			{
+				for (int a = 0; a < slist.count(); a++)
+				{
+					if (fontStyle.toLower() == slist[a].toLower())
+					{
+						found = true;
+						fontName = it.current().family() + " " + slist[a];
+						break;
+					}
+				}
+				if (!found)
+				{
+					int reInd = slist.indexOf("Regular");
+					if (reInd < 0)
+						fontName = it.current().family() + " " + slist[0];
+					else
+						fontName = it.current().family() + " " + slist[reInd];
+					found = true;
+				}
+			}
+			else
+			{
+				fontName = it.current().family();
+				found = true;
+			}
+			break;
+		}
+	}
+	if (!found)
+	{
+		if (importerFlags & LoadSavePlugin::lfCreateThumbnail)
+			fontName = PrefsManager::instance()->appPrefs.itemToolPrefs.textFont;
+		else
+		{
+			QString family = fontBaseName;
+			if (!fontStyle.isEmpty())
+				family += " " + fontStyle;
+			if (!PrefsManager::instance()->appPrefs.fontPrefs.GFontSub.contains(family))
+			{
+				qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+				MissingFont *dia = new MissingFont(0, family, m_Doc);
+				dia->exec();
+				fontName = dia->getReplacementFont();
+				delete dia;
+				qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
+				PrefsManager::instance()->appPrefs.fontPrefs.GFontSub[family] = fontName;
+			}
+			else
+				fontName = PrefsManager::instance()->appPrefs.fontPrefs.GFontSub[family];
+		}
+	}
+	return fontName;
+}
+
+double RawPainter::fromPercentage( const QString &s )
+{
+	QString s1 = s;
+	if (s1.endsWith( ";" ))
+		s1.chop(1);
+	if (s1.endsWith( "%" ))
+	{
+		s1.chop(1);
+		return ScCLocale::toDoubleC(s1) / 100.0;
+	}
+	else
+		return ScCLocale::toDoubleC(s1);
+}
+
+QColor RawPainter::parseColorN( const QString &rgbColor )
+{
+	int r, g, b;
+	keywordToRGB( rgbColor.toLower(), r, g, b );
+	return QColor( r, g, b );
+}
+
+QString RawPainter::parseColor( const QString &s )
+{
+	QColor c;
+	QString ret = CommonStrings::None;
+	if (s.startsWith( "rgb(" ) )
+	{
+		QString parse = s.trimmed();
+		QStringList colors = parse.split(',', QString::SkipEmptyParts);
+		QString r = colors[0].right( ( colors[0].length() - 4 ) );
+		QString g = colors[1];
+		QString b = colors[2].left( ( colors[2].length() - 1 ) );
+		if (r.contains( "%" ))
+		{
+			r.chop(1);
+			r = QString::number( static_cast<int>( ( static_cast<double>( 255 * ScCLocale::toDoubleC(r) ) / 100.0 ) ) );
+		}
+		if (g.contains( "%" ))
+		{
+			g.chop(1);
+			g = QString::number( static_cast<int>( ( static_cast<double>( 255 * ScCLocale::toDoubleC(g) ) / 100.0 ) ) );
+		}
+		if (b.contains( "%" ))
+		{
+			b.chop(1);
+			b = QString::number( static_cast<int>( ( static_cast<double>( 255 * ScCLocale::toDoubleC(b) ) / 100.0 ) ) );
+		}
+		c = QColor(r.toInt(), g.toInt(), b.toInt());
+	}
+	else
+	{
+		QString rgbColor = s.trimmed();
+		if (rgbColor.startsWith( "#" ))
+		{
+			rgbColor = rgbColor.left(7);
+			c.setNamedColor( rgbColor );
+		}
+		else
+			c = parseColorN( rgbColor );
+	}
+	ScColor tmp;
+	tmp.fromQColor(c);
+	tmp.setSpotColor(false);
+	tmp.setRegistrationColor(false);
+	QString newColorName = "FromPUB"+c.name();
+	QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
+	if (fNam == newColorName)
+		importedColors->append(newColorName);
+	ret = fNam;
+	return ret;
+}
+
+void RawPainter::insertImage(PageItem* ite, QString imgExt, QByteArray &imageData)
+{
+	QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_pub_XXXXXX." + imgExt);
+	tempFile->setAutoRemove(false);
+	if (tempFile->open())
+	{
+		tempFile->write(imageData);
+		QString fileName = getLongPathName(tempFile->fileName());
+		tempFile->close();
+		ite->isTempFile = true;
+		ite->isInlineImage = true;
+		if (m_style["draw:red"] && m_style["draw:green"] && m_style["draw:blue"])
+		{
+			int r = qRound(m_style["draw:red"]->getDouble() * 255);
+			int g = qRound(m_style["draw:green"]->getDouble() * 255);
+			int b = qRound(m_style["draw:blue"]->getDouble() * 255);
+			QString colVal = QString("#%1%2%3").arg(r, 2, 16, QLatin1Char('0')).arg(g, 2, 16, QLatin1Char('0')).arg(b, 2, 16, QLatin1Char('0'));
+			QString efVal = parseColor(colVal);
+			efVal += "\n";
+			struct ImageEffect ef;
+			efVal += "100";
+			ef.effectCode = ScImage::EF_COLORIZE;
+			ef.effectParameters = efVal;
+			ite->effectsInUse.append(ef);
+		}
+		if (m_style["draw:luminance"])
+		{
+			double per = m_style["draw:luminance"]->getDouble();
+			struct ImageEffect ef;
+			ef.effectCode = ScImage::EF_BRIGHTNESS;
+			ef.effectParameters = QString("%1").arg(qRound((per - 0.5) * 255));
+			ite->effectsInUse.append(ef);
+		}
+		m_Doc->loadPict(fileName, ite);
+#if HAVE_REVENGE
+		if (m_style["librevenge:rotate"])
+		{
+			int rot = QString(m_style["librevenge:rotate"]->getStr().cstr()).toInt();
+			ite->setImageRotation(rot);
+			ite->AdjustPictScale();
+		}
+#else
+		if (m_style["libwpg:rotate"])
+		{
+			int rot = QString(m_style["libwpg:rotate"]->getStr().cstr()).toInt();
+			ite->setImageRotation(rot);
+			ite->AdjustPictScale();
+		}
+#endif
+	}
+	delete tempFile;
+}
 
 void RawPainter::applyShadow(PageItem* ite)
 {
@@ -1420,44 +2854,6 @@
 		return;
 	if(m_style["draw:shadow"] && m_style["draw:shadow"]->getStr() == "visible")
 	{
-/*		double xp = ite->xPos();
-		double yp = ite->yPos();
-		double xof = 0.0;
-		double yof = 0.0;
-		if (m_style["draw:shadow-offset-x"])
-			xof = valueAsPoint(m_style["draw:shadow-offset-x"]);
-		if (m_style["draw:shadow-offset-y"])
-			yof = valueAsPoint(m_style["draw:shadow-offset-y"]);
-		xp += xof;
-		yp += yof;
-		QString shadowColor = CurrColorFill;
-		double shadowTrans = 1.0;
-		if (m_style["draw:shadow-color"])
-		{
-			shadowColor = parseColor(QString(m_style["draw:shadow-color"]->getStr().cstr()));
-			if(m_style["draw:shadow-opacity"])
-				shadowTrans = 1.0 - qMin(1.0, qMax(fromPercentage(QString(m_style["draw:shadow-opacity"]->getStr().cstr())), 0.0));
-		}
-		int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xp, yp, ite->width(), ite->height(), 0, shadowColor, CommonStrings::None, true);
-		PageItem *nite = m_Doc->Items->takeAt(z);
-		nite->PoLine = ite->PoLine.copy();
-		nite->updateClip();
-		nite->setFillTransparency(shadowTrans);
-		nite->ClipEdited = true;
-		nite->FrameType = 3;
-		m_Doc->Items->takeAt(z-1);
-		Elements->takeAt(z-1);
-		m_Doc->Items->append(nite);
-		m_Doc->Items->append(ite);
-		Elements->append(nite);
-		Elements->append(ite);
-		if (groupStack.count() != 0)
-		{
-			groupStack.top().Items.takeLast();
-			groupStack.top().Items.append(nite);
-			groupStack.top().Items.append(ite);
-		}
-*/
 		double xof = 0.0;
 		double yof = 0.0;
 		if (m_style["draw:shadow-offset-x"])
@@ -1834,24 +3230,17 @@
 		qDebug() << "File " << QFile::encodeName(fn).data() << " does not exist" << endl;
 		return false;
 	}
-	
+#if HAVE_REVENGE
+	librevenge::RVNGFileStream input(QFile::encodeName(fn).data());
+#else
 	WPXFileStream input(QFile::encodeName(fn).data());
+#endif
 	if (!libmspub::MSPUBDocument::isSupported(&input))
 	{
 		qDebug() << "ERROR: Unsupported file format!";
 		return false;
 	}
-	RawPainter painter;
-	painter.m_Doc = m_Doc;
-	painter.baseX = baseX;
-	painter.baseY = baseY;
-	painter.docWidth = docWidth;
-	painter.docHeight = docHeight;
-	painter.importerFlags = importerFlags;
-	painter.Elements = &Elements;
-	painter.importedColors = &importedColors;
-	painter.importedPatterns = &importedPatterns;
-	painter.tmpSel = tmpSel;
+	RawPainter painter(m_Doc, baseX, baseY, docWidth, docHeight, importerFlags, &Elements, &importedColors, &importedPatterns, tmpSel);
 	libmspub::MSPUBDocument::parse(&input, &painter);
 	if (Elements.count() == 0)
 	{

Modified: trunk/Scribus/scribus/plugins/import/pub/importpub.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19222&path=/trunk/Scribus/scribus/plugins/import/pub/importpub.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pub/importpub.h (original)
+++ trunk/Scribus/scribus/plugins/import/pub/importpub.h Sat Jun 14 16:48:07 2014
@@ -20,20 +20,160 @@
 #include <QMultiMap>
 #include <QVector>
 
-#include <libmspub/libmspub.h>
-#include <libwpd-stream/libwpd-stream.h>
-#include <libwpd/libwpd.h>
-#include <libwpg/libwpg.h>
-
 class MultiProgressDialog;
 class ScribusDoc;
 class Selection;
 class TransactionSettings;
 
+#if HAVE_REVENGE
+	#include <librevenge/librevenge.h>
+	#include <librevenge-stream/librevenge-stream.h>
+	#include <librevenge-generators/librevenge-generators.h>
+	#include <libmspub/libmspub.h>
+
+struct RawPainterPrivate;
+
+class RawPainter : public librevenge::RVNGDrawingInterface
+{
+public:
+	RawPainter(ScribusDoc* Doc, double x, double y, double w, double h, int iflags, QList<PageItem*> *Elem, QStringList *iColors, QStringList *iPatterns, Selection* tSel);
+	~RawPainter();
+
+	void startDocument(const librevenge::RVNGPropertyList &propList);
+	void endDocument();
+	void setDocumentMetaData(const librevenge::RVNGPropertyList &propList);
+	void defineEmbeddedFont(const librevenge::RVNGPropertyList &propList);
+	void startPage(const librevenge::RVNGPropertyList &propList);
+	void endPage();
+	void startMasterPage(const librevenge::RVNGPropertyList &propList);
+	void endMasterPage();
+	void startLayer(const librevenge::RVNGPropertyList &propList);
+	void endLayer();
+	void startEmbeddedGraphics(const librevenge::RVNGPropertyList &propList);
+	void endEmbeddedGraphics();
+
+	void openGroup(const librevenge::RVNGPropertyList &propList);
+	void closeGroup();
+
+	void setStyle(const librevenge::RVNGPropertyList &propList);
+
+	void drawRectangle(const librevenge::RVNGPropertyList &propList);
+	void drawEllipse(const librevenge::RVNGPropertyList &propList);
+	void drawPolyline(const librevenge::RVNGPropertyList &propList);
+	void drawPolygon(const librevenge::RVNGPropertyList &propList);
+	void drawPath(const librevenge::RVNGPropertyList &propList);
+	void drawGraphicObject(const librevenge::RVNGPropertyList &propList);
+	void drawConnector(const librevenge::RVNGPropertyList &propList);
+	void startTextObject(const librevenge::RVNGPropertyList &propList);
+	void endTextObject();
+
+	void startTableObject(const librevenge::RVNGPropertyList &propList);
+	void openTableRow(const librevenge::RVNGPropertyList &propList);
+	void closeTableRow();
+	void openTableCell(const librevenge::RVNGPropertyList &propList);
+	void closeTableCell();
+	void insertCoveredTableCell(const librevenge::RVNGPropertyList &propList);
+	void endTableObject();
+
+	void openOrderedListLevel(const librevenge::RVNGPropertyList &propList);
+	void closeOrderedListLevel();
+
+	void openUnorderedListLevel(const librevenge::RVNGPropertyList &propList);
+	void closeUnorderedListLevel();
+	void openListElement(const librevenge::RVNGPropertyList &propList);
+	void closeListElement();
+
+	void defineParagraphStyle(const librevenge::RVNGPropertyList &propList);
+	void openParagraph(const librevenge::RVNGPropertyList &propList);
+	void closeParagraph();
+
+	void defineCharacterStyle(const librevenge::RVNGPropertyList &propList);
+	void openSpan(const librevenge::RVNGPropertyList &propList);
+	void closeSpan();
+
+	void openLink(const librevenge::RVNGPropertyList &propList);
+	void closeLink();
+
+	void insertTab();
+	void insertSpace();
+	void insertText(const librevenge::RVNGString &text);
+	void insertLineBreak();
+	void insertField(const librevenge::RVNGPropertyList &propList);
+	double valueAsPoint(const librevenge::RVNGProperty *prop);
+	QString constructFontName(QString fontBaseName, QString fontStyle);
+	double fromPercentage(const QString &s );
+	QColor  parseColorN( const QString &rgbColor );
+	QString parseColor( const QString &s );
+	void insertImage(PageItem* ite, QString imgExt, QByteArray &imageData);
+	void applyFill(PageItem* ite);
+	void applyShadow(PageItem* ite);
+	void applyFlip(PageItem* ite);
+	void recolorItem(PageItem* ite, QString efVal);
+	void finishItem(PageItem* ite);
+private:
+	RawPainterPrivate *m_pImpl;
+	ScribusDoc* m_Doc;
+	double baseX, baseY;
+	double docWidth;
+	double docHeight;
+	QList<PageItem*> *Elements;
+	QStringList *importedColors;
+	QStringList *importedPatterns;
+	Selection* tmpSel;
+	struct groupEntry
+	{
+		QList<PageItem*> Items;
+		FPointArray clip;
+	};
+	QStack<groupEntry> groupStack;
+	double LineW;
+	QString CurrColorFill;
+	QString CurrColorStroke;
+	double CurrStrokeShade;
+	double CurrFillShade;
+	double CurrStrokeTrans;
+	double CurrFillTrans;
+	FPointArray Coords;
+	bool fillrule;
+	double gradientAngle;
+	bool isGradient;
+	VGradient currentGradient;
+	QString gradColor1Str;
+	QColor gradColor1;
+	double gradColor1Trans;
+	QString gradColor2Str;
+	QColor gradColor2;
+	double gradColor2Trans;
+	QVector<double> dashArray;
+	Qt::PenJoinStyle lineJoin;
+	Qt::PenCapStyle lineEnd;
+	bool firstPage;
+	QString baseLayer;
+	int actPage;
+	librevenge::RVNGPropertyList m_style;
+	PageItem *actTextItem;
+	ParagraphStyle textStyle;
+	CharStyle textCharStyle;
+	double m_linespace;
+	double m_maxFontSize;
+	bool lineSpSet;
+	bool lineSpIsPT;
+	int importerFlags;
+	bool doProcessing;
+
+};
+
+#else
+	#include <libwpd-stream/libwpd-stream.h>
+	#include <libwpd/libwpd.h>
+	#include <libwpg/libwpg.h>
+	#include <libmspub/libmspub.h>
+
+
 class RawPainter : public libwpg::WPGPaintInterface
 {
 public:
-	RawPainter();
+	RawPainter(ScribusDoc* Doc, double x, double y, double w, double h, int iflags, QList<PageItem*> *Elem, QStringList *iColors, QStringList *iPatterns, Selection* tSel);
 	void startGraphics(const ::WPXPropertyList &propList);
 	void endGraphics();
 	void startLayer(const ::WPXPropertyList &propList);
@@ -115,6 +255,7 @@
 	bool lineSpIsPT;
 	bool doProcessing;
 };
+#endif
 
 //! \brief PUB importer plugin
 class PubPlug : public QObject
@@ -149,7 +290,7 @@
 
 private:
 	bool convert(QString fn);
-	
+
 	QList<PageItem*> Elements;
 	double baseX, baseY;
 	double docWidth;




More information about the scribus-commit mailing list