[Libreoffice-commits] .: 2 commits - src/docrecord.py src/docstream.py
Miklos Vajna
vmiklos at kemper.freedesktop.org
Wed Nov 21 05:34:59 PST 2012
src/docrecord.py | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/docstream.py | 16 +++++++-
2 files changed, 113 insertions(+), 2 deletions(-)
New commits:
commit c5eb2a70373ec6400dfc6314c6bf7bafbe1f97de
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Nov 21 14:34:51 2012 +0100
dump PlcfBkl
diff --git a/src/docrecord.py b/src/docrecord.py
index 7a01627..cecdef4 100755
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -101,7 +101,7 @@ class FBKF(DOCDirStream):
self.pos += 2
print '</aFBKF>'
-class PlcfAtnBkf(DOCDirStream, PLC):
+class PlcfBkf(DOCDirStream, PLC):
"""A PLCFBKF is a PLC whose data elements are FBKF structures."""
def __init__(self, mainStream, offset, size):
DOCDirStream.__init__(self, mainStream.doc.getDirectoryStreamByName("1Table").bytes, mainStream = mainStream)
@@ -110,7 +110,7 @@ class PlcfAtnBkf(DOCDirStream, PLC):
self.size = size
def dump(self):
- print '<plcfAtnBkf type="PlcfAtnBkf" offset="%d" size="%d bytes">' % (self.pos, self.size)
+ print '<plcfBkf type="PlcfAtnBkf" offset="%d" size="%d bytes">' % (self.pos, self.size)
offset = self.mainStream.fcMin
pos = self.pos
for i in range(self.getElements()):
@@ -124,7 +124,53 @@ class PlcfAtnBkf(DOCDirStream, PLC):
aFBKF = FBKF(self, self.getOffset(self.pos, i))
aFBKF.dump()
print '</aCP>'
- print '</plcfAtnBkf>'
+ print '</plcfBkf>'
+
+class PlcfBkf(DOCDirStream, PLC):
+ """A PLCFBKF is a PLC whose data elements are FBKF structures."""
+ def __init__(self, mainStream, offset, size):
+ DOCDirStream.__init__(self, mainStream.doc.getDirectoryStreamByName("1Table").bytes, mainStream = mainStream)
+ PLC.__init__(self, size, 4) # 4 is defined by 2.8.10
+ self.pos = offset
+ self.size = size
+
+ def dump(self):
+ print '<plcfBkf type="PlcfBkf" offset="%d" size="%d bytes">' % (self.pos, self.size)
+ offset = self.mainStream.fcMin
+ pos = self.pos
+ for i in range(self.getElements()):
+ # aCp
+ start = offset + self.getuInt32(pos = pos)
+ print '<aCP index="%d" bookmarkStart="%d">' % (i, start)
+ print '<transformed value="%s"/>' % FcCompressed.getFCTransformedValue(self.mainStream.bytes, start, start + 1)
+ pos += 4
+
+ # aFBKF
+ aFBKF = FBKF(self, self.getOffset(self.pos, i))
+ aFBKF.dump()
+ print '</aCP>'
+ print '</plcfBkf>'
+
+class PlcfBkl(DOCDirStream, PLC):
+ """The Plcfbkl structure is a PLC that contains only CPs and no additional data."""
+ def __init__(self, mainStream, offset, size):
+ DOCDirStream.__init__(self, mainStream.doc.getDirectoryStreamByName("1Table").bytes, mainStream = mainStream)
+ PLC.__init__(self, size, 0) # 0 is defined by 2.8.12
+ self.pos = offset
+ self.size = size
+
+ def dump(self):
+ print '<plcfBkl type="PlcfBkl" offset="%d" size="%d bytes">' % (self.pos, self.size)
+ offset = self.mainStream.fcMin
+ pos = self.pos
+ for i in range(self.getElements()):
+ # aCp
+ end = offset + self.getuInt32(pos = pos)
+ print '<aCP index="%d" bookmarkEnd="%d">' % (i, end)
+ print '<transformed value="%s"/>' % FcCompressed.getFCTransformedValue(self.mainStream.bytes, end, end + 1)
+ pos += 4
+ print '</aCP>'
+ print '</plcfBkl>'
class PlcPcd(DOCDirStream, PLC):
"""The PlcPcd structure is a PLC whose data elements are Pcds (8 bytes each)."""
diff --git a/src/docstream.py b/src/docstream.py
index 98cc8e2..d9a539d 100755
--- a/src/docstream.py
+++ b/src/docstream.py
@@ -275,7 +275,7 @@ class WordDocumentStream(DOCDirStream):
["fcPlcfAtnBkf"],
["lcbPlcfAtnBkf", self.handleLcbPlcfAtnBkf],
["fcPlcfAtnBkl"],
- ["lcbPlcfAtnBkl"],
+ ["lcbPlcfAtnBkl", self.handleLcbPlcfAtnBkl],
["fcPms"],
["lcbPms"],
["fcFormFldSttbs"],
@@ -433,8 +433,14 @@ class WordDocumentStream(DOCDirStream):
def handleLcbPlcfAtnBkf(self):
offset = self.fcPlcfAtnBkf
size = self.lcbPlcfAtnBkf
- plcfAtnBkf = docrecord.PlcfAtnBkf(self, offset, size)
- plcfAtnBkf.dump()
+ plcfBkf = docrecord.PlcfBkf(self, offset, size)
+ plcfBkf.dump()
+
+ def handleLcbPlcfAtnBkl(self):
+ offset = self.fcPlcfAtnBkl
+ size = self.lcbPlcfAtnBkl
+ plcfBkl = docrecord.PlcfBkl(self, offset, size)
+ plcfBkl.dump()
def dumpFibRgFcLcb97(self, name):
print '<%s type="FibRgFcLcb97" size="744 bytes">' % name
commit 74d77409cdcbd7f96325efffeea774c42c89e11b
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Nov 21 14:22:17 2012 +0100
dump PlcfAtnBkf
diff --git a/src/docrecord.py b/src/docrecord.py
index 7378068..7a01627 100755
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -73,6 +73,59 @@ class PLC:
def getPLCOffset(pos, elements, structSize, i):
return pos + (4 * (elements + 1)) + (structSize * i)
+class BKC(DOCDirStream):
+ """The BKC structure contains information about how a bookmark interacts with tables."""
+ def __init__(self, bkc):
+ self.bkc = bkc
+
+ def dump(self):
+ print '<bkc type="BKC">'
+ self.printAndSet("itcFirst", self.bkc & 0x007f) # 1..7th bits
+ self.printAndSet("fPub", self.getBit(self.bkc, 8))
+ self.printAndSet("itcLim", (self.bkc & 0x3f00) >> 8) # 9..14th bits
+ self.printAndSet("fNative", self.getBit(self.bkc, 15))
+ self.printAndSet("fCol", self.getBit(self.bkc, 16))
+ print '</bkc>'
+
+class FBKF(DOCDirStream):
+ """The FBKF structure contains information about a bookmark."""
+ def __init__(self, plcfAtnBkf, offset):
+ DOCDirStream.__init__(self, plcfAtnBkf.bytes)
+ self.pos = offset
+
+ def dump(self):
+ print '<aFBKF type="FBKF" offset="%d">' % self.pos
+ self.printAndSet("ibkl", self.getuInt16())
+ self.pos += 2
+ BKC(self.getuInt16()).dump()
+ self.pos += 2
+ print '</aFBKF>'
+
+class PlcfAtnBkf(DOCDirStream, PLC):
+ """A PLCFBKF is a PLC whose data elements are FBKF structures."""
+ def __init__(self, mainStream, offset, size):
+ DOCDirStream.__init__(self, mainStream.doc.getDirectoryStreamByName("1Table").bytes, mainStream = mainStream)
+ PLC.__init__(self, size, 4) # 4 is defined by 2.8.10
+ self.pos = offset
+ self.size = size
+
+ def dump(self):
+ print '<plcfAtnBkf type="PlcfAtnBkf" offset="%d" size="%d bytes">' % (self.pos, self.size)
+ offset = self.mainStream.fcMin
+ pos = self.pos
+ for i in range(self.getElements()):
+ # aCp
+ start = offset + self.getuInt32(pos = pos)
+ print '<aCP index="%d" bookmarkStart="%d">' % (i, start)
+ print '<transformed value="%s"/>' % FcCompressed.getFCTransformedValue(self.mainStream.bytes, start, start + 1)
+ pos += 4
+
+ # aFBKF
+ aFBKF = FBKF(self, self.getOffset(self.pos, i))
+ aFBKF.dump()
+ print '</aCP>'
+ print '</plcfAtnBkf>'
+
class PlcPcd(DOCDirStream, PLC):
"""The PlcPcd structure is a PLC whose data elements are Pcds (8 bytes each)."""
def __init__(self, bytes, mainStream, offset, size):
diff --git a/src/docstream.py b/src/docstream.py
index 91644dd..98cc8e2 100755
--- a/src/docstream.py
+++ b/src/docstream.py
@@ -273,7 +273,7 @@ class WordDocumentStream(DOCDirStream):
["fcPlcSpaHdr"],
["lcbPlcSpaHdr"],
["fcPlcfAtnBkf"],
- ["lcbPlcfAtnBkf"],
+ ["lcbPlcfAtnBkf", self.handleLcbPlcfAtnBkf],
["fcPlcfAtnBkl"],
["lcbPlcfAtnBkl"],
["fcPms"],
@@ -430,6 +430,12 @@ class WordDocumentStream(DOCDirStream):
sttbfAtnBkmk = docrecord.SttbfAtnBkmk(self, offset, size)
sttbfAtnBkmk.dump()
+ def handleLcbPlcfAtnBkf(self):
+ offset = self.fcPlcfAtnBkf
+ size = self.lcbPlcfAtnBkf
+ plcfAtnBkf = docrecord.PlcfAtnBkf(self, offset, size)
+ plcfAtnBkf.dump()
+
def dumpFibRgFcLcb97(self, name):
print '<%s type="FibRgFcLcb97" size="744 bytes">' % name
self.__dumpFibRgFcLcb97()
More information about the Libreoffice-commits
mailing list