[Libreoffice-commits] .: src/docrecord.py src/docstream.py test/doc
Miklos Vajna
vmiklos at kemper.freedesktop.org
Fri Jan 11 03:37:08 PST 2013
src/docrecord.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++++-----
src/docstream.py | 5 +++-
test/doc/list.doc |binary
test/doc/list.rtf | 49 +++++++++++++++++++++++++++++++++++++++
test/doc/test.py | 6 ++++
5 files changed, 120 insertions(+), 7 deletions(-)
New commits:
commit abd802bff3247df6fb1c87ed41fce45ba01a9a95
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Jan 11 12:19:28 2013 +0100
dump PlfLfo
diff --git a/src/docrecord.py b/src/docrecord.py
index 6e69156..ef87891 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -2393,13 +2393,14 @@ class PlcfGram(DOCDirStream, PLC):
class LSTF(DOCDirStream):
"""The LSTF structure contains formatting properties that apply to an entire list."""
- def __init__(self, plfLst):
+ def __init__(self, plfLst, index):
DOCDirStream.__init__(self, plfLst.bytes)
self.pos = plfLst.pos
self.size = 28
+ self.index = index
def dump(self):
- print '<lstf type="LSTF" offset="%d" size="%d bytes">' % (self.pos, self.size)
+ print '<lstf type="LSTF" index="%d" offset="%d" size="%d bytes">' % (self.index, self.pos, self.size)
self.printAndSet("lsid", self.readInt32())
self.printAndSet("tplc", self.readInt32())
for i in range(9):
@@ -2445,12 +2446,13 @@ class LVLF(DOCDirStream):
class LVL(DOCDirStream):
"""The LVL structure contains formatting information about a specific level in a list."""
- def __init__(self, plfLst):
+ def __init__(self, plfLst, index):
DOCDirStream.__init__(self, plfLst.bytes)
self.pos = plfLst.pos
+ self.index = index
def dump(self):
- print '<lvl type="LVL" offset="%d">' % self.pos
+ print '<lvl type="LVL" index="%d" offset="%d">' % (self.index, self.pos)
lvlf = LVLF(self)
lvlf.dump()
self.pos = lvlf.pos
@@ -2489,7 +2491,7 @@ class PlfLst(DOCDirStream):
self.printAndSet("cLst", self.readInt16())
cLvl = 0
for i in range(self.cLst):
- rgLstf = LSTF(self)
+ rgLstf = LSTF(self, i)
rgLstf.dump()
if rgLstf.fSimpleList:
cLvl += 1
@@ -2497,9 +2499,62 @@ class PlfLst(DOCDirStream):
cLvl += 9
self.pos = rgLstf.pos
for i in range(cLvl):
- lvl = LVL(self)
+ lvl = LVL(self, i)
lvl.dump()
self.pos = lvl.pos
print '</plfLst>'
+class LFO(DOCDirStream):
+ """The LFO structure specifies the LSTF element that corresponds to a list that contains a paragraph."""
+ def __init__(self, plfLfo):
+ DOCDirStream.__init__(self, plfLfo.bytes)
+ self.pos = plfLfo.pos
+
+ def dump(self):
+ print '<lfo type="LFO" offset="%d">' % self.pos
+ self.printAndSet("lsid", self.readInt32())
+ self.printAndSet("unused1", self.readuInt32())
+ self.printAndSet("unused2", self.readuInt32())
+ self.printAndSet("clfolvl", self.readuInt8())
+ self.printAndSet("ibstFltAutoNum", self.readuInt8())
+ self.printAndSet("grfhic", self.readuInt8()) # TODO dump grfhic
+ self.printAndSet("unused3", self.readuInt8())
+ print '</lfo>'
+
+class LFOData(DOCDirStream):
+ """The LFOData structure contains the Main Document CP of the corresponding LFO."""
+ def __init__(self, plfLfo, lfo):
+ DOCDirStream.__init__(self, plfLfo.bytes)
+ self.pos = plfLfo.pos
+ self.lfo = lfo
+
+ def dump(self):
+ print '<lfoData type="LFOData" offset="%d">' % self.pos
+ self.printAndSet("cp", self.readuInt32())
+ if self.lfo.clfolvl > 0:
+ print '<todo what="LFOData: clfolvl != 0"/>'
+ print '</lfoData>'
+
+class PlfLfo(DOCDirStream):
+ """The PlfLfo structure contains the list format override data for the document."""
+ def __init__(self, mainStream):
+ DOCDirStream.__init__(self, mainStream.doc.getDirectoryStreamByName("1Table").bytes, mainStream = mainStream)
+ self.pos = mainStream.fcPlfLfo
+ self.size = mainStream.lcbPlfLfo
+
+ def dump(self):
+ print '<plfLfo type="PlfLfo" offset="%d" size="%d bytes">' % (self.pos, self.size)
+ self.printAndSet("lfoMac", self.readInt32())
+ lfos = []
+ for i in range(self.lfoMac):
+ lfo = LFO(self)
+ lfos.append(lfo)
+ lfo.dump()
+ self.pos = lfo.pos
+ for i in range(self.lfoMac):
+ lfoData = LFOData(self, lfos[i])
+ lfoData.dump()
+ self.pos = lfoData.pos
+ print '</plfLfo>'
+
# vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab:
diff --git a/src/docstream.py b/src/docstream.py
index ad46e1a..648fe81 100644
--- a/src/docstream.py
+++ b/src/docstream.py
@@ -352,7 +352,7 @@ class WordDocumentStream(DOCDirStream):
["fcPlfLst"],
["lcbPlfLst", self.handleLcbPlfLst],
["fcPlfLfo"],
- ["lcbPlfLfo"],
+ ["lcbPlfLfo", self.handleLcbPlfLfo],
["fcPlcfTxbxBkd"],
["lcbPlcfTxbxBkd"],
["fcPlcfTxbxHdrBkd"],
@@ -521,6 +521,9 @@ class WordDocumentStream(DOCDirStream):
def handleLcbPlfLst(self):
docrecord.PlfLst(self).dump()
+ def handleLcbPlfLfo(self):
+ docrecord.PlfLfo(self).dump()
+
def dumpFibRgFcLcb97(self, name):
print '<%s type="FibRgFcLcb97" size="744 bytes">' % name
self.__dumpFibRgFcLcb97()
diff --git a/test/doc/list.doc b/test/doc/list.doc
new file mode 100755
index 0000000..06f8917
Binary files /dev/null and b/test/doc/list.doc differ
diff --git a/test/doc/list.rtf b/test/doc/list.rtf
new file mode 100644
index 0000000..66766eb
--- /dev/null
+++ b/test/doc/list.rtf
@@ -0,0 +1,49 @@
+{\rtf1
+{\*\listtable
+{\list\listtemplateid1
+{\listlevel\levelnfc23\leveljc0\levelstartat1\levelfollow0
+{\leveltext \'01\u8226 ?;}
+{\levelnumbers;}
+\f8\fi-360\li720}
+{\listlevel\levelnfc23\leveljc0\levelstartat1\levelfollow0
+{\leveltext \'01\u9702 ?;}
+{\levelnumbers;}
+\f8\fi-360\li1080}
+{\listlevel\levelnfc23\leveljc0\levelstartat1\levelfollow0
+{\leveltext \'01\u9642 ?;}
+{\levelnumbers;}
+\f8\fi-360\li1440}
+{\listlevel\levelnfc23\leveljc0\levelstartat1\levelfollow0
+{\leveltext \'01\u8226 ?;}
+{\levelnumbers;}
+\f8\fi-360\li1800}
+{\listlevel\levelnfc23\leveljc0\levelstartat1\levelfollow0
+{\leveltext \'01\u9702 ?;}
+{\levelnumbers;}
+\f8\fi-360\li2160}
+{\listlevel\levelnfc23\leveljc0\levelstartat1\levelfollow0
+{\leveltext \'01\u9642 ?;}
+{\levelnumbers;}
+\f8\fi-360\li2520}
+{\listlevel\levelnfc23\leveljc0\levelstartat1\levelfollow0
+{\leveltext \'01\u8226 ?;}
+{\levelnumbers;}
+\f8\fi-360\li2880}
+{\listlevel\levelnfc23\leveljc0\levelstartat1\levelfollow0
+{\leveltext \'01\u9702 ?;}
+{\levelnumbers;}
+\f8\fi-360\li3240}
+{\listlevel\levelnfc23\leveljc0\levelstartat1\levelfollow0
+{\leveltext \'01\u9642 ?;}
+{\levelnumbers;}
+\f8\fi-360\li3600}
+\listid1}
+}
+{\listoverridetable
+{\listoverride\listid1\listoverridecount0\ls1}
+}
+\pard\plain\ilvl0\ls1 Foo
+\par\pard\plain\ilvl0\ls1 Bar
+\par\pard\plain\ilvl0\ls1 Baz
+\par
+}
diff --git a/test/doc/test.py b/test/doc/test.py
index 0088e41..6936f1a 100755
--- a/test/doc/test.py
+++ b/test/doc/test.py
@@ -153,6 +153,12 @@ class Test(unittest.TestCase):
self.assertEqual('Before section 1.\\x0D\\x0D\\x0C', sections[0].findall('transformed')[0].attrib['value'])
self.assertEqual("\\x0DThe next one isn't a balanced one:\\x0D\\x0D\\x0C", sections[2].findall('transformed')[0].attrib['value'])
+ def test_list(self):
+ self.dump('list')
+
+ levels = self.root.findall('stream[@name="WordDocument"]/fib/fibRgFcLcbBlob/lcbPlfLst/plfLst/lvl')
+ self.assertEqual("â¢", levels[0].findall('xst/rgtchar')[0].attrib['value'])
+
if __name__ == '__main__':
unittest.main()
More information about the Libreoffice-commits
mailing list