r23276 by craig - #15872: apply pdfimport patch for code cleanup. ale

scribus-commit scribus-commit at lists.scribus.net
Thu Oct 24 18:10:28 UTC 2019


Author: craig
Date: Thu Oct 24 18:10:27 2019
New Revision: 23276

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23276
Log:
#15872: apply pdfimport patch for code cleanup. ale

Modified:
    trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp

Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23276&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	Thu Oct 24 18:10:27 2019
@@ -542,21 +542,20 @@
 							}
 						}
 					}
-					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)
 						{
-							QString actL = m_Doc->activeLayerName();
-							for (int a = 0; a < ocgGroups.count(); a++)
-							{
-								OptionalContentGroup *oc = ocgGroups[a];
+							QString actL(m_Doc->activeLayerName());
+							for (int i = 0; i < ocgGroups.count(); i++)
+							{
+								OptionalContentGroup *oc = ocgGroups[i];
 								if (actL != UnicodeParsedString(oc->getName()))
 									currentLayer = m_Doc->addLayer(UnicodeParsedString(oc->getName()), false);
 								else
@@ -634,14 +633,14 @@
 						}
 						m_Doc->setPageSize("Custom");
 					//	m_Doc->pdfOptions().PresentVals.clear();
-						for (uint ap = 0; ap < pageNs.size(); ++ap)
-						{
-							int pp = pageNs[ap];
+						for (int i = 0; i < pageNs.size(); ++i)
+						{
+							int pp = pageNs[i];
 							m_Doc->setActiveLayer(baseLayer);
 							if (firstPg)
 								firstPg = false;
 							else
-								m_Doc->addPage(ap);
+								m_Doc->addPage(i);
 							QRectF mdBox = getCBox(0, pp);
 							QRectF crBox = getCBox(contentRect, pp);
 							if (cropped)
@@ -687,38 +686,23 @@
 							m_Doc->reformPages(true);
 							if (hasOcg)
 							{
-							//	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);
-							//	else
-							//		pdfDoc->displayPage(dev, pp, hDPI, vDPI, rotate, 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++)
-								{
-									OptionalContentGroup *oc = ocgGroups[a];
-							//		m_Doc->setActiveLayer(UnicodeParsedString(oc->getName()));
-							//		currentLayer = m_Doc->activeLayer();
+								for (int j = 0; j < ocgGroups.count(); j++)
+								{
+									OptionalContentGroup *oc = ocgGroups[j];
 									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++)
-							//		{
-							//			PageItem *iteD = m_Doc->Items->takeAt(numObj2);
-							//			delete iteD;
-							//		}
-							//		numObj2 = m_Doc->Items->count();
 								}
 							}
 							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;
@@ -852,7 +836,7 @@
 								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;
@@ -870,9 +854,9 @@
 	{
 		if (importedColors.count() != 0)
 		{
-			for (int cd = 0; cd < importedColors.count(); cd++)
+			for (int i = 0; i < importedColors.count(); i++)
 			{
-				m_Doc->PageColors.remove(importedColors[cd]);
+				m_Doc->PageColors.remove(importedColors[i]);
 			}
 		}
 	}




More information about the scribus-commit mailing list