[Libreoffice-commits] .: src/lib
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Feb 25 01:33:42 PST 2013
src/lib/VSDContentCollector.cpp | 90 +++++++++++++++++++++++-----------------
1 file changed, 53 insertions(+), 37 deletions(-)
New commits:
commit b4a25befe6748808e2de5ec35b9b1d9169856bee
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Mon Feb 25 10:33:18 2013 +0100
Improve the embedded binary dumping a bit
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 8901fa1..6b67ae0 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -36,7 +36,9 @@
#include "VSDParser.h"
#include "VSDInternalStream.h"
+#ifndef DUMP_BITMAP
#define DUMP_BITMAP 0
+#endif
#if DUMP_BITMAP
static unsigned bitmapId = 0;
@@ -1122,43 +1124,6 @@ void libvisio::VSDContentCollector::_handleForeignData(const WPXBinaryData &bina
}
m_currentForeignData.append(binaryData);
-#if DUMP_BITMAP
- if (m_foreignType == 1 || m_foreignType == 4)
- {
- ::WPXString filename;
- switch(m_foreignFormat)
- {
- case 0:
- case 255:
- filename.sprintf("binarydump%i.bmp", bitmapId++);
- break;
- case 1:
- filename.sprintf("binarydump%i.jpeg", bitmapId++);
- break;
- case 2:
- filename.sprintf("binarydump%i.gif", bitmapId++);
- break;
- case 3:
- filename.sprintf("binarydump%i.tiff", bitmapId++);
- break;
- case 4:
- filename.sprintf("binarydump%i.png", bitmapId++);
- break;
- default:
- filename.sprintf("binarydump%i.bin", bitmapId++);
- break;
- }
- FILE *f = fopen(filename.cstr(), "wb");
- if (f)
- {
- const unsigned char *tmpBuffer = m_currentForeignData.getDataBuffer();
- for (unsigned long k = 0; k < m_currentForeignData.size(); k++)
- fprintf(f, "%c",tmpBuffer[k]);
- fclose(f);
- }
- }
-#endif
-
if (m_foreignType == 1)
{
switch(m_foreignFormat)
@@ -1200,6 +1165,57 @@ void libvisio::VSDContentCollector::_handleForeignData(const WPXBinaryData &bina
m_currentForeignProps.insert("libwpg:mime-type", "object/ole");
m_currentForeignData.append(binaryData);
}
+
+#if DUMP_BITMAP
+ ::WPXString filename;
+ if (m_foreignType == 1)
+ {
+ switch(m_foreignFormat)
+ {
+ case 0:
+ case 255:
+ filename.sprintf("binarydump%i.bmp", bitmapId++);
+ break;
+ case 1:
+ filename.sprintf("binarydump%i.jpeg", bitmapId++);
+ break;
+ case 2:
+ filename.sprintf("binarydump%i.gif", bitmapId++);
+ break;
+ case 3:
+ filename.sprintf("binarydump%i.tiff", bitmapId++);
+ break;
+ case 4:
+ filename.sprintf("binarydump%i.png", bitmapId++);
+ break;
+ default:
+ filename.sprintf("binarydump%i.bin", bitmapId++);
+ break;
+ }
+ }
+ else if (m_foreignType == 4)
+ {
+ const unsigned char *tmpBinData = m_currentForeignData.getDataBuffer();
+ // Check for EMF signature
+ if (tmpBinData[0x28] == 0x20 && tmpBinData[0x29] == 0x45 && tmpBinData[0x2A] == 0x4D && tmpBinData[0x2B] == 0x46)
+ filename.sprintf("binarydump%i.emf", bitmapId++);
+ else
+ filename.sprintf("binarydump%i.wmf", bitmapId++);
+ }
+ else if (m_foreignType == 2)
+ {
+ filename.sprintf("binarydump%i.ole", bitmapId++);
+ }
+
+ FILE *f = fopen(filename.cstr(), "wb");
+ if (f)
+ {
+ const unsigned char *tmpBuffer = m_currentForeignData.getDataBuffer();
+ for (unsigned long k = 0; k < m_currentForeignData.size(); k++)
+ fprintf(f, "%c",tmpBuffer[k]);
+ fclose(f);
+ }
+#endif
}
void libvisio::VSDContentCollector::collectGeometry(unsigned /* id */, unsigned level, bool noFill, bool noLine, bool noShow)
More information about the Libreoffice-commits
mailing list