[Libreoffice-commits] .: 4 commits - src/msodraw.py
Miklos Vajna
vmiklos at kemper.freedesktop.org
Tue May 7 01:56:33 PDT 2013
src/msodraw.py | 48 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 3 deletions(-)
New commits:
commit a61584730899b23850ceb13de2d3727a802a1602
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue May 7 10:55:10 2013 +0200
msodraw: dump wzName
diff --git a/src/msodraw.py b/src/msodraw.py
index 20ab513..0a30f71 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -445,6 +445,11 @@ class FOPT:
def __init__(self):
UnicodeComplex.__init__(self, "gtextFont")
+ class WzName(UnicodeComplex):
+
+ def __init__(self):
+ UnicodeComplex.__init__(self, "wzName")
+
class ShadowOffsetX:
def appendLines(self, recHdl, prop, level):
@@ -524,6 +529,7 @@ class FOPT:
0x01BF: ['Fill Style Boolean Properties', FillStyle],
0x01C0: ['Line Color', LineColor],
0x0303: ['Connector Shape Style (cxstyle)', CXStyle],
+ 0x0380: ['wzName', WzName],
0x03BF: ['Group Shape Boolean Properties', GroupShape],
0x0205: ['X Shadow Offset', ShadowOffsetX],
0x01CB: ['Line Width', LineWidth],
commit 1d11432e5fdc27891b13f7cc7a3204d66fc75191
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue May 7 10:43:04 2013 +0200
msodraw: dump gtextFont
diff --git a/src/msodraw.py b/src/msodraw.py
index ca3fe8a..20ab513 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -413,7 +413,15 @@ class FOPT:
color.dumpXml(recHdl)
recHdl.appendLine('</lineColor>')
- class GtextUNICODE:
+ # Hack, can't inherit from nested class otherwise.
+ global UnicodeComplex
+
+ class UnicodeComplex:
+ """Base class for properties that have a null-terminated Unicode string
+ as a complex property."""
+
+ def __init__(self, name):
+ self.name = name
def __parseBytes(self, prop):
# A null-terminated Unicode string.
@@ -421,11 +429,21 @@ class FOPT:
def appendLines(self, recHdl, prop, level):
self.__parseBytes(prop)
- recHdl.appendLine(indent(level)+"gtextUNICODE: %s"%self.string)
+ recHdl.appendLine(indent(level)+"%s: %s"%(self.name,self.string))
def dumpXml(self, recHdl, prop):
self.__parseBytes(prop)
- recHdl.appendLine('<gtextUNICODE value="%s"/>' % self.string)
+ recHdl.appendLine('<%s value="%s"/>' % (self.name, self.string))
+
+ class GtextUNICODE(UnicodeComplex):
+
+ def __init__(self):
+ UnicodeComplex.__init__(self, "gtextUNICODE")
+
+ class GtextFont(UnicodeComplex):
+
+ def __init__(self):
+ UnicodeComplex.__init__(self, "gtextFont")
class ShadowOffsetX:
@@ -501,6 +519,7 @@ class FOPT:
propTable = {
0x00BF: ['Text Boolean Properties', TextBoolean],
0x00C0: ['gtextUNICODE', GtextUNICODE],
+ 0x00C5: ['gtextFont', GtextFont],
0x0181: ['Fill Color', FillColor],
0x01BF: ['Fill Style Boolean Properties', FillStyle],
0x01C0: ['Line Color', LineColor],
commit 85fffcb694cbb2a3e943b287d9a283ff4250a4aa
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue May 7 10:30:27 2013 +0200
msodraw: dump gtextUNICODE
diff --git a/src/msodraw.py b/src/msodraw.py
index e029527..ca3fe8a 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -413,6 +413,20 @@ class FOPT:
color.dumpXml(recHdl)
recHdl.appendLine('</lineColor>')
+ class GtextUNICODE:
+
+ def __parseBytes(self, prop):
+ # A null-terminated Unicode string.
+ self.string = prop.extra[0:-2].decode('utf-16')
+
+ def appendLines(self, recHdl, prop, level):
+ self.__parseBytes(prop)
+ recHdl.appendLine(indent(level)+"gtextUNICODE: %s"%self.string)
+
+ def dumpXml(self, recHdl, prop):
+ self.__parseBytes(prop)
+ recHdl.appendLine('<gtextUNICODE value="%s"/>' % self.string)
+
class ShadowOffsetX:
def appendLines(self, recHdl, prop, level):
@@ -486,6 +500,7 @@ class FOPT:
propTable = {
0x00BF: ['Text Boolean Properties', TextBoolean],
+ 0x00C0: ['gtextUNICODE', GtextUNICODE],
0x0181: ['Fill Color', FillColor],
0x01BF: ['Fill Style Boolean Properties', FillStyle],
0x01C0: ['Line Color', LineColor],
commit 6d1929df8e31bb128fda23d0b92c36e2938b21b5
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue May 7 09:54:40 2013 +0200
msodraw: fix reading non-complex props after complex ones
For non-complex properties, the situation is easy: there is an array of
record headers, and the value is part of the header as well. The old
code assumed that the complex payload (the size of it is specified by
the value in the header) is right after each header, but it turns out
that the stream first contains all the headers, then the payloads.
Note that in case the only complex property is the last one, then the
behavior is unchanged.
A reproducer for this can be a watermark-enabled doc file produced by
Word, and LO's DffPropSet::ReadPropSet() does the same.
diff --git a/src/msodraw.py b/src/msodraw.py
index 082f0a3..e029527 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -539,8 +539,9 @@ class FOPT:
self.type = type
def __parseBytes(self, rh):
+ complexPos = self.strm.pos + (rh.recInstance * 6)
strm = globals.ByteStream(self.strm.readBytes(rh.recLen))
- while not strm.isEndOfRecord():
+ for i in xrange(0, rh.recInstance):
entry = FOPT.E()
val = strm.readUnsignedInt(2)
entry.ID = (val & 0x3FFF)
@@ -548,9 +549,10 @@ 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:
+ if self.strm.pos + entry.value > self.strm.size:
break
- entry.extra = strm.readBytes(entry.value)
+ entry.extra = self.strm.bytes[complexPos:complexPos+entry.value]
+ complexPos += entry.value
self.properties.append(entry)
def appendLines (self, recHdl, rh):
More information about the Libreoffice-commits
mailing list