View Issue Details

IDProjectCategoryView StatusLast Update
0015872ScribusInternalpublic2019-12-08 21:24
Reporterale Assigned Tocbradney  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version1.5.6.svn 
Target VersionFixed in Version1.5.6.svn 
Summary0015872: De-obfuscate a bit the rotation in pdfimport
Descriptionit is not really easy to figure out what the current code is doing:

bool rotated = false;
dev->startDoc(pdfDoc, pdfDoc->getXRef(), pdfDoc->getCatalog());
int rotate = pdfDoc->getPageRotate(firstPage);
if ((rotate == 90) || (rotate == 270))
    rotated = true;
dev->rotate = rotate;
rotate = 0;


we can do better:

const int zeroRotation = 0;

dev->startDoc(pdfDoc, pdfDoc->getXRef(), pdfDoc->getCatalog());
dev->rotate = pdfDoc->getPageRotate(firstPage);
bool rotated = (dev->rotate == 90) || (dev->rotate == 270);

patch is attached.
TagsNo tags attached.
PatchYes

Activities

ale

2019-10-24 09:08

manager  

pdfdev-rotation.diff (4,302 bytes)
diff --git a/scribus/plugins/import/pdf/importpdf.cpp b/scribus/plugins/import/pdf/importpdf.cpp
index ffd8837c4..4b4f44ea8 100644
--- a/scribus/plugins/import/pdf/importpdf.cpp
+++ b/scribus/plugins/import/pdf/importpdf.cpp
@@ -590,13 +590,12 @@ bool PdfPlug::convert(const QString& fn)
 							}
 						}
 					}
-					bool rotated = false;
+					const int zeroRotate = 0;
+
 					dev->startDoc(pdfDoc, pdfDoc->getXRef(), pdfDoc->getCatalog());
-					int rotate = pdfDoc->getPageRotate(firstPage);
-					if ((rotate == 90) || (rotate == 270))
-						rotated = true;
-					dev->rotate = rotate;
-					rotate = 0;
+					dev->rotate = pdfDoc->getPageRotate(firstPage);
+					bool rotated = dev->rotate == 90 || dev->rotate == 270;
+
 					if (importerFlags & LoadSavePlugin::lfCreateDoc)
 					{
 						if (hasOcg)
@@ -737,9 +736,9 @@ bool PdfPlug::convert(const QString& fn)
 							{
 							//	int numObj = m_Doc->Items->count();
 							//	if (cropped)
-							//		pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, crBox.x(), crBox.y(), crBox.width(), crBox.height(), nullptr, nullptr, dev->annotations_callback, dev);
+							//		pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, zeroRotate, useMediaBox, crop, printing, crBox.x(), crBox.y(), crBox.width(), crBox.height(), nullptr, nullptr, dev->annotations_callback, dev);
 							//	else
-							//		pdfDoc->displayPage(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, nullptr, nullptr, dev->annotations_callback, dev);
+							//		pdfDoc->displayPage(dev, pp, hDPI, vDPI, zeroRotate, useMediaBox, crop, printing, nullptr, nullptr, dev->annotations_callback, dev);
 							//	int numObj2 = m_Doc->Items->count();
 							//	int countObj = numObj2 - numObj;
 								for (int a = 0; a < ocgGroups.count(); a++)
@@ -749,9 +748,9 @@ bool PdfPlug::convert(const QString& fn)
 							//		currentLayer = m_Doc->activeLayer();
 									oc->setState(OptionalContentGroup::On);
 									if (cropped)
-										pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, crBox.x() - mdBox.x(), mdBox.bottom() - crBox.bottom(), crBox.width(), crBox.height(), nullptr, nullptr, dev->annotations_callback, dev);
+										pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, zeroRotate, useMediaBox, crop, printing, crBox.x() - mdBox.x(), mdBox.bottom() - crBox.bottom(), crBox.width(), crBox.height(), nullptr, nullptr, dev->annotations_callback, dev);
 									else
-										pdfDoc->displayPage(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, nullptr, nullptr, dev->annotations_callback, dev);
+										pdfDoc->displayPage(dev, pp, hDPI, vDPI, zeroRotate, useMediaBox, crop, printing, nullptr, nullptr, dev->annotations_callback, dev);
 									oc->setState(OptionalContentGroup::Off);
 							//		for (int dd = 0; dd < countObj; dd++)
 							//		{
@@ -764,9 +763,9 @@ bool PdfPlug::convert(const QString& fn)
 							else
 							{
 								if (cropped)
-									pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, crBox.x() - mdBox.x(), mdBox.bottom() - crBox.bottom(), crBox.width(), crBox.height(), nullptr, nullptr, dev->annotations_callback, dev);
+									pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, zeroRotate, useMediaBox, crop, printing, crBox.x() - mdBox.x(), mdBox.bottom() - crBox.bottom(), crBox.width(), crBox.height(), nullptr, nullptr, dev->annotations_callback, dev);
 								else
-									pdfDoc->displayPage(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, nullptr, nullptr, dev->annotations_callback, dev);
+									pdfDoc->displayPage(dev, pp, hDPI, vDPI, zeroRotate, useMediaBox, crop, printing, nullptr, nullptr, dev->annotations_callback, dev);
 							}
 
 							PDFPresentationData ef;
@@ -900,7 +899,7 @@ bool PdfPlug::convert(const QString& fn)
 								ocgGroups[a]->setState(OptionalContentGroup::On);
 							}
 						}
-						pdfDoc->displayPage(dev, firstPage, hDPI, vDPI, rotate, useMediaBox, crop, printing, nullptr, nullptr, dev->annotations_callback, dev);
+						pdfDoc->displayPage(dev, firstPage, hDPI, vDPI, zeroRotate, useMediaBox, crop, printing, nullptr, nullptr, dev->annotations_callback, dev);
 					}
 				}
 				delete dev;
pdfdev-rotation.diff (4,302 bytes)

Issue History

Date Modified Username Field Change
2019-10-24 09:08 ale New Issue
2019-10-24 09:08 ale File Added: pdfdev-rotation.diff
2019-10-24 18:08 cbradney Assigned To => cbradney
2019-10-24 18:08 cbradney Status new => resolved
2019-10-24 18:08 cbradney Resolution open => fixed
2019-10-24 18:08 cbradney Fixed in Version => 1.5.6.svn
2019-10-25 00:11 jghali Category - => Internal
2019-10-25 00:12 jghali Summary [PATCH] de-obfuscate a bit the rotation in pdfimport => De-obfuscate a bit the rotation in pdfimport
2019-12-08 21:24 cbradney Status resolved => closed