src/docrecord.py | 37 +++++++++++++++++++++++++++++++++++++ src/docstream.py | 6 +++++- 2 files changed, 42 insertions(+), 1 deletion(-)
New commits: commit 47c1588c33281f15635bbf5c4ba6e44f09998467 Author: Miklos Vajna <vmik...@suse.cz> Date: Fri May 3 18:28:26 2013 +0200 doc: dump PlcfHdd (initial support for headers / footers) diff --git a/src/docrecord.py b/src/docrecord.py index 36b29c3..62ca85f 100644 --- a/src/docrecord.py +++ b/src/docrecord.py @@ -805,6 +805,43 @@ class PlcBteChpx(DOCDirStream, PLC): print '</aFC>' print '</plcBteChpx>' +class PlcfHdd(DOCDirStream, PLC): + """The Plcfhdd structure is a PLC that contains only CPs and no additional data. It specifies where + header document stories begin and end.""" + def __init__(self, mainStream): + DOCDirStream.__init__(self, mainStream.doc.getDirectoryStreamByName("1Table").bytes, mainStream=mainStream) + PLC.__init__(self, mainStream.lcbPlcfHdd, 0) + self.pos = mainStream.fcPlcfHdd + self.size = mainStream.lcbPlcfHdd + + def dump(self): + print '<plcfHdd type="PlcfHdd" offset="%d" size="%d bytes">' % (self.pos, self.size) + offset = self.mainStream.fcMin + self.mainStream.ccpText + pos = self.pos + for i in range(self.getElements() - 1): + start = self.getuInt32(pos = pos) + end = self.getuInt32(pos = pos + 4) + contentsMap = { + 0: "Footnote separator", + 1: "Footnote continuation separator", + 2: "Footnote continuation notice", + 3: "Endnote separator", + 4: "Endnote continuation separator", + 5: "Endnote continuation notice", + + 6: "Even page header", + 7: "Odd page header", + 8: "Even page footer", + 9: "Odd page footer", + 10: "First page header", + 11: "First page footer", + } + print '<aCP index="%d" contents="%s" start="%d" end="%d">' % (i, contentsMap[i], start, end) + print '<transformed value="%s"/>' % self.quoteAttr(self.mainStream.retrieveText(offset + start, offset + end)) + pos += 4 + print '</aCP>' + print '</plcfHdd>' + class PlcfandTxt(DOCDirStream, PLC): """The PlcfandTxt structure is a PLC that contains only CPs and no additional data.""" def __init__(self, mainStream, offset, size): diff --git a/src/docstream.py b/src/docstream.py index d9003aa..7f3cc51 100644 --- a/src/docstream.py +++ b/src/docstream.py @@ -233,7 +233,7 @@ class WordDocumentStream(DOCDirStream): ["fcPlcfGlsy"], ["lcbPlcfGlsy"], ["fcPlcfHdd"], - ["lcbPlcfHdd"], + ["lcbPlcfHdd", self.handleLcbPlcfHdd], ["fcPlcfBteChpx"], ["lcbPlcfBteChpx", self.handleLcbPlcfBteChpx], ["fcPlcfBtePapx"], @@ -437,6 +437,10 @@ class WordDocumentStream(DOCDirStream): if not silent: self.clx.dump() + def handleLcbPlcfHdd(self): + plcfHdd = docrecord.PlcfHdd(self) + plcfHdd.dump() + def handleLcbPlcfBteChpx(self): plcBteChpx = docrecord.PlcBteChpx(self) plcBteChpx.dump() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits