r24374 by jghali - #16142: Preliminary support for import PDF text as text <oliverthered>

scribus-commit scribus-commit at lists.scribus.net
Mon Jan 4 21:30:39 UTC 2021


Author: jghali
Date: Mon Jan  4 21:30:39 2021
New Revision: 24374

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24374
Log:
#16142: Preliminary support for import PDF text as text <oliverthered>

Added:
    trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp
    trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.h
Modified:
    trunk/Scribus/scribus/plugins/import/pdf/CMakeLists.txt
    trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
    trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp
    trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h
    trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui
    trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
    trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
    trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj
    trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj.filters
    trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj
    trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj.filters
    trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj
    trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj.filters

Modified: trunk/Scribus/scribus/plugins/import/pdf/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/scribus/plugins/import/pdf/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/CMakeLists.txt	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/CMakeLists.txt	Mon Jan  4 21:30:39 2021
@@ -17,12 +17,13 @@
 
 set(IMPORTPDF_PLUGIN_SOURCES
 	importpdf.cpp
-	importpdfplugin.cpp
+	importpdfplugin.cpp
 	pdfimportoptions.cpp
-	slaoutput.cpp
-)
-
-if(HAVE_POPPLER)
+	pdftextrecognition.cpp
+	slaoutput.cpp
+)
+
+if(HAVE_POPPLER)
 	if(HAVE_LCMS1)
 		add_definitions(-DUSE_CMS)
 	endif()

Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp	Mon Jan  4 21:30:39 2021
@@ -30,6 +30,7 @@
 
 #include "importpdf.h"
 #include "importpdfconfig.h"
+#include "pdftextrecognition.h"
 #include "slaoutput.h"
 
 #include "commonstrings.h"
@@ -430,6 +431,7 @@
 				else if (getCBox(Art_Box, 1) != mediaRect)
 					boxesAreDifferent = true;
 				bool cropped = false;
+				bool importTextAsVectors = true;
 				int contentRect = Media_Box;
 				if (((interactive) || (importerFlags & LoadSavePlugin::lfCreateDoc)) && ((lastPage > 1) || boxesAreDifferent))
 				{
@@ -455,6 +457,7 @@
 					cropped = optImp->croppingEnabled();
 					if (!cropped)
 						crop = cropped;
+					importTextAsVectors = optImp->getImportAsVectors();
 					// When displaying  pages slices, we should always set useMediaBox to true
 					// in order to use MediaBox (x, y) as coordinate system
 					if (contentRect != Media_Box)
@@ -468,7 +471,12 @@
 				}
 				parsePagesString(pageString, &pageNs, lastPage);
 				firstPage = pageNs[0];
-				SlaOutputDev *dev = new SlaOutputDev(m_Doc, &Elements, &importedColors, importerFlags);
+				SlaOutputDev* dev = {};
+				if (importTextAsVectors)
+					dev = new SlaOutputDev(m_Doc, &Elements, &importedColors, importerFlags);
+				else
+					dev = new PdfTextOutputDev(m_Doc, &Elements, &importedColors, importerFlags);
+
 				if (dev->isOk())
 				{
 					OCGs* ocg = pdfDoc->getOptContentConfig();
@@ -895,7 +903,7 @@
 {
 	if (!m_pdfDoc)
 		return QImage();
-	
+
 	double h = m_pdfDoc->getPageMediaHeight(pgNum);
 	double w = m_pdfDoc->getPageMediaWidth(pgNum);
 	double scale = qMin(height / h, width / w);

Modified: trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp	Mon Jan  4 21:30:39 2021
@@ -1,134 +1,141 @@
-/*
-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 "pdfimportoptions.h"
-#include "ui_pdfimportoptions.h"
-#include "importpdf.h"
-#include "ui/createrange.h"
-#include "usertaskstructs.h"
-#include "iconmanager.h"
-
-PdfImportOptions::PdfImportOptions(QWidget *parent) : QDialog(parent), ui(new Ui::PdfImportOptions)
-{
-	ui->setupUi(this);
-	ui->pageSelectButton->setIcon(IconManager::instance().loadIcon("ellipsis.png"));
-	m_plugin = nullptr;
-	m_maxPage = 0;
-	m_resized = false;
-}
-
-PdfImportOptions::~PdfImportOptions()
-{
-	delete ui;
-}
-
-void PdfImportOptions::resizeEvent(QResizeEvent *e)
-{
-	m_resized = true;
-	QDialog::resizeEvent(e);
-}
-
-void PdfImportOptions::paintEvent(QPaintEvent *e)
-{
-	if (m_resized)
-		updatePreview(ui->pgSelect->getCurrentPage());
-	m_resized = false;
-	QDialog::paintEvent(e);
-}
-
-QString PdfImportOptions::getPagesString()
-{
-	if (ui->allPages->isChecked())
-		return "*";
-	if (ui->singlePage->isChecked())
-		return QString("%1").arg(ui->spinBox->value());
-	return ui->pageRangeString->text();
-}
-
-int PdfImportOptions::getCropBox()
-{
-	int ret = 0;
-	if (ui->cropGroup->isChecked())
-		ret = ui->cropBox->currentIndex();
-	return ret;
-}
-
-bool PdfImportOptions::croppingEnabled()
-{
-	return ui->cropGroup->isChecked();
-}
-
-void PdfImportOptions::setUpOptions(const QString& fileName, int actPage, int numPages, bool interact, bool cropPossible, PdfPlug* plug)
-{
-	m_plugin = plug;
-	ui->fileLabel->setText(fileName);
-	ui->spinBox->setMaximum(numPages);
-	ui->spinBox->setMinimum(actPage);
-	ui->spinBox->setValue(actPage);
-	ui->cropGroup->setVisible(cropPossible);
-	ui->cropGroup->setChecked(cropPossible);
-	ui->cropBox->setCurrentIndex(3); // Use CropBox by default
-	if (interact)
-	{
-		ui->allPages->setChecked(false);
-		ui->selectedPages->setChecked(false);
-		ui->allPages->setEnabled(false);
-		ui->selectedPages->setEnabled(false);
-		ui->singlePage->setChecked(true);
-		ui->spinBox->setEnabled(true);
-	}
-	else
-		ui->allPages->setChecked(true);
-	ui->pageRangeString->setText("");
-	ui->pgSelect->setMaximum(numPages);
-	ui->pgSelect->setGUIForPage(actPage - 1);
-	m_maxPage = numPages;
-	updatePreview(actPage);
-	connect(ui->pgSelect, SIGNAL(pageChanged(int)), this, SLOT(updatePreview(int)));
-	connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFromSpinBox(int)));
-	connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updatePreview(int)));
-	connect(ui->pageSelectButton, SIGNAL(clicked()), this, SLOT(createPageNumberRange()));
-	connect(ui->cropGroup, SIGNAL(clicked()), this, SLOT(updateFromCrop()));
-	connect(ui->cropBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateFromCrop()));
-}
-
-void PdfImportOptions::updateFromCrop()
-{
-	updatePreview(ui->pgSelect->getCurrentPage());
-}
-
-void PdfImportOptions::updateFromSpinBox(int pg)
-{
-	ui->pgSelect->setGUIForPage(pg - 1);
-}
-
-void PdfImportOptions::updatePreview(int pg)
-{
-	if (!m_plugin)
-		return;
-
-	int cb = 0;
-	if (ui->cropGroup->isChecked())
-		cb =  ui->cropBox->currentIndex();
-	QImage img = m_plugin->readPreview(pg, ui->previewWidget->width(), ui->previewWidget->height(), cb);
-	ui->previewWidget->setPixmap(QPixmap::fromImage(img));
-	disconnect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFromSpinBox(int)));
-	disconnect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updatePreview(int)));
-	ui->spinBox->setValue(pg);
-	connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFromSpinBox(int)));
-	connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updatePreview(int)));
-}
-
-void PdfImportOptions::createPageNumberRange()
-{
-	CreateRange cr(ui->pageRangeString->text(), m_maxPage, this);
-	if (cr.exec())
-	{
-		CreateRangeData crData;
-		cr.getCreateRangeData(crData);
-		ui->pageRangeString->setText(crData.pageRange);
-	}
-}
+/*
+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 "pdfimportoptions.h"
+#include "ui_pdfimportoptions.h"
+#include "importpdf.h"
+#include "ui/createrange.h"
+#include "usertaskstructs.h"
+#include "iconmanager.h"
+
+PdfImportOptions::PdfImportOptions(QWidget *parent) : QDialog(parent), ui(new Ui::PdfImportOptions)
+{
+	ui->setupUi(this);
+	ui->pageSelectButton->setIcon(IconManager::instance().loadIcon("ellipsis.png"));
+	m_plugin = nullptr;
+	m_maxPage = 0;
+	m_resized = false;
+}
+
+PdfImportOptions::~PdfImportOptions()
+{
+	delete ui;
+}
+
+void PdfImportOptions::resizeEvent(QResizeEvent *e)
+{
+	m_resized = true;
+	QDialog::resizeEvent(e);
+}
+
+void PdfImportOptions::paintEvent(QPaintEvent *e)
+{
+	if (m_resized)
+		updatePreview(ui->pgSelect->getCurrentPage());
+	m_resized = false;
+	QDialog::paintEvent(e);
+}
+
+QString PdfImportOptions::getPagesString()
+{
+	if (ui->allPages->isChecked())
+		return "*";
+	if (ui->singlePage->isChecked())
+		return QString("%1").arg(ui->spinBox->value());
+	return ui->pageRangeString->text();
+}
+
+int PdfImportOptions::getCropBox()
+{
+	int ret = 0;
+	if (ui->cropGroup->isChecked())
+		ret = ui->cropBox->currentIndex();
+	return ret;
+}
+
+bool PdfImportOptions::croppingEnabled()
+{
+	return ui->cropGroup->isChecked();
+}
+
+bool PdfImportOptions::getImportAsVectors()
+{
+	return ui->textAsVectors->isChecked();
+}
+
+void PdfImportOptions::setUpOptions(const QString& fileName, int actPage, int numPages, bool interact, bool cropPossible, PdfPlug* plug)
+{
+	m_plugin = plug;
+	ui->fileLabel->setText(fileName);
+	ui->spinBox->setMaximum(numPages);
+	ui->spinBox->setMinimum(actPage);
+	ui->spinBox->setValue(actPage);
+	ui->cropGroup->setVisible(cropPossible);
+	ui->cropGroup->setChecked(cropPossible);
+	ui->cropBox->setCurrentIndex(3); // Use CropBox by default
+	ui->textAsVectors->setChecked(true);
+	ui->textAsText->setChecked(false);
+	if (interact)
+	{
+		ui->allPages->setChecked(false);
+		ui->selectedPages->setChecked(false);
+		ui->allPages->setEnabled(false);
+		ui->selectedPages->setEnabled(false);
+		ui->singlePage->setChecked(true);
+		ui->spinBox->setEnabled(true);
+	}
+	else
+		ui->allPages->setChecked(true);
+	ui->pageRangeString->setText("");
+	ui->pgSelect->setMaximum(numPages);
+	ui->pgSelect->setGUIForPage(actPage - 1);
+	m_maxPage = numPages;
+	updatePreview(actPage);
+	connect(ui->pgSelect, SIGNAL(pageChanged(int)), this, SLOT(updatePreview(int)));
+	connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFromSpinBox(int)));
+	connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updatePreview(int)));
+	connect(ui->pageSelectButton, SIGNAL(clicked()), this, SLOT(createPageNumberRange()));
+	connect(ui->cropGroup, SIGNAL(clicked()), this, SLOT(updateFromCrop()));
+	connect(ui->cropBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateFromCrop()));
+}
+
+void PdfImportOptions::updateFromCrop()
+{
+	updatePreview(ui->pgSelect->getCurrentPage());
+}
+
+void PdfImportOptions::updateFromSpinBox(int pg)
+{
+	ui->pgSelect->setGUIForPage(pg - 1);
+}
+
+void PdfImportOptions::updatePreview(int pg)
+{
+	if (!m_plugin)
+		return;
+
+	int cb = 0;
+	if (ui->cropGroup->isChecked())
+		cb =  ui->cropBox->currentIndex();
+	QImage img = m_plugin->readPreview(pg, ui->previewWidget->width(), ui->previewWidget->height(), cb);
+	ui->previewWidget->setPixmap(QPixmap::fromImage(img));
+	disconnect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFromSpinBox(int)));
+	disconnect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updatePreview(int)));
+	ui->spinBox->setValue(pg);
+	connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFromSpinBox(int)));
+	connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updatePreview(int)));
+}
+
+void PdfImportOptions::createPageNumberRange()
+{
+	CreateRange cr(ui->pageRangeString->text(), m_maxPage, this);
+	if (cr.exec())
+	{
+		CreateRangeData crData;
+		cr.getCreateRangeData(crData);
+		ui->pageRangeString->setText(crData.pageRange);
+	}
+}

Modified: trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h	Mon Jan  4 21:30:39 2021
@@ -1,46 +1,48 @@
-/*
-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 PDFIMPORTOPTIONS_H
-#define PDFIMPORTOPTIONS_H
-
-#include <QDialog>
-
-namespace Ui {
-class PdfImportOptions;
-}
-class PdfPlug;
-
-class PdfImportOptions : public QDialog
-{
-	Q_OBJECT
-	
-public:
-	explicit PdfImportOptions(QWidget* parent = nullptr);
-	~PdfImportOptions();
-	void setUpOptions(const QString& fileName, int actPage, int numPages, bool interact, bool cropPossible, PdfPlug* plug);
-	QString getPagesString();
-	int getCropBox();
-	bool croppingEnabled();
-	void paintEvent(QPaintEvent *e);
-
-protected:
-	void resizeEvent(QResizeEvent *e);
-
-public slots:
-	void updateFromCrop();
-	void updateFromSpinBox(int pg);
-	void updatePreview(int pg);
-	void createPageNumberRange();
-
-private:
-	Ui::PdfImportOptions *ui;
-	PdfPlug* m_plugin;
-	int m_maxPage;
-	bool m_resized;
-};
-
-#endif // PDFIMPORTOPTIONS_H
+/*
+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 PDFIMPORTOPTIONS_H
+#define PDFIMPORTOPTIONS_H
+
+#include <QDialog>
+
+namespace Ui {
+class PdfImportOptions;
+}
+class PdfPlug;
+
+class PdfImportOptions : public QDialog
+{
+	Q_OBJECT
+	
+public:
+	explicit PdfImportOptions(QWidget* parent = nullptr);
+	~PdfImportOptions();
+
+	void setUpOptions(const QString& fileName, int actPage, int numPages, bool interact, bool cropPossible, PdfPlug* plug);
+	QString getPagesString();
+	int getCropBox();
+	bool croppingEnabled();
+	bool getImportAsVectors();
+
+protected:
+	void paintEvent(QPaintEvent *e) override;
+	void resizeEvent(QResizeEvent *e) override;
+
+public slots:
+	void updateFromCrop();
+	void updateFromSpinBox(int pg);
+	void updatePreview(int pg);
+	void createPageNumberRange();
+
+private:
+	Ui::PdfImportOptions *ui;
+	PdfPlug* m_plugin;
+	int m_maxPage;
+	bool m_resized;
+};
+
+#endif // PDFIMPORTOPTIONS_H

Modified: trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui	Mon Jan  4 21:30:39 2021
@@ -176,6 +176,51 @@
         </widget>
        </item>
        <item>
+        <widget class="QGroupBox" name="groupBox_2">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="title">
+          <string/>
+         </property>
+         <layout class="QVBoxLayout" name="verticalLayout_8">
+          <item>
+           <widget class="QRadioButton" name="textAsVectors">
+            <property name="enabled">
+             <bool>true</bool>
+            </property>
+            <property name="text">
+             <string>Import Text As Vectors</string>
+            </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QRadioButton" name="textAsText">
+            <property name="text">
+             <string>Import Text As Text</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="label_2">
+            <property name="text">
+             <string>Note: importing text as text may significantly alter PDF visual aspect</string>
+            </property>
+            <property name="wordWrap">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
         <spacer name="verticalSpacer">
          <property name="orientation">
           <enum>Qt::Vertical</enum>

Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp	Mon Jan  4 21:30:39 2021
@@ -20,6 +20,10 @@
 #include "util_math.h"
 #include <tiffio.h>
 
+//#ifndef DEBUG_TEXT_IMPORT
+//	#define DEBUG_TEXT_IMPORT
+//#endif
+
 namespace
 {
 	// Compute the intersection of two paths while considering the fillrule of each of them.
@@ -129,45 +133,45 @@
 
 AnoOutputDev::~AnoOutputDev()
 {
-	delete m_fontName;
-	delete m_itemText;
+	delete fontName;
+	delete itemText;
 }
 
 AnoOutputDev::AnoOutputDev(ScribusDoc* doc, QStringList *importedColors)
 {
 	m_doc = doc;
 	m_importedColors = importedColors;
-	CurrColorText = "Black";
-	CurrColorFill = CommonStrings::None;
-	CurrColorStroke = CommonStrings::None;
+	currColorText = "Black";
+	currColorFill = CommonStrings::None;
+	currColorStroke = CommonStrings::None;
 }
 
 void AnoOutputDev::eoFill(GfxState *state)
 {
 	int shade = 100;
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
+	currColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 }
 
 void AnoOutputDev::fill(GfxState *state)
 {
 	int shade = 100;
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
+	currColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 }
 
 void AnoOutputDev::stroke(GfxState *state)
 {
 	int shade = 100;
-	CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &shade);
+	currColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &shade);
 }
 
 void AnoOutputDev::drawString(GfxState *state, POPPLER_CONST GooString *s)
 {
 	int shade = 100;
-	CurrColorText = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
-	m_fontSize = state->getFontSize();
+	currColorText = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
+	fontSize = state->getFontSize();
 	if (state->getFont())
-		m_fontName = state->getFont()->getName()->copy();
-	m_itemText = s->copy();
+		fontName = state->getFont()->getName()->copy();
+	itemText = s->copy();
 }
 
 QString AnoOutputDev::getColor(GfxColorSpace *color_space, POPPLER_CONST_070 GfxColor *color, int *shade)
@@ -277,8 +281,8 @@
 	m_Elements = Elements;
 	pushGroup();
 	m_importedColors = importedColors;
-	CurrColorStroke = "Black";
-	CurrColorFill = "Black";
+	m_currColorStroke = "Black";
+	m_currColorFill = "Black";
 	tmpSel = new Selection(m_doc, false);
 	importerFlags = flags;
 	currentLayer = m_doc->activeLayer();
@@ -670,47 +674,47 @@
 				if (bgCol)
 				{
 					bgFound = true;
-					CurrColorFill = getAnnotationColor(bgCol);
+					m_currColorFill = getAnnotationColor(bgCol);
 				}
 				else
-					CurrColorFill = CommonStrings::None;
+					m_currColorFill = CommonStrings::None;
 				POPPLER_CONST AnnotColor *fgCol = achar->getBorderColor();
 				if (fgCol)
 				{
 					fgFound = true;
-					CurrColorStroke = getAnnotationColor(fgCol);
+					m_currColorStroke = getAnnotationColor(fgCol);
 				}
 				else
 				{
 					fgCol = achar->getBackColor();
 					if (fgCol)
-						CurrColorStroke = getAnnotationColor(fgCol);
+						m_currColorStroke = getAnnotationColor(fgCol);
 					else
-						CurrColorStroke = CommonStrings::None;
-				}
-			}
-			QString CurrColorText = "Black";
+						m_currColorStroke = CommonStrings::None;
+				}
+			}
+			QString m_currColorText = "Black";
 			double fontSize = 12;
 			QString fontName = "";
 			QString itemText = "";
 			AnnotAppearance *apa = annota->getAppearStreams();
 			if (apa || !achar)
 			{
-				AnoOutputDev *Adev = new AnoOutputDev(m_doc, m_importedColors);
-				Gfx *gfx = new Gfx(pdfDoc, Adev, pdfDoc->getPage(m_actPage)->getResourceDict(), annota->getRect(), nullptr);
+				AnoOutputDev *annotOutDev = new AnoOutputDev(m_doc, m_importedColors);
+				Gfx *gfx = new Gfx(pdfDoc, annotOutDev, pdfDoc->getPage(m_actPage)->getResourceDict(), annota->getRect(), nullptr);
 				ano->draw(gfx, false);
 				if (!bgFound)
-					CurrColorFill = Adev->CurrColorFill;
+					m_currColorFill = annotOutDev->currColorFill;
 				if (!fgFound)
-					CurrColorStroke = Adev->CurrColorStroke;
-				CurrColorText = Adev->CurrColorText;
-				fontSize = Adev->m_fontSize;
-				fontName = UnicodeParsedString(Adev->m_fontName);
-				itemText = UnicodeParsedString(Adev->m_itemText);
+					m_currColorStroke = annotOutDev->currColorStroke;
+				m_currColorText = annotOutDev->currColorText;
+				fontSize = annotOutDev->fontSize;
+				fontName = UnicodeParsedString(annotOutDev->fontName);
+				itemText = UnicodeParsedString(annotOutDev->itemText);
 				delete gfx;
-				delete Adev;
-			}
-			int z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Rectangle, xCoor, yCoor, width, height, 0, CurrColorFill, CommonStrings::None);
+				delete annotOutDev;
+			}
+			int z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Rectangle, xCoor, yCoor, width, height, 0, m_currColorFill, CommonStrings::None);
 			PageItem *ite = m_doc->Items->at(z);
 			int flg = annota->getFlags();
 			if (!(flg & 16))
@@ -742,7 +746,7 @@
 				else if (bsty == AnnotBorder::borderUnderlined)
 					bsty = 2;
 				ite->annotation().setBorderStyle(bsty);
-				ite->annotation().setBorderColor(CurrColorStroke);
+				ite->annotation().setBorderColor(m_currColorStroke);
 				ite->annotation().setBorderWidth(qRound(brd->getWidth()));
 			}
 			else
@@ -778,12 +782,12 @@
 				ite->annotation().setVis(3);
 			if (wtyp == Annotation::Button)
 			{
-				ite->setFillColor(CurrColorFill);
+				ite->setFillColor(m_currColorFill);
 				if (achar)
 					ite->itemText.insertChars(UnicodeParsedString(achar->getNormalCaption()));
 				else
 					ite->itemText.insertChars(itemText);
-				applyTextStyle(ite, fontName, CurrColorText, fontSize);
+				applyTextStyle(ite, fontName, m_currColorText, fontSize);
 				ite->annotation().addToFlag(Annotation::Flag_PushButton);
 				FormWidgetButton *btn = (FormWidgetButton*)fm;
 				if (!btn->isReadOnly())
@@ -796,7 +800,7 @@
 				if (btn)
 				{
 					ite->itemText.insertChars(UnicodeParsedString(btn->getContent()));
-					applyTextStyle(ite, fontName, CurrColorText, fontSize);
+					applyTextStyle(ite, fontName, m_currColorText, fontSize);
 					ite->itemText.trim();
 					if (btn->isMultiline())
 						ite->annotation().addToFlag(Annotation::Flag_Multiline);
@@ -859,7 +863,7 @@
 						}
 						ite->itemText.insertChars(inh);
 					}
-					applyTextStyle(ite, fontName, CurrColorText, fontSize);
+					applyTextStyle(ite, fontName, m_currColorText, fontSize);
 					if (!btn->isReadOnly())
 						ite->annotation().addToFlag(Annotation::Flag_Edit);
 					handleActions(ite, ano);
@@ -1594,14 +1598,14 @@
 
 void SlaOutputDev::updateFillColor(GfxState *state)
 {
-	CurrFillShade = 100;
-	CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade);
+	m_currFillShade = 100;
+	m_currColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &m_currFillShade);
 }
 
 void SlaOutputDev::updateStrokeColor(GfxState *state)
 {
-	CurrStrokeShade = 100;
-	CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &CurrStrokeShade);
+	m_currStrokeShade = 100;
+	m_currColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &m_currStrokeShade);
 }
 
 void SlaOutputDev::clip(GfxState *state)
@@ -1654,10 +1658,10 @@
 	if ((m_Elements->count() != 0) && (output == Coords))			// Path is the same as in last fill
 	{
 		PageItem* ite = m_Elements->last();
-		ite->setLineColor(CurrColorStroke);
-		ite->setLineShade(CurrStrokeShade);
-		ite->setLineEnd(PLineEnd);
-		ite->setLineJoin(PLineJoin);
+		ite->setLineColor(m_currColorStroke);
+		ite->setLineShade(m_currStrokeShade);
+		ite->setLineEnd(m_lineEnd);
+		ite->setLineJoin(m_lineJoin);
 		ite->setLineWidth(state->getTransformedLineWidth());
 		ite->setDashes(DashValues);
 		ite->setDashOffset(DashOffset);
@@ -1672,12 +1676,12 @@
 		FPoint wh = out.widthHeight();
 		if ((out.size() > 3) && ((wh.x() != 0.0) || (wh.y() != 0.0)))
 		{
-			CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &CurrStrokeShade);
+			m_currColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &m_currStrokeShade);
 			int z;
 			if (pathIsClosed)
-				z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, CurrColorStroke);
+				z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, m_currColorStroke);
 			else
-				z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, CurrColorStroke);
+				z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, m_currColorStroke);
 			PageItem* ite = m_doc->Items->at(z);
 			ite->PoLine = out.copy();
 			ite->ClipEdited = true;
@@ -1689,13 +1693,13 @@
 				PageItem* lItem = m_Elements->last();
 				if ((lItem->lineColor() == CommonStrings::None) && (lItem->PoLine == ite->PoLine))
 				{
-					lItem->setLineColor(CurrColorStroke);
+					lItem->setLineColor(m_currColorStroke);
 					lItem->setLineWidth(state->getTransformedLineWidth());
-					lItem->setLineShade(CurrStrokeShade);
+					lItem->setLineShade(m_currStrokeShade);
 					lItem->setLineTransparency(1.0 - state->getStrokeOpacity());
 					lItem->setLineBlendmode(getBlendMode(state));
-					lItem->setLineEnd(PLineEnd);
-					lItem->setLineJoin(PLineJoin);
+					lItem->setLineEnd(m_lineEnd);
+					lItem->setLineJoin(m_lineJoin);
 					lItem->setDashes(DashValues);
 					lItem->setDashOffset(DashOffset);
 					lItem->setTextFlowMode(PageItem::TextFlowDisabled);
@@ -1703,11 +1707,11 @@
 				}
 				else
 				{
-					ite->setLineShade(CurrStrokeShade);
+					ite->setLineShade(m_currStrokeShade);
 					ite->setLineTransparency(1.0 - state->getStrokeOpacity());
 					ite->setLineBlendmode(getBlendMode(state));
-					ite->setLineEnd(PLineEnd);
-					ite->setLineJoin(PLineJoin);
+					ite->setLineEnd(m_lineEnd);
+					ite->setLineJoin(m_lineJoin);
 					ite->setDashes(DashValues);
 					ite->setDashOffset(DashOffset);
 					ite->setTextFlowMode(PageItem::TextFlowDisabled);
@@ -1718,11 +1722,11 @@
 			}
 			else
 			{
-				ite->setLineShade(CurrStrokeShade);
+				ite->setLineShade(m_currStrokeShade);
 				ite->setLineTransparency(1.0 - state->getStrokeOpacity());
 				ite->setLineBlendmode(getBlendMode(state));
-				ite->setLineEnd(PLineEnd);
-				ite->setLineJoin(PLineJoin);
+				ite->setLineEnd(m_lineEnd);
+				ite->setLineJoin(m_lineJoin);
 				ite->setDashes(DashValues);
 				ite->setDashOffset(DashOffset);
 				ite->setTextFlowMode(PageItem::TextFlowDisabled);
@@ -1773,17 +1777,17 @@
 	QRectF bbox = clippedPath.boundingRect();
 	if (!clippedPath.isEmpty() && !bbox.isNull())
 	{
-		CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade);
+		m_currColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &m_currFillShade);
 		int z;
 		if (pathIsClosed)
-			z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, CurrColorFill, CommonStrings::None);
+			z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, m_currColorFill, CommonStrings::None);
 		else
-			z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, CurrColorFill, CommonStrings::None);
+			z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, m_currColorFill, CommonStrings::None);
 		PageItem* ite = m_doc->Items->at(z);
 		ite->PoLine.fromQPainterPath(clippedPath, true);
 		ite->ClipEdited = true;
 		ite->FrameType = 3;
-		ite->setFillShade(CurrFillShade);
+		ite->setFillShade(m_currFillShade);
 		ite->setLineShade(100);
 		ite->setRotation(-angle);
 		// Only the new path has to be interpreted according to fillRule. QPainterPath
@@ -1792,8 +1796,8 @@
 		ite->setFillEvenOdd(clippedPath.fillRule() == Qt::OddEvenFill);
 		ite->setFillTransparency(1.0 - state->getFillOpacity());
 		ite->setFillBlendmode(getBlendMode(state));
-		ite->setLineEnd(PLineEnd);
-		ite->setLineJoin(PLineJoin);
+		ite->setLineEnd(m_lineEnd);
+		ite->setLineJoin(m_lineJoin);
 		ite->setWidthHeight(bbox.width(),bbox.height());
 		ite->setTextFlowMode(PageItem::TextFlowDisabled);
 		m_doc->adjustItemSize(ite);
@@ -1898,7 +1902,7 @@
 	output += QString("Z");
 	pathIsClosed = true;
 	Coords = output;
-	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), bb.width(), bb.height(), 0, CurrColorFill, CommonStrings::None);
+	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), bb.width(), bb.height(), 0, m_currColorFill, CommonStrings::None);
 	PageItem* ite = m_doc->Items->at(z);
 	if (checkClip())
 	{
@@ -1908,12 +1912,12 @@
 	ite->setRotation(-angle);
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(CurrFillShade);
+	ite->setFillShade(m_currFillShade);
 	ite->setLineShade(100);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
 	ite->setFillBlendmode(getBlendMode(state));
-	ite->setLineEnd(PLineEnd);
-	ite->setLineJoin(PLineJoin);
+	ite->setLineEnd(m_lineEnd);
+	ite->setLineJoin(m_lineJoin);
 	ite->setTextFlowMode(PageItem::TextFlowDisabled);
 	ite->GrType = 6;
 	if (!shading->getExtend0() || !shading->getExtend1())
@@ -2017,7 +2021,7 @@
 	output += QString("Z");
 	pathIsClosed = true;
 	Coords = output;
-	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None);
+	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, m_currColorFill, CommonStrings::None);
 	PageItem* ite = m_doc->Items->at(z);
 	if (checkClip())
 	{
@@ -2029,12 +2033,12 @@
 	}
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(CurrFillShade);
+	ite->setFillShade(m_currFillShade);
 	ite->setLineShade(100);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
 	ite->setFillBlendmode(getBlendMode(state));
-	ite->setLineEnd(PLineEnd);
-	ite->setLineJoin(PLineJoin);
+	ite->setLineEnd(m_lineEnd);
+	ite->setLineJoin(m_lineJoin);
 	ite->setTextFlowMode(PageItem::TextFlowDisabled);
 	ite->GrType = 7;
 	if (!shading->getExtend0() || !shading->getExtend1())
@@ -2079,17 +2083,17 @@
 	Coords = output;
 	const double *ctm = state->getCTM();
 	m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
-	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None);
+	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, m_currColorFill, CommonStrings::None);
 	PageItem* ite = m_doc->Items->at(z);
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(CurrFillShade);
+	ite->setFillShade(m_currFillShade);
 	ite->setLineShade(100);
 	ite->setFillEvenOdd(false);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
 	ite->setFillBlendmode(getBlendMode(state));
-	ite->setLineEnd(PLineEnd);
-	ite->setLineJoin(PLineJoin);
+	ite->setLineEnd(m_lineEnd);
+	ite->setLineJoin(m_lineJoin);
 	ite->setTextFlowMode(PageItem::TextFlowDisabled);
 	m_doc->adjustItemSize(ite);
 	m_Elements->append(ite);
@@ -2159,17 +2163,17 @@
 	Coords = output;
 	const double *ctm = state->getCTM();
 	m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
-	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None);
+	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, m_currColorFill, CommonStrings::None);
 	PageItem* ite = m_doc->Items->at(z);
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(CurrFillShade);
+	ite->setFillShade(m_currFillShade);
 	ite->setLineShade(100);
 	ite->setFillEvenOdd(false);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
 	ite->setFillBlendmode(getBlendMode(state));
-	ite->setLineEnd(PLineEnd);
-	ite->setLineJoin(PLineJoin);
+	ite->setLineEnd(m_lineEnd);
+	ite->setLineJoin(m_lineJoin);
 	ite->setTextFlowMode(PageItem::TextFlowDisabled);
 	m_doc->adjustItemSize(ite);
 	m_Elements->append(ite);
@@ -2379,7 +2383,7 @@
 	output += QString("Z");
 	pathIsClosed = true;
 	Coords = output;
-	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None);
+	int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, m_currColorFill, CommonStrings::None);
 	ite = m_doc->Items->at(z);
 
 	m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
@@ -2398,12 +2402,12 @@
 	}
 	ite->ClipEdited = true;
 	ite->FrameType = 3;
-	ite->setFillShade(CurrFillShade);
+	ite->setFillShade(m_currFillShade);
 	ite->setLineShade(100);
 	ite->setFillTransparency(1.0 - state->getFillOpacity());
 	ite->setFillBlendmode(getBlendMode(state));
-	ite->setLineEnd(PLineEnd);
-	ite->setLineJoin(PLineJoin);
+	ite->setLineEnd(m_lineEnd);
+	ite->setLineJoin(m_lineJoin);
 	ite->setTextFlowMode(PageItem::TextFlowDisabled);
 	ite->GrType = 8;
 	ite->setPattern(id);
@@ -2471,7 +2475,7 @@
 			}
 		}
 	}
-	QColor backColor = ScColorEngine::getShadeColorProof(m_doc->PageColors[CurrColorFill], m_doc, CurrFillShade);
+	QColor backColor = ScColorEngine::getShadeColorProof(m_doc->PageColors[m_currColorFill], m_doc, m_currFillShade);
 	QImage res = QImage(width, height, QImage::Format_ARGB32);
 	res.fill(backColor.rgb());
 	unsigned char cc, cm, cy, ck;
@@ -2570,9 +2574,9 @@
 			t++;
 		}
 	}
-	
+
 	createImageFrame(res, state, 3);
-	
+
 	delete imgStr;
 	delete[] buffer;
 	delete image;
@@ -2639,9 +2643,9 @@
 			t++;
 		}
 	}
-	
+
 	createImageFrame(res, state, colorMap->getNumPixelComps());
-	
+
 	delete imgStr;
 	delete[] buffer;
 	delete image;
@@ -2761,7 +2765,7 @@
 
     // Determine the width and height of the image by undoing the rotation part
 	// of the CTM and applying the result to the unit square.
-	QTransform without_rotation; 
+	QTransform without_rotation;
 	without_rotation = m_ctm * without_rotation.rotate(angle);
 	QRectF trect_wr = without_rotation.mapRect(QRectF(0, 0, 1, 1));
 
@@ -3039,13 +3043,13 @@
 	tmpBuf = nullptr;
 	fontLoc = nullptr;
 
-	if (!(gfxFont = state->getFont())) {
+	gfxFont = state->getFont();
+	if (!gfxFont)
 		goto err1;
-	}
+
 	fontType = gfxFont->getType();
-	if (fontType == fontType3) {
+	if (fontType == fontType3)
 		goto err1;
-	}
 
 	// check the font file cache
 	id = new SlaOutFontFileID(gfxFont->getID());
@@ -3249,7 +3253,7 @@
 		fontsrc->unref();
 }
 
-void SlaOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, POPPLER_CONST_082 Unicode *u, int uLen)
+void SlaOutputDev::drawChar(GfxState* state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, POPPLER_CONST_082 Unicode* u, int uLen)
 {
 //	qDebug() << "SlaOutputDev::drawChar code:" << code << "bytes:" << nBytes << "Unicode:" << u << "ulen:" << uLen << "render:" << state->getRender();
 	double x1, y1, x2, y2;
@@ -3295,11 +3299,11 @@
 					qPath.cubicTo(x1,y1,x2,y2,x3,y3);
 				}
 				else
-					qPath.lineTo(x1,y1);
+					qPath.lineTo(x1, y1);
 				if (f & splashPathLast)
 					qPath.closeSubpath();
 			}
-			const double *ctm = state->getCTM();
+			const double * ctm = state->getCTM();
 			m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
 			double xCoor = m_doc->currentPage()->xOffset();
 			double yCoor = m_doc->currentPage()->yOffset();
@@ -3318,37 +3322,16 @@
 			{
 				int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, CommonStrings::None, CommonStrings::None);
 				PageItem* ite = m_doc->Items->at(z);
+
+				// todo: merge this between vector and text implementations.
 				QTransform mm;
 				mm.scale(1, -1);
 				mm.translate(x, -y);
 				textPath.map(mm);
 				textPath.map(m_ctm);
 				ite->PoLine = textPath.copy();
-				ite->ClipEdited = true;
-				ite->FrameType = 3;
-				ite->setLineEnd(PLineEnd);
-				ite->setLineJoin(PLineJoin);
-				ite->setTextFlowMode(PageItem::TextFlowDisabled);
+				setItemFillAndStroke(state, ite);
 				// Fill text rendering modes. See above
-				if (textRenderingMode == 0 || textRenderingMode == 2 || textRenderingMode == 4 || textRenderingMode == 6)
-				{
-					CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade);
-					ite->setFillColor(CurrColorFill);
-					ite->setFillShade(CurrFillShade);
-					ite->setFillEvenOdd(false);
-					ite->setFillTransparency(1.0 - state->getFillOpacity());
-					ite->setFillBlendmode(getBlendMode(state));
-				}
-				// Stroke text rendering modes. See above
-				if (textRenderingMode == 1 || textRenderingMode == 2 || textRenderingMode == 5 || textRenderingMode == 6)
-				{
-					CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &CurrStrokeShade);
-					ite->setLineColor(CurrColorStroke);
-					ite->setLineWidth(state->getTransformedLineWidth());
-					ite->setLineTransparency(1.0 - state->getStrokeOpacity());
-					ite->setLineBlendmode(getBlendMode(state));
-					ite->setLineShade(CurrStrokeShade);
-				}
 				m_doc->adjustItemSize(ite);
 				m_Elements->append(ite);
 				if (m_groupStack.count() != 0)
@@ -3356,11 +3339,13 @@
 					m_groupStack.top().Items.append(ite);
 					applyMask(ite);
 				}
-				delete fontPath;
-			}
-		}
-	}
-}
+			}
+			delete fontPath;
+
+		}
+	}
+}
+
 
 GBool SlaOutputDev::beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, POPPLER_CONST_082 Unicode *u, int uLen)
 {
@@ -3398,8 +3383,8 @@
 			ite = m_doc->m_Selection->itemAt(0);
 		if (!f3e.colored)
 		{
-			m_doc->itemSelection_SetItemBrush(CurrColorFill);
-			m_doc->itemSelection_SetItemBrushShade(CurrFillShade);
+			m_doc->itemSelection_SetItemBrush(m_currColorFill);
+			m_doc->itemSelection_SetItemBrushShade(m_currFillShade);
 			m_doc->itemSelection_SetItemFillTransparency(1.0 - state->getFillOpacity());
 			m_doc->itemSelection_SetItemFillBlend(getBlendMode(state));
 		}
@@ -3667,25 +3652,25 @@
 	switch (state->getLineCap())
 	{
 		case 0:
-			PLineEnd = Qt::FlatCap;
+			m_lineEnd = Qt::FlatCap;
 			break;
 		case 1:
-			PLineEnd = Qt::RoundCap;
+			m_lineEnd = Qt::RoundCap;
 			break;
 		case 2:
-			PLineEnd = Qt::SquareCap;
+			m_lineEnd = Qt::SquareCap;
 			break;
 	}
 	switch (state->getLineJoin())
 	{
 		case 0:
-			PLineJoin = Qt::MiterJoin;
+			m_lineJoin = Qt::MiterJoin;
 			break;
 		case 1:
-			PLineJoin = Qt::RoundJoin;
+			m_lineJoin = Qt::RoundJoin;
 			break;
 		case 2:
-			PLineJoin = Qt::BevelJoin;
+			m_lineJoin = Qt::BevelJoin;
 			break;
 	}
 	double lw = state->getLineWidth();
@@ -3893,3 +3878,66 @@
 	}
 	return ret;
 }
+
+void SlaOutputDev::setItemFillAndStroke(GfxState* state, PageItem* textNode)
+{
+
+	textNode->ClipEdited = true;
+	textNode->FrameType = 3;
+	textNode->setLineEnd(m_lineEnd);
+	textNode->setLineJoin(m_lineJoin);
+	textNode->setTextFlowMode(PageItem::TextFlowDisabled);
+
+	int textRenderingMode = state->getRender();
+	// Invisible or only used for clipping
+	if (textRenderingMode == 3)
+		return;
+
+	// Fill text rendering modes. See above
+	if (textRenderingMode == 0 || textRenderingMode == 2 || textRenderingMode == 4 || textRenderingMode == 6)
+	{
+		m_currColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &m_currFillShade);
+		if (textNode->isTextFrame())
+		{
+			textNode->setFillTransparency(1.0 - (state->getFillOpacity() > state->getStrokeOpacity() ? state->getFillOpacity() : state->getStrokeOpacity())); //fill colour sets the background colour for the frame not the fill colour fore  the text
+			textNode->setLineTransparency(1.0); // this sets the transparency of the textbox border and we don't want to see it
+			textNode->setFillColor(CommonStrings::None);
+			textNode->setLineColor(CommonStrings::None);
+			textNode->setLineWidth(0);//line  width doesn't effect drawing text, it creates a bounding box state->getTransformedLineWidth());
+			textNode->setFillShade(m_currFillShade);
+		}
+		else
+		{
+			textNode->setFillColor(m_currColorFill);
+			textNode->setFillShade(m_currFillShade);
+			textNode->setFillEvenOdd(false);
+			textNode->setFillTransparency(1.0 - state->getFillOpacity());
+			textNode->setFillBlendmode(getBlendMode(state));
+		}
+	}
+	// Stroke text rendering modes. See above
+	if (textRenderingMode == 1 || textRenderingMode == 2 || textRenderingMode == 5 || textRenderingMode == 6)
+	{
+		m_currColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &m_currStrokeShade);
+		if (textNode->isTextFrame())
+		{
+			//fill color sets the background color for the frame not the fill color fore  the text
+			textNode->setFillTransparency(1.0 - (state->getFillOpacity() > state->getStrokeOpacity() ? state->getFillOpacity() : state->getStrokeOpacity()));
+			textNode->setLineTransparency(1.0); // this sets the transparency of the textbox border and we don't want to see it
+			textNode->setFillColor(CommonStrings::None); //TODO: Check if we override the stroke color with the fill color when there is a choice
+			textNode->setLineColor(CommonStrings::None);
+			textNode->setLineWidth(0);//line  width doesn't effect drawing text, it creates a bounding box state->getTransformedLineWidth());
+			textNode->setFillBlendmode(getBlendMode(state));
+			textNode->setFillShade(m_currFillShade);
+		}
+		else
+		{
+			textNode->setLineColor(m_currColorStroke);
+			textNode->setLineWidth(0);//line  width doesn't effect drawing text, it creates a bounding box state->getTransformedLineWidth());
+			textNode->setFillTransparency(1.0 - state->getFillOpacity() > state->getStrokeOpacity() ? state->getFillOpacity() : state->getStrokeOpacity());
+			textNode->setLineTransparency(1.0); // this sets the transparency of the textbox border and we don't want to see it
+			textNode->setLineBlendmode(getBlendMode(state));
+			textNode->setLineShade(m_currStrokeShade);
+		}
+	}
+}

Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h	Mon Jan  4 21:30:39 2021
@@ -141,18 +141,19 @@
 	void fill(GfxState *state) override;
 	void drawString(GfxState *state, POPPLER_CONST GooString *s) override;
 
-	QString CurrColorText;
-	QString CurrColorFill;
-	QString CurrColorStroke;
-	double m_fontSize {12};
-	GooString *m_fontName {nullptr};
-	GooString *m_itemText {nullptr};
+	QString currColorText;
+	QString currColorFill;
+	QString currColorStroke;
+	double  fontSize {12};
+	GooString *fontName {nullptr};
+	GooString *itemText {nullptr};
 
 private:
 	QString getColor(GfxColorSpace *color_space, POPPLER_CONST_070 GfxColor *color, int *shade);
 	ScribusDoc* m_doc;
 	QStringList *m_importedColors;
 };
+
 
 
 class SlaOutputDev : public OutputDev
@@ -263,7 +264,7 @@
 
 	void updateFillColor(GfxState *state) override;
 	void updateStrokeColor(GfxState *state) override;
-	void updateFont(GfxState *state) override;
+	void updateFont(GfxState* state) override;
 
 	//----- text drawing
 	void  beginTextObject(GfxState *state) override;
@@ -285,14 +286,39 @@
 	double cropOffsetY {0.0};
 	int rotate;
 
+protected:
+	void setItemFillAndStroke(GfxState* state, PageItem* textNode);
+	void applyMask(PageItem* ite);
+	void pushGroup(const QString& maskName = "", GBool forSoftMask = gFalse, GBool alpha = gFalse, bool inverted = false);
+
+	ScribusDoc* m_doc;
+	Qt::PenCapStyle m_lineEnd{ Qt::FlatCap };
+	Qt::PenJoinStyle m_lineJoin{ Qt::MiterJoin };
+	QList<PageItem*>* m_Elements;
+
+	struct groupEntry
+	{
+		QList<PageItem*> Items;
+		GBool forSoftMask;
+		GBool isolated;
+		GBool alpha;
+		QString maskName;
+		QPointF maskPos;
+		bool inverted;
+	};
+
+	QStack<groupEntry> m_groupStack;
+	QString m_currColorFill;
+	QString m_currColorStroke;
+	int m_currFillShade{ 100 };
+	int m_currStrokeShade {100};
+
 private:
 	void getPenState(GfxState *state);
 	QString getColor(GfxColorSpace *color_space, POPPLER_CONST_070 GfxColor *color, int *shade);
 	QString getAnnotationColor(const AnnotColor *color);
 	QString convertPath(POPPLER_CONST_083 GfxPath *path);
 	int getBlendMode(GfxState *state);
-	void applyMask(PageItem *ite);
-	void pushGroup(const QString& maskName = "", GBool forSoftMask = gFalse, GBool alpha = gFalse, bool inverted = false);
 	QString UnicodeParsedString(POPPLER_CONST GooString *s1);
 	QString UnicodeParsedString(const std::string& s1);
 	bool checkClip();
@@ -308,12 +334,6 @@
 	void createImageFrame(QImage& image, GfxState *state, int numColorComponents);
 
 	bool pathIsClosed {false};
-	QString CurrColorFill;
-	int CurrFillShade {100};
-	QString CurrColorStroke;
-	int CurrStrokeShade {100};
-	Qt::PenCapStyle PLineEnd {Qt::FlatCap};
-	Qt::PenJoinStyle PLineJoin {Qt::MiterJoin};
 	QVector<double> DashValues;
 	double DashOffset {0.0};
 	QString Coords;
@@ -328,22 +348,9 @@
 	// Collect the paths of character glyphs for clipping of a whole text group.
 	QPainterPath  m_clipTextPath;
 
-	struct groupEntry
-	{
-		QList<PageItem*> Items;
-		GBool forSoftMask;
-		GBool isolated;
-		GBool alpha;
-		QString maskName;
-		QPointF maskPos;
-		bool inverted;
-	};
-	QStack<groupEntry> m_groupStack;
 	QString m_currentMask;
 	QPointF m_currentMaskPosition;
-	ScribusDoc* m_doc;
 	Selection* tmpSel;
-	QList<PageItem*> *m_Elements;
 	QStringList *m_importedColors;
 	QTransform m_ctm;
 	struct F3Entry
@@ -373,5 +380,4 @@
 	QHash<int, PageItem*> m_radioButtons;
 	int m_actPage;
 };
-
 #endif

Modified: trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj	(original)
+++ trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj	Mon Jan  4 21:30:39 2021
@@ -207,6 +207,7 @@
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\importpdf.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\importpdfplugin.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\pdfimportoptions.cpp" />
+    <ClCompile Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\slaoutput.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\plugins_pch.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
@@ -217,6 +218,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\scribus\plugins\import\pdf\importpdfconfig.h" />
+    <ClInclude Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.h" />
     <ClInclude Include="..\..\..\scribus\plugins\plugins_pch.h" />
     <moc Include="..\..\..\scribus\plugins\import\pdf\importpdf.h" />
     <moc Include="..\..\..\scribus\plugins\import\pdf\importpdfplugin.h" />

Modified: trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj.filters	(original)
+++ trunk/Scribus/win32/msvc2015/pdfimport/pdfimport.vcxproj.filters	Mon Jan  4 21:30:39 2021
@@ -30,6 +30,9 @@
     <ClCompile Include="..\..\..\scribus\plugins\plugins_pch.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\scribus\plugins\import\pdf\slaoutput.h">
@@ -39,6 +42,9 @@
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="..\..\..\scribus\plugins\import\pdf\importpdfconfig.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.h">
       <Filter>Header Files</Filter>
     </ClInclude>
   </ItemGroup>

Modified: trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj	(original)
+++ trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj	Mon Jan  4 21:30:39 2021
@@ -207,6 +207,7 @@
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\importpdf.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\importpdfplugin.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\pdfimportoptions.cpp" />
+    <ClCompile Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\slaoutput.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\plugins_pch.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
@@ -217,6 +218,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\scribus\plugins\import\pdf\importpdfconfig.h" />
+    <ClInclude Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.h" />
     <ClInclude Include="..\..\..\scribus\plugins\plugins_pch.h" />
     <moc Include="..\..\..\scribus\plugins\import\pdf\importpdf.h" />
     <moc Include="..\..\..\scribus\plugins\import\pdf\importpdfplugin.h" />

Modified: trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj.filters	(original)
+++ trunk/Scribus/win32/msvc2017/pdfimport/pdfimport.vcxproj.filters	Mon Jan  4 21:30:39 2021
@@ -30,6 +30,9 @@
     <ClCompile Include="..\..\..\scribus\plugins\plugins_pch.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\scribus\plugins\import\pdf\slaoutput.h">
@@ -39,6 +42,9 @@
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="..\..\..\scribus\plugins\import\pdf\importpdfconfig.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.h">
       <Filter>Header Files</Filter>
     </ClInclude>
   </ItemGroup>

Modified: trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj	(original)
+++ trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj	Mon Jan  4 21:30:39 2021
@@ -208,6 +208,7 @@
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\importpdf.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\importpdfplugin.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\pdfimportoptions.cpp" />
+    <ClCompile Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\import\pdf\slaoutput.cpp" />
     <ClCompile Include="..\..\..\scribus\plugins\plugins_pch.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
@@ -218,6 +219,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\scribus\plugins\import\pdf\importpdfconfig.h" />
+    <ClInclude Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.h" />
     <ClInclude Include="..\..\..\scribus\plugins\plugins_pch.h" />
     <moc Include="..\..\..\scribus\plugins\import\pdf\importpdf.h" />
     <moc Include="..\..\..\scribus\plugins\import\pdf\importpdfplugin.h" />

Modified: trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24374&path=/trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj.filters	(original)
+++ trunk/Scribus/win32/msvc2019/pdfimport/pdfimport.vcxproj.filters	Mon Jan  4 21:30:39 2021
@@ -30,6 +30,9 @@
     <ClCompile Include="..\..\..\scribus\plugins\plugins_pch.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\scribus\plugins\import\pdf\slaoutput.h">
@@ -39,6 +42,9 @@
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="..\..\..\scribus\plugins\import\pdf\importpdfconfig.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\plugins\import\pdf\pdftextrecognition.h">
       <Filter>Header Files</Filter>
     </ClInclude>
   </ItemGroup>




More information about the scribus-commit mailing list