ooo-build r15057 - in trunk: . scratch/mso-dumper scratch/mso-dumper/src scratch/sd-pptutil



Author: thorstenb
Date: Mon Jan 12 14:57:11 2009
New Revision: 15057
URL: http://svn.gnome.org/viewvc/ooo-build?rev=15057&view=rev

Log:
    * scratch/sd-pptutil/*: moved stuff to mso-dumper common dir
    * scratch/mso-dumper/*: adapted ppt-dump.py, merged changes from
    sd-pptutil into globals.py and ole.py. Move & merge done.



Added:
   trunk/scratch/mso-dumper/ppt-dump.py   (contents, props changed)
      - copied, changed from r15053, /trunk/scratch/sd-pptutil/ppt-dump.py
   trunk/scratch/mso-dumper/src/pptrecord.py   (props changed)
      - copied unchanged from r15053, /trunk/scratch/sd-pptutil/src/record.py
   trunk/scratch/mso-dumper/src/pptstream.py   (contents, props changed)
      - copied, changed from r15053, /trunk/scratch/sd-pptutil/src/stream.py
   trunk/scratch/mso-dumper/src/xmlpp.py   (props changed)
      - copied unchanged from r15053, /trunk/scratch/sd-pptutil/src/xmlpp.py
Removed:
   trunk/scratch/sd-pptutil/
Modified:
   trunk/ChangeLog
   trunk/scratch/mso-dumper/src/globals.py
   trunk/scratch/mso-dumper/src/ole.py

Copied: trunk/scratch/mso-dumper/ppt-dump.py (from r15053, /trunk/scratch/sd-pptutil/ppt-dump.py)
==============================================================================
--- /trunk/scratch/sd-pptutil/ppt-dump.py	(original)
+++ trunk/scratch/mso-dumper/ppt-dump.py	Mon Jan 12 14:57:11 2009
@@ -16,7 +16,7 @@
 
 import sys, os.path, getopt
 sys.path.append(sys.path[0]+"/src")
-import ole, stream, globals
+import ole, pptstream, globals
 
 from globals import error
 
@@ -45,7 +45,7 @@
 
     def dump (self):
         file = open(self.filepath, 'rb')
-        strm = stream.PPTFile(file.read(), self.params)
+        strm = pptstream.PPTFile(file.read(), self.params)
         file.close()
         strm.printStreamInfo()
         strm.printHeader()

Modified: trunk/scratch/mso-dumper/src/globals.py
==============================================================================
--- trunk/scratch/mso-dumper/src/globals.py	(original)
+++ trunk/scratch/mso-dumper/src/globals.py	Mon Jan 12 14:57:11 2009
@@ -1,5 +1,17 @@
+########################################################################
+#
+#    OpenOffice.org - a multi-platform office productivity suite
+#
+#    Author:
+#      Kohei Yoshida  <kyoshida novell com>
+#
+#   The Contents of this file are made available subject to the terms
+#   of GNU Lesser General Public License Version 2.1 and any later
+#   version.
+#
+########################################################################
 
-import sys, struct, math
+import sys, struct, math, zipfile, xmlpp, StringIO
 
 class ByteConvertError(Exception): pass
 
@@ -230,6 +242,58 @@
             code += bytes[i*2+1]
         if bytes[i*2] != '\x00':
             code += bytes[i*2]
-        text += unicode(code, 'utf-8')
+        try:    
+            text += unicode(code, 'utf-8')
+        except UnicodeDecodeError:
+            text += "<%d invalid chars>"%len(code)
     return text
 
+class StreamWrap(object):
+    def __init__ (self,printer):
+        self.printer = printer
+        self.buffer = ""
+    def write (self,string):
+        self.buffer += string
+    def flush (self):
+        for line in self.buffer.splitlines():
+            self.printer(line)
+
+def outputZipContent (bytes, printer, width=80):
+    printer("Zipped content:")
+    rawFile = StringIO.StringIO(bytes)
+    zipFile = zipfile.ZipFile(rawFile)
+    i = 0
+    # TODO: when 2.6/3.0 is in widespread use, change to infolist
+    # here, names might be ambiguous
+    for filename in zipFile.namelist():
+        if i > 0:
+            printer('-'*width)
+        i += 1
+        printer("")
+        printer(filename + ":")
+        printer('-'*width)
+
+        contents = zipFile.read(filename)
+        if filename.endswith(".xml") or contents.startswith("<?xml"):
+            wrapper = StreamWrap(printer)
+            xmlpp.pprint(contents,wrapper,1,80)
+            wrapper.flush()
+        else:
+            dumpBytes(contents)
+            
+    zipFile.close()
+
+def stringizeColorRef(colorRef, colorName="color"):
+    def split (packedColor):
+        return ((packedColor & 0xFF0000) // 0x10000, (packedColor & 0xFF00) / 0x100, (packedColor & 0xFF))
+    
+    colorValue = colorRef & 0xFFFFFF
+    if colorRef & 0xFE000000 == 0xFE000000 or colorRef & 0xFF000000 == 0:
+        colors = split(colorValue)
+        return "%s = (%d,%d,%d)"%(colorName, colors[0], colors[1], colors[2])
+    elif colorRef & 0x08000000 or colorRef & 0x10000000:
+        return "%s = schemecolor(%d)"%(colorName, colorValue)
+    elif colorRef & 0x04000000:
+        return "%s = colorschemecolor(%d)"%(colorName, colorValue)
+    else:
+        return "%s = <unidentified color>(%4.4Xh)"%(colorName, colorValue)

Modified: trunk/scratch/mso-dumper/src/ole.py
==============================================================================
--- trunk/scratch/mso-dumper/src/ole.py	(original)
+++ trunk/scratch/mso-dumper/src/ole.py	Mon Jan 12 14:57:11 2009
@@ -1,3 +1,15 @@
+########################################################################
+#
+#    OpenOffice.org - a multi-platform office productivity suite
+#
+#    Author:
+#      Kohei Yoshida  <kyoshida novell com>
+#
+#   The Contents of this file are made available subject to the terms
+#   of GNU Lesser General Public License Version 2.1 and any later
+#   version.
+#
+########################################################################
 
 import sys
 import globals
@@ -314,7 +326,6 @@
         self.sectorIDs = []
         self.bytes = bytes
         self.array = []
-
         self.params = params
 
 
@@ -342,10 +353,10 @@
 
 
     def outputRawBytes (self):
-        bytes = []
+        bytes = ""
         for secID in self.sectorIDs:
             pos = 512 + secID*self.sectorSize
-            bytes.extend(self.bytes[pos:pos+self.sectorSize])
+            bytes += self.bytes[pos:pos+self.sectorSize]
         globals.dumpBytes(bytes, 512)
 
 
@@ -485,7 +496,7 @@
         self.SSAT = header.getSSAT()
         self.header = header
         self.RootStorage = None
-        self.RootStorageBytes = []
+        self.RootStorageBytes = ""
         self.params = params
 
 
@@ -498,7 +509,7 @@
         chain = self.header.getSAT().getSectorIDChain(firstSecID)
         for secID in chain:
             pos = 512 + secID*self.sectorSize
-            self.RootStorageBytes.extend(self.header.bytes[pos:pos+self.sectorSize])
+            self.RootStorageBytes += self.header.bytes[pos:pos+self.sectorSize]
 
 
     def __getRawStream (self, entry):
@@ -514,20 +525,20 @@
             if self.RootStorage == None:
                 raise NoRootStorage
 
-            bytes = []
+            bytes = ""
             self.__buildRootStorageBytes()
             size = self.header.getShortSectorSize()
             for id in chain:
                 pos = id*size
-                bytes.extend(self.RootStorageBytes[pos:pos+size])
+                bytes += self.RootStorageBytes[pos:pos+size]
             return bytes
 
         offset = 512
         size = self.header.getSectorSize()
-        bytes = []
+        bytes = ""
         for id in chain:
             pos = offset + id*size
-            bytes.extend(self.header.bytes[pos:pos+size])
+            bytes += self.header.bytes[pos:pos+size]
 
         return bytes
 
@@ -683,10 +694,10 @@
             return
 
         # combine all sectors first.
-        bytes = []
+        bytes = ""
         for secID in self.sectorIDs:
             pos = globals.getSectorPos(secID, self.sectorSize)
-            bytes.extend(self.bytes[pos:pos+self.sectorSize])
+            bytes += self.bytes[pos:pos+self.sectorSize]
 
         self.entries = []
 

Copied: trunk/scratch/mso-dumper/src/pptstream.py (from r15053, /trunk/scratch/sd-pptutil/src/stream.py)
==============================================================================
--- /trunk/scratch/sd-pptutil/src/stream.py	(original)
+++ trunk/scratch/mso-dumper/src/pptstream.py	Mon Jan 12 14:57:11 2009
@@ -13,7 +13,7 @@
 ########################################################################
 
 import sys
-import ole, globals, record
+import ole, globals, pptrecord
 from globals import output
 
 class EndOfStream(Exception): pass
@@ -31,7 +31,7 @@
     7:  ["DFF_PST_ClientSignal2"],              
    10:  ["DFF_PST_PowerPointStateInfoAtom"],    
  1000:  ["DFF_PST_Document"],                   
- 1001:  ["DFF_PST_DocumentAtom", record.DocAtom],               
+ 1001:  ["DFF_PST_DocumentAtom", pptrecord.DocAtom],               
  1002:  ["DFF_PST_EndDocument"],                
  1003:  ["DFF_PST_SlidePersist"],               
  1004:  ["DFF_PST_SlideBase"],                  
@@ -67,16 +67,16 @@
  1034:  ["DFF_PST_ExObjListAtom"],              
  1035:  ["DFF_PST_PPDrawingGroup"],             
  1036:  ["DFF_PST_PPDrawing"],                  
- 1038:  ["DFF_PST_Theme", record.ZipRecord],                  
+ 1038:  ["DFF_PST_Theme", pptrecord.ZipRecord],                  
  1039:  ["DFF_PST_ColorMapping"],                  
  1040:  ["DFF_PST_NamedShows"],                 
  1041:  ["DFF_PST_NamedShow"],                  
  1042:  ["DFF_PST_NamedShowSlides"],            
  1052:  ["DFF_PST_OriginalMainMasterId"],           
- 1054:  ["DFF_PST_RoundTripContentMasterInfo", record.ZipRecord],           
+ 1054:  ["DFF_PST_RoundTripContentMasterInfo", pptrecord.ZipRecord],           
  1055:  ["DFF_PST_RoundTripShapeId"],           
  1058:  ["DFF_PST_RoundTripContentMasterId"],           
- 1059:  ["DFF_PST_RoundTripOArtTextStyles", record.ZipRecord],
+ 1059:  ["DFF_PST_RoundTripOArtTextStyles", pptrecord.ZipRecord],
  1064:  ["DFF_PST_RoundTripCustomTableStyles"],
  2000:  ["DFF_PST_List"],                       
  2005:  ["DFF_PST_FontCollection"],             
@@ -92,7 +92,7 @@
  2029:  ["DFF_PST_RunArrayAtom"],               
  2030:  ["DFF_PST_ArrayElementAtom"],           
  2031:  ["DFF_PST_Int4ArrayAtom"],              
- 2032:  ["DFF_PST_ColorSchemeAtom", record.ColorScheme],            
+ 2032:  ["DFF_PST_ColorSchemeAtom", pptrecord.ColorScheme],            
  3008:  ["DFF_PST_OEShape"],                    
  3009:  ["DFF_PST_ExObjRefAtom"],               
  3011:  ["DFF_PST_OEPlaceholderAtom"],          
@@ -104,22 +104,22 @@
  3035:  ["DFF_PST_OEShapeAtom"],                
  3998:  ["DFF_PST_OutlineTextRefAtom"],         
  3999:  ["DFF_PST_TextHeaderAtom"],             
- 4000:  ["DFF_PST_TextCharsAtom", record.ShapeUniString],
- 4001:  ["DFF_PST_StyleTextPropAtom", record.TextStyles],          
- 4002:  ["DFF_PST_BaseTextPropAtom", record.TextStyles],           
- 4003:  ["DFF_PST_TxMasterStyleAtom", record.MasterTextStyles],          
+ 4000:  ["DFF_PST_TextCharsAtom", pptrecord.ShapeUniString],
+ 4001:  ["DFF_PST_StyleTextPropAtom", pptrecord.TextStyles],          
+ 4002:  ["DFF_PST_BaseTextPropAtom", pptrecord.TextStyles],           
+ 4003:  ["DFF_PST_TxMasterStyleAtom", pptrecord.MasterTextStyles],          
  4004:  ["DFF_PST_TxCFStyleAtom"],              
  4005:  ["DFF_PST_TxPFStyleAtom"],              
  4006:  ["DFF_PST_TextRulerAtom"],              
  4007:  ["DFF_PST_TextBookmarkAtom"],           
- 4008:  ["DFF_PST_TextBytesAtom", record.ShapeString],
+ 4008:  ["DFF_PST_TextBytesAtom", pptrecord.ShapeString],
  4009:  ["DFF_PST_TxSIStyleAtom"],              
  4010:  ["DFF_PST_TextSpecInfoAtom"],           
  4011:  ["DFF_PST_DefaultRulerAtom"],           
  4023:  ["DFF_PST_FontEntityAtom"],             
  4024:  ["DFF_PST_FontEmbedData"],              
  4025:  ["DFF_PST_TypeFace"],                   
- 4026:  ["DFF_PST_CString", record.UniString],                    
+ 4026:  ["DFF_PST_CString", pptrecord.UniString],                    
  4027:  ["DFF_PST_ExternalObject"],             
  4033:  ["DFF_PST_MetaFile"],                   
  4034:  ["DFF_PST_ExOleObj"],                   
@@ -198,7 +198,7 @@
 0xF000: ["DFF_msofbtDggContainer"],    
 0xF006: ["DFF_msofbtDgg"],             
 0xF016: ["DFF_msofbtCLSID"],           
-0xF00B: ["DFF_msofbtOPT", record.Property],             
+0xF00B: ["DFF_msofbtOPT", pptrecord.Property],             
 0xF11A: ["DFF_msofbtColorMRU"],        
 0xF11E: ["DFF_msofbtSplitMenuColors"], 
 0xF001: ["DFF_msofbtBstoreContainer"], 
@@ -222,7 +222,7 @@
 0xF011: ["DFF_msofbtClientData"],      
 0xF11F: ["DFF_msofbtOleObject"],       
 0xF11D: ["DFF_msofbtDeletedPspl"],     
-0xF122: ["DFF_msofbtUDefProp", record.Property],        
+0xF122: ["DFF_msofbtUDefProp", pptrecord.Property],        
 0xF005: ["DFF_msofbtSolverContainer"], 
 0xF012: ["DFF_msofbtConnectorRule"],   
 0xF013: ["DFF_msofbtAlignRule"],       



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]