[Libreoffice-commits] .: 2 commits - src/docdraw.py src/docrecord.py
Miklos Vajna
vmiklos at kemper.freedesktop.org
Fri Dec 7 07:14:46 PST 2012
src/docdraw.py | 68 ++++++++++++++++---------------------------------------
src/docrecord.py | 4 +--
2 files changed, 22 insertions(+), 50 deletions(-)
New commits:
commit e78e15a34c5b4221cb486784774ca6e6127b06a0
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Dec 7 16:14:41 2012 +0100
docdraw: add common base for OfficeArtDggContainer/OfficeArtDgContainer
diff --git a/src/docdraw.py b/src/docdraw.py
index d10065b..02138c1 100644
--- a/src/docdraw.py
+++ b/src/docdraw.py
@@ -11,16 +11,16 @@ from docdirstream import DOCDirStream
import docsprm
import msodraw
-class OfficeArtDggContainer(DOCDirStream):
- """The OfficeArtDggContainer record type specifies the container for all the OfficeArt file records that contain document-wide data."""
- def __init__(self, officeArtContent, name):
- DOCDirStream.__init__(self, officeArtContent.bytes)
+class OfficeArtContainer(DOCDirStream):
+ def __init__(self, parent, name, type):
+ DOCDirStream.__init__(self, parent.bytes)
self.name = name
- self.pos = officeArtContent.pos
- self.officeArtContent = officeArtContent
+ self.type = type
+ self.pos = parent.pos
+ self.parent = parent
def dumpXml(self):
- print '<%s type="OfficeArtDggContainer" offset="%d">' % (self.name, self.pos)
+ print '<%s type="%s" offset="%d">' % (self.name, self.type, self.pos)
self.rh = msodraw.RecordHeader(self)
self.rh.dumpXml(self)
pos = self.pos
@@ -43,11 +43,21 @@ class OfficeArtDggContainer(DOCDirStream):
child.dumpXml(self, rh)
self.pos = posOrig
else:
- print '<todo what="OfficeArtDggContainer: recType = %s unhandled (size: %d bytes)"/>' % (hex(rh.recType), rh.recLen)
+ print '<todo what="%s: recType = %s unhandled (size: %d bytes)"/>' % (self.type, hex(rh.recType), rh.recLen)
pos += rh.recLen
print '</%s>' % self.name
assert pos == self.pos + self.rh.recLen
- self.officeArtContent.pos = pos
+ self.parent.pos = pos
+
+class OfficeArtDggContainer(OfficeArtContainer):
+ """The OfficeArtDggContainer record type specifies the container for all the OfficeArt file records that contain document-wide data."""
+ def __init__(self, officeArtContent, name):
+ OfficeArtContainer.__init__(self, officeArtContent, name, "OfficeArtDggContainer")
+
+class OfficeArtDgContainer(OfficeArtContainer):
+ """The OfficeArtDgContainer record specifies the container for all the file records for the objects in a drawing."""
+ def __init__(self, officeArtContent, name):
+ OfficeArtContainer.__init__(self, officeArtContent, name, "OfficeArtDgContainer")
class OfficeArtSpContainer(DOCDirStream):
"""The OfficeArtSpContainer record specifies a shape container."""
@@ -121,44 +131,6 @@ class OfficeArtSpgrContainer(DOCDirStream):
assert pos == self.pos + self.rh.recLen
self.pos = pos
-class OfficeArtDgContainer(DOCDirStream):
- """The OfficeArtDgContainer record specifies the container for all the file records for the objects in a drawing."""
- def __init__(self, officeArtContent, name):
- DOCDirStream.__init__(self, officeArtContent.bytes)
- self.name = name
- self.pos = officeArtContent.pos
- self.officeArtContent = officeArtContent
-
- def dumpXml(self):
- print '<%s type="OfficeArtDgContainer" offset="%d">' % (self.name, self.pos)
- self.rh = msodraw.RecordHeader(self)
- self.rh.dumpXml(self)
- pos = self.pos
- while (self.rh.recLen - (pos - self.pos)) > 0:
- posOrig = self.pos
- self.pos = pos
- rh = msodraw.RecordHeader(self)
- rh.dumpXml(self)
- self.pos = posOrig
- pos += msodraw.RecordHeader.size
- if rh.recType in recMap:
- if len(recMap[rh.recType]) == 2:
- child = recMap[rh.recType][0](self, pos)
- child.dumpXml(self, rh)
- assert child.pos == pos + rh.recLen
- else:
- posOrig = self.pos
- self.pos = pos
- child = recMap[rh.recType][0](self)
- child.dumpXml(self, rh)
- self.pos = posOrig
- else:
- print '<todo what="OfficeArtDgContainer: recType = %s unhandled (size: %d bytes)"/>' % (hex(rh.recType), rh.recLen)
- pos += rh.recLen
- print '</%s>' % self.name
- assert pos == self.pos + self.rh.recLen
- self.officeArtContent.pos = pos
-
recMap = {
0xf003: [OfficeArtSpgrContainer, True],
0xf004: [OfficeArtSpContainer, True],
commit b6ba97f4f6d0105855418a07d99ec5a98c2fad50
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Dec 7 16:03:53 2012 +0100
docdraw: dump -> dumpXml
diff --git a/src/docdraw.py b/src/docdraw.py
index d7a861d..d10065b 100644
--- a/src/docdraw.py
+++ b/src/docdraw.py
@@ -19,7 +19,7 @@ class OfficeArtDggContainer(DOCDirStream):
self.pos = officeArtContent.pos
self.officeArtContent = officeArtContent
- def dump(self):
+ def dumpXml(self):
print '<%s type="OfficeArtDggContainer" offset="%d">' % (self.name, self.pos)
self.rh = msodraw.RecordHeader(self)
self.rh.dumpXml(self)
@@ -129,7 +129,7 @@ class OfficeArtDgContainer(DOCDirStream):
self.pos = officeArtContent.pos
self.officeArtContent = officeArtContent
- def dump(self):
+ def dumpXml(self):
print '<%s type="OfficeArtDgContainer" offset="%d">' % (self.name, self.pos)
self.rh = msodraw.RecordHeader(self)
self.rh.dumpXml(self)
diff --git a/src/docrecord.py b/src/docrecord.py
index ff54747..2d11e51 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -1575,7 +1575,7 @@ class OfficeArtWordDrawing(DOCDirStream):
def dump(self):
print '<officeArtWordDrawing type="OfficeArtWordDrawing" pos="%d">' % self.pos
self.printAndSet("dgglbl", self.readuInt8())
- docdraw.OfficeArtDgContainer(self, "container").dump()
+ docdraw.OfficeArtDgContainer(self, "container").dumpXml()
print '</officeArtWordDrawing>'
self.officeArtContent.pos = self.pos
@@ -1589,7 +1589,7 @@ class OfficeArtContent(DOCDirStream):
def dump(self):
print '<officeArtContent type="OfficeArtContent" offset="%d" size="%d bytes">' % (self.pos, self.size)
- docdraw.OfficeArtDggContainer(self, "DrawingGroupData").dump()
+ docdraw.OfficeArtDggContainer(self, "DrawingGroupData").dumpXml()
print '<Drawings type="main" offset="%d">' % self.pos
OfficeArtWordDrawing(self).dump()
print '</Drawings>'
More information about the Libreoffice-commits
mailing list