[Libreoffice-commits] mso-dumper.git: msodumper/docrecord.py
msodumper/docrecord.py |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) New commits: commit 771b435fb0941d21c58cafd78d2c90f905ed29f6 Author: Miklos Vajna Date: Wed Aug 6 11:36:21 2014 +0200 docrecord: avoid UnicodeEncodeError on non-utf8 terminals As reported by Tor Lillqvist. diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py index 6904c5e..bb13b94 100644 --- a/msodumper/docrecord.py +++ b/msodumper/docrecord.py @@ -6,6 +6,7 @@ # import struct +import locale import globals from docdirstream import DOCDirStream import docsprm @@ -3070,7 +3071,8 @@ class Xst(DOCDirStream): def dump(self): print '' % self.pos self.printAndSet("cch", self.readuInt16()) -print '' % globals.encodeName(self.bytes[self.pos:self.pos + 2 * self.cch].decode('utf-16'), lowOnly=True) +lowOnly = locale.getdefaultlocale()[1] == "UTF-8" +print '' % globals.encodeName(self.bytes[self.pos:self.pos + 2 * self.cch].decode('utf-16'), lowOnly=lowOnly) self.pos += 2 * self.cch print '' ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] mso-dumper.git: msodumper/docrecord.py
msodumper/docrecord.py | 31 --- 1 file changed, 28 insertions(+), 3 deletions(-) New commits: commit ace8c2bce95132942b7116a92cf3ac97742ffcae Author: Miklos Vajna Date: Mon May 5 09:51:34 2014 +0200 dump TableBordersOperand diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py index 61512d7..63d3744 100644 --- a/msodumper/docrecord.py +++ b/msodumper/docrecord.py @@ -434,9 +434,11 @@ class COLORREF(DOCDirStream): class BRC(DOCDirStream): """The Brc structure specifies a border.""" -def __init__(self, parent): +def __init__(self, parent, name="brc"): DOCDirStream.__init__(self, parent.bytes) self.pos = parent.pos +self.parent = parent +self.name = name self.posOrig = self.pos self.cv = COLORREF(self) self.dptLineWidth = self.readuInt8() @@ -448,7 +450,7 @@ class BRC(DOCDirStream): self.fReserved = (buf & 0xff80) >> 7 # 8..16th bits def dump(self): -print '' % self.posOrig +print '<%s type="BRC" offset="%d">' % (self.name, self.posOrig) self.cv.dump("cv") self.printAndSet("dptLineWidth", self.dptLineWidth) self.printAndSet("brcType", self.brcType, dict=BrcType) @@ -456,7 +458,8 @@ class BRC(DOCDirStream): self.printAndSet("fShadow", self.fShadow) self.printAndSet("fFrame", self.fFrame) self.printAndSet("fReserved", self.fReserved) -print '' +print '' % self.name +self.parent.pos = self.pos class PChgTabsDel(DOCDirStream): @@ -1189,6 +1192,26 @@ class TDefTableOperand(DOCDirStream): print '' +class TableBordersOperand(DOCDirStream): +"""The TableBordersOperand structure specifies a set of borders for a table row.""" +def __init__(self, parent): +DOCDirStream.__init__(self, parent.bytes) +self.pos = parent.pos + +def dump(self): +print '' +self.printAndSet("cb", self.readuInt8()) +posOrig = self.pos +BRC(self, "brcTop").dump() +BRC(self, "brcLeft").dump() +BRC(self, "brcBottom").dump() +BRC(self, "brcRight").dump() +BRC(self, "brcHorizontalInside").dump() +BRC(self, "brcVerticalInside").dump() +assert self.pos == posOrig + 0x30 +print '' + + class SHDOperand(DOCDirStream): """The SDHOperand structure is an operand that is used by several Sprm structures to specify the background shading to be applied.""" @@ -1276,6 +1299,8 @@ class Sprm(DOCDirStream): self.ct = TDefTableOperand(self) elif self.sprm == 0xca71: self.ct = SHDOperand(self) +elif self.sprm == 0xd613: +self.ct = TableBordersOperand(self) else: print '' % (self.getOperandSize(), hex(self.sprm)) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] mso-dumper.git: msodumper/docrecord.py
msodumper/docrecord.py | 23 +++ 1 file changed, 23 insertions(+) New commits: commit d68a41972acc9414a5316e61e2d3e7975026f351 Author: Miklos Vajna Date: Mon May 5 10:32:28 2014 +0200 dump TableBordersOperand80 diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py index 63d3744..7b9dcfc 100644 --- a/msodumper/docrecord.py +++ b/msodumper/docrecord.py @@ -1212,6 +1212,27 @@ class TableBordersOperand(DOCDirStream): print '' +class TableBordersOperand80(DOCDirStream): +"""The TableBordersOperand80 structure is an operand that specifies the +borders which are applied to a row of table cells.""" +def __init__(self, parent): +DOCDirStream.__init__(self, parent.bytes) +self.pos = parent.pos + +def dump(self): +print '' +self.printAndSet("cb", self.readuInt8()) +posOrig = self.pos +Brc80MayBeNil(self, "brcTop").dump() +Brc80MayBeNil(self, "brcLeft").dump() +Brc80MayBeNil(self, "brcBottom").dump() +Brc80MayBeNil(self, "brcRight").dump() +Brc80MayBeNil(self, "brcHorizontalInside").dump() +Brc80MayBeNil(self, "brcVerticalInside").dump() +assert self.pos == posOrig + 0x18 +print '' + + class SHDOperand(DOCDirStream): """The SDHOperand structure is an operand that is used by several Sprm structures to specify the background shading to be applied.""" @@ -1301,6 +1322,8 @@ class Sprm(DOCDirStream): self.ct = SHDOperand(self) elif self.sprm == 0xd613: self.ct = TableBordersOperand(self) +elif self.sprm == 0xd605: +self.ct = TableBordersOperand80(self) else: print '' % (self.getOperandSize(), hex(self.sprm)) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] mso-dumper.git: msodumper/docrecord.py
msodumper/docrecord.py | 33 + 1 file changed, 33 insertions(+) New commits: commit b70d0f07e654c4a7dbf46ef5a70a3c94440546e8 Author: Miklos Vajna Date: Sun Apr 6 15:27:14 2014 +0200 doc: dump SHDOperand and SHD diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py index eaac4ff..61512d7 100644 --- a/msodumper/docrecord.py +++ b/msodumper/docrecord.py @@ -1109,6 +1109,21 @@ Fts = { } +class SHD(DOCDirStream): +"""The Shd structure specifies the colors and pattern that are used for background shading.""" +def __init__(self, parent): +DOCDirStream.__init__(self, parent.bytes) +self.parent = parent +self.pos = parent.pos + +def dump(self): +print '' % self.pos +COLORREF(self).dump("cvFore") +COLORREF(self).dump("cvBack") +self.printAndSet("ipat", self.readuInt16(), dict=Ipat) +print '' + + class TCGRF(DOCDirStream): """A TCGRF structure specifies the text layout and cell merge properties for a single cell in a table.""" def __init__(self, parent): @@ -1174,6 +1189,20 @@ class TDefTableOperand(DOCDirStream): print '' +class SHDOperand(DOCDirStream): +"""The SDHOperand structure is an operand that is used by several Sprm +structures to specify the background shading to be applied.""" +def __init__(self, parent): +DOCDirStream.__init__(self, parent.bytes) +self.pos = parent.pos + +def dump(self): +print '' +self.printAndSet("cb", self.readuInt8()) +SHD(self).dump() +print '' + + class BrcOperand(DOCDirStream): """The BrcOperand structure is the operand to several SPRMs that control borders.""" def __init__(self, parent): @@ -1245,6 +1274,10 @@ class Sprm(DOCDirStream): else: if self.sprm == 0xd608: self.ct = TDefTableOperand(self) +elif self.sprm == 0xca71: +self.ct = SHDOperand(self) +else: +print '' % (self.getOperandSize(), hex(self.sprm)) def dump(self): sgcmap = { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] mso-dumper.git: msodumper/docrecord.py test/doc
msodumper/docrecord.py |4 +++- test/doc/bookmark-nested.doc |binary test/doc/test.py | 13 + 3 files changed, 16 insertions(+), 1 deletion(-) New commits: commit 8218b715ca1dc17bbb0dc48a513d55cdcfd5fbf5 Author: Miklos Vajna Date: Tue Feb 4 13:54:28 2014 +0100 PlcfBkl: don't assume PlcfBkf and PlcfBkl are entirely parallel This is true for a single entry, but for multiple entires they may not be parallel: the ibkl in PlcfBkf contains the index in the PlcfBkl. diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py index a6e63c4..529a7bc 100644 --- a/msodumper/docrecord.py +++ b/msodumper/docrecord.py @@ -109,6 +109,7 @@ class PlcfBkf(DOCDirStream, PLC): self.pos = offset self.size = size self.aCP = [] +self.aFBKF = [] def dump(self): print '' % (self.pos, self.size) @@ -123,6 +124,7 @@ class PlcfBkf(DOCDirStream, PLC): # aFBKF aFBKF = FBKF(self, self.getOffset(self.pos, i)) aFBKF.dump() +self.aFBKF.append(aFBKF) print '' print '' @@ -202,7 +204,7 @@ class PlcfBkl(DOCDirStream, PLC): # aCp end = self.getuInt32(pos = pos) print '' % (i, end) -start = self.start.aCP[i] +start = self.start.aCP[self.start.aFBKF[i].ibkl] print '' % self.quoteAttr(self.mainStream.retrieveCPs(start, end)) pos += 4 print '' diff --git a/test/doc/bookmark-nested.doc b/test/doc/bookmark-nested.doc new file mode 100644 index 000..8cee8fa Binary files /dev/null and b/test/doc/bookmark-nested.doc differ diff --git a/test/doc/test.py b/test/doc/test.py index 1812d53..ec3f815 100755 --- a/test/doc/test.py +++ b/test/doc/test.py @@ -137,6 +137,19 @@ class Test(unittest.TestCase): # The bookmark covers Hello self.assertEqual('Hello', bookmarkEnds[0].findall('transformed')[0].attrib['value']) +def test_bookmark_nested(self): +self.dump('bookmark-nested') + +bookmarkStarts = self.root.findall('stream[@name="WordDocument"]/fib/fibRgFcLcbBlob/lcbPlcfBkf/plcfBkf/aCP') +bookmarkEnds = self.root.findall('stream[@name="WordDocument"]/fib/fibRgFcLcbBlob/lcbPlcfBkl/plcfBkl/aCP') +self.assertEqual(2, len(bookmarkStarts)) +self.assertEqual(2, len(bookmarkEnds)) + +# The outer bookmark should cover the inner one. +# This was 'aaa bbb', not 'bbb': the bookmark start was incorrect. +self.assertEqual('bbb', bookmarkEnds[0].findall('transformed')[0].attrib['value']) +self.assertEqual('aaa bbb ccc', bookmarkEnds[1].findall('transformed')[0].attrib['value']) + def test_zoom(self): self.dump('zoom') dopBase = self.root.findall('stream[@name="WordDocument"]/fib/fibRgFcLcbBlob/lcbDop/dop/dop2007/dop2003/dop2002/dop2000/dop97/dop95/dopBase')[0] ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits