src/docdirstream.py | 12 ++++++---- src/docrecord.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 6 deletions(-)
New commits: commit 388bef4e111c22d9a373f49f9453781d268f6ed4 Author: Miklos Vajna <[email protected]> Date: Sun May 12 21:19:06 2013 +0200 dump TextFlow, VerticalMergeFlag, VerticalAlign and Fts enums diff --git a/src/docdirstream.py b/src/docdirstream.py index ba94936..497ccea 100644 --- a/src/docdirstream.py +++ b/src/docdirstream.py @@ -21,19 +21,21 @@ class DOCDirStream: self.mainStream = mainStream self.doc = doc - def printAndSet(self, key, value, hexdump = True, end = True, offset = False, silent = False): + def printAndSet(self, key, value, hexdump = True, end = True, offset = False, silent = False, dict = None): setattr(self, key, value) if silent: return + attrs = "" + if dict: + attrs += ' name="%s"' % dict[value] if hexdump: value = hex(value) - offstr = "" if offset: - offstr += ' offset="%s"' % hex(self.pos) + attrs += ' offset="%s"' % hex(self.pos) if end: - print '<%s value="%s"%s/>' % (key, value, offstr) + print '<%s value="%s"%s/>' % (key, value, attrs) else: - print '<%s value="%s"%s>' % (key, value, offstr) + print '<%s value="%s"%s>' % (key, value, attrs) def quoteAttr(self, value): """Wrapper around xml.sax.saxutils.quoteattr, assumes the caller will put " around the result.""" diff --git a/src/docrecord.py b/src/docrecord.py index 7851cd9..68ffdd2 100644 --- a/src/docrecord.py +++ b/src/docrecord.py @@ -482,6 +482,41 @@ class PChgTabsOperand(DOCDirStream): PChgTabsAdd(self).dump() print '</pchgTabsOperand>' +# The TextFlow enumeration specifies the rotation settings for a block of text and for the individual +# East Asian characters in each line of the block. +TextFlow = { + 0x0000: "grpfTFlrtb", + 0x0001: "grpfTFtbrl", + 0x0003: "grpfTFbtlr", + 0x0004: "grpfTFlrtbv", + 0x0005: "grpfTFtbrlv" + } + +# The VerticalMergeFlag enumeration provides a 2-bit value that specifies whether a table cell is +# merged with the cells above or below it. +VerticalMergeFlag = { + 0x00: "fvmClear", + 0x01: "fvmMerge", + 0x03: "fvmRestart" + } + +# The VerticalAlign enumeration specifies the vertical alignment of content within table cells. +VerticalAlign = { + 0x00: "vaTop", + 0x01: "vaCenter", + 0x02: "vaBottom", + } + +# The Fts enumeration specifies how the preferred width for a table, table indent, table cell, cell +# margin, or cell spacing is defined. +Fts = { + 0x00: "ftsNil", + 0x01: "ftsAuto", + 0x02: "ftsPercent", + 0x03: "ftsDxa", + 0x13: "ftsDxaSys" + } + 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): @@ -492,12 +527,11 @@ class TCGRF(DOCDirStream): def dump(self): print '<tcgrf type="TCGRF" offset="%d">' % self.pos buf = self.readuInt16() - # TODO TextFlow, VerticalMergeFlag, VerticalAlign and Fts enums self.printAndSet("horzMerge", buf & 0x0003) # 1..2nd bits - self.printAndSet("textFlow", (buf & 0x001c) >> 2) # 3..6th bits - self.printAndSet("vertMerge", (buf & 0x0060) >> 6) # 7..8th bits - self.printAndSet("vertAlign", (buf & 0x0180) >> 8) # 9..10th bits - self.printAndSet("ftsWidth", (buf & 0x0e00) >> 10) # 11..12th bits + self.printAndSet("textFlow", (buf & 0x001c) >> 2, dict = TextFlow) # 3..6th bits + self.printAndSet("vertMerge", (buf & 0x0060) >> 6, dict = VerticalMergeFlag) # 7..8th bits + self.printAndSet("vertAlign", (buf & 0x0180) >> 8, dict = VerticalAlign) # 9..10th bits + self.printAndSet("ftsWidth", (buf & 0x0e00) >> 10, dict = Fts) # 11..12th bits self.printAndSet("fFitText", self.getBit(buf, 12)) self.printAndSet("fNoWrap", self.getBit(buf, 13)) self.printAndSet("fHideMark", self.getBit(buf, 14)) commit a57a7e67b52c62644127dfd34b528552d46deac6 Author: Miklos Vajna <[email protected]> Date: Sun May 12 21:06:37 2013 +0200 dump TCGRF diff --git a/src/docrecord.py b/src/docrecord.py index 3616cd3..7851cd9 100644 --- a/src/docrecord.py +++ b/src/docrecord.py @@ -482,6 +482,29 @@ class PChgTabsOperand(DOCDirStream): PChgTabsAdd(self).dump() print '</pchgTabsOperand>' +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): + DOCDirStream.__init__(self, parent.bytes) + self.parent = parent + self.pos = parent.pos + + def dump(self): + print '<tcgrf type="TCGRF" offset="%d">' % self.pos + buf = self.readuInt16() + # TODO TextFlow, VerticalMergeFlag, VerticalAlign and Fts enums + self.printAndSet("horzMerge", buf & 0x0003) # 1..2nd bits + self.printAndSet("textFlow", (buf & 0x001c) >> 2) # 3..6th bits + self.printAndSet("vertMerge", (buf & 0x0060) >> 6) # 7..8th bits + self.printAndSet("vertAlign", (buf & 0x0180) >> 8) # 9..10th bits + self.printAndSet("ftsWidth", (buf & 0x0e00) >> 10) # 11..12th bits + self.printAndSet("fFitText", self.getBit(buf, 12)) + self.printAndSet("fNoWrap", self.getBit(buf, 13)) + self.printAndSet("fHideMark", self.getBit(buf, 14)) + self.printAndSet("fUnused", self.getBit(buf, 15)) + print '</tcgrf>' + self.parent.pos = self.pos + class TC80(DOCDirStream): """The TC80 structure specifies the border and other formatting for a single cell in a table.""" def __init__(self, parent, index): @@ -492,7 +515,7 @@ class TC80(DOCDirStream): def dump(self): print '<tc80 index="%d">' % self.index - self.printAndSet("tcgrf", self.readuInt16()) # TODO dump TCGRF + TCGRF(self).dump() self.printAndSet("wWidth", self.readuInt16(), hexdump = False) self.printAndSet("brcTop", self.readuInt32()) # TODO dump Brc80MayBeNil self.printAndSet("brcLeft", self.readuInt32()) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
