r17444 by fschmid - PDF Import: enable all optional content layers when importing.

scribus-commit scribus-commit at lists.scribus.net
Sat Apr 14 20:36:09 UTC 2012


Author: fschmid
Date: Sat Apr 14 20:36:09 2012
New Revision: 17444

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17444
Log:
PDF Import: enable all optional content layers when importing.

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=17444&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 Sat Apr 14 20:36:09 2012
@@ -308,6 +308,48 @@
 				double vDPI = 72.0;
 				int firstPage = 1;
 				int lastPage = pdfDoc->getNumPages();
+				OCGs* ocg = pdfDoc->getOptContentConfig();
+				if (ocg)
+				{
+					GBool hasOcg = ocg->hasOCGs();
+					if (hasOcg)
+					{
+					//	qDebug() << "File has OCGs";
+						Array *order = ocg->getOrderArray();
+						if (order)
+						{
+							for (int i = 0; i < order->getLength (); ++i)
+							{
+								Object orderItem;
+								order->get(i, &orderItem);
+								if (orderItem.isDict())
+								{
+									Object ref;
+									order->getNF(i, &ref);
+									if (ref.isRef())
+									{
+										OptionalContentGroup *oc = ocg->findOcgByRef(ref.getRef());
+								//		qDebug() << "Name" << UnicodeParsedString(oc->getName()) << "State" << oc->getState() << "View" << oc->getViewState() << "Print" << oc->getPrintState();
+										oc->setState(OptionalContentGroup::On);
+									}
+									ref.free();
+								}
+							}
+						}
+						else
+						{
+							GooList *ocgs;
+							int i;
+							ocgs = ocg->getOCGs ();
+							for (i = 0; i < ocgs->getLength (); ++i)
+							{
+								OptionalContentGroup *oc = (OptionalContentGroup *)ocgs->get(i);
+							//	qDebug() << "Name" << UnicodeParsedString(oc->getName()) << "State" << oc->getState() << "View" << oc->getViewState() << "Print" << oc->getPrintState();
+								oc->setState(OptionalContentGroup::On);
+							}
+						}
+					}
+				}
 	//			qDebug() << "converting page" << firstPage;
 				SlaOutputDev *dev = new SlaOutputDev(m_Doc, &Elements, &importedColors, importerFlags);
 				if (dev->isOk())




More information about the scribus-commit mailing list