[Libreoffice-commits] .: 2 commits - src/docrecord.py

Miklos Vajna vmiklos at kemper.freedesktop.org
Wed Nov 28 10:19:28 PST 2012


 src/docrecord.py |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 4 deletions(-)

New commits:
commit 41c83e2258ecf18d22559c35116fcc1470bf08d1
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Nov 28 19:19:30 2012 +0100

    dump GRFSTD

diff --git a/src/docrecord.py b/src/docrecord.py
index 015a20c..adf0de5 100755
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -630,6 +630,35 @@ class DTTM(DOCDirStream):
         print '</%s>' % self.name
         self.parent.pos = self.pos
 
+class GRFSTD(DOCDirStream):
+    """The GRFSTD structure specifies the general properties of a style."""
+    def __init__(self, parent):
+        DOCDirStream.__init__(self, parent.bytes)
+        self.parent = parent
+        self.pos = parent.pos
+
+    def dump(self):
+        print '<grfstd type="GRFSTD" offset="%d" size="2 bytes">' % self.pos
+        buf = self.readuInt8()
+        self.printAndSet("fAutoRedef", self.getBit(buf, 0))
+        self.printAndSet("fHidden", self.getBit(buf, 1))
+        self.printAndSet("f97LidsSet", self.getBit(buf, 2))
+        self.printAndSet("fCopyLang", self.getBit(buf, 3))
+        self.printAndSet("fPersonalCompose", self.getBit(buf, 4))
+        self.printAndSet("fPersonalReply", self.getBit(buf, 5))
+        self.printAndSet("fPersonal", self.getBit(buf, 6))
+        self.printAndSet("fNoHtmlExport", self.getBit(buf, 7))
+
+        buf = self.readuInt8()
+        self.printAndSet("fSemiHidden", self.getBit(buf, 0))
+        self.printAndSet("fLocked", self.getBit(buf, 1))
+        self.printAndSet("fInternalUse", self.getBit(buf, 2))
+        self.printAndSet("fUnhideWhenUsed", self.getBit(buf, 3))
+        self.printAndSet("fQFormat", self.getBit(buf, 4))
+        self.printAndSet("fReserved", (buf & 0xe0) >> 5) # 6..8th bits
+        print '</grfstd>'
+        self.parent.pos = self.pos
+
 class DopBase(DOCDirStream):
     """The DopBase structure contains document and compatibility settings."""
     def __init__(self, dop):
@@ -1484,7 +1513,7 @@ class StdfBase(DOCDirStream):
         self.printAndSet("cupx", buf & 0x000f) # 1..4th bits
         self.printAndSet("istdNext", (buf & 0xfff0) >> 4) # 5..16th bits
         self.printAndSet("bchUpe", self.readuInt16(), hexdump = False)
-        self.printAndSet("grfstd", self.readuInt16()) # TODO dedicated GRFSTD class
+        GRFSTD(self).dump()
         print '</stdfBase>'
 
 class StdfPost2000(DOCDirStream):
commit 89f2fdb4fcfa4e943d9e6987dd08fc84f273b4e6
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Nov 28 19:11:06 2012 +0100

    dump DTTM

diff --git a/src/docrecord.py b/src/docrecord.py
index 824738f..015a20c 100755
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -609,6 +609,27 @@ class Copts60(DOCDirStream):
         self.printAndSet("fDntBlnSbDbWid", self.getBit(buf, 7))
         print '</copts60>'
 
+class DTTM(DOCDirStream):
+    """The DTTM structure specifies date and time."""
+    def __init__(self, parent, name):
+        DOCDirStream.__init__(self, parent.bytes)
+        self.parent = parent
+        self.pos = parent.pos
+        self.name = name
+
+    def dump(self):
+        buf = self.readuInt32()
+        print '<%s type="DTTM" offset="%d" size="4 bytes">' % (self.name, self.pos)
+        self.printAndSet("mint", buf & 0x0000003f) # 1..6th bits
+        self.printAndSet("hr",  (buf & 0x000007c0) >> 6) # 7..11th bits
+        self.printAndSet("dom", (buf & 0x0000f800) >> 11) # 12..16th bits
+        self.printAndSet("mon", (buf & 0x000f0000) >> 16) # 17..20th bits
+        self.printAndSet("yr",  (buf & 0x1ff00000) >> 20) # 21..29th bits
+        self.printAndSet("wdy", (buf & 0xe0000000) >> 29) # 30..32th bits
+        print '<transformed value="%s-%s-%s %s:%s"/>' % (1900+self.yr, self.mon, self.dom, self.hr, self.mint)
+        print '</%s>' % self.name
+        self.parent.pos = self.pos
+
 class DopBase(DOCDirStream):
     """The DopBase structure contains document and compatibility settings."""
     def __init__(self, dop):
@@ -681,9 +702,9 @@ class DopBase(DOCDirStream):
         self.printAndSet("dxaHotZ", self.readuInt16())
         self.printAndSet("cConsecHypLim", self.readuInt16())
         self.printAndSet("wSpare2", self.readuInt16())
-        self.printAndSet("dttmCreated", self.readuInt32()) # TODO extract DTTM here and below
-        self.printAndSet("dttmRevised", self.readuInt32())
-        self.printAndSet("dttmLastPrint", self.readuInt32())
+        DTTM(self, "dttmCreated").dump()
+        DTTM(self, "dttmRevised").dump()
+        DTTM(self, "dttmLastprint").dump()
         self.printAndSet("nRevision", self.readInt16())
         self.printAndSet("tmEdited", self.readInt32())
         self.printAndSet("cWords", self.readInt32())


More information about the Libreoffice-commits mailing list