r13854 by pierre - Made building against PoDoFo Trunk easier (at least to maintain) when PoDoFo is moving

scribus-commit scribus-commit at lists.scribus.net
Wed Aug 26 05:37:13 CEST 2009


Revision: 13854
Author: pierre
Date: 2009-08-13T09:35:19.975953Z
Commit message: Made building against PoDoFo Trunk easier (at least to maintain) when PoDoFo is moving

Changeset: 
M  /trunk/Scribus/scribus/pdflib_core.cpp
M  /trunk/Scribus/scribus/plugins/aiimplugin/importai.cpp

Diffs:
Index: scribus/pdflib_core.cpp
===================================================================
--- scribus/pdflib_core.cpp	(revision 13853)
+++ scribus/pdflib_core.cpp	(revision 13854)
@@ -6462,12 +6462,20 @@
 			}
 			*/
 			char * mbuffer = NULL;
-#if defined(pdf_long)
-			pdf_long mlen = 0;
+			long mlen = 0;
+
+#if ( (PODOFO_VERSION_MAJOR == 0) && (PODOFO_VERSION_MINOR == 7) && (PODOFO_VERSION_PATCH == 99) ) || ( (PODOFO_VERSION_MAJOR == 0) && (PODOFO_VERSION_MINOR > 7) )
+			// seems more complicated at first, but in fact it makes the code more stable wrt podofo changes
+			PoDoFo::PdfMemoryOutputStream oStream(1);
+			stream->GetCopy(&oStream);
+			oStream.Close();
+			mlen = oStream.GetLength();
+			mbuffer = oStream.TakeBuffer();
 #else
-			long mlen = 0;
+
+
+			stream->GetCopy(&mbuffer, &mlen);
 #endif
-			stream->GetCopy(&mbuffer, &mlen);
 			if (mbuffer[mlen-1] == '\n')
 				--mlen;
 			PutDoc("\n/Length " + QString::number(mlen));
@@ -6722,14 +6730,20 @@
 	copyPoDoFoDirect(obj, referencedObjects, importedObjects);
 	if (obj->HasStream())
 	{
+		const PoDoFo::PdfStream* stream = obj->GetStream();
 		char * mbuffer = NULL;
-#if defined(pdf_long)
-			pdf_long mlen = 0;
+		long mlen = 0;
+
+#if ( (PODOFO_VERSION_MAJOR == 0) && (PODOFO_VERSION_MINOR == 7) && (PODOFO_VERSION_PATCH == 99) ) || ( (PODOFO_VERSION_MAJOR == 0) && (PODOFO_VERSION_MINOR > 7) )
+		// seems more complicated at first, but in fact it makes the code more stable wrt podofo changes
+		PoDoFo::PdfMemoryOutputStream oStream(1);
+		stream->GetCopy(&oStream);
+		oStream.Close();
+		mlen = oStream.GetLength();
+		mbuffer = oStream.TakeBuffer();
 #else
-			long mlen = 0;
+		stream->GetCopy(&mbuffer, &mlen);
 #endif
-		const PoDoFo::PdfStream* stream = obj->GetStream();
-		stream->GetCopy(&mbuffer, &mlen);
 		if (mbuffer[mlen-1] == '\n')
 			--mlen;
 		PutDoc("\nstream\n");
Index: scribus/plugins/aiimplugin/importai.cpp
===================================================================
--- scribus/plugins/aiimplugin/importai.cpp	(revision 13853)
+++ scribus/plugins/aiimplugin/importai.cpp	(revision 13854)
@@ -412,13 +412,11 @@
 							Key = name.arg(1);
 							data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data()));
 							PoDoFo::PdfStream const *stream = data->GetStream();
-							char *Buffer;
-#if defined(pdf_long)
-							pdf_long bLen = 0;
-#else
-							long bLen = 0;
-#endif
-							stream->GetFilteredCopy(&Buffer, &bLen);
+							PoDoFo::PdfMemoryOutputStream oStream(1);
+							stream->GetFilteredCopy(&oStream);
+							oStream.Close();
+							long bLen = oStream.GetLength();
+							char *Buffer = oStream.TakeBuffer();
 							outf.write(Buffer, bLen);
 							free( Buffer );
 						}
@@ -431,13 +429,11 @@
 								if (data == NULL)
 									break;
 								PoDoFo::PdfStream const *stream = data->GetStream();
-								char *Buffer;
-#if defined(pdf_long)
-								pdf_long bLen = 0;
-#else
-								long bLen = 0;
-#endif
-								stream->GetFilteredCopy(&Buffer, &bLen);
+								PoDoFo::PdfMemoryOutputStream oStream(1);
+								stream->GetFilteredCopy(&oStream);
+								oStream.Close();
+								long bLen = oStream.GetLength();
+								char *Buffer = oStream.TakeBuffer();
 								outf.write(Buffer, bLen);
 								free( Buffer );
 							}




More information about the scribus-commit mailing list