[Libreoffice-commits] .: 2 commits - src/docrecord.py src/msodraw.py
Miklos Vajna
vmiklos at kemper.freedesktop.org
Wed Jan 16 08:35:53 PST 2013
src/docrecord.py | 4 +--
src/msodraw.py | 73 +++++++++++++++++++++++++++++++++----------------------
2 files changed, 47 insertions(+), 30 deletions(-)
New commits:
commit 318a8dc91b9fbd0ee3654049c70b8bd84a8fb14b
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Jan 16 17:34:09 2013 +0100
msodraw: handle Word OfficeArtClientAnchor and guard against invalid size
diff --git a/src/msodraw.py b/src/msodraw.py
index b11ea5d..81002a9 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -473,6 +473,8 @@ class FOPT:
entry.flagComplex = (val & 0x8000) # if true, the value stores the size of the extra bytes.
entry.value = strm.readSignedInt(4)
if entry.flagComplex:
+ if strm.pos + entry.value > strm.size:
+ break
entry.extra = strm.readBytes(entry.value)
self.properties.append(entry)
@@ -507,23 +509,24 @@ class FOPT:
recHdl.appendLine('<fopt type="OfficeArtRGFOPTE">')
for i in xrange(0, rh.recInstance):
recHdl.appendLine('<rgfopte index="%d">' % i)
- prop = self.properties[i]
- recHdl.appendLine('<opid>')
- recHdl.appendLine('<opid value="0x%4.4X"/>' % prop.ID)
- recHdl.appendLine('<opid fBid="%d"/>' % prop.flagBid)
- recHdl.appendLine('<opid fComplex="%d"/>' % prop.flagComplex)
- recHdl.appendLine('</opid>')
- if FOPT.propTable.has_key(prop.ID):
- # We have a handler for this property.
- # propData is expected to have two elements: name (0) and handler (1).
- propHdl = FOPT.propTable[prop.ID]
- recHdl.appendLine('<op name="%s" value="0x%4.4X">' % (propHdl[0], prop.ID))
- propHdl[1]().dumpXml(recHdl, prop)
- recHdl.appendLine('</op>')
- else:
- recHdl.appendLine('<op value="0x%8.8X"/>' % prop.value)
- if prop.flagComplex:
- recHdl.appendLine('<todo what="FOPT: fComplex != 0 unhandled"/>')
+ if i < len(self.properties):
+ prop = self.properties[i]
+ recHdl.appendLine('<opid>')
+ recHdl.appendLine('<opid value="0x%4.4X"/>' % prop.ID)
+ recHdl.appendLine('<opid fBid="%d"/>' % prop.flagBid)
+ recHdl.appendLine('<opid fComplex="%d"/>' % prop.flagComplex)
+ recHdl.appendLine('</opid>')
+ if FOPT.propTable.has_key(prop.ID):
+ # We have a handler for this property.
+ # propData is expected to have two elements: name (0) and handler (1).
+ propHdl = FOPT.propTable[prop.ID]
+ recHdl.appendLine('<op name="%s" value="0x%4.4X">' % (propHdl[0], prop.ID))
+ propHdl[1]().dumpXml(recHdl, prop)
+ recHdl.appendLine('</op>')
+ else:
+ recHdl.appendLine('<op value="0x%8.8X"/>' % prop.value)
+ if prop.flagComplex:
+ recHdl.appendLine('<todo what="FOPT: fComplex != 0 unhandled"/>')
recHdl.appendLine('</rgfopte>')
recHdl.appendLine('</fopt>')
recHdl.appendLine('</shapePrimaryOptions>')
@@ -718,6 +721,17 @@ class FClientAnchorSheet:
obj = xlsmodel.Shape(self.col1, self.row1, self.dx1, self.dy1, self.col2, self.row2, self.dx2, self.dy2)
sheet.addShape(obj)
+class OfficeArtClientAnchor:
+ """Word-specific anchor data."""
+
+ def __init__ (self, strm):
+ self.clientanchor = strm.readSignedInt(4)
+
+ def dumpXml(self, recHdl):
+ recHdl.appendLine('<officeArtClientAnchor type="OfficeArtClientAnchor">')
+ recHdl.appendLine('<clientanchor value="0x%4.4X"/>' % self.clientanchor)
+ recHdl.appendLine('</officeArtClientAnchor>')
+
# ----------------------------------------------------------------------------
class MSODrawHandler(globals.ByteStream):
@@ -780,7 +794,10 @@ class MSODrawHandler(globals.ByteStream):
rh = RecordHeader(self)
rh.dumpXml(self)
saved = self.pos
- if rh.recType in recData:
+ if rh.recType == RecordHeader.Type.FClientAnchor and model.hostApp == globals.ModelBase.HostAppType.Word:
+ child = OfficeArtClientAnchor(self)
+ child.dumpXml(self)
+ elif rh.recType in recData:
child = recData[rh.recType](self)
child.dumpXml(self, model, rh)
else:
commit 5e1e18c11b0174c08657fcabf1c6246009f0cff0
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Jan 16 17:09:45 2013 +0100
msodraw: pass the model, so app-specific client anchor can be dumped
diff --git a/src/docrecord.py b/src/docrecord.py
index 5210db5..f277196 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -1802,7 +1802,7 @@ class OfficeArtWordDrawing(DOCDirStream):
def dump(self):
print '<officeArtWordDrawing type="OfficeArtWordDrawing" pos="%d">' % self.pos
self.printAndSet("dgglbl", self.readuInt8())
- msodraw.DgContainer(self, "container").dumpXml(self)
+ msodraw.DgContainer(self, "container").dumpXml(self, globals.ModelBase(globals.ModelBase.HostAppType.Word))
print '</officeArtWordDrawing>'
self.officeArtContent.pos = self.pos
@@ -1816,7 +1816,7 @@ class OfficeArtContent(DOCDirStream):
def dump(self):
print '<officeArtContent type="OfficeArtContent" offset="%d" size="%d bytes">' % (self.pos, self.size)
- msodraw.DggContainer(self, "DrawingGroupData").dumpXml(self)
+ msodraw.DggContainer(self, "DrawingGroupData").dumpXml(self, globals.ModelBase(globals.ModelBase.HostAppType.Word))
print '<Drawings type="main" offset="%d">' % self.pos
OfficeArtWordDrawing(self).dump()
print '</Drawings>'
diff --git a/src/msodraw.py b/src/msodraw.py
index 29c65ce..b11ea5d 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -183,7 +183,7 @@ class FDG:
recHdl.appendLine(" shape count: %d"%self.shapeCount)
recHdl.appendLine(" last shape ID: %d"%self.lastShapeID)
- def dumpXml(self, recHdl, rh):
+ def dumpXml(self, recHdl, model, rh):
recHdl.appendLine('<drawingData type="OfficeArtFDG">')
recHdl.appendLine('<csp value="%d"/>' % self.shapeCount)
recHdl.appendLine('<spidCur value="%d"/>' % self.lastShapeID)
@@ -244,7 +244,7 @@ class FDGGBlock:
for idcl in self.idcls:
idcl.appendLines(recHdl, rh)
- def dumpXml(self, recHdl, rh):
+ def dumpXml(self, recHdl, model, rh):
recHdl.appendLine('<drawingGroup type="OfficeArtFDGGBlock">')
self.head.dumpXml(recHdl, rh)
for i, idcl in enumerate(self.idcls):
@@ -500,7 +500,7 @@ class FOPT:
# regular property value
recHdl.appendLine(" property value: 0x%8.8X"%prop.value)
- def dumpXml(self, recHdl, rh):
+ def dumpXml(self, recHdl, model, rh):
self.__parseBytes(rh)
recHdl.appendLine('<shapePrimaryOptions type="OfficeArtFOPT">')
@@ -571,8 +571,8 @@ class FSP:
recHdl.appendLineBoolean(" background shape", self.background)
recHdl.appendLineBoolean(" have shape type property", self.haveProperties)
- def dumpXml(self, recHdl, rh):
- recHdl.appendLine('<shapeProp type="OfficeArtFSPGR">')
+ def dumpXml(self, recHdl, model, rh):
+ recHdl.appendLine('<shapeProp type="OfficeArtFSP">')
recHdl.appendLine('<spid value="%d"/>' % self.spid)
recHdl.appendLine('<fGroup value="%d"/>' % self.groupShape)
recHdl.appendLine('<fChild value="%d"/>' % self.childShape)
@@ -603,7 +603,7 @@ class FSPGR:
recHdl.appendLine(" right boundary: %d"%self.right)
recHdl.appendLine(" bottom boundary: %d"%self.bottom)
- def dumpXml(self, recHdl, rh):
+ def dumpXml(self, recHdl, model, rh):
recHdl.appendLine('<shapeGroup type="OfficeArtFSPGR">')
recHdl.appendLine('<xLeft value="%d"/>' % self.left)
recHdl.appendLine('<yTop value="%d"/>' % self.top)
@@ -662,7 +662,7 @@ class FClientData:
recHdl.appendLine("FClientData content")
recHdl.appendLine(" data: 0x%8.8X"%self.data)
- def dumpXml(self, recHdl, rh):
+ def dumpXml(self, recHdl, model, rh):
recHdl.appendLine('<clientData type="OfficeArtClientData">')
recHdl.appendLine('<data value="0x%8.8X"/>' % self.data)
recHdl.appendLine('</clientData>')
@@ -679,7 +679,7 @@ class SplitMenuColorContainer:
for msocr in self.smca:
msocr.appendLines(recHdl, rh)
- def dumpXml(self, recHdl, rh):
+ def dumpXml(self, recHdl, model, rh):
recHdl.appendLine('<splitColors type="OfficeArtSplitMenuColorContainer">')
for i, smca in enumerate(self.smca):
recHdl.appendLine('<smca index="%d">' % i)
@@ -768,7 +768,7 @@ class MSODrawHandler(globals.ByteStream):
# unknown object
bytes = self.readBytes(rh.recLen)
- def dumpXml (self, recHdl, rh = None):
+ def dumpXml (self, recHdl, model, rh = None):
recHdl.appendLine('<%s type="%s">' % (self.name, self.type))
if rh:
self.rh = rh
@@ -782,7 +782,7 @@ class MSODrawHandler(globals.ByteStream):
saved = self.pos
if rh.recType in recData:
child = recData[rh.recType](self)
- child.dumpXml(self, rh)
+ child.dumpXml(self, model, rh)
else:
recHdl.appendLine('<todo what="%s: recType = %s unhandled (size: %d bytes)"/>' % (self.type, hex(rh.recType), rh.recLen))
self.pos = saved + rh.recLen
More information about the Libreoffice-commits
mailing list