[Libreoffice-commits] .: src/docrecord.py src/docstream.py
Miklos Vajna
vmiklos at kemper.freedesktop.org
Wed Jan 9 13:05:06 PST 2013
src/docrecord.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/docstream.py | 5 +++-
2 files changed, 65 insertions(+), 1 deletion(-)
New commits:
commit 82098141b68aa00f5335c8b6e1083b6d7e8f4557
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Jan 9 22:05:12 2013 +0100
dump PlcfSpl
diff --git a/src/docrecord.py b/src/docrecord.py
index cae0153..6dccd2d 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -2297,4 +2297,65 @@ class STSH(DOCDirStream):
print '</rglpstd>'
print '</stsh>'
+class SPLS(DOCDirStream):
+ """The SPLS structure specifies the current state of a range of text with regard to one of the language checking features."""
+ size = 2 # defined by 2.9.253
+ def __init__(self, name, plcfSpl, offset):
+ DOCDirStream.__init__(self, plcfSpl.bytes)
+ self.name = name
+ self.plcfSpl = plcfSpl
+ self.pos = offset
+
+ def dump(self):
+ splfMap = {
+ 0x1: "splfPending",
+ 0x2: "splfMaybeDirty",
+ 0x3: "splfDirty",
+ 0x4: "splfEdit",
+ 0x5: "splfForeign",
+ 0x7: "splfClean",
+ 0x8: "splfNoLAD",
+ 0xA: "splfErrorMin",
+ 0xB: "splfRepeatWord",
+ 0xC: "splfUnknownWord",
+ }
+ print '<spls type="SPLS" offset="%d" size="%d bytes">' % (self.pos, SPLS.size)
+ buf = self.readuInt16()
+ self.printAndSet("splf", buf & 0x000f, end = False) # 1..4th bits
+ if self.splf in splfMap:
+ print '<transformed name="%s"/>' % splfMap[self.splf]
+ print '</splf>'
+ self.printAndSet("fError", self.getBit(buf, 4))
+ self.printAndSet("fExtend", self.getBit(buf, 5))
+ self.printAndSet("fTypo", self.getBit(buf, 6))
+ self.printAndSet("unused", (buf & 0xff80) >> 7) # 8..16th bits
+ print '</spls>'
+
+class PlcfSpl(DOCDirStream, PLC):
+ """The Plcfspl structure is a Plc structure whose data elements are SpellingSpls structures."""
+ def __init__(self, mainStream):
+ DOCDirStream.__init__(self, mainStream.doc.getDirectoryStreamByName("1Table").bytes, mainStream = mainStream)
+ PLC.__init__(self, mainStream.lcbPlcfSpl, 2) # 2 is defined by 2.8.28
+ self.pos = mainStream.fcPlcfSpl
+ self.size = mainStream.lcbPlcfSpl
+
+ def dump(self):
+ print '<plcfSpl type="PlcfSpl" offset="%d" size="%d bytes">' % (self.pos, self.size)
+ offset = self.mainStream.fcMin
+ pos = self.pos
+ for i in range(self.getElements()):
+ # aCp
+ start = self.getuInt32(pos = pos)
+ end = self.getuInt32(pos = pos + 4)
+ print '<aCP index="%d" start="%d" end="%d">' % (i, start, end)
+ pos += 4
+
+ # aSpellingSpls
+ aSpellingSpls = SPLS("SpellingSpls", self, self.getOffset(self.pos, i))
+ aSpellingSpls.dump()
+
+ print '<transformed value="%s"/>' % self.quoteAttr(self.mainStream.retrieveText(offset + start, offset + end, logicalLength = True))
+ print '</aCP>'
+ print '</plcfSpl>'
+
# vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab:
diff --git a/src/docstream.py b/src/docstream.py
index 6ec39f5..a690b8d 100644
--- a/src/docstream.py
+++ b/src/docstream.py
@@ -314,7 +314,7 @@ class WordDocumentStream(DOCDirStream):
["fcPlcfWkb"],
["lcbPlcfWkb"],
["fcPlcfSpl"],
- ["lcbPlcfSpl"],
+ ["lcbPlcfSpl", self.handleLcbPlcfSpl],
["fcPlcftxbxTxt"],
["lcbPlcftxbxTxt"],
["fcPlcfFldTxbx"],
@@ -512,6 +512,9 @@ class WordDocumentStream(DOCDirStream):
def handleLcbPlcfFldMom(self):
docrecord.PlcFld(self).dump()
+ def handleLcbPlcfSpl(self):
+ docrecord.PlcfSpl(self).dump()
+
def dumpFibRgFcLcb97(self, name):
print '<%s type="FibRgFcLcb97" size="744 bytes">' % name
self.__dumpFibRgFcLcb97()
More information about the Libreoffice-commits
mailing list