[Libreoffice-commits] mso-dumper.git: msodumper/vsdstream.py vsd-dump.py
Miklos Vajna
vmiklos at collabora.co.uk
Mon Dec 1 06:15:42 PST 2014
msodumper/vsdstream.py | 62 -------------------------------------------------
vsd-dump.py | 2 -
2 files changed, 1 insertion(+), 63 deletions(-)
New commits:
commit eb13528d71d8fc8cb191c41236fd5206635c6cc0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Dec 1 15:00:42 2014 +0100
vsd: clean up gsf bits
The root entry is important for VSD, and gsf hides that.
diff --git a/msodumper/vsdstream.py b/msodumper/vsdstream.py
index d2403a3..4c7cd67 100644
--- a/msodumper/vsdstream.py
+++ b/msodumper/vsdstream.py
@@ -55,68 +55,8 @@ class VSDFile:
return "native"
-class GsfVSDFile(VSDFile):
- """Same as VSDFile, but uses gsf to read the OLE streams."""
- def __init__(self, chars, params, gsf):
- self.gsf = gsf
- VSDFile.__init__(self, chars, params)
-
- def disableStderr(self):
- nil = os.open(os.devnull, os.O_WRONLY)
- self.savedStderr = os.dup(2)
- os.dup2(nil, 2)
-
- def enableStderr(self):
- os.dup2(self.savedStderr, 2)
-
- def init(self):
- self.streams = {}
- self.gsf.gsf_init()
- gsfInput = self.gsf.gsf_input_memory_new(self.chars, len(self.chars), False)
- self.disableStderr()
- gsfInfile = self.gsf.gsf_infile_msole_new(gsfInput, None)
- self.enableStderr()
- if not gsfInfile:
- self.error = "gsf_infile_msole_new() failed"
- return
- for i in range(self.gsf.gsf_infile_num_children(gsfInfile)):
- child = self.gsf.gsf_infile_child_by_index(gsfInfile, i)
- childName = ctypes.string_at(self.gsf.gsf_infile_name_by_index(gsfInfile, i))
- childSize = self.gsf.gsf_input_size(child)
- childData = ""
- while True:
- bufSize = 1024
- pos = self.gsf.gsf_input_tell(child)
- if pos == childSize:
- break
- elif pos + bufSize > childSize:
- bufSize = childSize - pos
- childData += ctypes.string_at(self.gsf.gsf_input_read(child, bufSize, None), bufSize)
- self.streams[childName] = childData
- self.gsf.gsf_shutdown()
-
- def getDirectoryNames(self):
- return self.streams.keys()
-
- def getDirectoryStreamByName(self, name):
- return self.getStreamFromBytes(name, self.streams[name])
-
- def getName(self):
- return "gsf"
-
-
def createVSDFile(chars, params):
- hasGsf = True
- try:
- gsf = ctypes.cdll.LoadLibrary('libgsf-1.so')
- gsf.gsf_input_read.restype = ctypes.c_void_p
- except:
- hasGsf = False
-
- if hasGsf:
- return GsfVSDFile(chars, params, gsf)
- else:
- return VSDFile(chars, params)
+ return VSDFile(chars, params)
PIDDSI = {
diff --git a/vsd-dump.py b/vsd-dump.py
index 9d56f8f..cb18e8d 100755
--- a/vsd-dump.py
+++ b/vsd-dump.py
@@ -26,8 +26,6 @@ class VSDDumper:
if strm.error:
print '<error what="%s"/>' % strm.error
for dirname in dirnames:
- if len(dirname) == 0 or dirname in ['Root Entry']:
- continue
strm.getDirectoryStreamByName(dirname).dump()
print '</streams>'
More information about the Libreoffice-commits
mailing list