[ooo-build-commit] 2 commits - scratch/mso-dumper
Thorsten Behrens
thorsten at kemper.freedesktop.org
Wed Sep 23 03:51:55 PDT 2009
scratch/mso-dumper/src/pptrecord.py | 131 ++++++++++++++++++++++++++++++++++--
scratch/mso-dumper/src/pptstream.py | 22 +++---
2 files changed, 136 insertions(+), 17 deletions(-)
New commits:
commit e227b231140f7f48d03e840a19e6aa1ead074f55
Author: Thorsten Behrens <tbehrens at novell.com>
Date: Wed Sep 23 12:49:56 2009 +0200
More parser robustness
* scratch/mso-dumper/src/pptrecord.py:
* scratch/mso-dumper/src/pptstream.py:
diff --git a/scratch/mso-dumper/src/pptrecord.py b/scratch/mso-dumper/src/pptrecord.py
index 999fc47..f341f06 100644
--- a/scratch/mso-dumper/src/pptrecord.py
+++ b/scratch/mso-dumper/src/pptrecord.py
@@ -40,7 +40,10 @@ append a line to be displayed.
pass
def __print (self, text):
- print(self.prefix + text)
+ try:
+ print(self.prefix + text)
+ except UnicodeEncodeError:
+ print(self.prefix + "<%d invalid chars>"%len(text))
def output (self):
self.parseBytes()
@@ -402,7 +405,7 @@ class AnimNode(BaseRecordHandler):
"""Animation node."""
restartDesc=["default","always","whenNotActive","never"]
- groupTypeDesc=["parallel","sequential","node","media"]
+ groupTypeDesc=["parallel","sequential","node","media","unknown"]
fillDesc=["unknown","always","whenOff","never"]
nodeActivationDesc=["unknown","onClick","withPrevious","afterPrevious",
"mainSequence","interactiveSequence","timingRoot"]
@@ -488,6 +491,9 @@ class AnimKeyTime(BaseRecordHandler):
class AnimValue(BaseRecordHandler):
"""Animate values."""
+ def handleDefault (self):
+ self.appendLine("unknown value: %Xh"%self.readUnsignedInt(4))
+
def handleRepeat (self):
self.appendLine("repeat count: %f"%globals.getFloat(self.readBytes(4)))
@@ -501,7 +507,7 @@ class AnimValue(BaseRecordHandler):
if self.readUnsignedInt(4) != 0:
self.appendLine("autoReverse is on")
- valueHandlers=[handleRepeat,None,None,handleAccelerate,handleDecelerate,handleAutoReverse]
+ valueHandlers=[handleRepeat,handleDefault,handleDefault,handleAccelerate,handleDecelerate,handleAutoReverse]
def parseBytes (self):
valueType = self.readUnsignedInt(4)
@@ -757,12 +763,12 @@ class MsoArrayPropertyHandler(BasePropertyHandler):
elementSize = self.readUnsignedInt(2)
self.printer("%4.4Xh: %s: [\"%s\"]"%(self.propType, self.propEntry[0], self.propEntry[2]))
for i in xrange(0, numElements):
- if elementSize > 4:
- bytes = self.readBytes(elementSize)
- self.printer("%4.4Xh: %d = [complex type]"%(self.propType,i))
- else:
+ if elementSize in [0,1,2,4]:
currElem = self.readUnsignedInt(elementSize)
self.printer("%4.4Xh: %d = %Xh"%(self.propType,i,currElem))
+ else:
+ bytes = self.readBytes(elementSize)
+ self.printer("%4.4Xh: %d = [complex type]"%(self.propType,i))
class UniCharPropertyHandler(BasePropertyHandler):
"""unicode string property."""
diff --git a/scratch/mso-dumper/src/pptstream.py b/scratch/mso-dumper/src/pptstream.py
index 96f0a82..a495413 100644
--- a/scratch/mso-dumper/src/pptstream.py
+++ b/scratch/mso-dumper/src/pptstream.py
@@ -164,11 +164,11 @@ class PPTDirStream(object):
subSubStrm = PPTDirStream(bytes, self.params, self.prefix+" ", recordInfo)
subSubStrm.readRecords()
elif (recordInfo is not None
- and recordInfo[1] == "magic"
- and self.isPPT10SpecialData()):
- # what a mess. PPT10 binary data is just another embedded
- # stream
- self.handlePPT10BinaryTags(bytes,recordInfo)
+ and recordInfo[1] == "magic"):
+ if self.isPPT10SpecialData():
+ # what a mess. PPT10 binary data is just another embedded
+ # stream
+ self.handlePPT10BinaryTags(bytes,recordInfo)
elif recordInfo is not None:
handler = recordInfo[1](recordType, recordInstance, size, bytes, self.properties, self.prefix)
print("")
commit e0214b2b2a71a7b6a8c2c481af8761316d1a0d64
Author: Thorsten Behrens <tbehrens at novell.com>
Date: Wed Sep 23 11:44:56 2009 +0200
Handle more of the smil anim atoms
* scratch/mso-dumper/src/pptrecord.py:
* scratch/mso-dumper/src/pptstream.py:
diff --git a/scratch/mso-dumper/src/pptrecord.py b/scratch/mso-dumper/src/pptrecord.py
index 0abd53a..999fc47 100644
--- a/scratch/mso-dumper/src/pptrecord.py
+++ b/scratch/mso-dumper/src/pptrecord.py
@@ -331,7 +331,7 @@ class ColorScheme(BaseRecordHandler):
"Accent and followed hyperlink"))
# -------------------------------------------------------------------
-# special record handlers: text style properties
+# special record handlers: ppt97 animation info
class AnimationInfo(BaseRecordHandler):
"""Animation properties."""
@@ -396,6 +396,119 @@ class AnimationInfo(BaseRecordHandler):
# -------------------------------------------------------------------
+# special record handlers: SMIL animation
+
+class AnimNode(BaseRecordHandler):
+ """Animation node."""
+
+ restartDesc=["default","always","whenNotActive","never"]
+ groupTypeDesc=["parallel","sequential","node","media"]
+ fillDesc=["unknown","always","whenOff","never"]
+ nodeActivationDesc=["unknown","onClick","withPrevious","afterPrevious",
+ "mainSequence","interactiveSequence","timingRoot"]
+
+ def parseBytes (self):
+ self.readUnsignedInt(4)
+ self.appendLine("restart: %s"%self.restartDesc[self.readUnsignedInt(4)])
+ self.appendLine("groupType: %s"%self.groupTypeDesc[self.readUnsignedInt(4)])
+ self.appendLine("fill: %s"%self.fillDesc[self.readUnsignedInt(4)])
+ self.readUnsignedInt(4)
+ self.readUnsignedInt(4)
+ self.appendLine("duration: %f secs"%(self.readSignedInt(4)/1000.0))
+ nodeKind = self.readUnsignedInt(4)
+ if nodeKind == 25:
+ self.appendLine("nodeKind: animation")
+ elif nodeKind == 24:
+ self.appendLine("nodeKind: transitionFilter")
+ else:
+ self.appendLine("nodeKind: unknown/ignore")
+
+
+class AnimAttributeValue(BaseRecordHandler):
+ """Animation attribute values."""
+
+ def handleByte (self):
+ self.appendLine("byte value: %2.2Xh"%self.readUnsignedInt(1))
+
+ def handleLong (self):
+ self.appendLine("long value: %d"%self.readUnsignedInt(4))
+
+ def handleFloat (self):
+ self.appendLine("float value: %f"%globals.getFloat(self.readBytes(4)))
+
+ def handleString (self):
+ value = globals.getUTF8FromUTF16(globals.getTextBytes(self.readRemainingBytes()))
+ self.appendLine("text value: '%s'"%value)
+
+ valueHandlers=[handleByte,handleLong,handleFloat,handleString]
+
+ def parseBytes (self):
+ valueType = self.readUnsignedInt(1)
+ self.valueHandlers[valueType](self)
+
+
+class AnimateData(BaseRecordHandler):
+ """Animate data values."""
+
+ calcModeDesc=["discrete","linear","formula"]
+ valueTypeDesc=["string","number","color"]
+ def parseBytes (self):
+ self.appendLine("calc mode: %s"%self.calcModeDesc[self.readUnsignedInt(4)])
+ self.appendLine("flags: %4.4Xh"%self.readUnsignedInt(4))
+ self.appendLine("value type: %s"%self.valueTypeDesc[self.readUnsignedInt(4)])
+
+
+class AnimKeyTime(BaseRecordHandler):
+ """Animate key times."""
+
+ def parseBytes (self):
+ self.appendLine("time: %f"%(self.readSignedInt(4)/1000.0))
+
+
+class AnimTrigger(BaseRecordHandler):
+ """Animation trigger."""
+
+ triggerDesc=["none","onBegin","onEnd","beginEvent","endEvent","onClick",
+ "onDoubleClick","onMouseEnter","onMouseLeave","onNext",
+ "onPrev","onStopAudio"]
+ def parseBytes (self):
+ self.readUnsignedInt(4)
+ self.appendLine("trigger: %s"%self.triggerDesc[self.readUnsignedInt(4)])
+ self.readUnsignedInt(4)
+ self.appendLine("begin time: %f"%(self.readSignedInt(4)/1000.0))
+
+
+class AnimKeyTime(BaseRecordHandler):
+ """Animate key times."""
+
+ def parseBytes (self):
+ self.appendLine("time: %f"%(self.readSignedInt(4)/1000.0))
+
+
+class AnimValue(BaseRecordHandler):
+ """Animate values."""
+
+ def handleRepeat (self):
+ self.appendLine("repeat count: %f"%globals.getFloat(self.readBytes(4)))
+
+ def handleAccelerate (self):
+ self.appendLine("accelerate amount: %f"%globals.getFloat(self.readBytes(4)))
+
+ def handleDecelerate (self):
+ self.appendLine("decelerate amount: %f"%globals.getFloat(self.readBytes(4)))
+
+ def handleAutoReverse (self):
+ if self.readUnsignedInt(4) != 0:
+ self.appendLine("autoReverse is on")
+
+ valueHandlers=[handleRepeat,None,None,handleAccelerate,handleDecelerate,handleAutoReverse]
+
+ def parseBytes (self):
+ valueType = self.readUnsignedInt(4)
+ self.valueHandlers[valueType](self)
+
+
+# -------------------------------------------------------------------
# special record handlers: text style properties
class TextStyles(BaseRecordHandler):
diff --git a/scratch/mso-dumper/src/pptstream.py b/scratch/mso-dumper/src/pptstream.py
index 46a42a1..96f0a82 100644
--- a/scratch/mso-dumper/src/pptstream.py
+++ b/scratch/mso-dumper/src/pptstream.py
@@ -410,9 +410,9 @@ recData = {
0x2AFB: ["DFF_msofbtAnimReference"],
0xF125: ["DFF_msofbtAnimEvent"],
-0xF127: ["DFF_msofbtAnimNode"],
-0xF128: ["DFF_msofbtAnimTrigger"],
-0xF129: ["DFF_msofbtAnimValue"],
+0xF127: ["DFF_msofbtAnimNode", pptrecord.AnimNode],
+0xF128: ["DFF_msofbtAnimTrigger", pptrecord.AnimTrigger],
+0xF129: ["DFF_msofbtAnimValue", pptrecord.AnimValue],
0xF12A: ["DFF_msofbtAnimateTarget"],
0xF12B: ["DFF_msofbtAnimate"],
0xF12C: ["DFF_msofbtAnimateColor"],
@@ -423,7 +423,7 @@ recData = {
0xF131: ["DFF_msofbtAnimateSet"],
0xF132: ["DFF_msofbtAnimCommand"],
0xF133: ["DFF_msofbtAnimateTargetSettings"],
-0xF134: ["DFF_msofbtAnimateData"],
+0xF134: ["DFF_msofbtAnimateData", pptrecord.AnimateData],
0xF135: ["DFF_msofbtAnimateColorData"],
0xF136: ["DFF_msofbtAnimateFilterData"],
0xF137: ["DFF_msofbtAnimateMotionData"],
@@ -436,8 +436,8 @@ recData = {
0xF13F: ["DFF_msofbtAnimKeyPoints"],
0xF140: ["DFF_msofbtAnimIteration"],
0xF141: ["DFF_msofbtAnimActions"],
-0xF142: ["DFF_msofbtAnimAttributeValue"],
-0xF143: ["DFF_msofbtAnimKeyTime"],
+0xF142: ["DFF_msofbtAnimAttributeValue", pptrecord.AnimAttributeValue],
+0xF143: ["DFF_msofbtAnimKeyTime", pptrecord.AnimKeyTime],
0xF144: ["DFF_msofbtAnimGroup"],
0xF145: ["DFF_msofbtAnimSubGoup"],
0xF138: ["DFF_msofbtAnimateRotationData"],
More information about the ooo-build-commit
mailing list