Browse Source

[core] Remove pyexcelerator

- Support CSV download only
- XLS download is CSV download, with different MIME and file extension
abec 14 years ago
parent
commit
fe930e9ebb
83 changed files with 9 additions and 16897 deletions
  1. 0 3
      NOTICE.txt
  2. 3 2
      apps/beeswax/src/beeswax/data_export.py
  3. 2 2
      apps/beeswax/src/beeswax/tests.py
  4. 0 1
      desktop/core/ext-py/pyexcelerator/.cvsignore
  5. 0 91
      desktop/core/ext-py/pyexcelerator/CHANGES.txt
  6. 0 47
      desktop/core/ext-py/pyexcelerator/LICENSE.txt
  7. 0 20
      desktop/core/ext-py/pyexcelerator/PKG-INFO
  8. 0 145
      desktop/core/ext-py/pyexcelerator/README.txt
  9. 0 25
      desktop/core/ext-py/pyexcelerator/THANKS.txt
  10. 0 4
      desktop/core/ext-py/pyexcelerator/TODO.txt
  11. 0 37
      desktop/core/ext-py/pyexcelerator/examples/big-16Mb.py
  12. 0 36
      desktop/core/ext-py/pyexcelerator/examples/big-35Mb.py
  13. 0 39
      desktop/core/ext-py/pyexcelerator/examples/blanks.py
  14. 0 19
      desktop/core/ext-py/pyexcelerator/examples/col_width.py
  15. 0 39
      desktop/core/ext-py/pyexcelerator/examples/dates.py
  16. 0 32
      desktop/core/ext-py/pyexcelerator/examples/format.py
  17. 0 18
      desktop/core/ext-py/pyexcelerator/examples/formula_names.py
  18. 0 51
      desktop/core/ext-py/pyexcelerator/examples/formulas.py
  19. 0 36
      desktop/core/ext-py/pyexcelerator/examples/hyperlinks.py
  20. 0 15
      desktop/core/ext-py/pyexcelerator/examples/image.py
  21. 0 42
      desktop/core/ext-py/pyexcelerator/examples/merged.py
  22. 0 32
      desktop/core/ext-py/pyexcelerator/examples/merged0.py
  23. 0 104
      desktop/core/ext-py/pyexcelerator/examples/merged1.py
  24. 0 11
      desktop/core/ext-py/pyexcelerator/examples/mini.py
  25. 0 62
      desktop/core/ext-py/pyexcelerator/examples/num_formats.py
  26. 0 27
      desktop/core/ext-py/pyexcelerator/examples/numbers.py
  27. 0 115
      desktop/core/ext-py/pyexcelerator/examples/outline.py
  28. 0 60
      desktop/core/ext-py/pyexcelerator/examples/panes.py
  29. 0 12
      desktop/core/ext-py/pyexcelerator/examples/parse-fmla.py
  30. 0 136
      desktop/core/ext-py/pyexcelerator/examples/protection.py
  31. BIN
      desktop/core/ext-py/pyexcelerator/examples/python.bmp
  32. 0 19
      desktop/core/ext-py/pyexcelerator/examples/row_styles.py
  33. 0 18
      desktop/core/ext-py/pyexcelerator/examples/row_styles_empty.py
  34. 0 54
      desktop/core/ext-py/pyexcelerator/examples/sst.py
  35. 0 16
      desktop/core/ext-py/pyexcelerator/examples/unicode0.py
  36. 0 30
      desktop/core/ext-py/pyexcelerator/examples/unicode1.py
  37. 0 21
      desktop/core/ext-py/pyexcelerator/examples/unicode2.py
  38. 0 157
      desktop/core/ext-py/pyexcelerator/examples/wsprops.py
  39. 0 44
      desktop/core/ext-py/pyexcelerator/examples/xls2csv.py
  40. 0 51
      desktop/core/ext-py/pyexcelerator/examples/xls2html.py
  41. 0 27
      desktop/core/ext-py/pyexcelerator/examples/xls2txt.py
  42. 0 312
      desktop/core/ext-py/pyexcelerator/hrc/py-2.4-hrc.py
  43. 0 347
      desktop/core/ext-py/pyexcelerator/hrc/python.hrc
  44. BIN
      desktop/core/ext-py/pyexcelerator/museum/P-0508-0000507647-3280-5298.xls
  45. BIN
      desktop/core/ext-py/pyexcelerator/museum/chart1v8.xls
  46. BIN
      desktop/core/ext-py/pyexcelerator/museum/excel2003.xls
  47. BIN
      desktop/core/ext-py/pyexcelerator/museum/frmla.xls
  48. BIN
      desktop/core/ext-py/pyexcelerator/museum/macro2v8.xls
  49. BIN
      desktop/core/ext-py/pyexcelerator/museum/mini-mini.xls
  50. BIN
      desktop/core/ext-py/pyexcelerator/museum/mini.xls
  51. BIN
      desktop/core/ext-py/pyexcelerator/museum/oo14.xls
  52. 0 2584
      desktop/core/ext-py/pyexcelerator/pyExcelerator/BIFFRecords.py
  53. 0 305
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Bitmap.py
  54. 0 200
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Cell.py
  55. 0 82
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Column.py
  56. 0 571
      desktop/core/ext-py/pyexcelerator/pyExcelerator/CompoundDoc.py
  57. 0 61
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Deco.py
  58. 0 109
      desktop/core/ext-py/pyexcelerator/pyExcelerator/ExcelFormula.py
  59. 0 162
      desktop/core/ext-py/pyexcelerator/pyExcelerator/ExcelFormulaLexer.py
  60. 0 457
      desktop/core/ext-py/pyexcelerator/pyExcelerator/ExcelFormulaParser.py
  61. 0 1061
      desktop/core/ext-py/pyexcelerator/pyExcelerator/ExcelMagic.py
  62. 0 320
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Formatting.py
  63. 0 476
      desktop/core/ext-py/pyexcelerator/pyExcelerator/ImportXLS.py
  64. 0 255
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Row.py
  65. 0 197
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Style.py
  66. 0 135
      desktop/core/ext-py/pyexcelerator/pyExcelerator/UnicodeUtils.py
  67. 0 170
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Utils.py
  68. 0 617
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Workbook.py
  69. 0 1435
      desktop/core/ext-py/pyexcelerator/pyExcelerator/Worksheet.py
  70. 0 20
      desktop/core/ext-py/pyexcelerator/pyExcelerator/__init__.py
  71. 0 2800
      desktop/core/ext-py/pyexcelerator/pyExcelerator/antlr.py
  72. 0 249
      desktop/core/ext-py/pyexcelerator/pyExcelerator/excel-formula.g
  73. 0 90
      desktop/core/ext-py/pyexcelerator/setup.py
  74. 0 1687
      desktop/core/ext-py/pyexcelerator/tools/Analyzer.py
  75. 0 143
      desktop/core/ext-py/pyexcelerator/tools/biff-dumper.py
  76. 0 55
      desktop/core/ext-py/pyexcelerator/tools/compdoc-dumper.py
  77. 0 79
      desktop/core/ext-py/pyexcelerator/tools/xls2csv-gerry.py
  78. 0 45
      desktop/core/ext-py/pyexcelerator/tools/xls2csv.py
  79. 0 52
      desktop/core/ext-py/pyexcelerator/tools/xls2html.py
  80. 0 29
      desktop/core/ext-py/pyexcelerator/tools/xls2txt.py
  81. 2 51
      desktop/core/src/desktop/lib/export_csvxls.py
  82. 2 40
      desktop/core/src/desktop/lib/test_export_csvxls.py
  83. 0 1
      ext/thirdparty/README.md

+ 0 - 3
NOTICE.txt

@@ -1,9 +1,6 @@
 This product includes software developed by Cloudera, Inc.
 (http://www.cloudera.com/).
 
-This product includes software developed by
-Roman V. Kiseliov <roman@kiseliov.ru> (PyExcel).
-
 This product includes software developed by
 Andrew Valums (http://valums.com/ajax-upload/).
 

+ 3 - 2
apps/beeswax/src/beeswax/data_export.py

@@ -22,7 +22,7 @@ import time
 
 from django.http import HttpResponse
 
-from desktop.lib.export_csvxls import CSVformatter, XLSformatter, TooBigToDownloadException
+from desktop.lib.export_csvxls import CSVformatter, TooBigToDownloadException
 
 from beeswax import common
 
@@ -46,7 +46,8 @@ def download(handle, format, db):
     formatter = CSVformatter()
     mimetype = 'application/csv'
   elif format == 'xls':
-    formatter = XLSformatter()
+    # We 'fool' the user by sending back CSV as XSL as it supports streaming and won't freeze Hue
+    formatter = CSVformatter()
     mimetype = 'application/xls'
 
   gen = data_generator(handle, formatter, db)

+ 2 - 2
apps/beeswax/src/beeswax/tests.py

@@ -35,7 +35,6 @@ from django.contrib.auth.models import User
 from beeswaxd import ttypes
 from desktop.lib.django_test_util import make_logged_in_client, assert_equal_mod_whitespace
 from desktop.lib.django_test_util import assert_similar_pages
-from desktop.lib.test_export_csvxls import xls2csv
 from desktop.lib.test_utils import grant_access
 
 import beeswax.create_table
@@ -503,7 +502,8 @@ for x in sys.stdin:
     # Get the result in xls.
     handle = self.db.execute_and_wait(query)
     xls_resp = download(handle, 'xls', self.db)
-    translated_csv = xls2csv(xls_resp.content)
+    # Should be CSV since we simply change the file extension and MIME type from CSV to XLS.
+    translated_csv = xls_resp.content
     # It should have 257 lines (256 + header)
     assert_equal(len(translated_csv.strip('\r\n').split('\r\n')), 257)
 

+ 0 - 1
desktop/core/ext-py/pyexcelerator/.cvsignore

@@ -1 +0,0 @@
-build

+ 0 - 91
desktop/core/ext-py/pyexcelerator/CHANGES.txt

@@ -1,91 +0,0 @@
-0.4.0a (27.03.2005)
----------
-    * First public version
-
-0.5.0a (11.05.2005)
----------
-    * pyExcelerator now can import Excel 5/95/97/2000/XP/2003 files.
-      With imported information you can do what you want.
-      See ./examples/xls2txt.py for reference.
-    * fixed bug in MS OLE2 compound document dumper (not in writer :))
-      Bug causes dumper to combine links in sectors' allocation chain sectors
-      contained in additional MSAT with SAT data.
-    * Excel files dumper supports now Excel 5/95/97/2000/XP/2003 files
-      and produces more informative output.
-      
-0.5.1a (14.05.2005)
----------
-    * improved floating point decoding code
-
-0.5.2a (18.05.2005)
----------
-    * improved perfomance (especially on nonfragmented streams)
-    * now pyExcelerator can process XLS files with short streams
-    * OLE2 compound document dumper supports short streams
-    * reading UTF-16-LE and Latin-1 with more accuracy
-    * in DSF (double stream file) XLS data extracted from stream "Workbook"
-    * improved floating point/integer values decoding code
-
-0.5.3a (19.05.2005)
----------
-    * typos in biff-dumper.py fixed :(
-    * now pyExcelerator can correctly import XLS files with charts
-    * added ability to override default file's encoding
-    * new examples (or tools :)) -- ./examples/xls2csv.py, ./examples/xls2html.py
-
-0.6.0a (19.07.2005)
----------
-    * blanks, numbers, currency (use number formats!) and dates (use number formats!)
-    * pyExcelerator uses 1.5-2 times less memory (thanks to __brains__ and __slots__)
-    * fixes for Big Endian CPUs
-    * some refactorings
-    * new examples: blanks.py, merged1.py, dates.py, numbers.py, num_formats.py, formulas.py
-    * most important change: formulas support
-
-0.6.1a (29.09.2005)
----------
-    * fixed: exception when reading OLE2 files with incorrect MSAT
-      (sector ids points to nonexistense sectors)
-
-0.6.2a (30.09.2005)
----------
-    * fixed: exception when reading OLE2 files with incorrect SSAT
-      (sector ids points to nonexistense sectors)
-
-0.6.3a (25.10.2005)
----------
-    * slightly new algorithm for reading OLE2 files. I hope it is
-      more robust
-    * splitting and frozing
-    * worksheet protection
-    * protection password
-    * workbook protection
-    * new example: protection.py, hyperlinks.py, panes.py
-    * extracting formula results
-    * speed optmizations(for example, benchmark big-35Mb.py runs about 
-      20-30% faster)
-    * updated THANKS file
-    * xls2csv, xls2txt, xls2html now resides in ./tools
-
-0.6.4.1 (11.04.2009)
----------
-    * support writing to file-like objects
-    * add support for setting formula cell options
-    * add support for using color name strings to set the Font color
-      properties
-    * add support for setting default row height records
-    * add set_column, set_columns, and write_cols which are similar
-      to the perl counter parts and allow setting/writing to multiple columns
-    * allow page breaks to be intergers in the page break list
-    * add support for setting print area, and beginnings of other macros
-      and builtin functions
-    * allow None to be given to add_style to set default style
-    * Accepted patch for some bugs in the RK conversion routine from
-      John Machin
-    * add support for setting default results for formulas
-    * fix bug in lexer where symbols of more than one character are
-      not recognized
-    * Fix #1621199: typo causes DIMENSIONS record to have wrong number
-      of columns
-    * add support hyperlinks
-    * FIX #1618833: XFStyle defaults are now copies of the default properties.

+ 0 - 47
desktop/core/ext-py/pyexcelerator/LICENSE.txt

@@ -1,47 +0,0 @@
-  Copyright (C) 2005 Roman V. Kiseliov
-  All rights reserved.
- 
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
- 
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
- 
-  2. Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-     the documentation and/or other materials provided with the
-     distribution.
- 
-  3. All advertising materials mentioning features or use of this
-     software must display the following acknowledgment:
-     "This product includes software developed by
-      Roman V. Kiseliov <roman@kiseliov.ru>."
- 
-  4. Redistributions of any form whatsoever must retain the following
-     acknowledgment:
-     "This product includes software developed by
-      Roman V. Kiseliov <roman@kiseliov.ru>."
- 
-  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Roman V. Kiseliov
-Russia
-Kursk
-Libknecht St., 4
-
-+7(0712)56-09-83
-
-<roman@kiseliov.ru>
-Subject: pyExcelerator

+ 0 - 20
desktop/core/ext-py/pyexcelerator/PKG-INFO

@@ -1,20 +0,0 @@
-Metadata-Version: 1.0
-Name: pyExcelerator
-Version: 0.6.3a1
-Summary: Library to generate Microsoft Excel (tm) spreadsheet files or to extract data from such files
-Home-page: http://www.sourceforge.net/projects/pyexcelerator
-Author: Roman V. Kiseliov
-Author-email: roman@kiseliov.ru
-License: BSD
-Download-URL: http://www.sourceforge.net/projects/pyexcelerator
-Description: Generate Excel 97+ files. Extract data from Excel 95+ spreadsheets. Full-blown UNICODE support. Pure Python code.
-Keywords: xls,excel,spreadsheet,workbook
-Platform: Platform-independent
-Classifier: Development Status :: 3 - Alpha
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: BSD License
-Classifier: Programming Language :: Python
-Classifier: Operating System :: OS Independent
-Classifier: Topic :: Database
-Classifier: Topic :: Office/Business
-Classifier: Topic :: Software Development :: Libraries :: Python Modules

+ 0 - 145
desktop/core/ext-py/pyexcelerator/README.txt

@@ -1,145 +0,0 @@
-
-                        pyExcelerator
-                    --------------------
-
-
-                                                         Dedicated to Olya. 
-                                                With you it can be reality.
-
-
-
-0x0000. What's this?
---------------------
-This   is   a    library   for   generating   Excel   97/2000/XP/2003   and
-OpenOffice    Calc   compatible     spreadsheets.     pyExcelerator     has
-full-blown   support   for  UNICODE  in Excel and Calc spreadsheets, allows
-using variety of formatting features,   provides   interface   to  printing
-options   of   Excel   and OpenOffice  Calc.  pyExcelerator  contains  also
-Excel BIFF8 dumper and MS compound  documents  dumper.  Main  advantage  is
-possibility of generating Excel  spreadsheets  without  MS  Windows  and/or
-COM  servers.  The  only requirement -- Python 2.4a3 or higher.
-
-
-0x0001. Why?
---------------------
-I  had need to generate .xls with UNICODE under FreeBSD.
-
-
-0x0002. Requirements.
---------------------
-Python    2.4   up   and   running.   I've   tested   pyExcelerator   under
-Win32  (Python     compiled     with    MS    C    compiler    and    Intel
-C  compiler),    Win64-x86  (MS       C      compiler),   FreeBSD/i386 (GCC
-3.4.2),   FreeBSD/amd64   (GCC    3.4.2).    Fastest    was   Python  under
-FreeBSD/amd64.
-
-
-0x0003. Installation.
---------------------
-As usually: python ./setup.py install
-
-
-0x0004. Documentation.
---------------------
-In progress. At the present time you can use examples and sources (I hope
-I commented sources well and gave variables good names).
-
-
-0x0005. Extra features.
---------------------
-See  ./tools/*.py.  You'll  find  there  BIFF8  dumper  and MS Compound doc
-dumper.  In  ./hrc  you  can take my python.hrc for Colorer plug-in for FAR
-manager.
-
-
-0x0006. Reporting bugs.
---------------------
-Please! 
-
-
-0x0008. Future.
---------------------
-Support for Esher layer and (maybe) charts.
-
-
-0x0009. Useful links.
---------------------
-http://www.python.org    --
-                           Python's home.
-http://sf.net/pyXLWriter -- 
-                           port of the first version Spreadsheet-WriteExcel.
-                           This library can write only BIFF5/7 spreadsheets
-                           and therefore can't use UNICODE in spreadsheets.
-                           pyXLWriter however can write formulas with help
-                           of PLY. IMHO, PLY and ambiguous grammar used by
-                           author for formulas support are too power tools.
-                           But in this case power was equals to simplicity.
-                           I want overcome these restrictions and (strictly
-                           IMHO) misfeatures. 
-http://www.openoffice.org --
-                           OpenOffice home. 
-                           About 650 Mb sources -- the best teachers.
-
-0x000A. Legality.
---------------------
-With  help  from  lawyers  pyExcelerator is protect by Russian Federation's
-laws  and  international  treaties and can be used iff you agreed following
-BSD-like agreement.
-
- Copyright (C) 2005 Roman V. Kiseliov
- All rights reserved.
- 
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 
- 1. Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer.
- 
- 2. Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
- 
- 3. All advertising materials mentioning features or use of this
-    software must display the following acknowledgment:
-    "This product includes software developed by
-     Roman V. Kiseliov <roman@kiseliov.ru>."
- 
- 4. Redistributions of any form whatsoever must retain the following
-    acknowledgment:
-    "This product includes software developed by
-     Roman V. Kiseliov <roman@kiseliov.ru>."
- 
- THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
- EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
- ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-0xFFFF. Contacting author.
---------------------
-Feel free to send me feedback and bug reports.
-
-Roman V. Kiseliov
-Russia
-Kursk
-Libknecht St., 4
-
-+7(0712)56-09-83
-
-<roman@kiseliov.ru>
-subject *must* be 
-"pyExcelerator-bug" (without quotes)
-or 
-"pyExcelerator-feedback" (without quotes)
-

+ 0 - 25
desktop/core/ext-py/pyexcelerator/THANKS.txt

@@ -1,25 +0,0 @@
-* My lovely wife Olya
---------------------------
-* Evgeny Filatov 
-* John McNamara 
-* Daniel Rentz
-* John Machin
-* Ksenia Marasanova
-* Choe, Cheng-Dae
-* Jan ONDREJ
-* Andy Gimblett
-* Blais, Gerard C.
-* McNevin Michael B.
-* John Fouby
-* <your name>. Feel free to update my memory!
---------------------------
-* Offspring
-* Lynkin Park
---------------------------
-* Nescafe
---------------------------
-* Python Team
-* FreeBSD Team
-* SF Team
-
-

+ 0 - 4
desktop/core/ext-py/pyexcelerator/TODO.txt

@@ -1,4 +0,0 @@
-*Write documentation
-*BSE container for Esher layer
-*Fully implement Name Records (for macros and functions)
-*Support Asian phonetic and rich-text settings

+ 0 - 37
desktop/core/ext-py/pyexcelerator/examples/big-16Mb.py

@@ -1,37 +0,0 @@
-#!/usr/bin/env python
-# tries stress SST, SAT and MSAT
-__rev_id__ = """$Id: big-16Mb.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from time import *
-from pyExcelerator.Workbook import *
-from pyExcelerator.Style import *
-
-style = XFStyle()
-
-wb = Workbook()
-ws0 = wb.add_sheet('0')
-
-colcount = 200 + 1
-rowcount = 6000 + 1
-
-t0 = time()
-print "\nstart: %s" % ctime(t0)
-
-print "Filling..."
-for col in xrange(colcount):
-    print "[%d]" % col, 
-    for row in xrange(rowcount):
-        #ws0.write(row, col, "BIG(%d, %d)" % (row, col))
-        ws0.write(row, col, "BIG")
-
-t1 = time() - t0
-print "\nsince starting elapsed %.2f s" % (t1)
-
-print "Storing..."
-wb.save('big-16Mb.xls')
-
-t2 = time() - t0
-print "since starting elapsed %.2f s" % (t2)
-
-

+ 0 - 36
desktop/core/ext-py/pyexcelerator/examples/big-35Mb.py

@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-# tries stress SST, SAT and MSAT
-__rev_id__ = """$Id: big-35Mb.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from time import *
-from pyExcelerator import *
-
-style = XFStyle()
-
-wb = Workbook()
-ws0 = wb.add_sheet('0')
-
-colcount = 200 + 1
-rowcount = 6000 + 1
-
-t0 = time()
-print "\nstart: %s" % ctime(t0)
-
-print "Filling..."
-for col in xrange(colcount):
-    print "[%d]" % col, 
-    for row in xrange(rowcount):
-        ws0.write(row, col, "BIG(%d, %d)" % (row, col))
-        #ws0.write(row, col, "BIG")
-
-t1 = time() - t0
-print "\nsince starting elapsed %.2f s" % (t1)
-
-print "Storing..."
-wb.save('big-35Mb.xls')
-
-t2 = time() - t0
-print "since starting elapsed %.2f s" % (t2)
-
-

+ 0 - 39
desktop/core/ext-py/pyexcelerator/examples/blanks.py

@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: blanks.py,v 1.2 2005/07/22 08:22:26 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-font0 = Font()
-font0.name = 'Times New Roman'
-font0.struck_out = True
-font0.bold = True
-
-style0 = XFStyle()
-style0.font = font0
-
-
-wb = Workbook()
-ws0 = wb.add_sheet('0')
-
-ws0.write(1, 1, 'Test', style0)
-
-for i in range(0, 0x53):
-    borders = Borders()
-    borders.left = i
-    borders.right = i
-    borders.top = i
-    borders.bottom = i
-
-    style = XFStyle()
-    style.borders = borders
-
-    ws0.write(i, 2, '', style)
-    ws0.write(i, 3, hex(i), style0)
-
-ws0.write_merge(5, 8, 6, 10, "")
-
-wb.save('blanks.xls')

+ 0 - 19
desktop/core/ext-py/pyexcelerator/examples/col_width.py

@@ -1,19 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: col_width.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws = w.add_sheet('Hey, Dude')
-
-for i in range(6, 80):
-    fnt = Font()
-    fnt.height = i*20
-    style = XFStyle()
-    style.font = fnt
-    ws.write(1, i, 'Test')
-    ws.col(i).width = 0x0d00 + i
-w.save('col_width.xls')

+ 0 - 39
desktop/core/ext-py/pyexcelerator/examples/dates.py

@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: dates.py,v 1.1 2005/07/20 07:24:11 rvk Exp $"""
-
-
-from pyExcelerator import *
-from datetime import datetime
-
-w = Workbook()
-ws = w.add_sheet('Hey, Dude')
-
-fmts = [
-    'M/D/YY',
-    'D-MMM-YY',
-    'D-MMM',
-    'MMM-YY',
-    'h:mm AM/PM',
-    'h:mm:ss AM/PM',
-    'h:mm',
-    'h:mm:ss',
-    'M/D/YY h:mm',
-    'mm:ss',
-    '[h]:mm:ss',
-    'mm:ss.0',
-]
-
-i = 0
-for fmt in fmts:
-    ws.write(i, 0, fmt)
-
-    style = XFStyle()
-    style.num_format_str = fmt
-
-    ws.write(i, 4, datetime.now(), style)
-
-    i += 1
-
-w.save('dates.xls')

+ 0 - 32
desktop/core/ext-py/pyexcelerator/examples/format.py

@@ -1,32 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: format.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-style0 = XFStyle()
-style0.font.name = 'Times New Roman'
-style0.font.struck_out = True
-style0.font.bold = True
-
-
-wb = Workbook()
-ws0 = wb.add_sheet('0')
-
-ws0.write(1, 1, 'Test', style0)
-
-for i in range(0, 0x53):
-    style = XFStyle()
-    style.font.name = 'Arial'
-    style.font.colour_index = i
-    style.font.outline = True
-    style.borders.left = i
-
-    ws0.write(i, 2, 'colour', style)
-    ws0.write(i, 3, hex(i), style0)
-
-
-wb.save('format.xls')

+ 0 - 18
desktop/core/ext-py/pyexcelerator/examples/formula_names.py

@@ -1,18 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: formula_names.py,v 1.1 2005/08/11 08:53:48 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws = w.add_sheet('F')
-
-i = 0
-for n in sorted(ExcelMagic.std_func_by_name):
-    ws.write(i, 0, n)
-    ws.write(i, 3, Formula(n + "($A$1)"))
-    i += 1
-
-w.save('formula_names.xls')

+ 0 - 51
desktop/core/ext-py/pyexcelerator/examples/formulas.py

@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: formulas.py,v 1.4 2005/10/26 07:44:24 rvk Exp $"""
-
-
-from pyExcelerator import *
-from pyExcelerator.Worksheet import *
-
-w = Workbook()
-ws = w.add_sheet('F')
-ws.frmla_opts=NoCalcs
-
-ws.write(0, 0, Formula("-(1+1)", None))
-ws.write(1, 0, Formula("-(1+1)/(-2-2)", 3.14))
-ws.write(2, 0, Formula("-(134.8780789+1)", ErrorCode("#NULL!"), CalcOnOpen))
-ws.write(3, 0, Formula("-(134.8780789e-10+1)", ErrorCode("#NAME?")))
-ws.write(4, 0, Formula("-1/(1+1)+9344", 12345))
-
-ws.write(0, 1, Formula("-(1+1)", "this is 2", CalcOnOpen))
-ws.write(1, 1, Formula("-(1+1)/(-2-2)", u"this is 0.5"))
-ws.write(2, 1, Formula("-(134.8780789+1)", ""))
-ws.write(3, 1, Formula("-(134.8780789e-10+1)"))
-ws.write(4, 1, Formula("-1/(1+1)+9344"))
-
-ws.write(0, 2, Formula("A1*B1"))
-ws.write(1, 2, Formula("A2*B2"))
-ws.write(2, 2, Formula("A3*B3"))
-ws.write(3, 2, Formula("A4*B4*sin(pi()/4)"))
-ws.write(4, 2, Formula("A5%*B5*pi()/1000"))
-
-##############
-## NOTE: parameters are separated by semicolon!!!
-##############
-
-
-ws.write(5, 2, Formula("C1+C2+C3+C4+C5/(C1+C2+C3+C4/(C1+C2+C3+C4/(C1+C2+C3+C4)+C5)+C5)-20.3e-2"))
-ws.write(5, 3, Formula("C1^2"))
-ws.write(6, 2, Formula("SUM(C1;C2;;;;;C3;;;C4)"))
-ws.write(6, 3, Formula("SUM($A$1:$C$5)"))
-
-ws.write(7, 0, Formula('"lkjljllkllkl"'))
-ws.write(7, 1, Formula('"yuyiyiyiyi"'))
-ws.write(7, 2, Formula('A8 & B8 & A8'))
-ws.write(8, 2, Formula('now()'))
-
-ws.write(10, 2, Formula('TRUE'))
-ws.write(11, 2, Formula('FALSE'))
-ws.write(12, 3, Formula('IF(A1>A2;3;"hkjhjkhk")'))
-
-w.save('formulas.xls')

+ 0 - 36
desktop/core/ext-py/pyexcelerator/examples/hyperlinks.py

@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: hyperlinks.py,v 1.1 2005/10/26 07:44:24 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-f = Font()
-f.height = 20*72
-f.name = 'Verdana'
-f.bold = True
-f.underline = Font.UNDERLINE_DOUBLE
-f.colour_index = 4
-
-h_style = XFStyle()
-h_style.font = f
-
-w = Workbook()
-ws = w.add_sheet('F')
-ws_A = w.add_sheet('A')
-
-##############
-## NOTE: parameters are separated by semicolon!!!
-##############
-
-n = "HYPERLINK"
-ws.write_merge(1, 1, 1, 10, Formula(n + '("http://www.irs.gov/pub/irs-pdf/f1000.pdf";"f1000.pdf")'), h_style)
-ws.write_merge(2, 2, 2, 25, Formula(n + '("mailto:roman.kiseliov@gmail.com?subject=pyExcelerator-feedback&Body=Hello,%20Roman!";"pyExcelerator-feedback")'), h_style)
-
-ws.write(3, 0, "Goto Google")
-ws.set_link(3, 0, "http://www.google.com", description="Google")
-ws.write(4, 0, "Goto Next Page")
-ws.set_link(4, 0, "#A!A2", description="page A")
-
-w.save("hyperlinks.xls")

+ 0 - 15
desktop/core/ext-py/pyexcelerator/examples/image.py

@@ -1,15 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: image.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws = w.add_sheet('Image')
-ws.insert_bitmap('python.bmp', 2, 2)
-ws.insert_bitmap('python.bmp', 10, 2)
-
-w.save('image.xls')

+ 0 - 42
desktop/core/ext-py/pyexcelerator/examples/merged.py

@@ -1,42 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: merged.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-fnt = Font()
-fnt.name = 'Arial'
-fnt.colour_index = 4
-fnt.bold = True
-
-borders = Borders()
-borders.left = 6
-borders.right = 6
-borders.top = 6
-borders.bottom = 6
-
-al = Alignment()
-al.horz = Alignment.HORZ_CENTER
-al.vert = Alignment.VERT_CENTER
-
-style = XFStyle()
-style.font = fnt
-style.borders = borders
-style.alignment = al
-
-
-wb = Workbook()
-ws0 = wb.add_sheet('sheet0')
-ws1 = wb.add_sheet('sheet1')
-ws2 = wb.add_sheet('sheet2')
-
-for i in range(0, 0x200, 2):
-    ws0.write_merge(i, i+1, 1, 5, 'test %d' % i, style)
-    ws1.write_merge(i, i, 1, 7, 'test %d' % i, style)
-    ws2.write_merge(i, i+1, 1, 7 + (i%10), 'test %d' % i, style)
-
-
-wb.save('merged.xls')

+ 0 - 32
desktop/core/ext-py/pyexcelerator/examples/merged0.py

@@ -1,32 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: merged0.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-wb = Workbook()
-ws0 = wb.add_sheet('sheet0')
-
-
-fnt = Font()
-fnt.name = 'Arial'
-fnt.colour_index = 4
-fnt.bold = True
-
-borders = Borders()
-borders.left = 6
-borders.right = 6
-borders.top = 6
-borders.bottom = 6
-
-style = XFStyle()
-style.font = fnt
-style.borders = borders
-
-ws0.write_merge(3, 3, 1, 5, 'test1', style)
-ws0.write_merge(4, 10, 1, 5, 'test2', style)
-ws0.col(1).width = 0x0d00
-
-wb.save('merged0.xls')

+ 0 - 104
desktop/core/ext-py/pyexcelerator/examples/merged1.py

@@ -1,104 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: merged1.py,v 1.1 2005/07/22 08:22:26 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-wb = Workbook()
-ws0 = wb.add_sheet('sheet0')
-
-fnt1 = Font()
-fnt1.name = 'Verdana'
-fnt1.bold = True
-fnt1.height = 18*0x14
-
-pat1 = Pattern()
-pat1.pattern = Pattern.SOLID_PATTERN
-pat1.pattern_fore_colour = 0x16
-
-brd1 = Borders()
-brd1.left = 0x06
-brd1.right = 0x06
-brd1.top = 0x06
-brd1.bottom = 0x06
-
-fnt2 = Font()
-fnt2.name = 'Verdana'
-fnt2.bold = True
-fnt2.height = 14*0x14
-
-brd2 = Borders()
-brd2.left = 0x01
-brd2.right = 0x01
-brd2.top = 0x01
-brd2.bottom = 0x01
-
-pat2 = Pattern()
-pat2.pattern = Pattern.SOLID_PATTERN
-pat2.pattern_fore_colour = 0x01F
-
-fnt3 = Font()
-fnt3.name = 'Verdana'
-fnt3.bold = True
-fnt3.italic = True
-fnt3.height = 12*0x14
-
-brd3 = Borders()
-brd3.left = 0x07
-brd3.right = 0x07
-brd3.top = 0x07
-brd3.bottom = 0x07
-
-fnt4 = Font()
-
-al1 = Alignment()
-al1.horz = Alignment.HORZ_CENTER
-al1.vert = Alignment.VERT_CENTER
-
-al2 = Alignment()
-al2.horz = Alignment.HORZ_RIGHT
-al2.vert = Alignment.VERT_CENTER
-
-al3 = Alignment()
-al3.horz = Alignment.HORZ_LEFT
-al3.vert = Alignment.VERT_CENTER
-
-style1 = XFStyle()
-style1.font = fnt1
-style1.alignment = al1
-style1.pattern = pat1
-style1.borders = brd1
-
-style2 = XFStyle()
-style2.font = fnt2
-style2.alignment = al1
-style2.pattern = pat2
-style2.borders = brd2
-
-style3 = XFStyle()
-style3.font = fnt3
-style3.alignment = al1
-style3.pattern = pat2
-style3.borders = brd3
-
-price_style = XFStyle()
-price_style.font = fnt4
-price_style.alignment = al2
-price_style.borders = brd3
-price_style.num_format_str = '_(#,##0.00_) "money"'
-
-ware_style = XFStyle()
-ware_style.font = fnt4
-ware_style.alignment = al3
-ware_style.borders = brd3
-
-
-ws0.merge(3, 3, 1, 5, style1)
-ws0.merge(4, 10, 1, 6, style2)
-ws0.merge(14, 16, 1, 7, style3)
-ws0.col(1).width = 0x0d00
-
-
-wb.save('merged1.xls')

+ 0 - 11
desktop/core/ext-py/pyexcelerator/examples/mini.py

@@ -1,11 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: mini.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws = w.add_sheet('Hey, Dude')
-w.save('mini.xls')

+ 0 - 62
desktop/core/ext-py/pyexcelerator/examples/num_formats.py

@@ -1,62 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: num_formats.py,v 1.1 2005/07/20 07:24:11 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws = w.add_sheet('Hey, Dude')
-
-fmts = [
-    'general',
-    '0',
-    '0.00',
-    '#,##0',
-    '#,##0.00',
-    '"$"#,##0_);("$"#,##',
-    '"$"#,##0_);[Red]("$"#,##',
-    '"$"#,##0.00_);("$"#,##',
-    '"$"#,##0.00_);[Red]("$"#,##',
-    '0%',
-    '0.00%',
-    '0.00E+00',
-    '# ?/?',
-    '# ??/??',
-    'M/D/YY',
-    'D-MMM-YY',
-    'D-MMM',
-    'MMM-YY',
-    'h:mm AM/PM',
-    'h:mm:ss AM/PM',
-    'h:mm',
-    'h:mm:ss',
-    'M/D/YY h:mm',
-    '_(#,##0_);(#,##0)',
-    '_(#,##0_);[Red](#,##0)',
-    '_(#,##0.00_);(#,##0.00)',
-    '_(#,##0.00_);[Red](#,##0.00)',
-    '_("$"* #,##0_);_("$"* (#,##0);_("$"* "-"_);_(@_)',
-    '_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)',
-    '_("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)',
-    '_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',
-    'mm:ss',
-    '[h]:mm:ss',
-    'mm:ss.0',
-    '##0.0E+0',
-    '@'   
-]
-
-i = 0
-for fmt in fmts:
-    ws.write(i, 0, fmt)
-
-    style = XFStyle()
-    style.num_format_str = fmt
-
-    ws.write(i, 4, -1278.9078, style)
-
-    i += 1
-
-w.save('num_formats.xls')

+ 0 - 27
desktop/core/ext-py/pyexcelerator/examples/numbers.py

@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: numbers.py,v 1.1 2005/07/20 07:24:11 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws = w.add_sheet('Hey, Dude')
-
-ws.write(0, 0, 1)
-ws.write(1, 0, 1.23)
-ws.write(2, 0, 12345678)
-ws.write(3, 0, 123456.78)
-
-ws.write(0, 1, -1)
-ws.write(1, 1, -1.23)
-ws.write(2, 1, -12345678)
-ws.write(3, 1, -123456.78)
-
-ws.write(0, 2, -17867868678687.0)
-ws.write(1, 2, -1.23e-5)
-ws.write(2, 2, -12345678.90780980)
-ws.write(3, 2, -123456.78)
-
-w.save('numbers.xls')

+ 0 - 115
desktop/core/ext-py/pyexcelerator/examples/outline.py

@@ -1,115 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: outline.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-fnt = Font()
-fnt.name = 'Arial'
-fnt.colour_index = 4
-fnt.bold = True
-
-borders = Borders()
-borders.left = 6
-borders.right = 6
-borders.top = 6
-borders.bottom = 6
-
-style = XFStyle()
-style.font = fnt
-style.borders = borders
-
-wb = Workbook()
-
-ws0 = wb.add_sheet('Rows Outline')
-
-ws0.write_merge(1, 1, 1, 5, 'test 1', style)
-ws0.write_merge(2, 2, 1, 4, 'test 1', style)
-ws0.write_merge(3, 3, 1, 3, 'test 2', style)
-ws0.write_merge(4, 4, 1, 4, 'test 1', style)
-ws0.write_merge(5, 5, 1, 4, 'test 3', style)
-ws0.write_merge(6, 6, 1, 5, 'test 1', style)
-ws0.write_merge(7, 7, 1, 5, 'test 4', style)
-ws0.write_merge(8, 8, 1, 4, 'test 1', style)
-ws0.write_merge(9, 9, 1, 3, 'test 5', style)
-
-ws0.row(1).level = 1
-ws0.row(2).level = 1
-ws0.row(3).level = 2
-ws0.row(4).level = 2
-ws0.row(5).level = 2
-ws0.row(6).level = 2
-ws0.row(7).level = 2
-ws0.row(8).level = 1
-ws0.row(9).level = 1
-
-
-ws1 = wb.add_sheet('Columns Outline')
-
-ws1.write_merge(1, 1, 1, 5, 'test 1', style)
-ws1.write_merge(2, 2, 1, 4, 'test 1', style)
-ws1.write_merge(3, 3, 1, 3, 'test 2', style)
-ws1.write_merge(4, 4, 1, 4, 'test 1', style)
-ws1.write_merge(5, 5, 1, 4, 'test 3', style)
-ws1.write_merge(6, 6, 1, 5, 'test 1', style)
-ws1.write_merge(7, 7, 1, 5, 'test 4', style)
-ws1.write_merge(8, 8, 1, 4, 'test 1', style)
-ws1.write_merge(9, 9, 1, 3, 'test 5', style)
-
-ws1.col(1).level = 1
-ws1.col(2).level = 1
-ws1.col(3).level = 2
-ws1.col(4).level = 2
-ws1.col(5).level = 2
-ws1.col(6).level = 2
-ws1.col(7).level = 2
-ws1.col(8).level = 1
-ws1.col(9).level = 1
-
-
-ws2 = wb.add_sheet('Rows and Columns Outline')
-
-ws2.write_merge(1, 1, 1, 5, 'test 1', style)
-ws2.write_merge(2, 2, 1, 4, 'test 1', style)
-ws2.write_merge(3, 3, 1, 3, 'test 2', style)
-ws2.write_merge(4, 4, 1, 4, 'test 1', style)
-ws2.write_merge(5, 5, 1, 4, 'test 3', style)
-ws2.write_merge(6, 6, 1, 5, 'test 1', style)
-ws2.write_merge(7, 7, 1, 5, 'test 4', style)
-ws2.write_merge(8, 8, 1, 4, 'test 1', style)
-ws2.write_merge(9, 9, 1, 3, 'test 5', style)
-
-ws2.row(1).level = 1
-ws2.row(2).level = 1
-ws2.row(3).level = 2
-ws2.row(4).level = 2
-ws2.row(5).level = 2
-ws2.row(6).level = 2
-ws2.row(7).level = 2
-ws2.row(8).level = 1
-ws2.row(9).level = 1
-
-ws2.write_merge(1, 1, 1, 5, 'test 1', style)
-ws2.write_merge(2, 2, 1, 4, 'test 1', style)
-ws2.write_merge(3, 3, 1, 3, 'test 2', style)
-ws2.write_merge(4, 4, 1, 4, 'test 1', style)
-ws2.write_merge(5, 5, 1, 4, 'test 3', style)
-ws2.write_merge(6, 6, 1, 5, 'test 1', style)
-ws2.write_merge(7, 7, 1, 5, 'test 4', style)
-ws2.write_merge(8, 8, 1, 4, 'test 1', style)
-ws2.write_merge(9, 9, 1, 3, 'test 5', style)
-
-ws2.col(1).level = 1
-ws2.col(2).level = 1
-ws2.col(3).level = 2
-ws2.col(4).level = 2
-ws2.col(5).level = 2
-ws2.col(6).level = 2
-ws2.col(7).level = 2
-ws2.col(8).level = 1
-ws2.col(9).level = 1
-
-
-wb.save('outline.xls')

+ 0 - 60
desktop/core/ext-py/pyexcelerator/examples/panes.py

@@ -1,60 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: panes.py,v 1.1 2005/10/26 07:44:24 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws1 = w.add_sheet('sheet 1')
-ws2 = w.add_sheet('sheet 2')
-ws3 = w.add_sheet('sheet 3')
-ws4 = w.add_sheet('sheet 4')
-ws5 = w.add_sheet('sheet 5')
-ws6 = w.add_sheet('sheet 6')
-
-for i in range(0x100):
-    ws1.write(i/0x10, i%0x10, i)
-
-for i in range(0x100):
-    ws2.write(i/0x10, i%0x10, i)
-
-for i in range(0x100):
-    ws3.write(i/0x10, i%0x10, i)
-
-for i in range(0x100):
-    ws4.write(i/0x10, i%0x10, i)
-
-for i in range(0x100):
-    ws5.write(i/0x10, i%0x10, i)
-
-for i in range(0x100):
-    ws6.write(i/0x10, i%0x10, i)
-
-ws1.panes_frozen = True
-ws1.horz_split_pos = 2
-
-ws2.panes_frozen = True
-ws2.vert_split_pos = 2
-
-ws3.panes_frozen = True
-ws3.horz_split_pos = 1
-ws3.vert_split_pos = 1
-
-ws4.panes_frozen = False
-ws4.horz_split_pos = 12
-ws4.horz_split_first_visible = 2
-
-ws5.panes_frozen = False
-ws5.vert_split_pos = 40
-ws4.vert_split_first_visible = 2
-
-ws6.panes_frozen = False
-ws6.horz_split_pos = 12
-ws4.horz_split_first_visible = 2
-ws6.vert_split_pos = 40
-ws4.vert_split_first_visible = 2
-
-w.save('panes.xls')
-

+ 0 - 12
desktop/core/ext-py/pyexcelerator/examples/parse-fmla.py

@@ -1,12 +0,0 @@
-from pyExcelerator import ExcelFormulaParser, ExcelFormula
-import sys
-
-f = ExcelFormula.Formula(
-""" -((1.80 + 2.898 * 1)/(1.80 + 2.898))*
-AVERAGE((1.80 + 2.898 * 1)/(1.80 + 2.898); 
-        (1.80 + 2.898 * 1)/(1.80 + 2.898); 
-        (1.80 + 2.898 * 1)/(1.80 + 2.898)) + 
-SIN(PI()/4)""")
-
-#for t in f.rpn():
-#    print "%15s %15s" % (ExcelFormulaParser.PtgNames[t[0]], t[1])

+ 0 - 136
desktop/core/ext-py/pyexcelerator/examples/protection.py

@@ -1,136 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: protection.py,v 1.1 2005/10/26 07:44:24 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-fnt = Font()
-fnt.name = 'Arial'
-fnt.colour_index = 4
-fnt.bold = True
-
-borders = Borders()
-borders.left = 6
-borders.right = 6
-borders.top = 6
-borders.bottom = 6
-
-style = XFStyle()
-style.font = fnt
-style.borders = borders
-
-wb = Workbook()
-
-ws0 = wb.add_sheet('Rows Outline')
-
-ws0.write_merge(1, 1, 1, 5, 'test 1', style)
-ws0.write_merge(2, 2, 1, 4, 'test 1', style)
-ws0.write_merge(3, 3, 1, 3, 'test 2', style)
-ws0.write_merge(4, 4, 1, 4, 'test 1', style)
-ws0.write_merge(5, 5, 1, 4, 'test 3', style)
-ws0.write_merge(6, 6, 1, 5, 'test 1', style)
-ws0.write_merge(7, 7, 1, 5, 'test 4', style)
-ws0.write_merge(8, 8, 1, 4, 'test 1', style)
-ws0.write_merge(9, 9, 1, 3, 'test 5', style)
-
-ws0.row(1).level = 1
-ws0.row(2).level = 1
-ws0.row(3).level = 2
-ws0.row(4).level = 2
-ws0.row(5).level = 2
-ws0.row(6).level = 2
-ws0.row(7).level = 2
-ws0.row(8).level = 1
-ws0.row(9).level = 1
-
-
-ws1 = wb.add_sheet('Columns Outline')
-
-ws1.write_merge(1, 1, 1, 5, 'test 1', style)
-ws1.write_merge(2, 2, 1, 4, 'test 1', style)
-ws1.write_merge(3, 3, 1, 3, 'test 2', style)
-ws1.write_merge(4, 4, 1, 4, 'test 1', style)
-ws1.write_merge(5, 5, 1, 4, 'test 3', style)
-ws1.write_merge(6, 6, 1, 5, 'test 1', style)
-ws1.write_merge(7, 7, 1, 5, 'test 4', style)
-ws1.write_merge(8, 8, 1, 4, 'test 1', style)
-ws1.write_merge(9, 9, 1, 3, 'test 5', style)
-
-ws1.col(1).level = 1
-ws1.col(2).level = 1
-ws1.col(3).level = 2
-ws1.col(4).level = 2
-ws1.col(5).level = 2
-ws1.col(6).level = 2
-ws1.col(7).level = 2
-ws1.col(8).level = 1
-ws1.col(9).level = 1
-
-
-ws2 = wb.add_sheet('Rows and Columns Outline')
-
-ws2.write_merge(1, 1, 1, 5, 'test 1', style)
-ws2.write_merge(2, 2, 1, 4, 'test 1', style)
-ws2.write_merge(3, 3, 1, 3, 'test 2', style)
-ws2.write_merge(4, 4, 1, 4, 'test 1', style)
-ws2.write_merge(5, 5, 1, 4, 'test 3', style)
-ws2.write_merge(6, 6, 1, 5, 'test 1', style)
-ws2.write_merge(7, 7, 1, 5, 'test 4', style)
-ws2.write_merge(8, 8, 1, 4, 'test 1', style)
-ws2.write_merge(9, 9, 1, 3, 'test 5', style)
-
-ws2.row(1).level = 1
-ws2.row(2).level = 1
-ws2.row(3).level = 2
-ws2.row(4).level = 2
-ws2.row(5).level = 2
-ws2.row(6).level = 2
-ws2.row(7).level = 2
-ws2.row(8).level = 1
-ws2.row(9).level = 1
-
-ws2.write_merge(1, 1, 1, 5, 'test 1', style)
-ws2.write_merge(2, 2, 1, 4, 'test 1', style)
-ws2.write_merge(3, 3, 1, 3, 'test 2', style)
-ws2.write_merge(4, 4, 1, 4, 'test 1', style)
-ws2.write_merge(5, 5, 1, 4, 'test 3', style)
-ws2.write_merge(6, 6, 1, 5, 'test 1', style)
-ws2.write_merge(7, 7, 1, 5, 'test 4', style)
-ws2.write_merge(8, 8, 1, 4, 'test 1', style)
-ws2.write_merge(9, 9, 1, 3, 'test 5', style)
-
-ws2.col(1).level = 1
-ws2.col(2).level = 1
-ws2.col(3).level = 2
-ws2.col(4).level = 2
-ws2.col(5).level = 2
-ws2.col(6).level = 2
-ws2.col(7).level = 2
-ws2.col(8).level = 1
-ws2.col(9).level = 1
-
-
-ws0.protect = True
-ws0.wnd_protect = True
-ws0.obj_protect = True
-ws0.scen_protect = True
-ws0.password = "123456"
-
-ws1.protect = True
-ws1.wnd_protect = True
-ws1.obj_protect = True
-ws1.scen_protect = True
-ws1.password = "abcdefghij"
-
-ws2.protect = True
-ws2.wnd_protect = True
-ws2.obj_protect = True
-ws2.scen_protect = True
-ws2.password = "ok"
-
-wb.protect = True
-wb.wnd_protect = True
-wb.obj_protect = True
-wb.save('protection.xls')

BIN
desktop/core/ext-py/pyexcelerator/examples/python.bmp


+ 0 - 19
desktop/core/ext-py/pyexcelerator/examples/row_styles.py

@@ -1,19 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: row_styles.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws = w.add_sheet('Hey, Dude')
-
-for i in range(6, 80):
-    fnt = Font()
-    fnt.height = i*20
-    style = XFStyle()
-    style.font = fnt
-    ws.write(i, 1, 'Test')
-    ws.row(i).set_style(style)
-w.save('row_styles.xls')

+ 0 - 18
desktop/core/ext-py/pyexcelerator/examples/row_styles_empty.py

@@ -1,18 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: row_styles_empty.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws = w.add_sheet('Hey, Dude')
-
-for i in range(6, 80):
-    fnt = Font()
-    fnt.height = i*20
-    style = XFStyle()
-    style.font = fnt
-    ws.row(i).set_style(style)
-w.save('row_styles_empty.xls')

+ 0 - 54
desktop/core/ext-py/pyexcelerator/examples/sst.py

@@ -1,54 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: sst.py,v 1.2 2005/03/25 07:31:12 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-font0 = Formatting.Font()
-font0.name = 'Arial'
-font1 = Formatting.Font()
-font1.name = 'Arial Cyr'
-font2 = Formatting.Font()
-font2.name = 'Times New Roman'
-font3 = Formatting.Font()
-font3.name = 'Courier New Cyr'
-
-num_format0 = '0.00000'
-num_format1 = '0.000000'
-num_format2 = '0.0000000'
-num_format3 = '0.00000000'
-
-st0 = XFStyle()
-st1 = XFStyle()
-st2 = XFStyle()
-st3 = XFStyle()
-st4 = XFStyle()
-
-st0.font = font0
-st0.num_format = num_format0
-
-st1.font = font1
-st1.num_format = num_format1
-
-st2.font = font2
-st2.num_format = num_format2
-
-st3.font = font3
-st3.num_format = num_format3
-
-wb = Workbook()
-
-wb.add_style(st0)
-wb.add_style(st1)
-wb.add_style(st2)
-wb.add_style(st3)
-
-ws0 = wb.add_sheet('0')
-ws0.write(0, 0, 'Olya'*0x4000, st0)
-
-#for i in range(0, 0x10):
-#    ws0.write(i, 2, ('%d'%i)*0x4000, st1)
-    
-wb.save('sst.xls')

+ 0 - 16
desktop/core/ext-py/pyexcelerator/examples/unicode0.py

@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: unicode0.py,v 1.1 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws1 = w.add_sheet('cp1251')
-
-UnicodeUtils.DEFAULT_ENCODING = 'cp1251'
-ws1.write(0, 0, 'Îëÿ')
-
-w.save('unicode0.xls')
-

+ 0 - 30
desktop/core/ext-py/pyexcelerator/examples/unicode1.py

@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: unicode1.py,v 1.1 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws1 = w.add_sheet(u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK SMALL LETTER BETA}\N{GREEK SMALL LETTER GAMMA}')
-
-ws1.write(0, 0, u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK SMALL LETTER BETA}\N{GREEK SMALL LETTER GAMMA}')
-ws1.write(1, 1, u'\N{GREEK SMALL LETTER DELTA}x = 1 + \N{GREEK SMALL LETTER DELTA}')
-
-ws1.write(2,0, u'A\u2262\u0391.')     # RFC2152 example
-ws1.write(3,0, u'Hi Mom -\u263a-!')   # RFC2152 example
-ws1.write(4,0, u'\u65E5\u672C\u8A9E') # RFC2152 example
-ws1.write(5,0, u'Item 3 is \u00a31.') # RFC2152 example
-ws1.write(8,0, u'\N{INTEGRAL}')       # RFC2152 example
-
-w.add_sheet(u'A\u2262\u0391.')     # RFC2152 example
-w.add_sheet(u'Hi Mom -\u263a-!')   # RFC2152 example
-one_more_ws = w.add_sheet(u'\u65E5\u672C\u8A9E') # RFC2152 example
-w.add_sheet(u'Item 3 is \u00a31.') # RFC2152 example
-
-one_more_ws.write(0, 0, u'\u2665\u2665')
-
-w.add_sheet(u'\N{GREEK SMALL LETTER ETA WITH TONOS}')
-w.save('unicode1.xls')
-

+ 0 - 21
desktop/core/ext-py/pyexcelerator/examples/unicode2.py

@@ -1,21 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-__rev_id__ = """$Id: unicode2.py,v 1.1 2005/03/27 12:47:06 rvk Exp $"""
-
-
-from pyExcelerator import *
-
-w = Workbook()
-ws1 = w.add_sheet(u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK SMALL LETTER BETA}\N{GREEK SMALL LETTER GAMMA}\u2665\u041e\u041b\u042f\u2665')
-
-fnt = Font()
-fnt.height = 26*20
-style = XFStyle()
-style.font = fnt
-
-for i in range(0x10000):
-    ws1.write(i/0x10, i%0x10, unichr(i), style)
-
-w.save('unicode2.xls')
-

+ 0 - 157
desktop/core/ext-py/pyexcelerator/examples/wsprops.py

@@ -1,157 +0,0 @@
-__rev_id__ = """$Id: wsprops.py,v 1.3 2005/03/27 12:47:06 rvk Exp $"""
-
-props = \
-[
-        'name',
-        'parent',
-        'rows',
-        'cols',
-        'merged_ranges',
-        'bmp_rec',
-        'show_formulas',
-        'show_grid',
-        'show_headers',
-        'panes_frozen',
-        'show_empty_as_zero',
-        'auto_colour_grid',
-        'cols_right_to_left',
-        'show_outline',
-        'remove_splits',
-        'selected',
-        'hidden',
-        'page_preview',
-        'first_visible_row',
-        'first_visible_col',
-        'grid_colour',
-        'preview_magn',
-        'normal_magn',
-        'row_gut_width',
-        'col_gut_height',
-        'show_auto_page_breaks',
-        'dialogue_sheet',
-        'auto_style_outline',
-        'outline_below',
-        'outline_right',
-        'fit_num_pages',
-        'show_row_outline',
-        'show_col_outline',
-        'alt_expr_eval',
-        'alt_formula_entries',
-        'row_default_height',
-        'col_default_width',
-        'calc_mode',
-        'calc_count',
-        'RC_ref_mode',
-        'iterations_on',
-        'delta',
-        'save_recalc',
-        'print_headers',
-        'print_grid',
-        'grid_set',
-        'vert_page_breaks',
-        'horz_page_breaks',
-        'header_str',
-        'footer_str',
-        'print_centered_vert',
-        'print_centered_horz',
-        'left_margin',
-        'right_margin',
-        'top_margin',
-        'bottom_margin',
-        'paper_size_code',
-        'print_scaling',
-        'start_page_number',
-        'fit_width_to_pages',
-        'fit_height_to_pages',
-        'print_in_rows',
-        'portrait',
-        'print_not_colour',
-        'print_draft',
-        'print_notes',
-        'print_notes_at_end',
-        'print_omit_errors',
-        'print_hres',
-        'print_vres',
-        'header_margin',
-        'footer_margin',
-        'copies_num',
-]
-
-from pyExcelerator import *
-
-wb = Workbook()
-ws = wb.add_sheet('sheet')
-
-print ws.name
-print ws.parent
-print ws.rows
-print ws.cols
-print ws.merged_ranges
-print ws.bmp_rec
-print ws.show_formulas
-print ws.show_grid
-print ws.show_headers
-print ws.panes_frozen
-print ws.show_empty_as_zero
-print ws.auto_colour_grid
-print ws.cols_right_to_left
-print ws.show_outline
-print ws.remove_splits
-print ws.selected
-print ws.hidden
-print ws.page_preview
-print ws.first_visible_row
-print ws.first_visible_col
-print ws.grid_colour
-print ws.preview_magn
-print ws.normal_magn
-#print ws.row_gut_width
-#print ws.col_gut_height
-print ws.show_auto_page_breaks
-print ws.dialogue_sheet
-print ws.auto_style_outline
-print ws.outline_below
-print ws.outline_right
-print ws.fit_num_pages
-print ws.show_row_outline
-print ws.show_col_outline
-print ws.alt_expr_eval
-print ws.alt_formula_entries
-print ws.row_default_height
-print ws.col_default_width
-print ws.calc_mode
-print ws.calc_count
-print ws.RC_ref_mode
-print ws.iterations_on
-print ws.delta
-print ws.save_recalc
-print ws.print_headers
-print ws.print_grid
-#print ws.grid_set
-print ws.vert_page_breaks
-print ws.horz_page_breaks
-print ws.header_str
-print ws.footer_str
-print ws.print_centered_vert
-print ws.print_centered_horz
-print ws.left_margin
-print ws.right_margin
-print ws.top_margin
-print ws.bottom_margin
-print ws.paper_size_code
-print ws.print_scaling
-print ws.start_page_number
-print ws.fit_width_to_pages
-print ws.fit_height_to_pages
-print ws.print_in_rows
-print ws.portrait
-print ws.print_colour
-print ws.print_draft
-print ws.print_notes
-print ws.print_notes_at_end
-print ws.print_omit_errors
-print ws.print_hres
-print ws.print_vres
-print ws.header_margin
-print ws.footer_margin
-print ws.copies_num

+ 0 - 44
desktop/core/ext-py/pyexcelerator/examples/xls2csv.py

@@ -1,44 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: xls2csv.py,v 1.1 2005/05/19 09:27:42 rvk Exp $"""
-
-
-from pyExcelerator import *
-import sys
-
-me, args = sys.argv[0], sys.argv[1:]
-
-
-if args:
-    for arg in args:
-        print >>sys.stderr, 'extracting data from', arg
-        for sheet_name, values in parse_xls(arg, 'cp1251'): # parse_xls(arg) -- default encoding
-            matrix = [[]]
-            print 'Sheet = "%s"' % sheet_name.encode('cp866', 'backslashreplace')
-            print '----------------'
-            for row_idx, col_idx in sorted(values.keys()):
-                v = values[(row_idx, col_idx)]
-                if isinstance(v, unicode):
-                    v = v.encode('cp866', 'backslashreplace')
-                else:
-                    v = str(v)
-                last_row, last_col = len(matrix), len(matrix[-1])
-                while last_row < row_idx:
-                    matrix.extend([[]])
-                    last_row = len(matrix)
-
-                while last_col < col_idx:
-                    matrix[-1].extend([''])
-                    last_col = len(matrix[-1])
-
-                matrix[-1].extend([v])
-                    
-            for row in matrix:
-                csv_row = ','.join(row)
-                print csv_row
-
-else:
-    print 'usage: %s (inputfile)+' % me
-

+ 0 - 51
desktop/core/ext-py/pyexcelerator/examples/xls2html.py

@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: xls2html.py,v 1.1 2005/05/19 09:27:42 rvk Exp $"""
-
-
-from pyExcelerator import *
-import sys
-
-me, args = sys.argv[0], sys.argv[1:]
-
-
-if args:
-    for arg in args:
-        print >>sys.stderr, 'extracting data from', arg
-        print '<html>'
-        for sheet_name, values in parse_xls(arg, 'cp1251'): # parse_xls(arg) -- default encoding
-            matrix = [[]]
-            print 'Sheet = "%s"' % sheet_name.encode('cp1251', 'backslashreplace')
-            print '<table border="2" cellpadding="1" cellspacing="1" >'
-
-            for row_idx, col_idx in sorted(values.keys()):
-                v = values[(row_idx, col_idx)]
-                if isinstance(v, unicode):
-                    v = v.encode('cp1251', 'backslashreplace')
-                else:
-                    v = str(v)
-                last_row, last_col = len(matrix), len(matrix[-1])
-                while last_row < row_idx:
-                    matrix.extend([[]])
-                    last_row = len(matrix)
-
-                while last_col < col_idx:
-                    matrix[-1].extend([''])
-                    last_col = len(matrix[-1])
-
-                matrix[-1].extend([v])
-                    
-            for row in matrix:
-                print '<tr>'
-                for col in row:
-                    print '<td> %s </td>' % col
-                print '</tr>'
-
-            print '</table>'
-        print '</html>'
-
-else:
-    print 'usage: %s (inputfile)+' % me
-

+ 0 - 27
desktop/core/ext-py/pyexcelerator/examples/xls2txt.py

@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: xls2txt.py,v 1.3 2005/05/19 09:27:42 rvk Exp $"""
-
-
-from pyExcelerator import *
-import sys
-
-me, args = sys.argv[0], sys.argv[1:]
-
-if args:
-    for arg in args:
-        print >>sys.stderr, 'extracting data from', arg
-        for sheet_name, values in parse_xls(arg, 'cp1251'): # parse_xls(arg) -- default encoding
-            print 'Sheet = "%s"' % sheet_name.encode('cp866', 'backslashreplace')
-            print '----------------'
-            for row_idx, col_idx in sorted(values.keys()):
-                v = values[(row_idx, col_idx)]
-                if isinstance(v, unicode):
-                    v = v.encode('cp866', 'backslashreplace')
-                print '(%d, %d) =' % (row_idx, col_idx), v
-            print '----------------'
-else:
-    print 'usage: %s (inputfile)+' % me
-

+ 0 - 312
desktop/core/ext-py/pyexcelerator/hrc/py-2.4-hrc.py

@@ -1,312 +0,0 @@
-specials = [
-    "Ellipsis", 
-    "False", 
-    "None", 
-    "NotImplemented", 
-    "True", 
-    "__abs__", 
-    "__add__", 
-    "__and__", 
-    "__base__", 
-    "__bases__", 
-    "__basicsize__", 
-    "__builtins__", 
-    "__call__", 
-    "__class__", 
-    "__cmp__", 
-    "__coerce__", 
-    "__contains__", 
-    "__debug__", 
-    "__del__", 
-    "__delattr__", 
-    "__delete__", 
-    "__delitem__", 
-    "__delslice__", 
-    "__dict__", 
-    "__dictoffset__", 
-    "__div__", 
-    "__divmod__", 
-    "__doc__", 
-    "__eq__", 
-    "__flags__", 
-    "__float__", 
-    "__floordiv__", 
-    "__ge__", 
-    "__get__", 
-    "__getattr__", 
-    "__getattribute__", 
-    "__getitem__", 
-    "__getnewargs__", 
-    "__getslice__", 
-    "__gt__", 
-    "__hash__", 
-    "__hex__", 
-    "__iadd__", 
-    "__iand__", 
-    "__idiv__", 
-    "__ifloordiv__", 
-    "__ilshift__", 
-    "__imod__", 
-    "__import__", 
-    "__imul__", 
-    "__init__", 
-    "__int__", 
-    "__invert__", 
-    "__ior__", 
-    "__ipow__", 
-    "__irshift__", 
-    "__isub__", 
-    "__itemsize__", 
-    "__iter__", 
-    "__itruediv__", 
-    "__ixor__", 
-    "__le__", 
-    "__len__", 
-    "__long__", 
-    "__lshift__", 
-    "__lt__", 
-    "__main__", 
-    "__mod__", 
-    "__module__", 
-    "__mro__", 
-    "__mul__", 
-    "__name__", 
-    "__ne__", 
-    "__neg__", 
-    "__new__", 
-    "__nonzero__", 
-    "__oct__", 
-    "__or__", 
-    "__pos__", 
-    "__pow__", 
-    "__radd__", 
-    "__rand__", 
-    "__rdiv__", 
-    "__rdivmod__", 
-    "__reduce__", 
-    "__reduce_ex__", 
-    "__repr__", 
-    "__rfloordiv__", 
-    "__rlshift__", 
-    "__rmod__", 
-    "__rmul__", 
-    "__ror__", 
-    "__rpow__", 
-    "__rrshift__", 
-    "__rshift__", 
-    "__rsub__", 
-    "__rtruediv__", 
-    "__rxor__", 
-    "__set__", 
-    "__setattr__", 
-    "__setitem__", 
-    "__setslice__", 
-    "__str__", 
-    "__sub__", 
-    "__truediv__", 
-    "__weakrefoffset__", 
-    "__xor__", 
-    "abs", 
-    "apply", 
-    "basestring", 
-    "bool", 
-    "buffer", 
-    "callable", 
-    "capitalize", 
-    "center", 
-    "chr", 
-    "classmethod", 
-    "cmp", 
-    "coerce", 
-    "compile", 
-    "complex", 
-    "count", 
-    "decode", 
-    "delattr", 
-    "dict", 
-    "dir", 
-    "divmod", 
-    "encode", 
-    "endswith", 
-    "enumerate", 
-    "eval", 
-    "execfile", 
-    "exit", 
-    "expandtabs", 
-    "file", 
-    "filter", 
-    "find", 
-    "float", 
-    "frozenset", 
-    "getattr", 
-    "globals", 
-    "hasattr", 
-    "hash", 
-    "hex", 
-    "id", 
-    "index", 
-    "input", 
-    "int", 
-    "intern", 
-    "isalnum", 
-    "isalpha", 
-    "isdigit", 
-    "isinstance", 
-    "islower", 
-    "isspace", 
-    "issubclass", 
-    "istitle", 
-    "isupper", 
-    "iter", 
-    "join", 
-    "len", 
-    "list", 
-    "ljust", 
-    "locals", 
-    "long", 
-    "lower", 
-    "lstrip", 
-    "map", 
-    "max", 
-    "min", 
-    "next", 
-    "object", 
-    "oct", 
-    "open", 
-    "ord", 
-    "pow", 
-    "property", 
-    "quit", 
-    "range", 
-    "raw_input", 
-    "reduce", 
-    "reload", 
-    "replace", 
-    "repr", 
-    "reversed", 
-    "rfind", 
-    "rindex", 
-    "rjust", 
-    "round", 
-    "rsplit", 
-    "rstrip", 
-    "set", 
-    "setattr", 
-    "slice", 
-    "sorted", 
-    "split", 
-    "splitlines", 
-    "startswith", 
-    "staticmethod", 
-    "str", 
-    "strip", 
-    "sum", 
-    "super", 
-    "swapcase", 
-    "title", 
-    "translate", 
-    "tuple", 
-    "type", 
-    "unichr", 
-    "unicode", 
-    "upper", 
-    "vars", 
-    "xrange", 
-    "zfill", 
-    "zip"
-]
-
-exceptions = [
-    "Exception",
-    "SystemExit",
-    "StopIteration",
-    "StandardError",
-    "KeyboardInterrupt",
-    "ImportError",
-    "EnvironmentError",
-    "IOError",
-    "OSError",
-    "WindowsError",
-    "EOFError",
-    "RuntimeError",
-    "NotImplementedError",
-    "NameError",
-    "UnboundLocalError",
-    "AttributeError",
-    "SyntaxError",
-    "IndentationError",
-    "TabError",
-    "TypeError",
-    "AssertionError",
-    "LookupError",
-    "IndexError",
-    "KeyError",
-    "ArithmeticError",
-    "OverflowError",
-    "ZeroDivisionError",
-    "FloatingPointError",
-    "ValueError",
-    "UnicodeError",
-    "UnicodeEncodeError",
-    "UnicodeDecodeError",
-    "UnicodeTranslateError",
-    "ReferenceError",
-    "SystemError",
-    "MemoryError",
-    "Warning",
-    "UserWarning",
-    "DeprecationWarning",
-    "PendingDeprecationWarning",
-    "SyntaxWarning",
-    "OverflowWarning", # not generated in 2.4; won't exist in 2.5
-    "RuntimeWarning",
-    "FutureWarning"
-]
-
-reserved_words = [
-    "and",
-    "del",       
-    "for",       
-    "is",       
-    "raise",
-    "assert",    
-    "elif",
-    "from" ,     
-    "lambda",    
-    "return",   
-    "break",     
-    "else",      
-    "global",    
-    "not",
-    "try",     
-    "class",     
-    "except",    
-    "if",   
-    "or",        
-    "while",    
-    "continue",  
-    "exec",      
-    "import",    
-    "pass" ,     
-    "yield" ,   
-    "def",       
-    "finally",   
-    "in",        
-    "print"
-]
-
-print '<keywords region="pyWord">'
-for word in sorted(reserved_words):
-    print '    <word name="%s"/>' % word
-print '</keywords>'
-
-print '<keywords region="pyException">'
-for exc in sorted(exceptions):
-    print '    <word name="%s"/>' % exc
-print '</keywords>'
-
-print '<keywords region="pyBuiltins">'
-for special in sorted(specials):
-    print '    <word name="%s"/>' % special
-print '</keywords>'
-

+ 0 - 347
desktop/core/ext-py/pyexcelerator/hrc/python.hrc

@@ -1,347 +0,0 @@
-<?xml version="1.0" encoding="Windows-1251"?>
-<!DOCTYPE hrc SYSTEM "../hrc.dtd">
-<?xml-stylesheet type="text/xsl" href="../hrc.xsl"?>
-<!--
-    Python Defs
-With help of:
-    Grzegorz Makarewicz <mak@mikroplan.com.pl>
--->
-
-<!--
-    Updated by Roman V. Kiseliov <roman@kiseliov.ru>
-    for Python 2.4
--->
-<hrc>
-
-<define name="pyString"   value="dString"/>
-<define name="pyComment"  value="dComment"/>
-<define name="pySymb"     value="dSymbol"/>
-<define name="pyWord"     value="dKeyword"/>
-<define name="pyBuiltins" value="dLabel"/>
-<define name="pyOctNumb"  value="dNumOct"/>
-
-<define name="pyException" value="dLabel"/>
-
-<scheme name="python">
-   <regexp match="/(\#.*$)/" region0="pyComment"/>
-   <block start='/\"\"\"/' end='/\"\"\"/' scheme="Comment"
-          region="pyComment" region00="dpOpenStruct" region10="dpCloseStruct"/>
-   <block start="/'''/" end="/'''/" scheme="Comment"
-          region="pyComment" region00="dpOpenStruct" region10="dpCloseStruct"/>
-   <!-- Strings -->
-   <regexp match='/("((\\.)|[^\\"])*?")/' region0="pyString"/>
-   <regexp match="/('((\\.)|[^\\'])*?')/" region0="pyString"/>
-
-   <!-- Numbers -->
-   <inherit scheme="mFloatNumb"/>
-   <inherit scheme="mcHexNumb"/>
-   <inherit scheme="mDecNumb"/>
-   <regexp match="/\b(0[0-7]*[Ll]?)\B/" region0="pyOctNumb"/>
-   <regexp match="/(`.*`)/" region0="pyBuiltins"/>
-
-   <keywords region="pySymb">
-      <symb name=";"/><symb name="="/><symb name="+"/><symb name="-"/>
-      <symb name="/"/><symb name="*"/><symb name="&amp;"/><symb name="|"/>
-      <symb name="^"/><symb name="("/><symb name=")"/><symb name="["/>
-      <symb name="]"/><symb name=","/><symb name="."/><symb name=":"/>
-      <symb name="!"/><symb name="~"/><symb name="&lt;"/><symb name="&gt;"/>
-      <symb name="%"/><symb name="{"/><symb name="}"/><symb name="?"/>
-      <symb name="@"/>
-   </keywords>
-   <keywords region="pyWord">
-       <word name="and"/>
-       <word name="assert"/>
-       <word name="break"/>
-       <word name="class"/>
-       <word name="continue"/>
-       <word name="def"/>
-       <word name="del"/>
-       <word name="elif"/>
-       <word name="else"/>
-       <word name="except"/>
-       <word name="exec"/>
-       <word name="finally"/>
-       <word name="for"/>
-       <word name="from"/>
-       <word name="global"/>
-       <word name="if"/>
-       <word name="import"/>
-       <word name="in"/>
-       <word name="is"/>
-       <word name="lambda"/>
-       <word name="not"/>
-       <word name="or"/>
-       <word name="pass"/>
-       <word name="print"/>
-       <word name="raise"/>
-       <word name="return"/>
-       <word name="try"/>
-       <word name="while"/>
-       <word name="yield"/>
-   </keywords>
-   <keywords region="pyException">
-       <word name="ArithmeticError"/>
-       <word name="AssertionError"/>
-       <word name="AttributeError"/>
-       <word name="DeprecationWarning"/>
-       <word name="EOFError"/>
-       <word name="EnvironmentError"/>
-       <word name="Exception"/>
-       <word name="FloatingPointError"/>
-       <word name="FutureWarning"/>
-       <word name="IOError"/>
-       <word name="ImportError"/>
-       <word name="IndentationError"/>
-       <word name="IndexError"/>
-       <word name="KeyError"/>
-       <word name="KeyboardInterrupt"/>
-       <word name="LookupError"/>
-       <word name="MemoryError"/>
-       <word name="NameError"/>
-       <word name="NotImplementedError"/>
-       <word name="OSError"/>
-       <word name="OverflowError"/>
-       <word name="OverflowWarning"/>
-       <word name="PendingDeprecationWarning"/>
-       <word name="ReferenceError"/>
-       <word name="RuntimeError"/>
-       <word name="RuntimeWarning"/>
-       <word name="StandardError"/>
-       <word name="StopIteration"/>
-       <word name="SyntaxError"/>
-       <word name="SyntaxWarning"/>
-       <word name="SystemError"/>
-       <word name="SystemExit"/>
-       <word name="TabError"/>
-       <word name="TypeError"/>
-       <word name="UnboundLocalError"/>
-       <word name="UnicodeDecodeError"/>
-       <word name="UnicodeEncodeError"/>
-       <word name="UnicodeError"/>
-       <word name="UnicodeTranslateError"/>
-       <word name="UserWarning"/>
-       <word name="ValueError"/>
-       <word name="Warning"/>
-       <word name="WindowsError"/>
-       <word name="ZeroDivisionError"/>
-   </keywords>
-   <keywords region="pyBuiltins">
-       <word name="Ellipsis"/>
-       <word name="False"/>
-       <word name="None"/>
-       <word name="NotImplemented"/>
-       <word name="True"/>
-       <word name="__abs__"/>
-       <word name="__add__"/>
-       <word name="__and__"/>
-       <word name="__base__"/>
-       <word name="__bases__"/>
-       <word name="__basicsize__"/>
-       <word name="__builtins__"/>
-       <word name="__call__"/>
-       <word name="__class__"/>
-       <word name="__cmp__"/>
-       <word name="__coerce__"/>
-       <word name="__contains__"/>
-       <word name="__debug__"/>
-       <word name="__del__"/>
-       <word name="__delattr__"/>
-       <word name="__delete__"/>
-       <word name="__delitem__"/>
-       <word name="__delslice__"/>
-       <word name="__dict__"/>
-       <word name="__dictoffset__"/>
-       <word name="__div__"/>
-       <word name="__divmod__"/>
-       <word name="__doc__"/>
-       <word name="__eq__"/>
-       <word name="__flags__"/>
-       <word name="__float__"/>
-       <word name="__floordiv__"/>
-       <word name="__ge__"/>
-       <word name="__get__"/>
-       <word name="__getattr__"/>
-       <word name="__getattribute__"/>
-       <word name="__getitem__"/>
-       <word name="__getnewargs__"/>
-       <word name="__getslice__"/>
-       <word name="__gt__"/>
-       <word name="__hash__"/>
-       <word name="__hex__"/>
-       <word name="__iadd__"/>
-       <word name="__iand__"/>
-       <word name="__idiv__"/>
-       <word name="__ifloordiv__"/>
-       <word name="__ilshift__"/>
-       <word name="__imod__"/>
-       <word name="__import__"/>
-       <word name="__imul__"/>
-       <word name="__init__"/>
-       <word name="__int__"/>
-       <word name="__invert__"/>
-       <word name="__ior__"/>
-       <word name="__ipow__"/>
-       <word name="__irshift__"/>
-       <word name="__isub__"/>
-       <word name="__itemsize__"/>
-       <word name="__iter__"/>
-       <word name="__itruediv__"/>
-       <word name="__ixor__"/>
-       <word name="__le__"/>
-       <word name="__len__"/>
-       <word name="__long__"/>
-       <word name="__lshift__"/>
-       <word name="__lt__"/>
-       <word name="__main__"/>
-       <word name="__mod__"/>
-       <word name="__module__"/>
-       <word name="__mro__"/>
-       <word name="__mul__"/>
-       <word name="__name__"/>
-       <word name="__ne__"/>
-       <word name="__neg__"/>
-       <word name="__new__"/>
-       <word name="__nonzero__"/>
-       <word name="__oct__"/>
-       <word name="__or__"/>
-       <word name="__pos__"/>
-       <word name="__pow__"/>
-       <word name="__radd__"/>
-       <word name="__rand__"/>
-       <word name="__rdiv__"/>
-       <word name="__rdivmod__"/>
-       <word name="__reduce__"/>
-       <word name="__reduce_ex__"/>
-       <word name="__repr__"/>
-       <word name="__rfloordiv__"/>
-       <word name="__rlshift__"/>
-       <word name="__rmod__"/>
-       <word name="__rmul__"/>
-       <word name="__ror__"/>
-       <word name="__rpow__"/>
-       <word name="__rrshift__"/>
-       <word name="__rshift__"/>
-       <word name="__rsub__"/>
-       <word name="__rtruediv__"/>
-       <word name="__rxor__"/>
-       <word name="__set__"/>
-       <word name="__setattr__"/>
-       <word name="__setitem__"/>
-       <word name="__setslice__"/>
-       <word name="__str__"/>
-       <word name="__sub__"/>
-       <word name="__truediv__"/>
-       <word name="__weakrefoffset__"/>
-       <word name="__xor__"/>
-       <word name="abs"/>
-       <word name="apply"/>
-       <word name="basestring"/>
-       <word name="bool"/>
-       <word name="buffer"/>
-       <word name="callable"/>
-       <word name="capitalize"/>
-       <word name="center"/>
-       <word name="chr"/>
-       <word name="classmethod"/>
-       <word name="cmp"/>
-       <word name="coerce"/>
-       <word name="compile"/>
-       <word name="complex"/>
-       <word name="count"/>
-       <word name="decode"/>
-       <word name="delattr"/>
-       <word name="dict"/>
-       <word name="dir"/>
-       <word name="divmod"/>
-       <word name="encode"/>
-       <word name="endswith"/>
-       <word name="enumerate"/>
-       <word name="eval"/>
-       <word name="execfile"/>
-       <word name="exit"/>
-       <word name="expandtabs"/>
-       <word name="file"/>
-       <word name="filter"/>
-       <word name="find"/>
-       <word name="float"/>
-       <word name="frozenset"/>
-       <word name="getattr"/>
-       <word name="globals"/>
-       <word name="hasattr"/>
-       <word name="hash"/>
-       <word name="hex"/>
-       <word name="id"/>
-       <word name="index"/>
-       <word name="input"/>
-       <word name="int"/>
-       <word name="intern"/>
-       <word name="isalnum"/>
-       <word name="isalpha"/>
-       <word name="isdigit"/>
-       <word name="isinstance"/>
-       <word name="islower"/>
-       <word name="isspace"/>
-       <word name="issubclass"/>
-       <word name="istitle"/>
-       <word name="isupper"/>
-       <word name="iter"/>
-       <word name="join"/>
-       <word name="len"/>
-       <word name="list"/>
-       <word name="ljust"/>
-       <word name="locals"/>
-       <word name="long"/>
-       <word name="lower"/>
-       <word name="lstrip"/>
-       <word name="map"/>
-       <word name="max"/>
-       <word name="min"/>
-       <word name="next"/>
-       <word name="object"/>
-       <word name="oct"/>
-       <word name="open"/>
-       <word name="ord"/>
-       <word name="pow"/>
-       <word name="property"/>
-       <word name="quit"/>
-       <word name="range"/>
-       <word name="raw_input"/>
-       <word name="reduce"/>
-       <word name="reload"/>
-       <word name="replace"/>
-       <word name="repr"/>
-       <word name="reversed"/>
-       <word name="rfind"/>
-       <word name="rindex"/>
-       <word name="rjust"/>
-       <word name="round"/>
-       <word name="rsplit"/>
-       <word name="rstrip"/>
-       <word name="set"/>
-       <word name="setattr"/>
-       <word name="slice"/>
-       <word name="sorted"/>
-       <word name="split"/>
-       <word name="splitlines"/>
-       <word name="startswith"/>
-       <word name="staticmethod"/>
-       <word name="str"/>
-       <word name="strip"/>
-       <word name="sum"/>
-       <word name="super"/>
-       <word name="swapcase"/>
-       <word name="title"/>
-       <word name="translate"/>
-       <word name="tuple"/>
-       <word name="type"/>
-       <word name="unichr"/>
-       <word name="unicode"/>
-       <word name="upper"/>
-       <word name="vars"/>
-       <word name="xrange"/>
-       <word name="zfill"/>
-       <word name="zip"/>
-   </keywords>
-</scheme>
-
-</hrc>

BIN
desktop/core/ext-py/pyexcelerator/museum/P-0508-0000507647-3280-5298.xls


BIN
desktop/core/ext-py/pyexcelerator/museum/chart1v8.xls


BIN
desktop/core/ext-py/pyexcelerator/museum/excel2003.xls


BIN
desktop/core/ext-py/pyexcelerator/museum/frmla.xls


BIN
desktop/core/ext-py/pyexcelerator/museum/macro2v8.xls


BIN
desktop/core/ext-py/pyexcelerator/museum/mini-mini.xls


BIN
desktop/core/ext-py/pyexcelerator/museum/mini.xls


BIN
desktop/core/ext-py/pyexcelerator/museum/oo14.xls


+ 0 - 2584
desktop/core/ext-py/pyexcelerator/pyExcelerator/BIFFRecords.py

@@ -1,2584 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-#
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-#
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-#
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-__rev_id__ = """$Id: BIFFRecords.py,v 1.7 2005/10/26 07:44:24 rvk Exp $"""
-
-
-from struct import pack
-from UnicodeUtils import *
-import sys
-
-class SharedStringTable(object):
-    _SST_ID = 0x00FC
-    _CONTINUE_ID = 0x003C
-
-    def __init__(self):
-        self._sst_record = ''
-        self._continues = []
-        self._current_piece = pack('<II', 0, 0)
-        self._pos = len(self._current_piece)
-
-        self._str_indexes = {}
-        self._add_calls = 0
-
-    def add_str(self, s):
-        self._add_calls += 1
-        if s not in self._str_indexes:
-            self._str_indexes[s] = len(self._str_indexes)
-            self._add_to_sst(s)
-        return self._str_indexes[s]
-
-    def str_index(self, s):
-        return self._str_indexes[s]
-
-    def get_biff_record(self):
-        self._new_piece()
-        result = pack('<2HII', self._SST_ID, len(self._sst_record), self._add_calls, len(self._str_indexes))
-        result += self._sst_record[8:]
-        result += ''.join(self._continues)
-        return result
-
-    def _add_to_sst(self, s):
-        u_str = upack2(s)
-        if len(u_str) > 0xFFFF:
-            raise Exception('error: very long string.')
-
-        is_unicode_str = u_str[2] == '\x01'
-        if is_unicode_str:
-            atom_len = 5 # 2 byte -- len,
-                         # 1 byte -- options,
-                         # 2 byte -- 1st sym
-        else:
-            atom_len = 4 # 2 byte -- len,
-                         # 1 byte -- options,
-                         # 1 byte -- 1st sym
-
-        self._save_atom(u_str[0:atom_len])
-        self._save_splitted(u_str[atom_len:], is_unicode_str)
-
-    def _new_piece(self):
-        if self._sst_record == '':
-            self._sst_record = self._current_piece
-        else:
-            curr_piece_len = len(self._current_piece)
-            self._continues.append(pack('<2H%ds'%curr_piece_len, self._CONTINUE_ID, curr_piece_len, self._current_piece))
-        self._current_piece = ''
-        self._pos = len(self._current_piece)
-
-    def _save_atom(self, s):
-        atom_len = len(s)
-        free_space = 0x2020 - len(self._current_piece)
-        if free_space < atom_len:
-            self._new_piece()
-        self._current_piece += s
-
-    def _save_splitted(self, s, is_unicode_str):
-        i = 0
-        str_len = len(s)
-        while i < str_len:
-            piece_len = len(self._current_piece)
-            free_space = 0x2020 - piece_len
-            tail_len = str_len - i
-            need_more_space = free_space < tail_len
-
-            if not need_more_space:
-                atom_len = tail_len
-            else:
-                if is_unicode_str:
-                    atom_len = free_space & 0xFFFE
-                else:
-                    atom_len = free_space
-
-            self._current_piece += s[i:i+atom_len]
-
-            if need_more_space:
-                self._new_piece()
-                if is_unicode_str:
-                    self._current_piece += '\x01'
-                else:
-                    self._current_piece += '\x00'
-
-            i += atom_len
-
-
-class BiffRecord(object):
-    def __init__(self):
-        self._rec_data = ''
-
-    def get_rec_id(self):
-        return _REC_ID
-
-    def get_rec_header(self):
-        return pack('<2H', self._REC_ID, len(self._rec_data))
-
-    def get_rec_data(self):
-        return self._rec_data
-
-    def get(self):
-        data = self.get_rec_data()
-
-        if len(data) > 0x2020: # limit for BIFF7/8
-            chunks = []
-            pos = 0
-            while pos < len(data):
-                chunk_pos = pos + 0x2020
-                chunk = data[pos:chunk_pos]
-                chunks.append(chunk)
-                pos = chunk_pos
-            continues = pack('<2H', self._REC_ID, len(chunks[0])) + chunks[0]
-            for chunk in chunks[1:]:
-                continues += pack('<2H%ds'%len(chunk), 0x003C, len(chunk), chunk)
-                # 0x003C -- CONTINUE record id
-            return continues
-        else:
-            return self.get_rec_header() + data
-
-
-class Biff8BOFRecord(BiffRecord):
-    """
-    Offset Size Contents
-    0      2    Version, contains 0600H for BIFF8 and BIFF8X
-    2      2    Type of the following data:
-                  0005H = Workbook globals
-                  0006H = Visual Basic module
-                  0010H = Worksheet
-                  0020H = Chart
-                  0040H = Macro sheet
-                  0100H = Workspace file
-    4      2    Build identifier
-    6      2    Build year
-    8      4    File history flags
-    12     4    Lowest Excel version that can read all records in this file
-    """
-    _REC_ID      = 0x0809
-    # stream types
-    BOOK_GLOBAL = 0x0005
-    VB_MODULE   = 0x0006
-    WORKSHEET   = 0x0010
-    CHART       = 0x0020
-    MACROSHEET  = 0x0040
-    WORKSPACE   = 0x0100
-
-    def __init__(self, rec_type):
-        BiffRecord.__init__(self)
-
-        version  = 0x0600
-        build    = 0x0DBB
-        year     = 0x07CC
-        file_hist_flags = 0x00L
-        ver_can_read    = 0x06L
-
-        self._rec_data = pack('<4H2I', version, rec_type, build, year, file_hist_flags, ver_can_read)
-
-
-class InteraceHdrRecord(BiffRecord):
-    _REC_ID = 0x00E1
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('BB', 0xB0, 0x04)
-
-
-class InteraceEndRecord(BiffRecord):
-    _REC_ID = 0x00E2
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = ''
-
-
-class MMSRecord(BiffRecord):
-    _REC_ID = 0x00C1
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', 0x00)
-
-
-class WriteAccessRecord(BiffRecord):
-    """
-    This record is part of the file protection. It contains the name of the
-    user  that  has  saved  the  file. The user name is always stored as an
-    equal-sized  string.  All  unused  characters after the name are filled
-    with space characters. It is not required to write the mentioned string
-    length. Every other length will be accepted too.
-    """
-    _REC_ID = 0x005C
-
-    def __init__(self, owner):
-        BiffRecord.__init__(self)
-
-        uowner = owner[0:0x30]
-        uowner_len = len(uowner)
-        self._rec_data = pack('%ds%ds' % (uowner_len, 0x70 - uowner_len), uowner, ' '*(0x70 - uowner_len))
-
-
-class DSFRecord(BiffRecord):
-    """
-    This  record  specifies  if the file contains an additional BIFF5/BIFF7
-    workbook stream.
-    Record DSF, BIFF8:
-    Offset Size Contents
-    0        2     0 = Only the BIFF8 Workbook stream is present
-                   1 = Additional BIFF5/BIFF7 Book stream is in the file
-    A  double  stream file can be read by Excel 5.0 and Excel 95, and still
-    contains  all  new  features  added to BIFF8 (which are left out in the
-    BIFF5/BIFF7 Book stream).
-    """
-    _REC_ID = 0x0161
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', 0x00)
-
-
-class TabIDRecord(BiffRecord):
-    _REC_ID = 0x013D
-
-    def __init__(self, sheetcount):
-        BiffRecord.__init__(self)
-
-        for i in range(sheetcount):
-            self._rec_data += pack('<H', i+1)
-
-
-class FnGroupCountRecord(BiffRecord):
-    _REC_ID = 0x009C
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('BB', 0x0E, 0x00)
-
-
-class WindowProtectRecord(BiffRecord):
-    """
-    This record is part of the worksheet/workbook protection. It determines
-    whether  the window configuration of this document is protected. Window
-    protection is not active, if this record is omitted.
-    """
-    _REC_ID = 0x0019
-
-    def __init__(self, wndprotect):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', wndprotect)
-
-
-class ObjectProtectRecord(BiffRecord):
-    """
-    This record is part of the worksheet/workbook protection.
-    It determines whether the objects of the current sheet are protected.
-    Object protection is not active, if this record is omitted.
-    """
-    _REC_ID = 0x0063
-
-
-    def __init__(self, objprotect):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', objprotect)
-
-
-class ScenProtectRecord(BiffRecord):
-    """
-    This record is part of the worksheet/workbook protection. It
-    determines whether the scenarios of the current sheet are protected.
-    Scenario protection is not active, if this record is omitted.
-    """
-    _REC_ID = 0x00DD
-
-
-    def __init__(self, scenprotect):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', scenprotect)
-
-
-class ProtectRecord(BiffRecord):
-    """
-    This  record is part of the worksheet/workbook protection. It specifies
-    whether  a  worksheet  or a workbook is protected against modification.
-    Protection is not active, if this record is omitted.
-    """
-
-    _REC_ID = 0x0012
-
-    def __init__(self, protect):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', protect)
-
-
-class PasswordRecord(BiffRecord):
-    """
-    This record is part of the worksheet/workbook protection. It
-    stores a 16-bit hash value, calculated from the worksheet or workbook
-    protection password.
-    """
-    _REC_ID = 0x0013
-    def passwd_hash(self, plaintext):
-        """
-        Based on the algorithm provided by Daniel Rentz of OpenOffice.
-        """
-        if plaintext == "":
-            return 0
-
-        passwd_hash = 0x0000
-        for i, char in enumerate(plaintext):
-            c = ord(char) << (i + 1)
-            low_15 = c & 0x7fff
-            high_15 = c & 0x7fff << 15
-            high_15 = high_15 >> 15
-            c = low_15 | high_15
-            passwd_hash ^= c
-        passwd_hash ^= len(plaintext)
-        passwd_hash ^= 0xCE4B
-        return passwd_hash
-
-    def __init__(self, passwd = ""):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', self.passwd_hash(passwd))
-
-
-class Prot4RevRecord(BiffRecord):
-    _REC_ID = 0x01AF
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', 0x00)
-
-
-class Prot4RevPassRecord(BiffRecord):
-    _REC_ID = 0x01BC
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', 0x00)
-
-
-class BackupRecord(BiffRecord):
-    """
-    This  record  contains  a Boolean value determining whether Excel makes
-    a backup of the file while saving.
-    """
-    _REC_ID = 0x0040
-
-    def __init__(self, backup):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', backup)
-
-class HideObjRecord(BiffRecord):
-    """
-    This record specifies whether and how to show objects in the workbook.
-
-    Record HIDEOBJ, BIFF3-BIFF8:
-    Offset  Size    Contents
-    0       2       Viewing mode for objects:
-                        0 = Show all objects
-                        1 = Show placeholders
-                        2 = Do not show objects
-    """
-    _REC_ID = 0x008D
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', 0x00)
-
-
-
-class RefreshAllRecord(BiffRecord):
-    """
-    """
-
-    _REC_ID = 0x01B7
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', 0x00)
-
-
-class BookBoolRecord(BiffRecord):
-    """
-    This record contains a Boolean value determining whether to save values
-    linked  from external workbooks (CRN records and XCT records). In BIFF3
-    and BIFF4 this option is stored in the WSBOOL record.
-
-    Record BOOKBOOL, BIFF5-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Save external linked values;
-                    1 = Do not save external linked values
-    """
-
-    _REC_ID = 0x00DA
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', 0x00)
-
-
-class CountryRecord(BiffRecord):
-    """
-    This   record   stores  two  Windows  country  identifiers.  The  first
-    represents  the  user  interface language of the Excel version that has
-    saved  the file, and the second represents the system regional settings
-    at the time the file was saved.
-
-    Record COUNTRY, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Windows country identifier of the user interface language of Excel
-    2       2       Windows country identifier of the system regional settings
-
-    The  following  table  shows most of the used country identifiers. Most
-    of  these  identifiers  are  equal to the international country calling
-    codes.
-
-    1   USA
-    2   Canada
-    7   Russia
-    """
-
-    _REC_ID = 0x00DA
-
-    def __init__(self, ui_id, sys_settings_id):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<2H', ui_id, sys_settings_id)
-
-
-class UseSelfsRecord(BiffRecord):
-    """
-    This  record  specifies if the formulas in the workbook can use natural
-    language  formulas”.  This  type  of  formula can refer to cells by its
-    content or the content of the column or row header cell.
-
-    Record USESELFS, BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Do not use natural language formulas
-                    1 = Use natural language formulas
-
-    """
-
-    _REC_ID = 0x0160
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', 0x01)
-
-
-class EOFRecord(BiffRecord):
-    _REC_ID = 0x000A
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = ''
-
-
-class DateModeRecord(BiffRecord):
-    """
-    This  record  specifies  the  base date for displaying date values. All
-    dates  are  stored as count of days past this base date. In BIFF2-BIFF4
-    this   record  is  part  of  the  Calculation  Settings  Block.
-    In BIFF5-BIFF8 it is stored in the Workbook Globals Substream.
-
-    Record DATEMODE, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Base is 1899-Dec-31 (the cell = 1 represents 1900-Jan-01)
-                    1 = Base is 1904-Jan-01 (the cell = 1 represents 1904-Jan-02)
-    """
-    _REC_ID = 0x0022
-
-    def __init__(self, from1904):
-        BiffRecord.__init__(self)
-
-        if from1904:
-            self._rec_data = pack('<H', 1)
-        else:
-            self._rec_data = pack('<H', 0)
-
-
-class PrecisionRecord(BiffRecord):
-    """
-    This record stores if formulas use the real cell values for calculation
-    or  the  values  displayed  on  the screen. In BIFF2- BIFF4 this record
-    is  part of the Calculation Settings Block. In BIFF5-BIFF8 it is stored
-    in the Workbook Globals Substream.
-
-    Record PRECISION, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Use displayed values;
-                    1 = Use real cell values
-    """
-    _REC_ID = 0x000E
-
-    def __init__(self, use_real_values):
-        BiffRecord.__init__(self)
-
-        if use_real_values:
-            self._rec_data = pack('<H', 1)
-        else:
-            self._rec_data = pack('<H', 0)
-
-
-class CodepageBiff8Record(BiffRecord):
-    """
-    This record stores the text encoding used to write byte strings, stored
-    as MS Windows code page identifier. The CODEPAGE record in BIFF8 always
-    contains  the  code  page  1200  (UTF-16).  Therefore  it is not
-    possible  to  obtain the encoding used for a protection password (it is
-    not UTF-16).
-
-    Record CODEPAGE, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Code page identifier used for byte string text encoding:
-                      016FH = 367 = ASCII
-                      01B5H = 437 = IBM PC CP-437 (US)
-                      02D0H = 720 = IBM PC CP-720 (OEM Arabic)
-                      02E1H = 737 = IBM PC CP-737 (Greek)
-                      0307H = 775 = IBM PC CP-775 (Baltic)
-                      0352H = 850 = IBM PC CP-850 (Latin I)
-                      0354H = 852 = IBM PC CP-852 (Latin II (Central European))
-                      0357H = 855 = IBM PC CP-855 (Cyrillic)
-                      0359H = 857 = IBM PC CP-857 (Turkish)
-                      035AH = 858 = IBM PC CP-858 (Multilingual Latin I with Euro)
-                      035CH = 860 = IBM PC CP-860 (Portuguese)
-                      035DH = 861 = IBM PC CP-861 (Icelandic)
-                      035EH = 862 = IBM PC CP-862 (Hebrew)
-                      035FH = 863 = IBM PC CP-863 (Canadian (French))
-                      0360H = 864 = IBM PC CP-864 (Arabic)
-                      0361H = 865 = IBM PC CP-865 (Nordic)
-                      0362H = 866 = IBM PC CP-866 (Cyrillic (Russian))
-                      0365H = 869 = IBM PC CP-869 (Greek (Modern))
-                      036AH = 874 = Windows CP-874 (Thai)
-                      03A4H = 932 = Windows CP-932 (Japanese Shift-JIS)
-                      03A8H = 936 = Windows CP-936 (Chinese Simplified GBK)
-                      03B5H = 949 = Windows CP-949 (Korean (Wansung))
-                      03B6H = 950 = Windows CP-950 (Chinese Traditional BIG5)
-                      04B0H = 1200 = UTF-16 (BIFF8)
-                      04E2H = 1250 = Windows CP-1250 (Latin II) (Central European)
-                      04E3H = 1251 = Windows CP-1251 (Cyrillic)
-                      04E4H = 1252 = Windows CP-1252 (Latin I) (BIFF4-BIFF7)
-                      04E5H = 1253 = Windows CP-1253 (Greek)
-                      04E6H = 1254 = Windows CP-1254 (Turkish)
-                      04E7H = 1255 = Windows CP-1255 (Hebrew)
-                      04E8H = 1256 = Windows CP-1256 (Arabic)
-                      04E9H = 1257 = Windows CP-1257 (Baltic)
-                      04EAH = 1258 = Windows CP-1258 (Vietnamese)
-                      0551H = 1361 = Windows CP-1361 (Korean (Johab))
-                      2710H = 10000 = Apple Roman
-                      8000H = 32768 = Apple Roman
-                      8001H = 32769 = Windows CP-1252 (Latin I) (BIFF2-BIFF3)
-    """
-    _REC_ID = 0x0042
-    UTF_16 = 0x04B0
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<H', self.UTF_16)
-
-class Window1Record(BiffRecord):
-    """
-    Offset Size Contents
-    0      2    Horizontal position of the document window (in twips = 1/20 of a point)
-    2      2    Vertical position of the document window (in twips = 1/20 of a point)
-    4      2    Width of the document window (in twips = 1/20 of a point)
-    6      2    Height of the document window (in twips = 1/20 of a point)
-    8      2    Option flags:
-                  Bits  Mask  Contents
-                  0     0001H 0 = Window is visible 1 = Window is hidden
-                  1     0002H 0 = Window is open 1 = Window is minimised
-                  3     0008H 0 = Horizontal scroll bar hidden 1 = Horizontal scroll bar visible
-                  4     0010H 0 = Vertical scroll bar hidden 1 = Vertical scroll bar visible
-                  5     0020H 0 = Worksheet tab bar hidden 1 = Worksheet tab bar visible
-    10     2    Index to active (displayed) worksheet
-    12     2    Index of first visible tab in the worksheet tab bar
-    14     2    Number of selected worksheets (highlighted in the worksheet tab bar)
-    16     2    Width of worksheet tab bar (in 1/1000 of window width). The remaining space is used by the
-                horizontal scrollbar.
-    """
-    _REC_ID = 0x003D
-    # flags
-
-    def __init__(self,
-                 hpos_twips, vpos_twips,
-                 width_twips, height_twips,
-                 flags,
-                 active_sheet,
-                 first_tab_index, selected_tabs, tab_width):
-        BiffRecord.__init__(self)
-
-        self._rec_data = pack('<9H', hpos_twips, vpos_twips,
-                                      width_twips, height_twips,
-                                      flags,
-                                      active_sheet,
-                                      first_tab_index, selected_tabs, tab_width)
-
-class FontRecord(BiffRecord):
-    """
-    WARNING
-        The font with index 4 is omitted in all BIFF versions.
-        This means the first four fonts have zero-based indexes, and
-        the fifth font and all following fonts are referenced with one-based
-        indexes.
-
-    Offset Size Contents
-    0      2    Height of the font (in twips = 1/20 of a point)
-    2      2    Option flags:
-                  Bit Mask    Contents
-                  0   0001H   1 = Characters are bold (redundant, see below)
-                  1   0002H   1 = Characters are italic
-                  2   0004H   1 = Characters are underlined (redundant, see below)
-                  3   0008H   1 = Characters are struck out
-                        0010H 1 = Outline
-                        0020H  1 = Shadow
-    4     2     Colour index
-    6     2     Font weight (100-1000).
-                Standard values are 0190H (400) for normal text and 02BCH
-                (700) for bold text.
-    8     2     Escapement type:
-                  0000H = None
-                  0001H = Superscript
-                  0002H = Subscript
-    10    1     Underline type:
-                  00H = None
-                  01H = Single
-                  21H = Single accounting
-                  02H = Double
-                  22H = Double accounting
-    11    1     Font family:
-                  00H = None (unknown or don't care)
-                  01H = Roman (variable width, serifed)
-                  02H = Swiss (variable width, sans-serifed)
-                  03H = Modern (fixed width, serifed or sans-serifed)
-                  04H = Script (cursive)
-                  05H = Decorative (specialised, i.e. Old English, Fraktur)
-    12    1     Character set:
-                  00H = 0 = ANSI Latin
-                  01H = 1 = System default
-                  02H = 2 = Symbol
-                  4DH = 77 = Apple Roman
-                  80H = 128 = ANSI Japanese Shift-JIS
-                  81H = 129 = ANSI Korean (Hangul)
-                  82H = 130 = ANSI Korean (Johab)
-                  86H = 134 = ANSI Chinese Simplified GBK
-                  88H = 136 = ANSI Chinese Traditional BIG5
-                  A1H = 161 = ANSI Greek
-                  A2H = 162 = ANSI Turkish
-                  A3H = 163 = ANSI Vietnamese
-                  B1H = 177 = ANSI Hebrew
-                  B2H = 178 = ANSI Arabic
-                  BAH = 186 = ANSI Baltic
-                  CCH = 204 = ANSI Cyrillic
-                  DEH = 222 = ANSI Thai
-                  EEH = 238 = ANSI Latin II (Central European)
-                  FFH = 255 = OEM Latin I
-    13    1     Not used
-    14    var.  Font name:
-                  BIFF5/BIFF7: Byte string, 8-bit string length
-                  BIFF8: Unicode string, 8-bit string length
-    The boldness and underline flags are still set in the options field,
-    but not used on reading the font. Font weight and underline type
-    are specified in separate fields instead.
-    """
-    _REC_ID = 0x0031
-
-    def __init__(self,
-                    height, options, colour_index, weight, escapement,
-                    underline, family, charset,
-                    name):
-        BiffRecord.__init__(self)
-
-        uname = upack1(name)
-        uname_len = len(uname)
-
-        self._rec_data = pack('<5H4B%ds' % uname_len, height, options, colour_index, weight, escapement,
-                                                underline, family, charset, 0x00,
-                                                uname)
-
-class NumberFormatRecord(BiffRecord):
-    """
-    Record FORMAT, BIFF8:
-    Offset  Size    Contents
-    0       2       Format index used in other records
-    2       var.    Number format string (Unicode string, 16-bit string length)
-
-    From  BIFF5  on,  the built-in number formats will be omitted. The built-in
-    formats  are  dependent  on  the current regional settings of the operating
-    system.  The following table shows which number formats are used by default
-    in  a  US-English  environment.  All indexes from 0 to 163 are reserved for
-    built-in formats. The first user-defined format starts at 164.
-
-    The built-in number formats, BIFF5-BIFF8
-
-    Index   Type        Format string
-    0       General     General
-    1       Decimal     0
-    2       Decimal     0.00
-    3       Decimal     #,##0
-    4       Decimal     #,##0.00
-    5       Currency    "$"#,##0_);("$"#,##
-    6       Currency    "$"#,##0_);[Red]("$"#,##
-    7       Currency    "$"#,##0.00_);("$"#,##
-    8       Currency    "$"#,##0.00_);[Red]("$"#,##
-    9       Percent     0%
-    10      Percent     0.00%
-    11      Scientific  0.00E+00
-    12      Fraction    # ?/?
-    13      Fraction    # ??/??
-    14      Date        M/D/YY
-    15      Date        D-MMM-YY
-    16      Date        D-MMM
-    17      Date        MMM-YY
-    18      Time        h:mm AM/PM
-    19      Time        h:mm:ss AM/PM
-    20      Time        h:mm
-    21      Time        h:mm:ss
-    22      Date/Time   M/D/YY h:mm
-    37      Account     _(#,##0_);(#,##0)
-    38      Account     _(#,##0_);[Red](#,##0)
-    39      Account     _(#,##0.00_);(#,##0.00)
-    40      Account     _(#,##0.00_);[Red](#,##0.00)
-    41      Currency    _("$"* #,##0_);_("$"* (#,##0);_("$"* "-"_);_(@_)
-    42      Currency    _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)
-    43      Currency    _("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)
-    44      Currency    _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)
-    45      Time        mm:ss
-    46      Time        [h]:mm:ss
-    47      Time        mm:ss.0
-    48      Scientific  ##0.0E+0
-    49      Text        @
-    """
-    _REC_ID = 0x041E
-
-    def __init__(self, idx, fmtstr):
-        BiffRecord.__init__(self)
-
-        ufmtstr = upack2(fmtstr)
-        ufmtstr_len = len(ufmtstr)
-
-        self._rec_data = pack('<H%ds' % ufmtstr_len, idx, ufmtstr)
-
-
-class XFRecord(BiffRecord):
-    """
-    XF Substructures
-    -------------------------------------------------------------------------
-    XF_TYPE_PROT  XF Type and Cell Protection (3 Bits), BIFF3-BIFF8
-    These 3 bits are part of a specific data byte.
-    Bit Mask    Contents
-    0   01H     1 = Cell is locked
-    1   02H     1 = Formula is hidden
-    2   04H     0 = Cell XF; 1 = Style XF
-
-    XF_USED_ATTRIB   Attributes   Used  from  Parent  Style  XF  (6  Bits),
-    BIFF3-BIFF8  Each  bit  describes  the  validity  of  a  specific group
-    of  attributes.  In  cell XFs a cleared bit means the attributes of the
-    parent  style XF are used (but only if the attributes are valid there),
-    a  set  bit  means  the  attributes  of  this XF are used. In style XFs
-    a cleared bit means the attribute setting is valid, a set bit means the
-    attribute should be ignored.
-    Bit Mask    Contents
-    0   01H     Flag for number format
-    1   02H     Flag for font
-    2   04H     Flag for horizontal and vertical alignment, text wrap, indentation, orientation, rotation, and
-                text direction
-    3   08H     Flag for border lines
-    4   10H     Flag for background area style
-    5   20H     Flag for cell protection (cell locked and formula hidden)
-
-    XF_HOR_ALIGN  Horizontal Alignment (3 Bits), BIFF2-BIFF8 The horizontal
-    alignment consists of 3 bits and is part of a specific data byte.
-    Value   Horizontal alignment
-    00H     General
-    01H     Left
-    02H     Centred
-    03H     Right
-    04H     Filled
-    05H     Justified (BIFF4-BIFF8X)
-    06H     Centred across selection (BIFF4-BIFF8X)
-    07H     Distributed (BIFF8X)
-
-    XF_VERT_ALIGN Vertical Alignment (2 or 3 Bits), BIFF4-BIFF8
-    The vertical alignment consists of 2 bits (BIFF4) or 3 bits (BIFF5-BIFF8)
-    and is part of a specific data byte. Vertical alignment is not available
-    in BIFF2 and BIFF3.
-    Value   Vertical alignment
-    00H     Top
-    01H     Centred
-    02H     Bottom
-    03H     Justified (BIFF5-BIFF8X)
-    04H     Distributed (BIFF8X)
-
-    XF_ORIENTATION  Text  Orientation  (2  Bits),  BIFF4-BIFF7  In the BIFF
-    versions  BIFF4-BIFF7,  text  can  be  rotated  in  steps of 90 degrees
-    or  stacked.  The  orientation  mode  consists of 2 bits and is part of
-    a specific data byte. In BIFF8 a rotation angle occurs instead of these
-    flags.
-    Value   Text orientation
-    00H     Not rotated
-    01H     Letters are stacked top-to-bottom, but not rotated
-    02H     Text is rotated 90 degrees counterclockwise
-    03H     Text is rotated 90 degrees clockwise
-
-    XF_ROTATION Text Rotation Angle (1 Byte), BIFF8
-    Value   Text rotation
-    0       Not rotated
-    1-90    1 to 90 degrees counterclockwise
-    91-180  1 to 90 degrees clockwise
-    255     Letters are stacked top-to-bottom, but not rotated
-
-    XF_BORDER_34  Cell  Border  Style  (4  Bytes), BIFF3-BIFF4 Cell borders
-    contain a line style and a line colour for each line of the border.
-    Bit     Mask        Contents
-    2-0     00000007H   Top line style
-    7-3     000000F8H   Colour index for top line colour
-    10-8    00000700H   Left line style
-    15-11   0000F800H   Colour index for left line colour
-    18-16   00070000H   Bottom line style
-    23-19   00F80000H   Colour index for bottom line colour
-    26-24   07000000H   Right line style
-    31-27   F8000000H   Colour index for right line colour
-
-    XF_AREA_34  Cell  Background  Area  Style (2 Bytes), BIFF3-BIFF4 A cell
-    background  area  style  contains  an area pattern and a foreground and
-    background colour.
-    Bit     Mask    Contents
-    5-0     003FH   Fill pattern
-    10-6    07C0H   Colour index for pattern colour
-    15-11   F800H   Colour index for pattern background
- ---------------------------------------------------------------------------------------------
-    Record XF, BIFF8:
-    Offset      Size    Contents
-    0           2       Index to FONT record
-    2           2       Index to FORMAT record
-    4           2       Bit     Mask    Contents
-                        2-0     0007H   XF_TYPE_PROT . XF type, cell protection (see above)
-                        15-4    FFF0H   Index to parent style XF (always FFFH in style XFs)
-    6           1       Bit     Mask    Contents
-                        2-0     07H     XF_HOR_ALIGN . Horizontal alignment (see above)
-                        3       08H     1 = Text is wrapped at right border
-                        6-4     70H     XF_VERT_ALIGN . Vertical alignment (see above)
-    7           1       XF_ROTATION: Text rotation angle (see above)
-    8           1       Bit     Mask    Contents
-                        3-0     0FH     Indent level
-                        4       10H     1 = Shrink content to fit into cell
-                        5               merge
-                        7-6     C0H     Text direction (BIFF8X only)
-                                        00b = According to context
-                                        01b = Left-to-right
-                                        10b = Right-to-left
-    9           1       Bit     Mask    Contents
-                        7-2     FCH     XF_USED_ATTRIB . Used attributes (see above)
-    10          4       Cell border lines and background area:
-                        Bit     Mask      Contents
-                        3-0     0000000FH Left line style
-                        7-4     000000F0H Right line style
-                        11-8    00000F00H Top line style
-                        15-12   0000F000H Bottom line style
-                        22-16   007F0000H Colour index for left line colour
-                        29-23   3F800000H Colour index for right line colour
-                        30      40000000H 1 = Diagonal line from top left to right bottom
-                        31      80000000H 1 = Diagonal line from bottom left to right top
-    14          4       Bit     Mask      Contents
-                        6-0     0000007FH Colour index for top line colour
-                        13-7    00003F80H Colour index for bottom line colour
-                        20-14   001FC000H Colour index for diagonal line colour
-                        24-21   01E00000H Diagonal line style
-                        31-26   FC000000H Fill pattern
-    18          2       Bit     Mask    Contents
-                        6-0     007FH   Colour index for pattern colour
-                        13-7    3F80H   Colour index for pattern background
-
-    """
-    _REC_ID = 0x00E0
-
-    def __init__(self, xf, xftype='cell'):
-        BiffRecord.__init__(self)
-
-        font_xf_idx, fmt_str_xf_idx, alignment, borders, pattern, protection = xf
-        fnt = struct.pack('<H', font_xf_idx)
-        fmt = struct.pack('<H', fmt_str_xf_idx)
-        if xftype == 'cell':
-            prt = struct.pack('<H',
-                ((protection.cell_locked    & 0x01) << 0) |
-                ((protection.formula_hidden & 0x01) << 1)
-            )
-        else:
-            prt = struct.pack('<H', 0xFFF5)
-        aln = struct.pack('B',
-            ((alignment.horz & 0x07) << 0) |
-            ((alignment.wrap & 0x01) << 3) |
-            ((alignment.vert & 0x07) << 4)
-        )
-        rot = struct.pack('B', alignment.rota)
-        txt = struct.pack('B',
-            ((alignment.inde & 0x0F) << 0) |
-            ((alignment.shri & 0x01) << 4) |
-            ((alignment.merg & 0x01) << 5) |
-            ((alignment.dire & 0x03) << 6)
-        )
-        if xftype == 'cell':
-            used_attr = struct.pack('B', 0xF8)
-        else:
-            used_attr = struct.pack('B', 0xF4)
-
-        if borders.left == borders.NO_LINE:
-            borders.left_colour = 0x00
-        if borders.right == borders.NO_LINE:
-            borders.right_colour = 0x00
-        if borders.top == borders.NO_LINE:
-            borders.top_colour = 0x00
-        if borders.bottom == borders.NO_LINE:
-            borders.bottom_colour = 0x00
-        if borders.diag == borders.NO_LINE:
-            borders.diag_colour = 0x00
-        brd1 = struct.pack('<L',
-            ((borders.left          & 0x0F) << 0 ) |
-            ((borders.right         & 0x0F) << 4 ) |
-            ((borders.top           & 0x0F) << 8 ) |
-            ((borders.bottom        & 0x0F) << 12) |
-            ((borders.left_colour   & 0x7F) << 16) |
-            ((borders.right_colour  & 0x7F) << 23) |
-            ((borders.need_diag1    & 0x01) << 30) |
-            ((borders.need_diag2    & 0x01) << 31)
-        )
-        brd2 = struct.pack('<L',
-            ((borders.top_colour    & 0x7F) << 0 ) |
-            ((borders.bottom_colour & 0x7F) << 7 ) |
-            ((borders.diag_colour   & 0x7F) << 14) |
-            ((borders.diag          & 0x0F) << 21) |
-            ((pattern.pattern       & 0x0F) << 26)
-        )
-        pat = struct.pack('<H',
-            ((pattern.pattern_fore_colour & 0x7F) << 0 ) |
-            ((pattern.pattern_back_colour & 0x7F) << 7 )
-        )
-        self._rec_data = fnt + fmt + prt + \
-                        aln + rot + txt + used_attr + \
-                        brd1 + brd2 + \
-                        pat
-
-class StyleRecord(BiffRecord):
-    """
-    STYLE record for user-defined cell styles, BIFF3-BIFF8:
-    Offset  Size    Contents
-    0       2       Bit     Mask    Contents
-                    11-0    0FFFH   Index to style XF record
-                    15      8000H   Always 0 for user-defined styles
-    2       var.    BIFF2-BIFF7: Non-empty byte string, 8-bit string length
-                    BIFF8: Non-empty Unicode string, 16-bit string length
-    STYLE record for built-in cell styles, BIFF3-BIFF8:
-    Offset  Size    Contents
-    0       2       Bit     Mask    Contents
-                    11-0    0FFFH   Index to style XF record
-                    15      8000H   Always 1 for built-in styles
-    2       1       Identifier of the built-in cell style:
-                        00H = Normal
-                        01H = RowLevel_lv (see next field)
-                        02H = ColLevel_lv (see next field)
-                        03H = Comma
-                        04H = Currency
-                        05H = Percent
-                        06H = Comma [0] (BIFF4-BIFF8)
-                        07H = Currency [0] (BIFF4-BIFF8)
-                        08H = Hyperlink (BIFF8)
-                        09H = Followed Hyperlink (BIFF8)
-    3       1       Level for RowLevel or ColLevel style
-                    (zero-based, lv), FFH otherwise
-    The  RowLevel  and  ColLevel  styles specify the formatting of subtotal
-    cells  in  a specific outline level. The level is specified by the last
-    field  in the STYLE record. Valid values are 0-6 for the outline levels
-    1-7.
-    """
-    _REC_ID = 0x0293
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-        self._rec_data = struct.pack('<HBB', 0x8000, 0x00, 0xFF)
-        # TODO: implement user-defined styles???
-
-
-class PaletteRecord(BiffRecord):
-    """
-    This  record  contains  the  definition  of  all  user-defined  colours
-    available for cell and object formatting.
-
-    Record PALETTE, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Number of following colours (nm). Contains 16 in BIFF3-BIFF4 and 56 in BIFF5-BIFF8.
-    2       4*nm    List of nm RGB colours
-
-    The following table shows how colour indexes are used in other records:
-
-    Colour index    Resulting colour or internal list index
-    00H             Built-in Black (R = 00H, G = 00H, B = 00H)
-    01H             Built-in White (R = FFH, G = FFH, B = FFH)
-    02H             Built-in Red (R = FFH, G = 00H, B = 00H)
-    03H             Built-in Green (R = 00H, G = FFH, B = 00H)
-    04H             Built-in Blue (R = 00H, G = 00H, B = FFH)
-    05H             Built-in Yellow (R = FFH, G = FFH, B = 00H)
-    06H             Built-in Magenta (R = FFH, G = 00H, B = FFH)
-    07H             Built-in Cyan (R = 00H, G = FFH, B = FFH)
-    08H             First user-defined colour from the PALETTE record (entry 0 from record colour list)
-    .........................
-
-    17H (BIFF3-BIFF4) Last user-defined colour from the PALETTE record (entry 15 or 55 from record colour list)
-    3FH (BIFF5-BIFF8)
-
-    18H (BIFF3-BIFF4) System window text colour for border lines (used in records XF, CF, and
-    40H (BIFF5-BIFF8) WINDOW2 (BIFF8 only))
-
-    19H (BIFF3-BIFF4) System window background colour for pattern background (used in records XF, and CF)
-    41H (BIFF5-BIFF8)
-
-    43H             System face colour (dialogue background colour)
-    4DH             System window text colour for chart border lines
-    4EH             System window background colour for chart areas
-    4FH             Automatic colour for chart border lines (seems to be always Black)
-    50H             System ToolTip background colour (used in note objects)
-    51H             System ToolTip text colour (used in note objects)
-    7FFFH           System window text colour for fonts (used in records FONT, EFONT, and CF)
-
-    """
-    _REC_ID = 0x0092
-
-
-class BoundSheetRecord(BiffRecord):
-    """
-    This  record  is  located  in  the workbook globals area and represents
-    a  sheet  inside  of  the  workbook. For each sheet a BOUNDSHEET record
-    is  written.  It  stores  the sheet name and a stream offset to the BOF
-    record    within   the   workbook   stream.  The  record  is also known
-    as BUNDLESHEET.
-
-    Record BOUNDSHEET, BIFF5-BIFF8:
-    Offset  Size    Contents
-    0       4       Absolute stream position of the BOF record of the sheet represented by this record. This
-                    field is never encrypted in protected files.
-    4       1       Visibility:
-                        00H = Visible
-                        01H = Hidden
-                        02H = Strong hidden
-    5       1       Sheet type:
-                        00H = Worksheet
-                        02H = Chart
-                        06H = Visual Basic module
-    6       var.    Sheet name:
-                        BIFF5/BIFF7: Byte string, 8-bit string length
-                        BIFF8: Unicode string, 8-bit string length
-    """
-    _REC_ID = 0x0085
-
-    def __init__(self, stream_pos, visibility, sheetname):
-        BiffRecord.__init__(self)
-
-        usheetname = upack1(sheetname)
-        uusheetname_len = len(usheetname)
-
-        self._rec_data = pack('<LBB%ds' % uusheetname_len, stream_pos, visibility, 0x00, usheetname)
-
-
-class ContinueRecord(BiffRecord):
-    """
-    Whenever  the content of a record exceeds the given limits (see table),
-    the  record  must  be  split.  Several  CONTINUE records containing the
-    additional data are added after the parent record.
-
-    BIFF version    Maximum data size of a record
-    BIFF2-BIFF7     2080 bytes (2084 bytes including record header)
-    BIFF8           8224 bytes (8228 bytes including record header) (0x2020)
-
-    Record CONTINUE, BIFF2-BIFF8:
-    Offset  Size    Contents
-    0       var.    Data continuation of the previous record
-
-    Unicode  strings  are  split in a special way. At the beginning of each
-    CONTINUE  record  the option flags byte is repeated. Only the character
-    size  flag  will  be set in this flags byte, the Rich-Text flag and the
-    Far-East  flag  are set to zero. In each CONTINUE record it is possible
-    that  the  character  size  changes  from  8-bit  characters  to 16-bit
-    characters and vice versa.
-
-    Never  a  Unicode  string  is  split  until  and  including  the  first
-    character.  That means, all header fields (string length, option flags,
-    optional Rich-Text size, and optional Far-East data size) and the first
-    character  of  the string have to occur together in the leading record,
-    or  have  to  be  moved completely into the CONTINUE record. Formatting
-    runs cannot be split between their components (character index and FONT
-    record  index).  If  a string is split between two formatting runs, the
-    option flags field will not be repeated in the CONTINUE record.
-    """
-    _REC_ID = 0x003C
-
-
-class SSTRecord(BiffRecord):
-    """
-    This  record  contains  a  list  of  all  strings  used anywhere in the
-    workbook.  Each string occurs only once. The workbook uses indexes into
-    the list to reference the strings.
-
-    Record SST, BIFF8:
-    Offset  Size    Contents
-    0       4       Total number of strings in the workbook (see below)
-    4       4       Number of following strings (nm)
-    8       var.    List of nm Unicode strings, 16-bit string length
-
-    The  first  field  of  the  SST  record  counts  the  total  occurrence
-    of  strings  in  the  workbook.  For  instance,  the string AAA is used
-    3  times  and  the string BBB is used 2 times. The first field contains
-    5 and the second field contains 2, followed by the two strings.
-    """
-    _REC_ID = 0x00FC
-
-
-class ExtSSTRecord(BiffRecord):
-    """
-    This  record  occurs  in  conjunction  with  the SST record. It is used
-    by  Excel  to create a hash table with stream offsets to the SST record
-    to optimise string search operations. Excel may not shorten this record
-    if  strings  are deleted from the shared string table, so the last part
-    might  contain  invalid  data. The stream indexes in this record divide
-    the SST into portions containing a constant number of strings.
-
-    Record EXTSST, BIFF8:
-
-    Offset  Size    Contents
-    0       2       Number of strings in a portion, this number is >=8
-    2       var.    List of OFFSET structures for all portions. Each OFFSET contains the following data:
-                        Offset Size Contents
-                        0       4   Absolute stream position of first string of the portion
-                        4       2   Position of first string of the portion inside of current record,
-                                    including record header. This counter restarts at zero, if the SST
-                                    record is continued with a CONTINUE record.
-                        6       2   Not used
-    """
-    _REC_ID = 0x00FF
-
-    def __init__(self, sst_stream_pos, str_placement, portions_len):
-        BiffRecord.__init__(self)
-
-        extsst = {}
-        abs_stream_pos = sst_stream_pos
-        str_counter = 0
-        portion_counter = 0
-        while str_counter < len(str_placement):
-            str_chunk_num, pos_in_chunk = str_placement[str_counter]
-            if str_chunk_num <> portion_counter:
-                portion_counter = str_chunk_num
-                abs_stream_pos += portions_len[portion_counter-1]
-                #print hex(abs_stream_pos)
-            str_stream_pos = abs_stream_pos + pos_in_chunk + 4 # header
-            extsst[str_counter] = (pos_in_chunk, str_stream_pos)
-            str_counter += 1
-
-        exsst_str_count_delta = max(8, len(str_placement)*8/0x2000) # maybe smth else?
-        self._rec_data = pack('<H', exsst_str_count_delta)
-        str_counter = 0
-        while str_counter < len(str_placement):
-            self._rec_data += pack('<IHH', extsst[str_counter][1], extsst[str_counter][0], 0)
-            str_counter += exsst_str_count_delta
-
-class DimensionsRecord(BiffRecord):
-    """
-    Record DIMENSIONS, BIFF8:
-
-    Offset  Size    Contents
-    0       4       Index to first used row
-    4       4       Index to last used row, increased by 1
-    8       2       Index to first used column
-    10      2       Index to last used column, increased by 1
-    12      2       Not used
-    """
-    _REC_ID = 0x0200
-    def __init__(self, first_used_row, last_used_row, first_used_col, last_used_col):
-        BiffRecord.__init__(self)
-
-        self._rec_data = struct.pack('<2L3H',
-                                            first_used_row, last_used_row + 1,
-                                            first_used_col, last_used_col + 1,
-                                            0x00)
-
-
-class Window2Record(BiffRecord):
-    """
-    Record WINDOW2, BIFF8:
-
-    Offset  Size Contents
-    0       2 Option flags (see below)
-    2       2 Index to first visible row
-    4       2 Index to first visible column
-    6       2 Colour index of grid line colour. Note that in BIFF2-BIFF7 an RGB colour is
-                written instead.
-    8       2 Not used
-    10      2 Cached magnification factor in page break preview (in percent); 0 = Default (60%)
-    12      2 Cached magnification factor in normal view (in percent); 0 = Default (100%)
-    14      4 Not used
-
-    In  BIFF8  this record stores used magnification factors for page break
-    preview  and  normal  view.  These  values  are  used  to  restore  the
-    magnification,  when the view is changed. The real magnification of the
-    currently  active  view  is  stored  in the SCL record. The type of the
-    active view is stored in the option flags field (see below).
-
-     0 0001H 0 = Show formula results 1 = Show formulas
-     1 0002H 0 = Do not show grid lines 1 = Show grid lines
-     2 0004H 0 = Do not show sheet headers 1 = Show sheet headers
-     3 0008H 0 = Panes are not frozen 1 = Panes are frozen (freeze)
-     4 0010H 0 = Show zero values as empty cells 1 = Show zero values
-     5 0020H 0 = Manual grid line colour 1 = Automatic grid line colour
-     6 0040H 0 = Columns from left to right 1 = Columns from right to left
-     7 0080H 0 = Do not show outline symbols 1 = Show outline symbols
-     8 0100H 0 = Keep splits if pane freeze is removed 1 = Remove splits if pane freeze is removed
-     9 0200H 0 = Sheet not selected 1 = Sheet selected (BIFF5-BIFF8)
-    10 0400H 0 = Sheet not visible 1 = Sheet visible (BIFF5-BIFF8)
-    11 0800H 0 = Show in normal view 1 = Show in page break preview (BIFF8)
-
-    The freeze flag specifies, if a following PANE record describes unfrozen or frozen panes.
-    """
-    _REC_ID = 0x023E
-
-    def __init__(self, options, first_visible_row, first_visible_col, grid_colour, preview_magn, normal_magn):
-        BiffRecord.__init__(self)
-
-        self._rec_data = struct.pack('<7HL', options,
-                                    first_visible_row, first_visible_col,
-                                    grid_colour,
-                                    0x00,
-                                    preview_magn, normal_magn,
-                                    0x00L)
-
-
-class PanesRecord(BiffRecord):
-    """
-    This record stores the position of window panes. It is part of the Sheet
-    View Settings Block. If the sheet does not contain any splits, this
-    record will not occur.
-    A sheet can be split in two different ways, with unfrozen panes or with
-    frozen panes. A flag in the WINDOW2 record specifies, if the panes are
-    frozen, which affects the contents of this record.
-
-    Record PANE, BIFF2-BIFF8:
-    Offset      Size        Contents
-    0           2           Position of the vertical split
-                            (px, 0 = No vertical split):
-                            Unfrozen pane: Width of the left pane(s)
-                            (in twips = 1/20 of a point)
-                            Frozen pane: Number of visible
-                            columns in left pane(s)
-    2           2           Position of the horizontal split
-                            (py, 0 = No horizontal split):
-                            Unfrozen pane: Height of the top pane(s)
-                            (in twips = 1/20 of a point)
-                            Frozen pane: Number of visible
-                            rows in top pane(s)
-    4           2           Index to first visible row
-                            in bottom pane(s)
-    6           2           Index to first visible column
-                            in right pane(s)
-    8           1           Identifier of pane with active
-                            cell cursor
-    [9]         1           Not used (BIFF5-BIFF8 only, not written
-                            in BIFF2-BIFF4)
-
-    If the panes are frozen, pane 0 is always active, regardless
-    of the cursor position. The correct identifiers for all possible
-    combinations of visible panes are shown in the following pictures.
-
-    px = 0, py = 0                  px = 0, py > 0
-    --------------------------      ------------|-------------
-    |                        |      |                        |
-    |                        |      |           3            |
-    |                        |      |                        |
-    -           3            -      --------------------------
-    |                        |      |                        |
-    |                        |      |           2            |
-    |                        |      |                        |
-    --------------------------      ------------|-------------
-
-    px > 0, py = 0                  px > 0, py > 0
-    ------------|-------------      ------------|-------------
-    |           |            |      |           |            |
-    |           |            |      |     3     |      2     |
-    |           |            |      |           |            |
-    -     3     |      1     -      --------------------------
-    |           |            |      |           |            |
-    |           |            |      |     1     |      0     |
-    |           |            |      |           |            |
-    ------------|-------------      ------------|-------------
-    """
-    _REC_ID = 0x0041
-    def __init__(self, px, py, first_row_bottom, first_col_right, active_pane):
-        BiffRecord.__init__(self)
-
-        self._rec_data = struct.pack('<5H',
-                                            px, py,
-                                            first_row_bottom, first_col_right,
-                                            active_pane)
-
-
-class RowRecord(BiffRecord):
-    """
-    This  record  contains  the properties of a single row in a sheet. Rows
-    and cells in a sheet are divided into blocks of 32 rows.
-
-    Record ROW, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Index of this row
-    2       2       Index to column of the first cell which is described by a cell record
-    4       2       Index to column of the last cell which is described by a cell record,
-                    increased by 1
-    6       2       Bit     Mask    Contents
-                    14-0    7FFFH   Height of the row, in twips = 1/20 of a point
-                    15      8000H   0 = Row has custom height; 1 = Row has default height
-    8       2       Not used
-    10      2       In BIFF3-BIFF4 this field contains a relative offset
-                    to calculate stream position of the first cell record
-                    for this row. In BIFF5-BIFF8 this field is not used
-                    anymore, but the DBCELL record instead.
-    12      4       Option flags and default row formatting:
-                    Bit     Mask        Contents
-                    2-0     00000007H   Outline level of the row
-                    4       00000010H   1 = Outline group starts or ends here (depending
-                                        on where the outline buttons are located,
-                                        see WSBOOL record), and is collapsed
-                    5       00000020H   1 = Row is hidden (manually, or by a filter or outline group)
-                    6       00000040H   1 = Row height and default font height do not match
-                    7       00000080H   1 = Row has explicit default format (fl)
-                    8       00000100H   Always 1
-                    27-16   0FFF0000H   If fl=1: Index to default XF record
-                    28      10000000H   1 = Additional space above the row. This flag is set,
-                                        if the upper border of at least one cell in this row
-                                        or if the lower border of at least one cell in the row
-                                        above is formatted with a thick line style.
-                                        Thin and medium line styles are not taken into account.
-                    29      20000000H   1 = Additional space below the row. This flag is set,
-                                        if the lower border of at least one cell in this row
-                                        or if the upper border of at least one cell in the row
-                                        below is formatted with a medium or thick line style.
-                                        Thin line styles are not taken into account.
-    """
-
-    _REC_ID = 0x0208
-
-    def __init__(self, index, first_col, last_col, height_options, options):
-        BiffRecord.__init__(self)
-
-        self._rec_data = struct.pack('<6HL', index, first_col, last_col + 1,
-                                        height_options,
-                                        0x00, 0x00,
-                                        options)
-
-class LabelSSTRecord(BiffRecord):
-    """
-    This record represents a cell that contains a string. It replaces the
-    LABEL record and RSTRING record used in BIFF2-BIFF7.
-    """
-    _REC_ID = 0x00FD
-
-    def __init__(self, row, col, xf_idx, sst_idx):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<3HL', row, col, xf_idx, sst_idx)
-
-
-class MergedCellsRecord(BiffRecord):
-    """
-    This record contains all merged cell ranges of the current sheet.
-
-    Record MERGEDCELLS, BIFF8:
-
-    Offset  Size    Contents
-    0       var.    Cell range address list with all merged ranges
-
-    ------------------------------------------------------------------
-
-    A cell range address list consists of a field with the number of ranges
-    and the list of the range addresses.
-
-    Cell range address list, BIFF8:
-
-    Offset  Size            Contents
-    0       2               Number of following cell range addresses (nm)
-    2       8*nm            List of nm cell range addresses
-
-    ---------------------------------------------------------------------
-    Cell range address, BIFF8:
-
-    Offset  Size    Contents
-    0       2       Index to first row
-    2       2       Index to last row
-    4       2       Index to first column
-    6       2       Index to last column
-
-    """
-    _REC_ID = 0x00E5
-
-    def __init__(self, merged_list):
-        BiffRecord.__init__(self)
-
-        i = len(merged_list) - 1
-        while i >= 0:
-            j = 0
-            merged = ''
-            while (i >= 0) and (j < 0x403):
-                r1, r2, c1, c2 = merged_list[i]
-                merged += struct.pack('<4H', r1, r2, c1, c2)
-                i -= 1
-                j += 1
-            self._rec_data += struct.pack('<3H', self._REC_ID, len(merged) + 2, j) + \
-                                    merged
-
-    # for some reason Excel doesn't use CONTINUE
-    def get(self):
-        return self._rec_data
-
-class MulBlankRecord(BiffRecord):
-    """
-    This  record  represents  a  cell  range  of empty cells. All cells are
-    located in the same row.
-
-    Record MULBLANK, BIFF5-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Index to row
-    2       2       Index to first column (fc)
-    4       2*nc    List of nc=lc-fc+1 16-bit indexes to XF records
-    4+2*nc  2       Index to last column (lc)
-    """
-    _REC_ID = 0x00BE
-
-    def __init__(self, row, first_col, last_col, xf_index):
-        BiffRecord.__init__(self)
-        blanks_count = last_col-first_col+1
-        self._rec_data = struct.pack('%dH' % blanks_count, *([xf_index]*blanks_count))
-        self._rec_data = struct.pack('<2H', row, first_col) +  self._rec_data + struct.pack('<H',  last_col)
-
-
-class BlankRecord(BiffRecord):
-    """
-    This  record  represents  an empty cell.
-
-    Record BLANK, BIFF5-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Index to row
-    2       2       Index to first column (fc)
-    4       2       indexes to XF record
-    """
-    _REC_ID = 0x0201
-
-    def __init__(self, row, col, xf_index):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<3H', row, col, xf_index)
-
-
-class RKRecord(BiffRecord):
-    """
-    This record represents a cell that contains an RK value (encoded integer or
-    floating-point value). If a floating-point value cannot be encoded to an RK value,
-    a NUMBER record will be written.
-    """
-    _REC_ID = 0x027E
-
-    def __init__(self, row, col, xf_index, rk_encoded):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<3HI', row, col, xf_index, rk_encoded)
-
-
-class NumberRecord(BiffRecord):
-    """
-    This record represents a cell that contains an IEEE-754 floating-point value.
-    """
-    _REC_ID = 0x0203
-
-    def __init__(self, row, col, xf_index, number):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<3Hd', row, col, xf_index, number)
-
-
-class StringRecord(BiffRecord):
-    """
-    Offset     Size   Contents
-    0       1 or 2  Length of the string (character count, ln)
-    1 or 2      1     Option flags:
-                     Bit       Mask Contents
-                                01H
-                      0                  Character compression (ccompr):
-                                         02 = Compressed (8-bit characters)
-                                         12 = Uncompressed (16-bit characters)
-                                04H
-                      2                  Asian phonetic settings (phonetic):
-                                         02 = Does not contain Asian phonetic settings
-                                         12 = Contains Asian phonetic settings
-                                08H
-                      3                  Rich-Text settings (richtext):
-                                         02 = Does not contain Rich-Text settings
-                                         12 = Contains Rich-Text settings
-    [2 or 3]     2     (optional, only if richtext=1) Number of Rich-Text formatting runs (rt)
-    [var.]      4     (optional, only if phonetic=1) Size of Asian phonetic settings block (in bytes, sz)
-    var.   ln or 2ln Character array (8-bit characters or 16-bit characters, dependent on ccompr)
-    [var.]    4rt     (optional, only if richtext=1) List of rt formatting runs (3.2)
-            sz
-    [var.]            (optional, only if phonetic=1) Asian Phonetic Settings Block (3.4.2)
-    """
-    _REC_ID = 0x0207
-
-    def __init__(self, s):
-        BiffRecord.__init__(self)
-        uncompressed = 0x01
-        asian_phonetic_settings = 0x04
-        rich_text_settings = 0x08
-        
-        s = s.encode('UTF-16le')
-        slen = len(s)/2
-        options = uncompressed
-        if not s[1::2].strip(chr(0x00)):
-            # if high bytes are all zero, do string compression
-            s = s[::2]
-            slen = len(s)
-            options &= ~uncompressed
-        self._rec_data = struct.pack('<HB%ds'%len(s), slen, options, s)
-
-
-class FormulaRecord(BiffRecord):
-    """
-    Offset Size Contents
-    0      2    Index to row
-    2      2    Index to column
-    4      2    Index to XF record
-    6      8    Result of the formula
-    14     2    Option flags:
-                Bit Mask    Contents
-                0   0001H   1 = Recalculate always
-                1   0002H   1 = Calculate on open
-                3   0008H   1 = Part of a shared formula
-    16     4    Not used
-    20     var. Formula data (RPN token array)
-
-    """
-    _REC_ID = 0x0006
-
-    def __init__(self, row, col, xf_index, result, opts, rpn):
-        BiffRecord.__init__(self)
-        # for an empty cell
-        self._rec_data = struct.pack('<3HQHL', row, col, xf_index, result, opts, 0) + rpn
-
-
-class HyperlinkRecord(BiffRecord):
-    """
-    Each HLINK record starts with the same data items and continues with
-    special data related to the current type of hyperlink. It starts with a
-    cell range. Each cell of this range will contain the same hyperlink.
-
-    Record HLINK, BIFF8:
-   Offset            Size        Contents
-       0               8         Cell range address of all cells containing this hyperlink (3.13.1)
-       8              16         GUID of StdLink:
-                                 D0H C9H EAH 79H F9H BAH CEH 11H 8CH 82H 00H AAH 00H 4BH A9H 0BH
-                                 (79EAC9D0-BAF9-11CE-8C82-00AA004BA90B)
-      24               4         Unknown value: 00000002H
-      28               4        Option flags (see below)
-     [32]              4        (optional, see option flags) Character count of description text, including trailing zero word
-                                (dl)
-     [36]            2dl        (optional, see option flags) Character array of description text, no Unicode string header,
-                                always 16-bit characters, zero-terminated
-    [var.]             4        (optional, see option flags) Character count of target frame, including trailing zero word
-                                (fl)
-    [var.]           2fl         (optional, see option flags) Character array of target frame, no Unicode string header,
-                                 always 16-bit characters, zero-terminated
-     var.            var.        Special data (6.53.2 and following)
-    [var.]             4         (optional, see option flags) Character count of the text mark, including trailing zero word
-                                 (tl)
-    [var.]           2tl         (optional, see option flags) Character array of the text mark without "#" sign, no Unicode
-                                 string header, always 16-bit characters, zero-terminated
-
-    """
-    _REC_ID = 0x01B8
-
-    def __init__(self, frow, lrow, fcol, lcol, url, target=None, description=None):
-        BiffRecord.__init__(self)
-        options = 0x00
-        special=None
-        textmark=None
-        
-        #~ assert url is not None or textmark is not None, 'must specify either url or textmark arguments'
-        
-        if description is not None:
-            options |= 0x14
-            description = description.encode('UTF-16le') + '\x00\x00'
-        
-        if target is not None:
-            options |= 0x80
-            target = target.encode('UTF-16le') + '\x00\x00'
-        
-        u16url = url.encode('UTF-16le') + '\x00\x00'
-        if url[0].isalpha() and url.find(':') > 3:
-            # hyperlink containing a URL (6.53.2)
-            assert url[:url.find(':')].isalpha(), 'not valid URL'%url
-            options |= 0x03
-            special  = pack('<4L', 0x79eac9e0, 0x11cebaf9, 0xaa00828c, 0x0ba94b00)
-            special += pack('<L%ds'%len(u16url), len(u16url), u16url)
-        elif url[0].isalnum() or url[0] in ('.',):
-            # hyperlink to the current workbook (6.53.3)
-            options |= 0x01
-            
-            uplvl_cnt=0
-            if url[0].isalpha() and url[1:].startswith(':\\'):
-                # this is an absolute path
-                options |= 0x02
-            else:
-                uplvl_cnt += 1
-                while url.startswith('..\\'):
-                    url = url[3:]
-            url += '\x00'
-            
-            special  = pack('<4L', 0x00000303, 0x00000000, 0x000000C0, 0x46000000)
-            special += pack('<HL%ds'%len(url), uplvl_cnt, len(url), url)
-            special += pack('<4s20x', '\xff\xff\xad\xde')
-            # I don't understand the first field here, setting to zero is safe
-            # till I figure out what it is
-            special += pack('<LL2s%ds'%len(u16url[:-2]), 0, len(u16url[:-2]), 
-                            '\x03\x00', u16url[:-2])
-        elif url.startswith('\\\\'):
-            # hyperlink to a File with UNC Path (6.53.4)
-            options |= 0x103
-            special  = pack('<L%ds'%len(u16url), len(u16url), u16url)
-        elif url.startswith('#'):
-            # hyperlink to the current workbook (6.53.5)
-            options |= 0x08
-            textmark = url[1:]
-        
-        if textmark is not None:
-            textmark = textmark.encode('UTF-16le') + '\x00\x00'
-        
-        self._rec_data  = pack('<4H', frow, lrow, fcol, lcol)
-        # GUID of StdLink
-        self._rec_data += pack('<4L', 0x79eac9d0, 0x11cebaf9, 0xaa00828c, 0x0ba94b00)
-        #~ self._rec_data += '\xd0\xc9\xea\x79\xf9\xba\xce\x11\x8c\x82\x00\xaa\x00\x4b\xa9\x0b'
-        self._rec_data += pack('<LL',   0x2, options)
-        if description is not None:
-            self._rec_data += pack('<L%ds'%len(description), len(description)/2, description)
-        if target is not None:
-            self._rec_data += pack('<L%ds'%len(target), len(target)/2, target)
-        if special is not None:
-            self._rec_data += pack('<%ds'%len(special), special)
-        if textmark is not None:
-            self._rec_data += pack('<L%ds'%len(textmark), len(textmark)/2, textmark)
-
-
-class QuicktipRecord(BiffRecord):
-    """
-    This record contains the cell range and text for a tool tip. It occurs in
-    conjunction with the HLINK record for hyperlinks (6.53) in the Hyperlink
-    Table (5.13). This record is only available in Excel 9.0 (Excel 2000) and
-    later.
-
-    Record QUICKTIP, BIFF8:
-
-    Offset Size Contents
-    0      2   0800H (repeated record identifier)
-    2      8   Cell range address of all cells containing the tool tip (3.13.1)
-    10    var. Character array of the tool tip, no Unicode string header, always 16-bit characters, zero-
-            terminated
-
-    """
-    _REC_ID = 0x0800
-
-    def __init__(self, frow, lrow, fcol, lcol, hint):
-        BiffRecord.__init__(self)
-        hint = hint.encode('UTF-16le')
-        self._rec_data = pack('<5H%dsx'%len(hint), self._REC_ID, frow, lrow, fcol, lcol, hint)
-
-
-class GutsRecord(BiffRecord):
-    """
-    This record contains information about the layout of outline symbols.
-
-    Record GUTS, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Width of the area to display row outlines (left of the sheet), in pixel
-    2       2       Height of the area to display column outlines (above the sheet), in pixel
-    4       2       Number of visible row outline levels (used row levels + 1; or 0, if not used)
-    6       2       Number of visible column outline levels (used column levels + 1; or 0, if not used)
-
-    """
-
-    _REC_ID = 0x0080
-
-    def __init__(self, row_gut_width, col_gut_height, row_visible_levels, col_visible_levels):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<4H', row_gut_width, col_gut_height, row_visible_levels, col_visible_levels)
-
-class WSBoolRecord(BiffRecord):
-    """
-    This  record stores a 16 bit value with Boolean options for the current
-    sheet.  From BIFF5 on the "Save external linked values" option is moved
-    to the record BOOKBOOL.
-
-    Option flags of record WSBOOL, BIFF3-BIFF8:
-
-    Bit     Mask    Contents
-    0       0001H   0 = Do not show automatic page breaks
-                    1 = Show automatic page breaks
-    4       0010H   0 = Standard sheet
-                    1 = Dialogue sheet (BIFF5-BIFF8)
-    5       0020H   0 = No automatic styles in outlines
-                    1 = Apply automatic styles to outlines
-    6       0040H   0 = Outline buttons above outline group
-                    1 = Outline buttons below outline group
-    7       0080H   0 = Outline buttons left of outline group
-                    1 = Outline buttons right of outline group
-    8       0100H   0 = Scale printout in percent
-                    1 = Fit printout to number of pages
-    9       0200H   0 = Save external linked values (BIFF3?BIFF4 only)
-                    1 = Do not save external linked values (BIFF3?BIFF4 only)
-    10      0400H   0 = Do not show row outline symbols
-                    1 = Show row outline symbols
-    11      0800H   0 = Do not show column outline symbols
-                    1 = Show column outline symbols
-    13-12   3000H   These flags specify the arrangement of windows.
-                    They are stored in BIFF4 only.
-                    00 = Arrange windows tiled
-                    01 = Arrange windows horizontal
-                    10 = Arrange windows vertical112 = Arrange windows cascaded
-    The following flags are valid for BIFF4-BIFF8 only:
-    14      4000H   0 = Standard expression evaluation
-                    1 = Alternative expression evaluation
-    15      8000H   0 = Standard formula entries
-                    1 = Alternative formula entries
-
-    """
-    _REC_ID = 0x0081
-
-    def __init__(self, options):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', options)
-
-class ColInfoRecord(BiffRecord):
-    """
-    This record specifies the width for a given range of columns.
-    If a column does not have a corresponding COLINFO record,
-    the width specified in the record STANDARDWIDTH is used. If
-    this record is also not present, the contents of the record
-    DEFCOLWIDTH is used instead.
-    This record also specifies a default XF record to use for
-    cells in the columns that are not described by any cell record
-    (which contain the XF index for that cell). Additionally,
-    the option flags field contains hidden, outline, and collapsed
-    options applied at the columns.
-
-    Record COLINFO, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Index to first column in the range
-    2       2       Index to last column in the range
-    4       2       Width of the columns in 1/256 of the width of the zero character, using default font
-                    (first FONT record in the file)
-    6       2       Index to XF record for default column formatting
-    8       2       Option flags:
-                    Bits    Mask    Contents
-                    0       0001H   1 = Columns are hidden
-                    10-8    0700H   Outline level of the columns (0 = no outline)
-                    12      1000H   1 = Columns are collapsed
-    10      2       Not used
-
-    """
-    _REC_ID = 0x007D
-
-    def __init__(self, first_col, last_col, width, xf_index, options):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<6H', first_col, last_col, width, xf_index, options, 0)
-
-class CalcModeRecord(BiffRecord):
-    """
-    This record is part of the Calculation Settings Block.
-    It specifies whether to calculate formulas manually,
-    automatically or automatically except for multiple table operations.
-
-    Record CALCMODE, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       FFFFH = automatic except for multiple table operations
-                    0000H = manually
-                    0001H = automatically (default)
-    """
-    _REC_ID = 0x000D
-
-    def __init__(self, calc_mode):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<h', calc_mode)
-
-
-class CalcCountRecord(BiffRecord):
-    """
-    This record is part of the Calculation Settings Block. It specifies the maximum
-    number of times the formulas should be iteratively calculated. This is a fail-safe
-    against mutually recursive formulas locking up a spreadsheet application.
-
-    Record CALCCOUNT, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Maximum number of iterations allowed in circular references
-    """
-
-    _REC_ID = 0x000C
-
-    def __init__(self, calc_count):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', calc_count)
-
-class RefModeRecord(BiffRecord):
-    """
-    This record is part of the Calculation Settings Block.
-    It stores which method is used to show cell addresses in formulas.
-    The “RC” mode uses numeric indexes for rows and columns,
-    i.e. “R(1)C(-1)”, or “R1C1:R2C2”.
-    The “A1” mode uses characters for columns and numbers for rows,
-    i.e. “B1”, or “$A$1:$B$2”.
-
-    Record REFMODE, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = RC mode; 1 = A1 mode
-
-    """
-    _REC_ID = 0x00F
-
-    def __init__(self, ref_mode):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', ref_mode)
-
-class IterationRecord(BiffRecord):
-    """
-    This record is part of the Calculation Settings Block.
-    It stores if iterations are allowed while calculating recursive formulas.
-
-    Record ITERATION, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Iterations off; 1 = Iterations on
-    """
-    _REC_ID = 0x011
-
-    def __init__(self, iterations_on):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', iterations_on)
-
-class DeltaRecord(BiffRecord):
-    """
-    This record is part of the Calculation Settings Block.
-    It stores the maximum change of the result to exit an iteration.
-
-    Record DELTA, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       8       Maximum change in iteration
-                    (IEEE 754 floating-point value,
-                     64bit double precision)
-    """
-    _REC_ID = 0x010
-
-    def __init__(self, delta):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<d', delta)
-
-class SaveRecalcRecord(BiffRecord):
-    """
-    This record is part of the Calculation Settings Block.
-    It contains the “Recalculate before save” option in
-    Excel's calculation settings dialogue.
-
-    Record SAVERECALC, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Do not recalculate;
-                    1 = Recalculate before saving the document
-
-    """
-    _REC_ID = 0x05F
-
-    def __init__(self, recalc):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', recalc)
-
-class PrintHeadersRecord(BiffRecord):
-    """
-    This record stores if the row and column headers
-    (the areas with row numbers and column letters) will be printed.
-
-    Record PRINTHEADERS, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Do not print row/column headers;
-                    1 = Print row/column headers
-    """
-    _REC_ID = 0x02A
-
-    def __init__(self, print_headers):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', print_headers)
-
-
-class PrintGridLinesRecord(BiffRecord):
-    """
-    This record stores if sheet grid lines will be printed.
-
-    Record PRINTGRIDLINES, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Do not print sheet grid lines;
-                    1 = Print sheet grid lines
-
-    """
-    _REC_ID = 0x02B
-
-    def __init__(self, print_grid):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', print_grid)
-
-
-class GridSetRecord(BiffRecord):
-    """
-    This record specifies if the option to print sheet grid lines
-    (record PRINTGRIDLINES) has ever been changed.
-
-    Record GRIDSET, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Print grid lines option never changed
-                    1 = Print grid lines option changed
-    """
-    _REC_ID = 0x082
-
-    def __init__(self, print_grid_changed):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', print_grid_changed)
-
-
-class DefaultRowHeight(BiffRecord):
-    """
-    This record specifies the default height and default flags
-    for rows that do not have a corresponding ROW record.
-
-    Record DEFAULTROWHEIGHT, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Option flags:
-                    Bit Mask    Contents
-                    0   0001H   1 = Row height and default font height do not match
-                    1   0002H   1 = Row is hidden
-                    2   0004H   1 = Additional space above the row
-                    3   0008H   1 = Additional space below the row
-    2       2       Default height for unused rows, in twips = 1/20 of a point
-
-    """
-    _REC_ID = 0x0225
-
-    def __init__(self, options, def_height):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<2H', options, def_height)
-
-
-class DefColWidthRecord(BiffRecord):
-    """
-    This record specifies the default column width for columns that
-    do not have a specific width set using the record COLINFO or COLWIDTH.
-    This record has no effect, if a STANDARDWIDTH record is present in the file.
-
-    Record DEFCOLWIDTH, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       2       Column width in characters, using the width of the zero
-                    character from default font (first FONT record in the file)
-    """
-    _REC_ID = 0x0055
-
-    def __init__(self, def_width):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', options, def_width)
-
-class HorizontalPageBreaksRecord(BiffRecord):
-    """
-    This  record  is  part  of  the  Page  Settings  Block. It contains all
-    horizontal manual page breaks.
-
-    Record HORIZONTALPAGEBREAKS, BIFF8:
-    Offset  Size  Contents
-    0       2     Number of following row index structures (nm)
-    2       6nm   List of nm row index structures. Each row index
-                  structure contains:
-                    Offset  Size    Contents
-                    0       2       Index to first row below the page break
-                    2       2       Index to first column of this page break
-                    4       2       Index to last column of this page break
-
-    The row indexes in the lists must be ordered ascending.
-    If in BIFF8 a row contains several page breaks, they must be ordered
-    ascending by start column index.
-    """
-    _REC_ID = 0x001B
-
-    def __init__(self, breaks_list):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', len(breaks_list))
-        for r, c1, c2 in breaks_list:
-            self._rec_data += struct.pack('<3H', r, c1, c2)
-
-class VerticalPageBreaksRecord(BiffRecord):
-    """
-    This  record  is  part  of  the  Page  Settings  Block. It contains all
-    vertical manual page breaks.
-
-    Record VERTICALPAGEBREAKS, BIFF8:
-    Offset  Size  Contents
-    0       2     Number of following column index structures (nm)
-    2       6nm   List of nm column index structures. Each column index
-                  structure contains:
-                    Offset  Size    Contents
-                    0       2       Index to first column following the page
-                                    break
-                    2       2       Index to first row of this page break
-                    4       2       Index to last row of this page break
-
-    The column indexes in the lists must be ordered ascending.
-    If in BIFF8 a column contains several page breaks, they must be ordered
-    ascending by start row index.
-    """
-    _REC_ID = 0x001A
-
-    def __init__(self, breaks_list):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', len(breaks_list))
-        for r, c1, c2 in breaks_list:
-            self._rec_data += struct.pack('<3H', r, c1, c2)
-
-class HeaderRecord(BiffRecord):
-    """
-    This record is part of the Page Settings Block. It specifies the
-    page  header  string  for  the current worksheet. If this record is not
-    present  or  completely  empty  (record  size is 0), the sheet does not
-    contain a page header.
-
-    Record HEADER for non-empty page header, BIFF2-BIFF8:
-    Offset      Size    Contents
-    0           var.    Page header string
-                        BIFF2-BIFF7:    Non-empty byte string, 8bit string
-                        length
-                        BIFF8: Non-empty Unicode string, 16bit string length
-    The  header  string may contain special commands, i.e. placeholders for
-    the  page  number,  current  date, or text formatting attributes. These
-    fields  are  represented  by  single  letters (exception: font name and
-    size,  see  below)  with  a  leading  ampersand ("&"). If the ampersand
-    is  part  of the regular header text, it will be duplicated ("&&"). The
-    page  header is divided into 3 sections: the left, the centred, and the
-    right  section.  Each  section  is introduced by a special command. All
-    text  and all commands following are part of the selected section. Each
-    section  starts  with the text formatting specified in the default font
-    (first  FONT  record  in  the  file). Active formatting attributes from
-    a previous section do not go into the next section.
-
-    The following table shows all available commands:
-
-    Command         Contents
-    &&              The "&" character itself
-    &L              Start of the left section
-    &C              Start of the centred section
-    &R              Start of the right section
-    &P              Current page number
-    &N              Page count
-    &D              Current date
-    &T              Current time
-    &A              Sheet name (BIFF5-BIFF8)
-    &F              File name without path
-    &Z              File path without file name (BIFF8X)
-    &G              Picture (BIFF8X)
-    &B              Bold on/off (BIFF2-BIFF4)
-    &I              Italic on/off (BIFF2-BIFF4)
-    &U              Underlining on/off
-    &E              Double underlining on/off (BIFF5-BIFF8)
-    &S              Strikeout on/off
-    &X              Superscript on/off (BIFF5-BIFF8)
-    &Y              Subscript on/off (BIFF5-BIFF8)
-    &"<fontname>"   Set new font <fontname>
-    &"<fontname>,<fontstyle>"
-                    Set new font with specified style <fontstyle>.
-                    The style <fontstyle> is in most cases one of
-                    "Regular", "Bold", "Italic", or "Bold Italic".
-                    But this setting is dependent on the used font,
-                    it may differ (localised style names, or "Standard",
-                    "Oblique", ...). (BIFF5-BIFF8)
-    &<fontheight>   Set font height in points (<fontheight> is a decimal value).
-                    If this command is followed by a plain number to be printed
-                    in the header, it will be separated from the font height
-                    with a space character.
-
-    """
-    _REC_ID = 0x0014
-
-    def __init__(self, header_str):
-        BiffRecord.__init__(self)
-        self._rec_data = upack2(header_str)
-
-class FooterRecord(BiffRecord):
-    """
-    Semantic is equal to HEADER record
-    """
-    _REC_ID = 0x0015
-
-    def __init__(self, footer_str):
-        BiffRecord.__init__(self)
-        self._rec_data = upack2(footer_str)
-
-
-class HCenterRecord(BiffRecord):
-    """
-    This  record  is  part  of the Page Settings Block. It specifies if the
-    sheet is centred horizontally when printed.
-
-    Record HCENTER, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Print sheet left aligned
-                    1 = Print sheet centred horizontally
-
-    """
-    _REC_ID = 0x0083
-
-    def __init__(self, is_horz_center):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', is_horz_center)
-
-
-class VCenterRecord(BiffRecord):
-    """
-    This  record  is  part  of the Page Settings Block. It specifies if the
-    sheet is centred vertically when printed.
-
-    Record VCENTER, BIFF3-BIFF8:
-
-    Offset  Size    Contents
-    0       2       0 = Print sheet aligned at top page border
-                    1 = Print sheet vertically centred
-
-    """
-    _REC_ID = 0x0084
-
-    def __init__(self, is_vert_center):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<H', is_vert_center)
-
-
-class LeftMarginRecord(BiffRecord):
-    """
-    This  record  is  part of the Page Settings Block. It contains the left
-    page margin of the current worksheet.
-
-    Record LEFTMARGIN, BIFF2-BIFF8:
-
-    Offset  Size    Contents
-    0       8       Left page margin in inches
-                    (IEEE 754 floating-point value, 64bit double precision)
-
-    """
-    _REC_ID = 0x0026
-
-    def __init__(self, margin):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<d', margin)
-
-
-class RightMarginRecord(BiffRecord):
-    """
-    This  record  is  part of the Page Settings Block. It contains the right
-    page margin of the current worksheet.
-
-    Offset  Size    Contents
-    0       8       Right page margin in inches
-                    (IEEE 754 floating-point value, 64?bit double precision)
-
-    """
-    _REC_ID = 0x0027
-
-    def __init__(self, margin):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<d', margin)
-
-class TopMarginRecord(BiffRecord):
-    """
-    This  record  is  part of the Page Settings Block. It contains the top
-    page margin of the current worksheet.
-
-    Offset  Size    Contents
-    0       8       Top page margin in inches
-                    (IEEE 754 floating-point value, 64?bit double precision)
-
-    """
-    _REC_ID = 0x0028
-
-    def __init__(self, margin):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<d', margin)
-
-
-class BottomMarginRecord(BiffRecord):
-    """
-    This  record  is  part of the Page Settings Block. It contains the bottom
-    page margin of the current worksheet.
-
-    Offset  Size    Contents
-    0       8       Bottom page margin in inches
-                    (IEEE 754 floating-point value, 64?bit double precision)
-
-    """
-    _REC_ID = 0x0029
-
-    def __init__(self, margin):
-        BiffRecord.__init__(self)
-        self._rec_data = struct.pack('<d', margin)
-
-class SetupPageRecord(BiffRecord):
-    """
-    This   record   is  part of the Page Settings Block. It stores the page
-    format   settings   of   the  current sheet. The pages may be scaled in
-    percent   or  by  using  an  absolute  number of pages. This setting is
-    located   in  the  WSBOOL  record.  If  pages  are  scaled in  percent,
-    the   scaling  factor  in  this  record is used, otherwise the "Fit  to
-    pages"  values. One of the "Fit to pages" values may be 0. In this case
-    the sheet is scaled to fit only to the other value.
-
-    Record SETUP, BIFF5-BIFF8:
-
-    Offset      Size    Contents
-    0           2       Paper size (see below)
-    2           2       Scaling factor in percent
-    4           2       Start page number
-    6           2       Fit worksheet width to this number of pages
-                        (0 = use as many as needed)
-    8           2       Fit worksheet height to this number of pages
-                        (0 = use as many as needed)
-    10          2       Option flags:
-                        Bit     Mask        Contents
-                        0       0001H       0 = Print pages in columns
-                                            1 = Print pages in rows
-                        1       0002H       0 = Landscape
-                                            1 = Portrait
-                        2       0004H       1 = Paper size, scaling factor,
-                                            paper orientation (portrait/landscape),
-                                            print resolution and number of copies
-                                            are not initialised
-                        3       0008H       0 = Print coloured
-                                            1 = Print black and white
-                        4       0010H       0 = Default print quality
-                                            1 = Draft quality
-                        5       0020H       0 = Do not print cell notes
-                                            1 = Print cell notes
-                        6       0040H       0 = Paper orientation setting is valid
-                                            1 = Paper orientation setting not
-                                            initialised
-                        7       0080H       0 = Automatic page numbers
-                                            1 = Use start page number
-                        The following flags are valid for BIFF8 only:
-                        9       0200H       0 = Print notes as displayed
-                                            1 = Print notes at end of sheet
-                        11-10   0C00H       00 = Print errors as displayed
-                                            01 = Do not print errors
-                                            10 = Print errors as "--"
-                                            11 = Print errors as "#N/A!"
-    12          2       Print resolution in dpi
-    14          2       Vertical print resolution in dpi
-    16          8       Header margin (IEEE 754 floating-point value,
-                        64bit double precision)
-    24          8       Footer margin (IEEE 754 floating-point value,
-                        64bit double precision)
-    32          2       Number of copies to print
-
-
-    PAPER TYPES:
-
-    Index   Paper type              Paper size
-    0       Undefined
-    1       Letter                  8 1/2" x 11"
-    2       Letter small            8 1/2" x 11"
-    3       Tabloid                 11" x 17"
-    4       Ledger                  17" x 11"
-    5       Legal                   8 1/2" x 14"
-    6       Statement               5 1/2" x 8 1/2"
-    7       Executive               7 1/4" x 10 1/2"
-    8       A3                      297mm x 420mm
-    9       A4                      210mm x 297mm
-    10      A4 small                210mm x 297mm
-    11      A5                      148mm x 210mm
-    12      B4 (JIS)                257mm x 364mm
-    13      B5 (JIS)                182mm x 257mm
-    14      Folio                   8 1/2" x 13"
-    15      Quarto                  215mm x 275mm
-    16      10x14                   10" x 14"
-    17      11x17                   11" x 17"
-    18      Note                    8 1/2" x 11"
-    19      Envelope #9             3 7/8" x 8 7/8"
-    20      Envelope #10            4 1/8" x 9 1/2"
-    21      Envelope #11            4 1/2" x 10 3/8"
-    22      Envelope #12            4 3/4" x 11"
-    23      Envelope #14            5" x 11 1/2"
-    24      C                       17" x 22"
-    25      D                       22" x 34"
-    26      E                       34" x 44"
-    27      Envelope DL             110mm x 220mm
-    28      Envelope C5             162mm x 229mm
-    29      Envelope C3             324mm x 458mm
-    30      Envelope C4             229mm x 324mm
-    31      Envelope C6             114mm x 162mm
-    32      Envelope C6/C5          114mm x 229mm
-    33      B4 (ISO)                250mm x 353mm
-    34      B5 (ISO)                176mm x 250mm
-    35      B6 (ISO)                125mm x 176mm
-    36      Envelope Italy          110mm x 230mm
-    37      Envelope Monarch        3 7/8" x 7 1/2"
-    38      63/4 Envelope           3 5/8" x 6 1/2"
-    39      US Standard Fanfold     14 7/8" x 11"
-    40      German Std. Fanfold     8 1/2" x 12"
-    41      German Legal Fanfold    8 1/2" x 13"
-    42      B4 (ISO)                250mm x 353mm
-    43      Japanese Postcard       100mm x 148mm
-    44      9x11                    9" x 11"
-    45      10x11                   10" x 11"
-    46      15x11                   15" x 11"
-    47      Envelope Invite         220mm x 220mm
-    48      Undefined
-    49      Undefined
-    50      Letter Extra            9 1/2" x 12"
-    51      Legal Extra             9 1/2" x 15"
-    52      Tabloid Extra           11 11/16" x 18"
-    53      A4 Extra                235mm x 322mm
-    54      Letter Transverse       8 1/2" x 11"
-    55      A4 Transverse           210mm x 297mm
-    56      Letter Extra Transv.    9 1/2" x 12"
-    57      Super A/A4              227mm x 356mm
-    58      Super B/A3              305mm x 487mm
-    59      Letter Plus             8 1/2" x 12 11/16"
-    60      A4 Plus                 210mm x 330mm
-    61      A5 Transverse           148mm x 210mm
-    62      B5 (JIS) Transverse     182mm x 257mm
-    63      A3 Extra                322mm x 445mm
-    64      A5 Extra                174mm x 235mm
-    65      B5 (ISO) Extra          201mm x 276mm
-    66      A2                      420mm x 594mm
-    67      A3 Transverse           297mm x 420mm
-    68      A3 Extra Transverse     322mm x 445mm
-    69      Dbl. Japanese Postcard  200mm x 148mm
-    70      A6                      105mm x 148mm
-    71
-    72
-    73
-    74
-    75      Letter Rotated          11" x 8 1/2"
-    76      A3 Rotated              420mm x 297mm
-    77      A4 Rotated              297mm x 210mm
-    78      A5 Rotated              210mm x 148mm
-    79      B4 (JIS) Rotated        364mm x 257mm
-    80      B5 (JIS) Rotated        257mm x 182mm
-    81      Japanese Postcard Rot.  148mm x 100mm
-    82      Dbl. Jap. Postcard Rot. 148mm x 200mm
-    83      A6 Rotated              148mm x 105mm
-    84
-    85
-    86
-    87
-    88      B6 (JIS)                128mm x 182mm
-    89      B6 (JIS) Rotated        182mm x 128mm
-    90      12x11                   12" x 11"
-
-    """
-    _REC_ID = 0x00A1
-    def __init__(self, paper, scaling, start_num, fit_width_to, fit_height_to,
-                    options,
-                    hres, vres,
-                    header_margin, footer_margin,
-                    num_copies):
-        BiffRecord.__init__(self)
-
-        self._rec_data = struct.pack('<8H2dH', paper, scaling, start_num,
-                                        fit_width_to, fit_height_to, \
-                                        options,
-                                        hres, vres,
-                                        header_margin, footer_margin,
-                                        num_copies)
-
-class NameRecord(BiffRecord):
-    """
-    This record is part of a Link Table. It contains the name and the token
-    array of an internal defined name. Token arrays of defined names
-    contain tokens with aberrant token classes.
-
-    Record NAME, BIFF5/BIFF7:
-    Offset      Size    Contents
-       0          2     Option flags, see below
-       2          1     Keyboard shortcut (only for command macro names, see below)
-       3          1     Length of the name (character count, ln)
-       4          2     Size of the formula data (sz)
-       6          2     0 = Global name, otherwise index to EXTERNSHEET record (one-based)
-       8          2     0 = Global name, otherwise index to sheet (one-based)
-      10          1     Length of menu text (character count, lm)
-      11          1     Length of description text (character count, ld)
-      12          1     Length of help topic text (character count, lh)
-      13          1     Length of status bar text (character count, ls)
-      14         ln     Character array of the name
-    14+ln        sz     Formula data (RPN token array without size field, 4)
-  14+ln+sz       lm     Character array of menu text
-     var.        ld     Character array of description text
-     var.        lh     Character array of help topic text
-     var.        ls     Character array of status bar text
-
-    Record NAME, BIFF8:
-    Offset      Size Contents
-       0          2  Option flags, see below
-       2          1  Keyboard shortcut (only for command macro names, see below)
-       3          1  Length of the name (character count, ln)
-       4          2  Size of the formula data (sz)
-       6          2  Not used
-       8          2  0 = Global name, otherwise index to sheet (one-based)
-      10          1  Length of menu text (character count, lm)
-      11          1  Length of description text (character count, ld)
-      12          1  Length of help topic text (character count, lh)
-      13          1  Length of status bar text (character count, ls)
-      14        var. Name (Unicode string without length field, 3.4)
-     var.        sz  Formula data (RPN token array without size field, 4)
-    [var.]      var. (optional, only if lm > 0) Menu text (Unicode string without length field, 3.4)
-    [var.]      var. (optional, only if ld > 0) Description text (Unicode string without length field, 3.4)
-    [var.]      var. (optional, only if lh > 0) Help topic text (Unicode string without length field, 3.4)
-    [var.]      var. (optional, only if ls > 0) Status bar text (Unicode string without length field, 3.4)
-    """
-    _REC_ID = 0x0018
-
-    def __init__(self, options, keyboard_shortcut, name, sheet_index, rpn, menu_text='', desc_text='', help_text='', status_text=''):
-        BiffRecord.__init__(self)
-        if type(name) == int:
-            uname = chr(name)
-        else:
-            uname = upack1(name)[1:]
-        uname_len = len(uname)
-        
-        #~ self._rec_data = struct.pack('<HBBHHHBBBB%ds%ds' % (uname_len, len(rpn)), options, keyboard_shortcut, uname_len, len(rpn), 0x0000, sheet_index, len(menu_text), len(desc_text), len(help_text), len(status_text), uname, rpn) + menu_text + desc_text + help_text + status_text
-        self._rec_data = struct.pack('<HBBHHHBBBBB%ds%ds' % (uname_len, len(rpn)), options, keyboard_shortcut, uname_len, len(rpn), 0x0000, sheet_index, 0x00, len(menu_text), len(desc_text), len(help_text), len(status_text), uname, rpn) + menu_text + desc_text + help_text + status_text
-        
-        #~ print repr(self.get())
-        #~ print repr(self._rec_data)
-        #~ print len(self._rec_data)
-
-class ExternSheetRecord(BiffRecord):
-    """
-    In BIFF8 the record stores a list with indexes to SUPBOOK
-    records (list of REF structures, 6.100). See 5.10.3 for 
-    details about external references in BIFF8.
-    
-    Record EXTERNSHEET, BIFF8:
-    Offset          Size      Contents
-       0             2        Number of following REF structures (nm)
-       2           6nm        List of nm REF structures. Each REF contains the following data:
-                              Offset     Size     Contents
-                                 0         2      Index to SUPBOOK record
-                                 2         2      Index to first SUPBOOK sheet
-                                 4         2      Index to last SUPBOOK sheet
-    """
-    _REC_ID = 0x0017
-
-    def __init__(self, refs=[]):
-        BiffRecord.__init__(self)
-        
-        # do we always need this ref? or only if there are no refs?
-        refs.insert(0, (0,0,0))
-        #~ ref_data = ''.join([ref.get() for r in refs])
-        ref_data = ''.join([struct.pack('<HHH', *r) for r in refs])
-        self._rec_data = struct.pack('<H%ds' % (len(refs)*6), len(refs), ref_data)
-
-class SupBookRecord(BiffRecord):
-    """
-    This record mainly stores the URL of an external document
-    and a list of sheet names inside this document. Furthermore
-    it is used to store DDE and OLE object links, or to indicate
-    an internal 3D reference or an add-in function. See 5.10.3
-    for details about external references in BIFF8.
-    
-    """
-    _REC_ID = 0x01AE
-
-    def __init__(self):
-        BiffRecord.__init__(self)
-
-class InternalReferenceSupBookRecord(SupBookRecord):
-    """
-    In each file occurs a SUPBOOK that is used for internal 3D
-    references. It stores the number of sheets of the own document.
-    
-    Record SUPBOOK for 3D references, BIFF8:
-    Offset         Size   Contents
-      0             2     Number of sheets in this document
-      2             2     01H 04H (relict of BIFF5/BIFF7, the byte string "<04H>", see 3.9.1)
-
-    """
-
-    def __init__(self, num_sheets):
-        SupBookRecord.__init__(self)
-        
-        self._rec_data = struct.pack('<HBB', num_sheets, 0x01, 0x04)

+ 0 - 305
desktop/core/ext-py/pyexcelerator/pyExcelerator/Bitmap.py

@@ -1,305 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-
-#  Portions are Copyright (c) 2004 Evgeny Filatov <fufff@users.sourceforge.net>
-
-#  Portions are Copyright (c) 2002-2004 John McNamara (Perl Spreadsheet::WriteExcel)
-
-#  All rights reserved.
-
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-__rev_id__ = """$Id: Bitmap.py,v 1.4 2005/07/20 07:24:11 rvk Exp $"""
-
-
-from BIFFRecords import BiffRecord
-from struct import *
-
-
-def _size_col(sheet, col):
-    return sheet.col_width(col)
-
-
-def _size_row(sheet, row):
-    return sheet.row_height(row)     
-
-
-def _position_image(sheet, row_start, col_start, x1, y1, width, height):
-    """Calculate the vertices that define the position of the image as required by
-    the OBJ record.
-
-             +------------+------------+
-             |     A      |      B     |
-       +-----+------------+------------+
-       |     |(x1,y1)     |            |
-       |  1  |(A1)._______|______      |
-       |     |    |              |     |
-       |     |    |              |     |
-       +-----+----|    BITMAP    |-----+
-       |     |    |              |     |
-       |  2  |    |______________.     |
-       |     |            |        (B2)|
-       |     |            |     (x2,y2)|
-       +---- +------------+------------+
-
-    Example of a bitmap that covers some of the area from cell A1 to cell B2.
-
-    Based on the width and height of the bitmap we need to calculate 8 vars:
-        col_start, row_start, col_end, row_end, x1, y1, x2, y2.
-    The width and height of the cells are also variable and have to be taken into
-    account.
-    The values of col_start and row_start are passed in from the calling
-    function. The values of col_end and row_end are calculated by subtracting
-    the width and height of the bitmap from the width and height of the
-    underlying cells.
-    The vertices are expressed as a percentage of the underlying cell width as
-    follows (rhs values are in pixels):
-
-           x1 = X / W *1024
-           y1 = Y / H *256
-           x2 = (X-1) / W *1024
-           y2 = (Y-1) / H *256
-
-           Where:  X is distance from the left side of the underlying cell
-                   Y is distance from the top of the underlying cell
-                   W is the width of the cell
-                   H is the height of the cell
-
-    Note: the SDK incorrectly states that the height should be expressed as a
-    percentage of 1024.
-
-    col_start  - Col containing upper left corner of object
-    row_start  - Row containing top left corner of object
-    x1  - Distance to left side of object
-    y1  - Distance to top of object
-    width  - Width of image frame
-    height  - Height of image frame
-    
-    """
-    # Adjust start column for offsets that are greater than the col width
-    while x1 >= _size_col(sheet, col_start):
-        x1 -= _size_col(sheet, col_start)
-        col_start += 1
-    # Adjust start row for offsets that are greater than the row height
-    while y1 >= _size_row(sheet, row_start):
-        y1 -= _size_row(sheet, row_start)
-        row_start += 1
-    # Initialise end cell to the same as the start cell
-    row_end = row_start   # Row containing bottom right corner of object
-    col_end = col_start   # Col containing lower right corner of object
-    width = width + x1 - 1
-    height = height + y1 - 1
-    # Subtract the underlying cell widths to find the end cell of the image
-    while (width >= _size_col(sheet, col_end)):
-        width -= _size_col(sheet, col_end)
-        col_end += 1
-    # Subtract the underlying cell heights to find the end cell of the image
-    while (height >= _size_row(sheet, row_end)):
-        height -= _size_row(sheet, row_end)
-        row_end += 1
-    # Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell
-    # with zero height or width.
-    if ((_size_col(sheet, col_start) == 0) or (_size_col(sheet, col_end) == 0)
-            or (_size_row(sheet, row_start) == 0) or (_size_row(sheet, row_end) == 0)):
-        return
-    # Convert the pixel values to the percentage value expected by Excel
-    x1 = float(x1) / _size_col(sheet, col_start) * 1024
-    y1 = float(y1) / _size_row(sheet, row_start) * 256
-    # Distance to right side of object
-    x2 = float(width) / _size_col(sheet, col_end) * 1024
-    # Distance to bottom of object
-    y2 = float(height) / _size_row(sheet, row_end) * 256
-    return (col_start, x1, row_start, y1, col_end, x2, row_end, y2)
-
-
-class ObjBmpRecord(BiffRecord):
-    _REC_ID = 0x005D    # Record identifier
-
-    def __init__(self, row, col, sheet, im_data_bmp, x, y, scale_x, scale_y):
-        # Scale the frame of the image.
-        width = im_data_bmp.width * scale_x
-        height = im_data_bmp.height * scale_y
-
-        # Calculate the vertices of the image and write the OBJ record
-        col_start, x1, row_start, y1, col_end, x2, row_end, y2 = _position_image(sheet, row, col, x, y, width, height)
-
-        """Store the OBJ record that precedes an IMDATA record. This could be generalise
-        to support other Excel objects.
-
-        """
-        cObj = 0x0001      # Count of objects in file (set to 1)
-        OT = 0x0008        # Object type. 8 = Picture
-        id = 0x0001        # Object ID
-        grbit = 0x0614     # Option flags
-        colL = col_start    # Col containing upper left corner of object
-        dxL = x1            # Distance from left side of cell
-        rwT = row_start     # Row containing top left corner of object
-        dyT = y1            # Distance from top of cell
-        colR = col_end      # Col containing lower right corner of object
-        dxR = x2            # Distance from right of cell
-        rwB = row_end       # Row containing bottom right corner of object
-        dyB = y2            # Distance from bottom of cell
-        cbMacro = 0x0000    # Length of FMLA structure
-        Reserved1 = 0x0000  # Reserved
-        Reserved2 = 0x0000  # Reserved
-        icvBack = 0x09      # Background colour
-        icvFore = 0x09      # Foreground colour
-        fls = 0x00          # Fill pattern
-        fAuto = 0x00        # Automatic fill
-        icv = 0x08          # Line colour
-        lns = 0xff          # Line style
-        lnw = 0x01          # Line weight
-        fAutoB = 0x00       # Automatic border
-        frs = 0x0000        # Frame style
-        cf = 0x0009         # Image format, 9 = bitmap
-        Reserved3 = 0x0000  # Reserved
-        cbPictFmla = 0x0000 # Length of FMLA structure
-        Reserved4 = 0x0000  # Reserved
-        grbit2 = 0x0001     # Option flags
-        Reserved5 = 0x0000  # Reserved
-        
-        data = pack("<L", cObj)
-        data += pack("<H", OT)
-        data += pack("<H", id)
-        data += pack("<H", grbit)
-        data += pack("<H", colL)
-        data += pack("<H", dxL)
-        data += pack("<H", rwT)
-        data += pack("<H", dyT)
-        data += pack("<H", colR)
-        data += pack("<H", dxR)
-        data += pack("<H", rwB)
-        data += pack("<H", dyB)
-        data += pack("<H", cbMacro)
-        data += pack("<L", Reserved1)
-        data += pack("<H", Reserved2)
-        data += pack("<B", icvBack)
-        data += pack("<B", icvFore)
-        data += pack("<B", fls)
-        data += pack("<B", fAuto)
-        data += pack("<B", icv)
-        data += pack("<B", lns)
-        data += pack("<B", lnw)
-        data += pack("<B", fAutoB)
-        data += pack("<H", frs)
-        data += pack("<L", cf)
-        data += pack("<H", Reserved3)
-        data += pack("<H", cbPictFmla)
-        data += pack("<H", Reserved4)
-        data += pack("<H", grbit2)
-        data += pack("<L", Reserved5)
-
-        self._rec_data = data
-
-def _process_bitmap(bitmap):
-    """Convert a 24 bit bitmap into the modified internal format used by Windows.
-    This is described in BITMAPCOREHEADER and BITMAPCOREINFO structures in the
-    MSDN library.
-
-    """
-    # Open file and binmode the data in case the platform needs it.
-    fh = file(bitmap, "rb")
-    try:
-        # Slurp the file into a string.
-        data = fh.read()
-    finally:
-        fh.close()
-    # Check that the file is big enough to be a bitmap.
-    if len(data) <= 0x36:
-        raise Exception("bitmap doesn't contain enough data.")
-    # The first 2 bytes are used to identify the bitmap.
-    if (data[:2] != "BM"):
-        raise Exception("bitmap doesn't appear to to be a valid bitmap image.")
-    # Remove bitmap data: ID.
-    data = data[2:]
-    # Read and remove the bitmap size. This is more reliable than reading
-    # the data size at offset 0x22.
-    #
-    size = unpack("<L", data[:4])[0]
-    size -=  0x36   # Subtract size of bitmap header.
-    size +=  0x0C   # Add size of BIFF header.
-    data = data[4:]
-    # Remove bitmap data: reserved, offset, header length.
-    data = data[12:]
-    # Read and remove the bitmap width and height. Verify the sizes.
-    width, height = unpack("<LL", data[:8])
-    data = data[8:]
-    if (width > 0xFFFF):
-        raise Exception("bitmap: largest image width supported is 65k.")
-    if (height > 0xFFFF):
-        raise Exception("bitmap: largest image height supported is 65k.")
-    # Read and remove the bitmap planes and bpp data. Verify them.
-    planes, bitcount = unpack("<HH", data[:4])
-    data = data[4:]
-    if (bitcount != 24):
-        raise Exception("bitmap isn't a 24bit true color bitmap.")
-    if (planes != 1):
-        raise Exception("bitmap: only 1 plane supported in bitmap image.")
-    # Read and remove the bitmap compression. Verify compression.
-    compression = unpack("<L", data[:4])[0]
-    data = data[4:]
-    if (compression != 0):
-        raise Exception("bitmap: compression not supported in bitmap image.")
-    # Remove bitmap data: data size, hres, vres, colours, imp. colours.
-    data = data[20:]
-    # Add the BITMAPCOREHEADER data
-    header = pack("<LHHHH", 0x000c, width, height, 0x01, 0x18)
-    data = header + data
-    return (width, height, size, data)
-
-
-class ImDataBmpRecord(BiffRecord):
-    _REC_ID = 0x007F
-
-    def __init__(self, filename):
-        """Insert a 24bit bitmap image in a worksheet. The main record required is
-        IMDATA but it must be proceeded by a OBJ record to define its position.
-
-        """
-        BiffRecord.__init__(self)
-
-        self.width, self.height, self.size, data = _process_bitmap(filename)
-        # Write the IMDATA record to store the bitmap data
-        cf = 0x09
-        env = 0x01
-        lcb = self.size
-        self._rec_data = pack("<HHL", cf, env, lcb) + data
-
-

+ 0 - 200
desktop/core/ext-py/pyexcelerator/pyExcelerator/Cell.py

@@ -1,200 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-__rev_id__ = """$Id: Cell.py,v 1.3 2005/08/11 08:53:48 rvk Exp $"""
-
-
-import struct
-import BIFFRecords
-from ExcelFormula import ErrorCode
-
-class StrCell(object):
-    __slots__ = ["__init__", "get_biff_data",
-                "__parent", "__idx", "__xf_idx", "__sst_idx"]
-
-    def __init__(self, parent, idx, xf_idx, sst_idx):
-        self.__parent = parent
-        self.__idx = idx
-        self.__xf_idx = xf_idx
-        self.__sst_idx = sst_idx
-
-    def get_biff_data(self):
-        return BIFFRecords.LabelSSTRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, self.__sst_idx).get()
-
-
-class BlankCell(object):
-    __slots__ = ["__init__", "get_biff_data",
-                "__parent", "__idx", "__xf_idx"]
-
-    def __init__(self, parent, idx, xf_idx):
-        self.__parent = parent
-        self.__idx = idx
-        self.__xf_idx = xf_idx
-
-    def get_biff_data(self):
-        return BIFFRecords.BlankRecord(self.__parent.get_index(), self.__idx, self.__xf_idx).get()
-
-
-class MulBlankCell(object):
-    __slots__ = ["__init__", "get_biff_data",
-                "__parent", "__col1", "__col2", "__xf_idx"]
-
-    def __init__(self, parent, col1, col2, xf_idx):
-        assert col1 < col2, '%d < %d is false'%(col1, col2)
-        self.__parent = parent
-        self.__col1 = col1
-        self.__col2 = col2
-        self.__xf_idx = xf_idx
-
-    def get_biff_data(self):
-        return BIFFRecords.MulBlankRecord(self.__parent.get_index(), self.__col1, self.__col2, self.__xf_idx).get()
-
-
-class NumberCell(object):
-    __slots__ = ["__init__", "get_biff_data",
-                "__parent", "__idx", "__xf_idx", "__number"]
-
-
-    def __init__(self, parent, idx, xf_idx, number):
-        self.__parent = parent
-        self.__idx = idx
-        self.__xf_idx = xf_idx
-        self.__number = float(number)
-
-
-    def get_biff_data(self):
-        rk_encoded = 0
-
-        packed = struct.pack('<d', self.__number)
-
-        #print self.__number
-        w0, w1, w2, w3 = struct.unpack('<4H', packed)
-        if w0 == 0 and w1 == 0 and w2 & 0xFFFC == w2:
-            # 34 lsb are 0
-            #print "float RK"
-            rk_encoded = (w3 << 16) | w2
-            return BIFFRecords.RKRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
-
-        if abs(self.__number) < 0x20000000 and int(self.__number) == self.__number:
-            #print "30-bit integer RK"
-            rk_encoded = (2 | (int(self.__number) << 2)) & 0xffffffffL
-            return BIFFRecords.RKRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
-
-        temp = self.__number*100
-        packed100 = struct.pack('<d', temp)
-        w0, w1, w2, w3 = struct.unpack('<4H', packed100)
-        if w0 == 0 and w1 == 0 and w2 & 0xFFFC == w2:
-            # 34 lsb are 0
-            #print "float RK*100"
-            rk_encoded = 1 | (w3 << 16) | w2
-            return BIFFRecords.RKRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
-
-        if abs(temp) < 0x20000000 and int(temp) == temp:
-            #print "30-bit integer RK*100"
-            rk_encoded = (3 | (int(temp) << 2)) & 0xffffffffL
-            return BIFFRecords.RKRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
-
-        #print "Number" 
-        #print
-        return BIFFRecords.NumberRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, self.__number).get()
-
-
-class MulNumberCell(object):
-    __slots__ = ["__init__", "get_biff_data"]
-
-    def __init__(self, parent, idx, xf_idx, sst_idx):
-        self.__parent = parent
-        self.__idx = idx
-        self.__xf_idx = xf_idx
-        self.__sst_idx = sst_idx
-
-
-    def get_biff_data(self):
-        raise Exception
-
-
-class FormulaCell(object):
-    __slots__ = ["__init__", "get_biff_data", "result",
-                "__parent", "__idx", "__xf_idx", "__result", "__opts", "__frmla", "__str"]
-
-    def __init__(self, parent, idx, xf_idx, frmla):
-        self.__str = None
-        self.__parent = parent
-        self.__idx = idx
-        self.__xf_idx = xf_idx
-        self.result = frmla.default
-        self.__opts = frmla.opts != None and frmla.opts or self.__parent.frmla_opts
-        self.__frmla = frmla
-
-
-    def get_biff_data(self):
-        frmla_block_data = BIFFRecords.FormulaRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, self.__result, self.__opts, self.__frmla.rpn()).get()
-        if self.__str:
-            frmla_block_data += BIFFRecords.StringRecord(self.__str).get()
-        return frmla_block_data
-
-    def set_result(self, value):
-        self.__result = self._convertToResult(value)
-
-    def get_result(self):
-        return self.__result
-
-    result = property(get_result, set_result)
-
-    def _convertToResult(self, val):
-        ret = 0
-        self.__str = ''
-        if isinstance(val, (int, float)):
-            ret = struct.pack('<d', val)
-        else:
-            if isinstance(val, bool):
-                ret = struct.pack('BxB3x', 0x01, val and 0x01 or 0x00)
-            elif isinstance(val, ErrorCode):
-                ret = struct.pack('BxB3x', 0x02, val.int())
-            elif (isinstance(val, (unicode, str)) and val) or bool(val):
-                ret = struct.pack('B5x', 0x00)
-                self.__str = unicode(val)
-            elif not val:
-                ret = struct.pack('B5x', 0x03)
-            ret += struct.pack('<H', 0xFFFF)
-        return struct.unpack('<Q', ret)[0]
-

+ 0 - 82
desktop/core/ext-py/pyexcelerator/pyExcelerator/Column.py

@@ -1,82 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-__rev_id__ = """$Id: Column.py,v 1.4 2005/07/20 07:24:11 rvk Exp $"""
-
-
-import Style
-from BIFFRecords import ColInfoRecord
-from Deco import *
-from Worksheet import Worksheet
-
-
-class Column(object):
-    @accepts(object, int, Worksheet)
-    def __init__(self, indx, parent_sheet):
-        self.__index = indx
-        self.__parent = parent_sheet
-        self.__parent_wb = parent_sheet.get_parent()
-        self.__xf_index = 0x0F
-        
-        self.width = 0x0B92
-        self.hidden = 0
-        self.level = 0
-        self.collapse = 0
-
-
-    def get_biff_record(self):
-        options =  (self.hidden & 0x01) << 0
-        options |= (self.level & 0x07) << 8
-        options |= (self.collapse & 0x01) << 12
-        
-        return ColInfoRecord(self.__index, self.__index, self.width, self.__xf_index, options).get()
-        
-        
-    @accepts(object, Style.XFStyle)
-    def set_style(self, style):
-        # self.__adjust_height(style)
-        self.__xf_index = self.__parent_wb.add_style(style)        
-        
-
-    def get_index(self):
-        return self.__index
-        

+ 0 - 571
desktop/core/ext-py/pyexcelerator/pyExcelerator/CompoundDoc.py

@@ -1,571 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-import sys
-import struct
-
-
-
-__rev_id__ = """$Id: CompoundDoc.py,v 1.7 2005/10/26 07:44:24 rvk Exp $"""
-
-        
-class Reader:
-    def __init__(self, filename, dump = False):
-        self.dump = dump
-        self.STREAMS = {}
-
-        f = filename
-        if not hasattr(filename, 'read'):
-            f = file(filename, 'rb')
-        doc = f.read()
-        self.header, self.data = doc[0:512], doc[512:]
-        del doc
-
-        self.__build_header()
-        self.__build_MSAT()
-        self.__build_SAT()
-        self.__build_directory()
-        self.__build_short_sectors_data()
-        
-        if len(self.short_sectors_data) > 0:
-            self.__build_SSAT()
-        else:
-            if self.dump and (self.total_ssat_sectors != 0 or self.ssat_start_sid != -2):
-                print 'NOTE: header says that must be', self.total_ssat_sectors, 'short sectors'
-                print 'NOTE: starting at', self.ssat_start_sid, 'sector'
-                print 'NOTE: but file does not contains data in short sectors'
-            self.ssat_start_sid = -2
-            self.total_ssat_sectors = 0
-            self.SSAT = [-2]
-
-        for dentry in self.dir_entry_list[1:]:
-            (did, 
-             sz, name, 
-             t, c, 
-             did_left, did_right, did_root, 
-             dentry_start_sid, 
-             stream_size
-            ) = dentry
-            stream_data = ''
-            if stream_size > 0:
-                if stream_size >= self.min_stream_size:
-                    args = (self.data, self.SAT, dentry_start_sid, self.sect_size)
-                else:
-                    args = (self.short_sectors_data, self.SSAT, dentry_start_sid, self.short_sect_size)
-                stream_data = self.get_stream_data(*args)
-
-            if name != '':
-                # BAD IDEA: names may be equal. NEED use full paths...
-                self.STREAMS[name] = stream_data
-
-    
-    def __build_header(self):
-        self.doc_magic             = self.header[0:8]
-
-        if self.doc_magic != '\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1':
-            raise Exception, 'Not an OLE file.'
-
-        self.file_uid              = self.header[8:24]
-        self.rev_num               = self.header[24:26]
-        self.ver_num               = self.header[26:28]
-        self.byte_order            = self.header[28:30]
-        self.log2_sect_size,       = struct.unpack('<H', self.header[30:32])
-        self.log2_short_sect_size, = struct.unpack('<H', self.header[32:34])
-        self.total_sat_sectors,    = struct.unpack('<L', self.header[44:48])
-        self.dir_start_sid,        = struct.unpack('<l', self.header[48:52])
-        self.min_stream_size,      = struct.unpack('<L', self.header[56:60])
-        self.ssat_start_sid,       = struct.unpack('<l', self.header[60:64])
-        self.total_ssat_sectors,   = struct.unpack('<L', self.header[64:68])
-        self.msat_start_sid,       = struct.unpack('<l', self.header[68:72])
-        self.total_msat_sectors,   = struct.unpack('<L', self.header[72:76])
-         
-        self.sect_size        = 1 << self.log2_sect_size
-        self.short_sect_size  = 1 << self.log2_short_sect_size
-
-        if self.dump:
-            print 'file magic: '
-            print_bin_data(self.doc_magic)
-
-            print 'file uid: '
-            print_bin_data(self.file_uid)
-
-            print 'revision number: '
-            print_bin_data(self.rev_num)
-         
-            print 'version number: '
-            print_bin_data(self.ver_num)
-            
-            print 'byte order: '
-            print_bin_data(self.byte_order)
-            
-            print 'sector size                                :', hex(self.sect_size), self.sect_size
-            #print 'total sectors in file                      :', hex(self.total_sectors), self.total_sectors
-            print 'short sector size                          :', hex(self.short_sect_size), self.short_sect_size
-            print 'Total number of sectors used for the SAT   :', hex(self.total_sat_sectors), self.total_sat_sectors
-            print 'SID of first sector of the directory stream:', hex(self.dir_start_sid), self.dir_start_sid
-            print 'Minimum size of a standard stream          :', hex(self.min_stream_size), self.min_stream_size
-            print 'SID of first sector of the SSAT            :', hex(self.ssat_start_sid), self.ssat_start_sid
-            print 'Total number of sectors used for the SSAT  :', hex(self.total_ssat_sectors), self.total_ssat_sectors
-            print 'SID of first additional sector of the MSAT :', hex(self.msat_start_sid), self.msat_start_sid
-            print 'Total number of sectors used for the MSAT  :', hex(self.total_msat_sectors), self.total_msat_sectors
-
-
-    def __build_MSAT(self):
-        self.MSAT = list(struct.unpack('<109l', self.header[76:]))
-        
-        next = self.msat_start_sid
-        while next > 0:
-           msat_sector = struct.unpack('<128l', self.data[next*self.sect_size:(next+1)*self.sect_size])
-           self.MSAT.extend(msat_sector[:127])
-           next = msat_sector[-1]
-
-        if self.dump:
-            print 'MSAT (header part): \n', self.MSAT[:109]
-            print 'additional MSAT sectors: \n', self.MSAT[109:]
-
-
-    def __build_SAT(self):
-        sat_stream = ''.join([self.data[i*self.sect_size:(i+1)*self.sect_size] for i in self.MSAT if i >= 0])
-
-        sat_sids_count = len(sat_stream) >> 2
-        self.SAT = struct.unpack('<%dl' % sat_sids_count, sat_stream) # SIDs tuple
-
-        if self.dump:
-            print 'SAT sid count:\n', sat_sids_count
-            print 'SAT content:\n', self.SAT
-
-
-    def __build_SSAT(self):
-        ssat_stream = self.get_stream_data(self.data, self.SAT, self.ssat_start_sid, self.sect_size)
-
-        ssids_count = len(ssat_stream) >> 2
-        self.SSAT = struct.unpack('<%dl' % ssids_count, ssat_stream)
-
-        if self.dump:
-            print 'SSID count:', ssids_count
-            print 'SSAT content:\n', self.SSAT
-
-
-    def __build_directory(self):
-        dir_stream = self.get_stream_data(self.data, self.SAT, self.dir_start_sid, self.sect_size)
-
-        self.dir_entry_list = []
-
-        i = 0
-        while i < len(dir_stream):
-            dentry = dir_stream[i:i+128] # 128 -- dir entry size
-            i += 128
-            
-            did = len(self.dir_entry_list)
-            sz, = struct.unpack('<H', dentry[64:66])
-            if sz > 0 :
-                name = dentry[0:sz-2].decode('utf_16_le', 'replace')
-            else:
-                name = u''
-            t,  = struct.unpack('B', dentry[66])
-            c,  = struct.unpack('B', dentry[67])
-            did_left ,  = struct.unpack('<l', dentry[68:72])
-            did_right ,  = struct.unpack('<l', dentry[72:76])
-            did_root ,  = struct.unpack('<l', dentry[76:80])
-            dentry_start_sid ,  = struct.unpack('<l', dentry[116:120])
-            stream_size ,  = struct.unpack('<L', dentry[120:124])
-
-            self.dir_entry_list.extend([(did, sz, name, t, c, 
-                                            did_left, did_right, did_root, 
-                                            dentry_start_sid, stream_size)]) 
-
-        if self.dump:
-            dentry_types = {
-                0x00: 'Empty',
-                0x01: 'User storage',
-                0x02: 'User stream',
-                0x03: 'LockBytes',
-                0x04: 'Property',
-                0x05: 'Root storage'
-            }
-            node_colours = {
-                0x00: 'Red',
-                0x01: 'Black'
-            }
-            print 'total directory entries:', len(self.dir_entry_list)
-
-            for dentry in self.dir_entry_list:
-                (did, sz, name, t, c, 
-                 did_left, did_right, did_root, 
-                 dentry_start_sid, stream_size) = dentry
-                print 'DID', did
-                print 'Size of the used area of the character buffer of the name:', sz
-                print 'dir entry name:', repr(name)
-                print 'type of entry:', t, dentry_types[t]
-                print 'entry colour:', c, node_colours[c]
-                print 'left child DID :', did_left
-                print 'right child DID:', did_right
-                print 'root DID       :', did_root
-                print 'start SID       :', dentry_start_sid
-                print 'stream size     :', stream_size
-                if stream_size == 0:
-                    print 'stream is empty'
-                elif stream_size >= self.min_stream_size:
-                    print 'stream stored as normal stream'
-                else:
-                    print 'stream stored as short-stream'
-
-    
-    def __build_short_sectors_data(self):
-        (did, sz, name, t, c, 
-         did_left, did_right, did_root, 
-         dentry_start_sid, stream_size) = self.dir_entry_list[0]
-        assert t == 0x05 # Short-Stream Container Stream (SSCS) resides in Root Storage
-        if stream_size == 0:
-            self.short_sectors_data = ''
-        else:
-            self.short_sectors_data = self.get_stream_data(self.data, self.SAT, dentry_start_sid, self.sect_size)
-
-
-    def get_stream_data(self, data, SAT, start_sid, sect_size):
-        sid = start_sid
-        chunks = [(sid, sid)]
-        stream_data = ''
-
-        while SAT[sid] >= 0:
-            next_in_chain = SAT[sid]
-            last_chunk_start, last_chunk_finish = chunks[-1]
-            if next_in_chain - last_chunk_finish <= 1:
-                chunks[-1] = last_chunk_start, next_in_chain
-            else:
-                chunks.extend([(next_in_chain, next_in_chain)]) 
-            sid = next_in_chain
-        for s, f in chunks:
-            stream_data += data[s*sect_size:(f+1)*sect_size]
-        #print chunks
-        return stream_data
-
-        
-def print_bin_data(data):
-    i = 0
-    while i < len(data):
-        j = 0
-        while (i < len(data)) and (j < 16):
-            c = '0x%02X' % ord(data[i])
-            sys.stdout.write(c)
-            sys.stdout.write(' ')
-            i += 1
-            j += 1
-        print
-    if i == 0:
-        print '<NO DATA>'
-
-
-
-# This implementation writes only 'Root Entry', 'Workbook' streams
-# and 2 empty streams for aligning directory stream on sector boundary
-# 
-# LAYOUT:
-# 0         header
-# 76                MSAT (1st part: 109 SID)
-# 512       workbook stream
-# ...       additional MSAT sectors if streams' size > about 7 Mb == (109*512 * 128)
-# ...       SAT
-# ...       directory stream
-#
-# NOTE: this layout is "ad hoc". It can be more general. RTFM
-
-class XlsDoc:
-    SECTOR_SIZE = 0x0200
-    MIN_LIMIT   = 0x1000
-
-    SID_FREE_SECTOR  = -1
-    SID_END_OF_CHAIN = -2
-    SID_USED_BY_SAT  = -3
-    SID_USED_BY_MSAT = -4
-
-    def __init__(self):
-        #self.book_stream = ''                # padded
-        self.book_stream_sect = []
-
-        self.dir_stream = ''
-        self.dir_stream_sect = []
-
-        self.packed_SAT = ''
-        self.SAT_sect = []
-
-        self.packed_MSAT_1st = ''
-        self.packed_MSAT_2nd = ''
-        self.MSAT_sect_2nd = []
-
-        self.header = ''
-
-    def __build_directory(self): # align on sector boundary
-        self.dir_stream = ''
-
-        dentry_name      = '\x00'.join('Root Entry\x00') + '\x00'
-        dentry_name_sz   = len(dentry_name)
-        dentry_name_pad  = '\x00'*(64 - dentry_name_sz)
-        dentry_type      = 0x05 # root storage
-        dentry_colour    = 0x01 # black
-        dentry_did_left  = -1
-        dentry_did_right = -1
-        dentry_did_root  = 1
-        dentry_start_sid = -2
-        dentry_stream_sz = 0
-
-        self.dir_stream += struct.pack('<64s H 2B 3l 9L l L L',
-           dentry_name + dentry_name_pad,
-           dentry_name_sz,
-           dentry_type,
-           dentry_colour,
-           dentry_did_left, 
-           dentry_did_right,
-           dentry_did_root,
-           0, 0, 0, 0, 0, 0, 0, 0, 0,
-           dentry_start_sid,
-           dentry_stream_sz,
-           0
-        )
-
-        dentry_name      = '\x00'.join('Workbook\x00') + '\x00'
-        dentry_name_sz   = len(dentry_name)
-        dentry_name_pad  = '\x00'*(64 - dentry_name_sz)
-        dentry_type      = 0x02 # user stream
-        dentry_colour    = 0x01 # black
-        dentry_did_left  = -1
-        dentry_did_right = -1
-        dentry_did_root  = -1
-        dentry_start_sid = 0     
-        dentry_stream_sz = self.book_stream_len
-
-        self.dir_stream += struct.pack('<64s H 2B 3l 9L l L L',
-           dentry_name + dentry_name_pad,
-           dentry_name_sz,
-           dentry_type,
-           dentry_colour,
-           dentry_did_left, 
-           dentry_did_right,
-           dentry_did_root,
-           0, 0, 0, 0, 0, 0, 0, 0, 0, 
-           dentry_start_sid,
-           dentry_stream_sz,
-           0
-        )
-        
-        # padding
-        dentry_name      = ''
-        dentry_name_sz   = len(dentry_name)
-        dentry_name_pad  = '\x00'*(64 - dentry_name_sz)
-        dentry_type      = 0x00 # empty
-        dentry_colour    = 0x01 # black
-        dentry_did_left  = -1
-        dentry_did_right = -1
-        dentry_did_root  = -1
-        dentry_start_sid = -2
-        dentry_stream_sz = 0
-
-        self.dir_stream += struct.pack('<64s H 2B 3l 9L l L L',
-           dentry_name + dentry_name_pad,
-           dentry_name_sz,
-           dentry_type,
-           dentry_colour,
-           dentry_did_left, 
-           dentry_did_right,
-           dentry_did_root,
-           0, 0, 0, 0, 0, 0, 0, 0, 0,
-           dentry_start_sid,
-           dentry_stream_sz,
-           0
-        ) * 2
-    
-    def __build_sat(self):
-        # Build SAT
-        book_sect_count = self.book_stream_len >> 9
-        dir_sect_count  = len(self.dir_stream) >> 9
-        
-        total_sect_count     = book_sect_count + dir_sect_count
-        SAT_sect_count       = 0
-        MSAT_sect_count      = 0
-        SAT_sect_count_limit = 109
-        while total_sect_count > 128*SAT_sect_count or SAT_sect_count > SAT_sect_count_limit:
-            SAT_sect_count   += 1
-            total_sect_count += 1
-            if SAT_sect_count > SAT_sect_count_limit:
-                MSAT_sect_count      += 1
-                total_sect_count     += 1
-                SAT_sect_count_limit += 127
-
-
-        SAT = [self.SID_FREE_SECTOR]*128*SAT_sect_count
-
-        sect = 0
-        while sect < book_sect_count - 1:
-            self.book_stream_sect.append(sect)
-            SAT[sect] = sect + 1
-            sect += 1
-        self.book_stream_sect.append(sect)
-        SAT[sect] = self.SID_END_OF_CHAIN
-        sect += 1
-
-        while sect < book_sect_count + MSAT_sect_count:
-            self.MSAT_sect_2nd.append(sect)
-            SAT[sect] = self.SID_USED_BY_MSAT
-            sect += 1
-
-        while sect < book_sect_count + MSAT_sect_count + SAT_sect_count:
-            self.SAT_sect.append(sect)            
-            SAT[sect] = self.SID_USED_BY_SAT
-            sect += 1
-
-        while sect < book_sect_count + MSAT_sect_count + SAT_sect_count + dir_sect_count - 1:
-            self.dir_stream_sect.append(sect)
-            SAT[sect] = sect + 1
-            sect += 1
-        self.dir_stream_sect.append(sect)
-        SAT[sect] = self.SID_END_OF_CHAIN
-        sect += 1
-
-        self.packed_SAT = struct.pack('<%dl' % (SAT_sect_count*128), *SAT)
-
-        MSAT_1st = [self.SID_FREE_SECTOR]*109
-        for i, SAT_sect_num in zip(range(0, 109), self.SAT_sect):
-            MSAT_1st[i] = SAT_sect_num
-        self.packed_MSAT_1st = struct.pack('<109l', *MSAT_1st)
-
-        MSAT_2nd = [self.SID_FREE_SECTOR]*128*MSAT_sect_count
-        if MSAT_sect_count > 0:
-            MSAT_2nd[- 1] = self.SID_END_OF_CHAIN
-
-        i = 109
-        msat_sect = 0
-        sid_num = 0
-        while i < SAT_sect_count:
-            if (sid_num + 1) % 128 == 0:
-                #print 'link: ',
-                msat_sect += 1
-                if msat_sect < len(self.MSAT_sect_2nd):
-                    MSAT_2nd[sid_num] = self.MSAT_sect_2nd[msat_sect]
-            else:
-                #print 'sid: ',
-                MSAT_2nd[sid_num] = self.SAT_sect[i]
-                i += 1
-            #print sid_num, MSAT_2nd[sid_num]
-            sid_num += 1
-
-        self.packed_MSAT_2nd = struct.pack('<%dl' % (MSAT_sect_count*128), *MSAT_2nd)
-
-        #print vars()
-        #print zip(range(0, sect), SAT)
-        #print self.book_stream_sect
-        #print self.MSAT_sect_2nd
-        #print MSAT_2nd
-        #print self.SAT_sect
-        #print self.dir_stream_sect
-
-
-    def __build_header(self):
-        doc_magic             = '\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1'
-        file_uid              = '\x00'*16
-        rev_num               = '\x3E\x00'
-        ver_num               = '\x03\x00'
-        byte_order            = '\xFE\xFF'
-        log_sect_size         = struct.pack('<H', 9)
-        log_short_sect_size   = struct.pack('<H', 6)
-        not_used0             = '\x00'*10
-        total_sat_sectors     = struct.pack('<L', len(self.SAT_sect))
-        dir_start_sid         = struct.pack('<l', self.dir_stream_sect[0])
-        not_used1             = '\x00'*4        
-        min_stream_size       = struct.pack('<L', 0x1000)
-        ssat_start_sid        = struct.pack('<l', -2)
-        total_ssat_sectors    = struct.pack('<L', 0)
-
-        if len(self.MSAT_sect_2nd) == 0:
-            msat_start_sid        = struct.pack('<l', -2)
-        else:
-            msat_start_sid        = struct.pack('<l', self.MSAT_sect_2nd[0])
-
-        total_msat_sectors    = struct.pack('<L', len(self.MSAT_sect_2nd))
-
-        self.header =       ''.join([  doc_magic,
-                                        file_uid,
-                                        rev_num,
-                                        ver_num,
-                                        byte_order,
-                                        log_sect_size,
-                                        log_short_sect_size,
-                                        not_used0,
-                                        total_sat_sectors,
-                                        dir_start_sid,
-                                        not_used1,
-                                        min_stream_size,
-                                        ssat_start_sid,
-                                        total_ssat_sectors,
-                                        msat_start_sid,
-                                        total_msat_sectors
-                                    ])
-                                        
-
-    def save(self, filename, stream):
-        # 1. Align stream on 0x1000 boundary (and therefore on sector boundary)
-        padding = '\x00' * (0x1000 - (len(stream) % 0x1000))
-        self.book_stream_len = len(stream) + len(padding)
-
-        self.__build_directory()
-        self.__build_sat()
-        self.__build_header()
-        
-        f = filename
-        if not hasattr(filename, 'write'):
-            f = file(filename, 'wb')
-        f.write(self.header)
-        f.write(self.packed_MSAT_1st)
-        f.write(stream)
-        f.write(padding)
-        f.write(self.packed_MSAT_2nd)
-        f.write(self.packed_SAT)
-        f.write(self.dir_stream)
-
-
-if __name__ == '__main__':
-    d = XlsDoc()
-    d.save('a.aaa', 'b'*17000)
-
-
-
-
-

+ 0 - 61
desktop/core/ext-py/pyexcelerator/pyExcelerator/Deco.py

@@ -1,61 +0,0 @@
-# This code from 
-
-# PEP: 318 
-# Title: Decorators for Functions and Methods 
-# Version: 1.35 
-# Last-Modified: 2004/09/14 07:34:23 
-# Author: Kevin D. Smith, Jim Jewett, Skip Montanaro, Anthony Baxter 
-
-# This code fixes error in example 4: 
-# authors' code contains
-#       @accepts(int, (int,float))
-#       @returns((int,float))
-#       def func(arg1, arg2):
-#           return arg1 * arg2
-# 
-# It should be:
-#       @returns((int,float))
-#       @accepts(int, (int,float))
-#       def func(arg1, arg2):
-#           return arg1 * arg2
-# because of decorators are applied from bottom to up.
-
-
-__rev_id__ = """$Id: Deco.py,v 1.4 2005/07/20 07:24:11 rvk Exp $"""
-
-
-def accepts(*types):
-    #print types
-    def check_accepts(f):
-        assert len(types) == f.func_code.co_argcount
-        def new_f(*args, **kwds):
-            for (a, t) in zip(args, types):
-                assert isinstance(a, t), \
-                       "arg %r does not match %s" % (a,t)
-            return f(*args, **kwds)
-        new_f.func_name = f.func_name
-        return new_f
-    return check_accepts
-
-def returns(rtype):
-    def check_returns(f):
-        def new_f(*args, **kwds):
-            result = f(*args, **kwds)
-            assert isinstance(result, rtype), \
-                   "return value %r does not match %s" % (result,rtype)
-            return result
-        new_f.func_name = f.func_name
-        return new_f
-    return check_returns
-
-
-if __name__ == '__main__':
-    import types 
-
-    @returns(types.NoneType)
-    @accepts(int, (int,float))
-    def func(arg1, arg2):
-        #return str(arg1 * arg2)
-        pass
-
-    func(1, 2)      

+ 0 - 109
desktop/core/ext-py/pyexcelerator/pyExcelerator/ExcelFormula.py

@@ -1,109 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-__rev_id__ = """$Id: ExcelFormula.py,v 1.3 2005/08/11 08:53:48 rvk Exp $"""
-
-
-import ExcelFormulaParser, ExcelFormulaLexer, ExcelMagic
-import struct
-from Deco import *
-from antlr import ANTLRException
-
-NoCalcs=0x00
-RecalcAlways=0x01
-CalcOnOpen=0x02
-PartOfShareFormula=0x08
-
-class ErrorCode(object):
-    error_msg = dict([(i[1], i[0]) for i in ExcelMagic.error_msg_by_code.items()])
-    
-    def __init__(self, s):
-        self.val = self.error_msg[s]
-    
-    def int(self): return self.val
-
-class Formula(object):
-    __slots__ = ["__init__", "text", "rpn", "default", "opts", "__s", "__parser", "__default", "__opts"]
-
-
-    def __init__(self, s, default=None, opts=None):
-        self.__default = default
-        self.__opts = opts
-        try:
-            self.__s = s
-            lexer = ExcelFormulaLexer.Lexer(s)
-            self.__parser = ExcelFormulaParser.Parser(lexer)
-            self.__parser.formula()
-        except ANTLRException:
-            raise Exception, "can't parse formula " + s
-
-    def set_default(self, val):
-        self.__default = val
-
-    def get_default(self):
-        return self.__default
-
-    default = property(get_default, set_default)
-
-    @accepts(object, int)
-    def set_opts(self, value):
-        assert (int(value) & ~(0x0b)) == 0, "Invalid bits set for opts (%s)"%hex(int(value))
-        self.__opts = int(value)
-
-    def get_opts(self):
-        return self.__opts
-
-    opts = property(get_opts, set_opts)
-
-    def text(self):
-        return self.__s
-
-    def rpn(self):
-        '''
-        Offset    Size    Contents
-        0         2       Size of the following formula data (sz)
-        2         sz      Formula data (RPN token array)
-        [2+sz]    var.    (optional) Additional data for specific tokens
-
-        '''
-        return struct.pack("<H", len(self.__parser.rpn)) + self.__parser.rpn
-

+ 0 - 162
desktop/core/ext-py/pyexcelerator/pyExcelerator/ExcelFormulaLexer.py

@@ -1,162 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-#
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-#
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-#
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-__rev_id__ = """$Id: ExcelFormulaLexer.py,v 1.4 2005/08/14 06:40:23 rvk Exp $"""
-
-
-import sys
-from antlr import EOF, CommonToken as Tok, TokenStream, TokenStreamException
-import struct
-import ExcelFormulaParser
-from re import compile as recompile, match, LOCALE, UNICODE, IGNORECASE
-
-
-int_const_pattern = recompile(r"\d+")
-flt_const_pattern = recompile(r"\d*\.\d+(?:[Ee][+-]?\d+)?")
-str_const_pattern = recompile(r'["][^"]*["]')
-#range2d_pattern   = recompile(r"\$?[A-I]?[A-Z]\$?\d+:\$?[A-I]?[A-Z]\$?\d+")
-ref2d_pattern     = recompile(r"\$?[A-I]?[A-Z]\$?\d+")
-true_pattern      = recompile(r"TRUE", IGNORECASE)
-false_pattern     = recompile(r"FALSE", IGNORECASE)
-name_pattern      = recompile(r"[\.\w]+", LOCALE)
-
-pattern_type_tuples = (
-    (flt_const_pattern, ExcelFormulaParser.NUM_CONST),
-    (int_const_pattern, ExcelFormulaParser.INT_CONST),
-    (str_const_pattern, ExcelFormulaParser.STR_CONST),
-#    (range2d_pattern  , ExcelFormulaParser.RANGE2D),
-    (ref2d_pattern    , ExcelFormulaParser.REF2D),
-    (true_pattern     , ExcelFormulaParser.TRUE_CONST),
-    (false_pattern    , ExcelFormulaParser.FALSE_CONST),
-    (name_pattern     , ExcelFormulaParser.NAME)
-)
-
-
-type_text_tuples = (
-    (ExcelFormulaParser.NE, '<>'),
-    (ExcelFormulaParser.LE, '<='),
-    (ExcelFormulaParser.GE, '>='),
-    (ExcelFormulaParser.EQ, '='),
-    (ExcelFormulaParser.LT, '<'),
-    (ExcelFormulaParser.GT, '>'),
-    (ExcelFormulaParser.ADD, '+'),
-    (ExcelFormulaParser.SUB, '-'),
-    (ExcelFormulaParser.MUL, '*'),
-    (ExcelFormulaParser.DIV, '/'),
-    (ExcelFormulaParser.COLON, ':'),
-    (ExcelFormulaParser.SEMICOLON, ';'),
-    (ExcelFormulaParser.COMMA, ','),
-    (ExcelFormulaParser.LP, '('),
-    (ExcelFormulaParser.RP, ')'),
-    (ExcelFormulaParser.CONCAT, '&'),
-    (ExcelFormulaParser.PERCENT, '%'),
-    (ExcelFormulaParser.POWER, '^')
-)
-
-
-class Lexer(TokenStream):
-    def __init__(self, text):
-        self._text = text[:]
-        self._pos = 0
-        self._line = 0
-
-
-    def isEOF(self):
-        return len(self._text) <= self._pos
-
-
-    def rest(self):
-        return self._text[self._pos:]
-
-
-    def curr_ch(self):
-        return self._text[self._pos]
-
-
-    def next_ch(self, n = 1):
-        self._pos += n
-
-
-    def is_whitespace(self):
-        return self.curr_ch() in " \t\n\r\f\v"
-
-
-    def match_pattern(self, pattern, toktype):
-        m = pattern.match(self._text[self._pos:])
-        if m:
-            start_pos = self._pos + m.start(0)
-            end_pos = self._pos + m.end(0)
-            tt = self._text[start_pos:end_pos]
-            self._pos = end_pos
-            return Tok(type = toktype, text = tt, col = start_pos + 1)
-        else:
-            return None
-
-
-    def nextToken(self):
-        # skip whitespace
-        while not self.isEOF() and self.is_whitespace():
-            self.next_ch()
-        if self.isEOF():
-            return Tok(type = EOF)
-        # first, try to match token with more chars
-        for ptt in pattern_type_tuples:
-            t = self.match_pattern(*ptt);
-            if t:
-                return t
-        # second, we want find short tokens
-        for ty, te in type_text_tuples:
-            if self.rest().startswith(te):
-                self.next_ch(len(te))
-                return Tok(type = ty, text = te, col = self._pos)
-        # at this point, smth strange is happened
-        raise TokenStreamException("Unknown char %s at %u col." % (self.curr_ch(), self._pos))
-
-
-if __name__ == '__main__' :
-    import locale
-    locale.setlocale(locale.LC_ALL, 'russian')
-    try:
-        for t in Lexer('1+2+3+67.8678 + " @##$$$ klhkh kljhklhkl " + .58e-678*A1:B4 - 1lkjljlkjl3535ïîðïîð'):
-            print t
-    except TokenStreamException, e:
-        print "error:", e

+ 0 - 457
desktop/core/ext-py/pyexcelerator/pyExcelerator/ExcelFormulaParser.py

@@ -1,457 +0,0 @@
-### $ANTLR 2.7.5 (20050128): "excel-formula.g" -> "ExcelFormulaParser.py"$
-### import antlr and other modules ..
-import sys
-import antlr
-
-version = sys.version.split()[0]
-if version < '2.2.1':
-    False = 0
-if version < '2.3':
-    True = not False
-### header action >>> 
-__rev_id__ = """$Id: ExcelFormulaParser.py,v 1.4 2005/08/14 06:40:23 rvk Exp $"""
-
-import struct
-import Utils
-from UnicodeUtils import upack1
-from ExcelMagic import *
-### header action <<< 
-### preamble action>>>
-
-### preamble action <<<
-
-### import antlr.Token 
-from antlr import Token
-### >>>The Known Token Types <<<
-SKIP                = antlr.SKIP
-INVALID_TYPE        = antlr.INVALID_TYPE
-EOF_TYPE            = antlr.EOF_TYPE
-EOF                 = antlr.EOF
-NULL_TREE_LOOKAHEAD = antlr.NULL_TREE_LOOKAHEAD
-MIN_USER_TYPE       = antlr.MIN_USER_TYPE
-TRUE_CONST = 4
-FALSE_CONST = 5
-STR_CONST = 6
-NUM_CONST = 7
-INT_CONST = 8
-NAME = 9
-EQ = 10
-NE = 11
-GT = 12
-LT = 13
-GE = 14
-LE = 15
-ADD = 16
-SUB = 17
-MUL = 18
-DIV = 19
-POWER = 20
-PERCENT = 21
-LP = 22
-RP = 23
-LB = 24
-RB = 25
-COLON = 26
-COMMA = 27
-SEMICOLON = 28
-CONCAT = 29
-REF2D = 30
-
-class Parser(antlr.LLkParser):
-    ### user action >>>
-    ### user action <<<
-    
-    def __init__(self, *args, **kwargs):
-        antlr.LLkParser.__init__(self, *args, **kwargs)
-        self.tokenNames = _tokenNames
-        ### __init__ header action >>> 
-        self.rpn = ""
-        ### __init__ header action <<< 
-        
-    def formula(self):    
-        
-        pass
-        self.expr("V")
-    
-    def expr(self,
-        arg_type
-    ):    
-        
-        pass
-        self.prec0_expr(arg_type)
-        while True:
-            if ((self.LA(1) >= EQ and self.LA(1) <= LE)):
-                pass
-                la1 = self.LA(1)
-                if False:
-                    pass
-                elif la1 and la1 in [EQ]:
-                    pass
-                    self.match(EQ)
-                    op = struct.pack('B', ptgEQ)
-                elif la1 and la1 in [NE]:
-                    pass
-                    self.match(NE)
-                    op = struct.pack('B', ptgNE)
-                elif la1 and la1 in [GT]:
-                    pass
-                    self.match(GT)
-                    op = struct.pack('B', ptgGT)
-                elif la1 and la1 in [LT]:
-                    pass
-                    self.match(LT)
-                    op = struct.pack('B', ptgLT)
-                elif la1 and la1 in [GE]:
-                    pass
-                    self.match(GE)
-                    op = struct.pack('B', ptgGE)
-                elif la1 and la1 in [LE]:
-                    pass
-                    self.match(LE)
-                    op = struct.pack('B', ptgLE)
-                else:
-                        raise antlr.NoViableAltException(self.LT(1), self.getFilename())
-                    
-                self.prec0_expr(arg_type)
-                self.rpn += op
-            else:
-                break
-            
-    
-    def prec0_expr(self,
-        arg_type
-    ):    
-        
-        pass
-        self.prec1_expr(arg_type)
-        while True:
-            if (self.LA(1)==CONCAT):
-                pass
-                pass
-                self.match(CONCAT)
-                op = struct.pack('B', ptgConcat)
-                self.prec1_expr(arg_type)
-                self.rpn += op
-            else:
-                break
-            
-    
-    def prec1_expr(self,
-        arg_type
-    ):    
-        
-        pass
-        self.prec2_expr(arg_type)
-        while True:
-            if (self.LA(1)==ADD or self.LA(1)==SUB):
-                pass
-                la1 = self.LA(1)
-                if False:
-                    pass
-                elif la1 and la1 in [ADD]:
-                    pass
-                    self.match(ADD)
-                    op = struct.pack('B', ptgAdd)
-                elif la1 and la1 in [SUB]:
-                    pass
-                    self.match(SUB)
-                    op = struct.pack('B', ptgSub)
-                else:
-                        raise antlr.NoViableAltException(self.LT(1), self.getFilename())
-                    
-                self.prec2_expr(arg_type)
-                self.rpn += op
-            else:
-                break
-            
-    
-    def prec2_expr(self,
-        arg_type
-    ):    
-        
-        pass
-        self.prec3_expr(arg_type)
-        while True:
-            if (self.LA(1)==MUL or self.LA(1)==DIV):
-                pass
-                la1 = self.LA(1)
-                if False:
-                    pass
-                elif la1 and la1 in [MUL]:
-                    pass
-                    self.match(MUL)
-                    op = struct.pack('B', ptgMul)
-                elif la1 and la1 in [DIV]:
-                    pass
-                    self.match(DIV)
-                    op = struct.pack('B', ptgDiv)
-                else:
-                        raise antlr.NoViableAltException(self.LT(1), self.getFilename())
-                    
-                self.prec3_expr(arg_type)
-                self.rpn += op
-            else:
-                break
-            
-    
-    def prec3_expr(self,
-        arg_type
-    ):    
-        
-        pass
-        self.prec4_expr(arg_type)
-        while True:
-            if (self.LA(1)==POWER):
-                pass
-                pass
-                self.match(POWER)
-                op = struct.pack('B', ptgPower)
-                self.prec4_expr(arg_type)
-                self.rpn += op
-            else:
-                break
-            
-    
-    def prec4_expr(self,
-        arg_type
-    ):    
-        
-        pass
-        self.prec5_expr(arg_type)
-        la1 = self.LA(1)
-        if False:
-            pass
-        elif la1 and la1 in [PERCENT]:
-            pass
-            self.match(PERCENT)
-            self.rpn += struct.pack('B', ptgPercent)
-        elif la1 and la1 in [EOF,EQ,NE,GT,LT,GE,LE,ADD,SUB,MUL,DIV,POWER,RP,SEMICOLON,CONCAT]:
-            pass
-        else:
-                raise antlr.NoViableAltException(self.LT(1), self.getFilename())
-            
-    
-    def prec5_expr(self,
-        arg_type
-    ):    
-        
-        la1 = self.LA(1)
-        if False:
-            pass
-        elif la1 and la1 in [TRUE_CONST,FALSE_CONST,STR_CONST,NUM_CONST,INT_CONST,NAME,LP,REF2D]:
-            pass
-            self.primary(arg_type)
-        elif la1 and la1 in [SUB]:
-            pass
-            self.match(SUB)
-            self.primary(arg_type)
-            self.rpn += struct.pack('B', ptgUminus)
-        else:
-                raise antlr.NoViableAltException(self.LT(1), self.getFilename())
-            
-    
-    def primary(self,
-        arg_type
-    ):    
-        
-        str_tok = None
-        int_tok = None
-        num_tok = None
-        ref2d_tok = None
-        ref2d1_tok = None
-        ref2d2_tok = None
-        name_tok = None
-        func_tok = None
-        la1 = self.LA(1)
-        if False:
-            pass
-        elif la1 and la1 in [TRUE_CONST]:
-            pass
-            self.match(TRUE_CONST)
-            self.rpn += struct.pack("2B", ptgBool, 1)
-        elif la1 and la1 in [FALSE_CONST]:
-            pass
-            self.match(FALSE_CONST)
-            self.rpn += struct.pack("2B", ptgBool, 0)
-        elif la1 and la1 in [STR_CONST]:
-            pass
-            str_tok = self.LT(1)
-            self.match(STR_CONST)
-            self.rpn += struct.pack("B", ptgStr) + upack1(str_tok.text[1:-1])
-        elif la1 and la1 in [INT_CONST]:
-            pass
-            int_tok = self.LT(1)
-            self.match(INT_CONST)
-            self.rpn += struct.pack("<BH", ptgInt, int(int_tok.text))
-        elif la1 and la1 in [NUM_CONST]:
-            pass
-            num_tok = self.LT(1)
-            self.match(NUM_CONST)
-            self.rpn += struct.pack("<Bd", ptgNum, float(num_tok.text))
-        elif la1 and la1 in [LP]:
-            pass
-            self.match(LP)
-            self.expr(arg_type)
-            self.match(RP)
-            self.rpn += struct.pack("B", ptgParen)
-        else:
-            if (self.LA(1)==REF2D) and (_tokenSet_0.member(self.LA(2))):
-                pass
-                ref2d_tok = self.LT(1)
-                self.match(REF2D)
-                r, c = Utils.cell_to_packed_rowcol(ref2d_tok.text)
-                if arg_type == "R":
-                   self.rpn += struct.pack("<B2H", ptgRefR, r, c)
-                else:
-                   self.rpn += struct.pack("<B2H", ptgRefV, r, c)
-            elif (self.LA(1)==REF2D) and (self.LA(2)==COLON):
-                pass
-                ref2d1_tok = self.LT(1)
-                self.match(REF2D)
-                self.match(COLON)
-                ref2d2_tok = self.LT(1)
-                self.match(REF2D)
-                r1, c1 = Utils.cell_to_packed_rowcol(ref2d1_tok.text)
-                r2, c2 = Utils.cell_to_packed_rowcol(ref2d2_tok.text)
-                if arg_type == "R":
-                   self.rpn += struct.pack("<B4H", ptgAreaR, r1, r2, c1, c2)
-                else:
-                   self.rpn += struct.pack("<B4H", ptgAreaV, r1, r2, c1, c2)
-            elif (self.LA(1)==NAME) and (_tokenSet_0.member(self.LA(2))):
-                pass
-                name_tok = self.LT(1)
-                self.match(NAME)
-                self.rpn += ""
-            elif (self.LA(1)==NAME) and (self.LA(2)==LP):
-                pass
-                func_tok = self.LT(1)
-                self.match(NAME)
-                if func_tok.text.upper() in std_func_by_name:
-                   (opcode,
-                   min_argc,
-                   max_argc,
-                   func_type,
-                   arg_type_list,
-                   volatile_func) = std_func_by_name[func_tok.text.upper()]
-                else:
-                   raise Exception, "unknown function: %s" % func_tok.text
-                self.match(LP)
-                arg_count=self.expr_list(arg_type_list, min_argc, max_argc)
-                self.match(RP)
-                if arg_count > max_argc or arg_count < min_argc:
-                   raise Exception, "%d parameters for function: %s" % (arg_count, func_tok.text)
-                if min_argc == max_argc:
-                   if func_type == "V":
-                       func_ptg = ptgFuncV
-                   elif func_type == "R":
-                       func_ptg = ptgFuncR
-                   elif func_type == "A":
-                       func_ptg = ptgFuncA
-                   else:
-                       raise Exception, "wrong function type"
-                   self.rpn += struct.pack("<BH", func_ptg, opcode)
-                else:
-                   if func_type == "V":
-                       func_ptg = ptgFuncVarV
-                   elif func_type == "R":
-                       func_ptg = ptgFuncVarR
-                   elif func_type == "A":
-                       func_ptg = ptgFuncVarA
-                   else:
-                       raise Exception, "wrong function type"
-                   self.rpn += struct.pack("<2BH", func_ptg, arg_count, opcode)
-            else:
-                raise antlr.NoViableAltException(self.LT(1), self.getFilename())
-            
-    
-    def expr_list(self,
-        arg_type_list, min_argc, max_argc
-    ):    
-        arg_cnt = None
-        
-        arg_cnt = 0
-        arg_type_list = arg_type_list.split()
-        arg_type = arg_type_list[arg_cnt]
-        la1 = self.LA(1)
-        if False:
-            pass
-        elif la1 and la1 in [TRUE_CONST,FALSE_CONST,STR_CONST,NUM_CONST,INT_CONST,NAME,SUB,LP,REF2D]:
-            pass
-            self.expr(arg_type)
-            arg_cnt += 1
-            while True:
-                if (self.LA(1)==SEMICOLON):
-                    pass
-                    if arg_cnt < len(arg_type_list):
-                       arg_type = arg_type_list[arg_cnt]
-                    else:
-                       arg_type = arg_type_list[-1]
-                    if arg_type == "...":
-                       arg_type = arg_type_list[-2]
-                    self.match(SEMICOLON)
-                    la1 = self.LA(1)
-                    if False:
-                        pass
-                    elif la1 and la1 in [TRUE_CONST,FALSE_CONST,STR_CONST,NUM_CONST,INT_CONST,NAME,SUB,LP,REF2D]:
-                        pass
-                        self.expr(arg_type)
-                    elif la1 and la1 in [RP,SEMICOLON]:
-                        pass
-                        self.rpn += struct.pack("B", ptgMissArg)
-                    else:
-                            raise antlr.NoViableAltException(self.LT(1), self.getFilename())
-                        
-                    arg_cnt += 1
-                else:
-                    break
-                
-        elif la1 and la1 in [RP]:
-            pass
-        else:
-                raise antlr.NoViableAltException(self.LT(1), self.getFilename())
-            
-        return arg_cnt
-    
-
-_tokenNames = [
-    "<0>", 
-    "EOF", 
-    "<2>", 
-    "NULL_TREE_LOOKAHEAD", 
-    "TRUE_CONST", 
-    "FALSE_CONST", 
-    "STR_CONST", 
-    "NUM_CONST", 
-    "INT_CONST", 
-    "NAME", 
-    "EQ", 
-    "NE", 
-    "GT", 
-    "LT", 
-    "GE", 
-    "LE", 
-    "ADD", 
-    "SUB", 
-    "MUL", 
-    "DIV", 
-    "POWER", 
-    "PERCENT", 
-    "LP", 
-    "RP", 
-    "LB", 
-    "RB", 
-    "COLON", 
-    "COMMA", 
-    "SEMICOLON", 
-    "CONCAT", 
-    "REF2D"
-]
-    
-
-### generate bit set
-def mk_tokenSet_0(): 
-    ### var1
-    data = [ 817888258L, 0L]
-    return data
-_tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
-    

+ 0 - 1061
desktop/core/ext-py/pyexcelerator/pyExcelerator/ExcelMagic.py

@@ -1,1061 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-#
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-#
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-#
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-__rev_id__ = """$Id: ExcelMagic.py,v 1.2 2005/10/26 07:44:24 rvk Exp $"""
-
-
-"""
-lots of Excel Magic Numbers
-"""
-
-# Boundaries BIFF8+
-
-MAX_ROW = 65536
-MAX_COL = 256
-
-
-biff_records = {
-    0x0000: "DIMENSIONS",
-    0x0001: "BLANK",
-    0x0002: "INTEGER",
-    0x0003: "NUMBER",
-    0x0004: "LABEL",
-    0x0005: "BOOLERR",
-    0x0006: "FORMULA",
-    0x0007: "STRING",
-    0x0008: "ROW",
-    0x0009: "BOF",
-    0x000A: "EOF",
-    0x000B: "INDEX",
-    0x000C: "CALCCOUNT",
-    0x000D: "CALCMODE",
-    0x000E: "PRECISION",
-    0x000F: "REFMODE",
-    0x0010: "DELTA",
-    0x0011: "ITERATION",
-    0x0012: "PROTECT",
-    0x0013: "PASSWORD",
-    0x0014: "HEADER",
-    0x0015: "FOOTER",
-    0x0016: "EXTERNCOUNT",
-    0x0017: "EXTERNSHEET",
-    0x0018: "NAME",
-    0x0019: "WINDOWPROTECT",
-    0x001A: "VERTICALPAGEBREAKS",
-    0x001B: "HORIZONTALPAGEBREAKS",
-    0x001C: "NOTE",
-    0x001D: "SELECTION",
-    0x001E: "FORMAT",
-    0x001F: "FORMATCOUNT",
-    0x0020: "COLUMNDEFAULT",
-    0x0021: "ARRAY",
-    0x0022: "1904",
-    0x0023: "EXTERNNAME",
-    0x0024: "COLWIDTH",
-    0x0025: "DEFAULTROWHEIGHT",
-    0x0026: "LEFTMARGIN",
-    0x0027: "RIGHTMARGIN",
-    0x0028: "TOPMARGIN",
-    0x0029: "BOTTOMMARGIN",
-    0x002A: "PRINTHEADERS",
-    0x002B: "PRINTGRIDLINES",
-    0x002F: "FILEPASS",
-    0x0031: "FONT",
-    0x0036: "TABLE",
-    0x003C: "CONTINUE",
-    0x003D: "WINDOW1",
-    0x003E: "WINDOW2",
-    0x0040: "BACKUP",
-    0x0041: "PANE",
-    0x0042: "CODEPAGE",
-    0x0043: "XF",
-    0x0044: "IXFE",
-    0x0045: "EFONT",
-    0x004D: "PLS",
-    0x0050: "DCON",
-    0x0051: "DCONREF",
-    0x0053: "DCONNAME",
-    0x0055: "DEFCOLWIDTH",
-    0x0056: "BUILTINFMTCNT",
-    0x0059: "XCT",
-    0x005A: "CRN",
-    0x005B: "FILESHARING",
-    0x005C: "WRITEACCESS",
-    0x005D: "OBJ",
-    0x005E: "UNCALCED",
-    0x005F: "SAFERECALC",
-    0x0060: "TEMPLATE",
-    0x0063: "OBJPROTECT",
-    0x007D: "COLINFO",
-    0x007E: "RK",
-    0x007F: "IMDATA",
-    0x0080: "GUTS",
-    0x0081: "WSBOOL",
-    0x0082: "GRIDSET",
-    0x0083: "HCENTER",
-    0x0084: "VCENTER",
-    0x0085: "BOUNDSHEET",
-    0x0086: "WRITEPROT",
-    0x0087: "ADDIN",
-    0x0088: "EDG",
-    0x0089: "PUB",
-    0x008C: "COUNTRY",
-    0x008D: "HIDEOBJ",
-    0x008E: "BUNDLESOFFSET",
-    0x008F: "BUNDLEHEADER",
-    0x0090: "SORT",
-    0x0091: "SUB",
-    0x0092: "PALETTE",
-    0x0093: "STYLE",
-    0x0094: "LHRECORD",
-    0x0095: "LHNGRAPH",
-    0x0096: "SOUND",
-    0x0098: "LPR",
-    0x0099: "STANDARDWIDTH",
-    0x009A: "FNGROUPNAME",
-    0x009B: "FILTERMODE",
-    0x009C: "FNGROUPCOUNT",
-    0x009D: "AUTOFILTERINFO",
-    0x009E: "AUTOFILTER",
-    0x00A0: "SCL",
-    0x00A1: "SETUP",
-    0x00A9: "COORDLIST",
-    0x00AB: "GCW",
-    0x00AE: "SCENMAN",
-    0x00AF: "SCENARIO",
-    0x00B0: "SXVIEW",
-    0x00B1: "SXVD",
-    0x00B2: "SXVI",
-    0x00B4: "SXIVD",
-    0x00B5: "SXLI",
-    0x00B6: "SXPI",
-    0x00B8: "DOCROUTE",
-    0x00B9: "RECIPNAME",
-    0x00BC: "SHRFMLA",
-    0x00BD: "MULRK",
-    0x00BE: "MULBLANK",
-    0x00C1: "MMS",
-    0x00C2: "ADDMENU",
-    0x00C3: "DELMENU",
-    0x00C5: "SXDI",
-    0x00C6: "SXDB",
-    0x00C7: "SXFIELD",
-    0x00C8: "SXINDEXLIST",
-    0x00C9: "SXDOUBLE",
-    0x00CD: "SXSTRING",
-    0x00CE: "SXDATETIME",
-    0x00D0: "SXTBL",
-    0x00D1: "SXTBRGITEM",
-    0x00D2: "SXTBPG",
-    0x00D3: "OBPROJ",
-    0x00D5: "SXIDSTM",
-    0x00D6: "RSTRING",
-    0x00D7: "DBCELL",
-    0x00DA: "BOOKBOOL",
-    0x00DC: "SXEXT|PARAMQRY",
-    0x00DD: "SCENPROTECT",
-    0x00DE: "OLESIZE",
-    0x00DF: "UDDESC",
-    0x00E0: "XF",
-    0x00E1: "INTERFACEHDR",
-    0x00E2: "INTERFACEEND",
-    0x00E3: "SXVS",
-    0x00E5: "MERGEDCELLS",
-    0x00E9: "BITMAP",
-    0x00EB: "MSODRAWINGGROUP",
-    0x00EC: "MSODRAWING",
-    0x00ED: "MSODRAWINGSELECTION",
-    0x00F0: "SXRULE",
-    0x00F1: "SXEX",
-    0x00F2: "SXFILT",
-    0x00F6: "SXNAME",
-    0x00F7: "SXSELECT",
-    0x00F8: "SXPAIR",
-    0x00F9: "SXFMLA",
-    0x00FB: "SXFORMAT",
-    0x00FC: "SST",
-    0x00FD: "LABELSST",
-    0x00FF: "EXTSST",
-    0x0100: "SXVDEX",
-    0x0103: "SXFORMULA",
-    0x0122: "SXDBEX",
-    0x0137: "CHTRINSERT",
-    0x0138: "CHTRINFO",
-    0x013B: "CHTRCELLCONTENT",
-    0x013D: "TABID",
-    0x0140: "CHTRMOVERANGE",
-    0x014D: "CHTRINSERTTAB",
-    0x015F: "LABELRANGES",
-    0x0160: "USESELFS",
-    0x0161: "DSF",
-    0x0162: "XL5MODIFY",
-    0x0196: "CHTRHEADER",
-    0x01A9: "USERBVIEW",
-    0x01AA: "USERSVIEWBEGIN",
-    0x01AB: "USERSVIEWEND",
-    0x01AD: "QSI",
-    0x01AE: "SUPBOOK",
-    0x01AF: "PROT4REV",
-    0x01B0: "CONDFMT",
-    0x01B1: "CF",
-    0x01B2: "DVAL",
-    0x01B5: "DCONBIN",
-    0x01B6: "TXO",
-    0x01B7: "REFRESHALL",
-    0x01B8: "HLINK",
-    0x01BA: "CODENAME",
-    0x01BB: "SXFDBTYPE",
-    0x01BC: "PROT4REVPASS",
-    0x01BE: "DV",
-    0x01C0: "XL9FILE",
-    0x01C1: "RECALCID",
-    0x0200: "DIMENSIONS",
-    0x0201: "BLANK",
-    0x0203: "NUMBER",
-    0x0204: "LABEL",
-    0x0205: "BOOLERR",
-    0x0206: "FORMULA",
-    0x0207: "STRING",
-    0x0208: "ROW",
-    0x0209: "BOF",
-    0x020B: "INDEX",
-    0x0218: "NAME",
-    0x0221: "ARRAY",
-    0x0223: "EXTERNNAME",
-    0x0225: "DEFAULTROWHEIGHT",
-    0x0231: "FONT",
-    0x0236: "TABLE",
-    0x023E: "WINDOW2",
-    0x0243: "XF",
-    0x027E: "RK",
-    0x0293: "STYLE",
-    0x0406: "FORMULA",
-    0x0409: "BOF",
-    0x041E: "FORMAT",
-    0x0443: "XF",
-    0x04BC: "SHRFMLA",
-    0x0800: "SCREENTIP",
-    0x0803: "WEBQRYSETTINGS",
-    0x0804: "WEBQRYTABLES",
-    0x0809: "BOF",
-    0x0862: "SHEETLAYOUT",
-    0x0867: "SHEETPROTECTION",
-    0x1001: "UNITS",
-    0x1002: "ChartChart",
-    0x1003: "ChartSeries",
-    0x1006: "ChartDataformat",
-    0x1007: "ChartLineformat",
-    0x1009: "ChartMarkerformat",
-    0x100A: "ChartAreaformat",
-    0x100B: "ChartPieformat",
-    0x100C: "ChartAttachedlabel",
-    0x100D: "ChartSeriestext",
-    0x1014: "ChartChartformat",
-    0x1015: "ChartLegend",
-    0x1016: "ChartSerieslist",
-    0x1017: "ChartBar",
-    0x1018: "ChartLine",
-    0x1019: "ChartPie",
-    0x101A: "ChartArea",
-    0x101B: "ChartScatter",
-    0x101C: "ChartChartline",
-    0x101D: "ChartAxis",
-    0x101E: "ChartTick",
-    0x101F: "ChartValuerange",
-    0x1020: "ChartCatserrange",
-    0x1021: "ChartAxislineformat",
-    0x1022: "ChartFormatlink",
-    0x1024: "ChartDefaulttext",
-    0x1025: "ChartText",
-    0x1026: "ChartFontx",
-    0x1027: "ChartObjectLink",
-    0x1032: "ChartFrame",
-    0x1033: "BEGIN",
-    0x1034: "END",
-    0x1035: "ChartPlotarea",
-    0x103A: "Chart3D",
-    0x103C: "ChartPicf",
-    0x103D: "ChartDropbar",
-    0x103E: "ChartRadar",
-    0x103F: "ChartSurface",
-    0x1040: "ChartRadararea",
-    0x1041: "ChartAxisparent",
-    0x1043: "ChartLegendxn",
-    0x1044: "ChartShtprops",
-    0x1045: "ChartSertocrt",
-    0x1046: "ChartAxesused",
-    0x1048: "ChartSbaseref",
-    0x104A: "ChartSerparent",
-    0x104B: "ChartSerauxtrend",
-    0x104E: "ChartIfmt",
-    0x104F: "ChartPos",
-    0x1050: "ChartAlruns",
-    0x1051: "ChartAI",
-    0x105B: "ChartSerauxerrbar",
-    0x105D: "ChartSerfmt",
-    0x105F: "Chart3DDataFormat",
-    0x1060: "ChartFbi",
-    0x1061: "ChartBoppop",
-    0x1062: "ChartAxcext",
-    0x1063: "ChartDat",
-    0x1064: "ChartPlotgrowth",
-    0x1065: "ChartSiindex",
-    0x1066: "ChartGelframe",
-    0x1067: "ChartBoppcustom",
-    0xFFFF: ""
-}
-
-
-std_func_by_name = {
-             "ABS": (0x018,  1,  1,   "V",             "V", False), # 1
-            "ACOS": (0x063,  1,  1,   "V",             "V", False), # 2
-           "ACOSH": (0x0e9,  1,  1,   "V",             "V", False), # 3
-         "ADDRESS": (0x0db,  2,  5,   "V",     "V V V V V", False), # 4
-             "AND": (0x024,  1, 30,   "V",         "R ...", False), # 5
-          "ARCTAN": (0x012,  1,  1,   "V",             "V", False), # 6
-           "AREAS": (0x04b,  1,  1,   "V",             "R", False), # 7
-             "ASC": (0x0d6,  1,  1,   "V",             "V", False), # 8
-            "ASIN": (0x062,  1,  1,   "V",             "V", False), # 9
-           "ASINH": (0x0e8,  1,  1,   "V",             "V", False), # 10
-           "ATAN2": (0x061,  2,  2,   "V",           "V V", False), # 11
-           "ATANH": (0x0ea,  1,  1,   "V",             "V", False), # 12
-          "AVEDEV": (0x10d,  1, 30,   "V",         "R ...", False), # 13
-         "AVERAGE": (0x005,  1, 30,   "V",         "R ...", False), # 14
-        "AVERAGEA": (0x169,  1, 30,   "V",         "R ...", False), # 15
-        "BETADIST": (0x10e,  3,  5,   "V",     "V V V V V", False), # 16
-         "BETAINV": (0x110,  3,  5,   "V",     "V V V V V", False), # 17
-       "BINOMDIST": (0x111,  4,  4,   "V",       "V V V V", False), # 18
-         "CEILING": (0x120,  2,  2,   "V",           "V V", False), # 19
-            "CELL": (0x07d,  1,  2,   "V",           "V R",  True), # 20
-            "CHAR": (0x06f,  1,  1,   "V",             "V", False), # 21
-         "CHIDIST": (0x112,  2,  2,   "V",           "V V", False), # 22
-          "CHIINV": (0x113,  2,  2,   "V",           "V V", False), # 23
-         "CHITEST": (0x132,  2,  2,   "V",           "A A", False), # 24
-          "CHOOSE": (0x064,  2, 30,   "R",       "V R ...", False), # 25
-           "CLEAN": (0x0a2,  1,  1,   "V",             "V", False), # 26
-            "CODE": (0x079,  1,  1,   "V",             "V", False), # 27
-          "COLUMN": (0x009,  0,  1,   "V",             "R", False), # 28
-         "COLUMNS": (0x04d,  1,  1,   "V",             "R", False), # 29
-          "COMBIN": (0x114,  2,  2,   "V",           "V V", False), # 30
-     "CONCATENATE": (0x150,  0, 30,   "V",         "V ...", False), # 31
-      "CONFIDENCE": (0x115,  3,  3,   "V",         "V V V", False), # 32
-          "CORREL": (0x133,  2,  2,   "V",           "A A", False), # 33
-             "COS": (0x010,  1,  1,   "V",             "V", False), # 34
-            "COSH": (0x0e6,  1,  1,   "V",             "V", False), # 35
-           "COUNT": (0x000,  0, 30,   "V",         "R ...", False), # 36
-          "COUNTA": (0x0a9,  0, 30,   "V",         "R ...", False), # 37
-      "COUNTBLANK": (0x15b,  1,  1,   "V",             "R", False), # 38
-         "COUNTIF": (0x15a,  2,  2,   "V",           "R V", False), # 39
-           "COVAR": (0x134,  2,  2,   "V",           "A A", False), # 40
-       "CRITBINOM": (0x116,  3,  3,   "V",         "V V V", False), # 41
-            "DATE": (0x041,  3,  3,   "V",         "V V V", False), # 42
-         "DATEDIF": (0x15f,  3,  3,   "V",         "V V V", False), # 43
-      "DATESTRING": (0x160,  1,  1,   "V",             "V", False), # 44
-       "DATEVALUE": (0x08c,  1,  1,   "V",             "V", False), # 45
-        "DAVERAGE": (0x02a,  3,  3,   "V",         "R R R", False), # 46
-             "DAY": (0x043,  1,  1,   "V",             "V", False), # 47
-         "DAYS360": (0x0dc,  2,  3,   "V",         "V V V", False), # 48
-              "DB": (0x0f7,  4,  5,   "V",     "V V V V V", False), # 49
-            "DBSC": (0x0d7,  1,  1,   "V",             "V", False), # 50
-          "DCOUNT": (0x028,  3,  3,   "V",         "R R R", False), # 51
-         "DCOUNTA": (0x0c7,  3,  3,   "V",         "R R R", False), # 52
-             "DDB": (0x090,  4,  5,   "V",     "V V V V V", False), # 53
-         "DEGREES": (0x157,  1,  1,   "V",             "V", False), # 54
-           "DEVSQ": (0x13e,  1, 30,   "V",         "R ...", False), # 55
-            "DGET": (0x0eb,  3,  3,   "V",         "R R R", False), # 56
-            "DMAX": (0x02c,  3,  3,   "V",         "R R R", False), # 57
-            "DMIN": (0x02b,  3,  3,   "V",         "R R R", False), # 58
-          "DOLLAR": (0x00d,  1,  2,   "V",           "V V", False), # 59
-        "DPRODUCT": (0x0bf,  3,  3,   "V",         "R R R", False), # 60
-          "DSTDEV": (0x02d,  3,  3,   "V",         "R R R", False), # 61
-         "DSTDEVP": (0x0c3,  3,  3,   "V",         "R R R", False), # 62
-            "DSUM": (0x029,  3,  3,   "V",         "R R R", False), # 63
-            "DVAR": (0x02f,  3,  3,   "V",         "R R R", False), # 64
-           "DVARP": (0x0c4,  3,  3,   "V",         "R R R", False), # 65
-      "ERROR.TYPE": (0x105,  1,  1,   "V",             "V", False), # 66
-            "EVEN": (0x117,  1,  1,   "V",             "V", False), # 67
-           "EXACT": (0x075,  2,  2,   "V",           "V V", False), # 68
-             "EXP": (0x015,  1,  1,   "V",             "V", False), # 69
-       "EXPONDIST": (0x118,  3,  3,   "V",         "V V V", False), # 70
-            "FACT": (0x0b8,  1,  1,   "V",             "V", False), # 71
-           "FALSE": (0x023,  0,  0,   "V",             "-", False), # 72
-           "FDIST": (0x119,  3,  3,   "V",         "V V V", False), # 73
-            "FIND": (0x07c,  2,  3,   "V",         "V V V", False), # 74
-           "FINDB": (0x0cd,  2,  3,   "V",         "V V V", False), # 75
-            "FINV": (0x11a,  3,  3,   "V",         "V V V", False), # 76
-          "FISHER": (0x11b,  1,  1,   "V",             "V", False), # 77
-       "FISHERINV": (0x11c,  1,  1,   "V",             "V", False), # 78
-           "FIXED": (0x00e,  2,  3,   "V",         "V V V", False), # 79
-           "FLOOR": (0x11d,  2,  2,   "V",           "V V", False), # 80
-        "FORECAST": (0x135,  3,  3,   "V",         "V A A", False), # 81
-       "FREQUENCY": (0x0fc,  2,  2,   "A",           "R R", False), # 82
-           "FTEST": (0x136,  2,  2,   "V",           "A A", False), # 83
-              "FV": (0x039,  3,  5,   "V",     "V V V V V", False), # 84
-       "GAMMADIST": (0x11e,  4,  4,   "V",       "V V V V", False), # 85
-        "GAMMAINV": (0x11f,  3,  3,   "V",         "V V V", False), # 86
-         "GAMMALN": (0x10f,  1,  1,   "V",             "V", False), # 87
-         "GEOMEAN": (0x13f,  1, 30,   "V",         "R ...", False), # 88
-    "GETPIVOTDATA": (0x166,  2, 30,   "A",             "-", False), # 89
-          "GROWTH": (0x034,  1,  4,   "A",       "R R R V", False), # 90
-         "HARMEAN": (0x140,  1, 30,   "V",         "R ...", False), # 91
-         "HLOOKUP": (0x065,  3,  4,   "V",       "V R R V", False), # 92
-            "HOUR": (0x047,  1,  1,   "V",             "V", False), # 93
-       "HYPERLINK": (0x167,  1,  2,   "V",           "V V", False), # 94
-     "HYPGEOMVERT": (0x121,  4,  4,   "V",       "V V V V", False), # 95
-              "IF": (0x001,  2,  3,   "R",         "V R R", False), # 96
-           "INDEX": (0x01d,  2,  4,   "R",       "R V V V", False), # 97
-        "INDIRECT": (0x094,  1,  2,   "R",           "V V",  True), # 98
-            "INFO": (0x0f4,  1,  1,   "V",             "V", False), # 99
-             "INT": (0x019,  1,  1,   "V",             "V", False), # 100
-       "INTERCEPT": (0x137,  2,  2,   "V",           "A A", False), # 101
-            "IPMT": (0x0a7,  4,  6,   "V",   "V V V V V V", False), # 102
-             "IRR": (0x03e,  1,  2,   "V",           "R V", False), # 103
-         "ISBLANK": (0x081,  1,  1,   "V",             "V", False), # 104
-           "ISERR": (0x07e,  1,  1,   "V",             "V", False), # 105
-         "ISERROR": (0x003,  1,  1,   "V",             "V", False), # 106
-       "ISLOGICAL": (0x0c6,  1,  1,   "V",             "V", False), # 107
-            "ISNA": (0x002,  1,  1,   "V",             "V", False), # 108
-       "ISNONTEXT": (0x0c0,  1,  1,   "V",             "V", False), # 109
-        "ISNUMBER": (0x080,  1,  1,   "V",             "V", False), # 110
-           "ISPMT": (0x15e,  4,  4,   "V",       "V V V V", False), # 111
-           "ISREF": (0x069,  1,  1,   "V",             "R", False), # 112
-          "ISTEXT": (0x07f,  1,  1,   "V",             "V", False), # 113
-            "KURT": (0x142,  1, 30,   "V",         "R ...", False), # 114
-           "LARGE": (0x145,  2,  2,   "V",           "R V", False), # 115
-            "LEFT": (0x073,  1,  2,   "V",           "V V", False), # 116
-           "LEFTB": (0x0d0,  1,  2,   "V",           "V V", False), # 117
-             "LEN": (0x020,  1,  1,   "V",             "V", False), # 118
-            "LENB": (0x0d3,  1,  1,   "V",             "V", False), # 119
-          "LINEST": (0x031,  1,  4,   "A",       "R R V V", False), # 120
-              "LN": (0x016,  1,  1,   "V",             "V", False), # 121
-             "LOG": (0x06d,  1,  2,   "V",           "V V", False), # 122
-           "LOG10": (0x017,  1,  1,   "V",             "V", False), # 123
-          "LOGEST": (0x033,  1,  4,   "A",       "R R V V", False), # 124
-          "LOGINV": (0x123,  3,  3,   "V",         "V V V", False), # 125
-     "LOGNORMDIST": (0x122,  3,  3,   "V",         "V V V", False), # 126
-          "LOOKUP": (0x01c,  2,  3,   "V",         "V R R", False), # 127
-           "LOWER": (0x070,  1,  1,   "V",             "V", False), # 128
-           "MATCH": (0x040,  2,  3,   "V",         "V R R", False), # 129
-             "MAX": (0x007,  1, 30,   "V",         "R ...", False), # 130
-            "MAXA": (0x16a,  1, 30,   "V",         "R ...", False), # 131
-         "MDETERM": (0x0a3,  1,  1,   "V",             "A", False), # 132
-          "MEDIAN": (0x0e3,  1, 30,   "V",         "R ...", False), # 133
-             "MID": (0x01f,  3,  3,   "V",         "V V V", False), # 134
-            "MIDB": (0x0d2,  3,  3,   "V",         "V V V", False), # 135
-             "MIN": (0x006,  1, 30,   "V",         "R ...", False), # 136
-            "MINA": (0x16b,  1, 30,   "V",         "R ...", False), # 137
-          "MINUTE": (0x048,  1,  1,   "V",             "V", False), # 138
-        "MINVERSE": (0x0a4,  1,  1,   "A",             "A", False), # 139
-            "MIRR": (0x03d,  3,  3,   "V",         "R V V", False), # 140
-           "MMULT": (0x0a5,  2,  2,   "A",           "A A", False), # 141
-       "MNORMSINV": (0x128,  1,  1,   "V",             "V", False), # 142
-             "MOD": (0x027,  2,  2,   "V",           "V V", False), # 143
-            "MODE": (0x14a,  1, 30,   "V",         "A ...", False), # 144
-           "MONTH": (0x044,  1,  1,   "V",             "V", False), # 145
-               "N": (0x083,  1,  1,   "V",             "R", False), # 146
-              "NA": (0x00a,  0,  0,   "V",             "-", False), # 147
-    "NEGBINOMDIST": (0x124,  3,  3,   "V",         "V V V", False), # 148
-        "NORMDIST": (0x125,  4,  4,   "V",       "V V V V", False), # 149
-         "NORMINV": (0x127,  3,  3,   "V",         "V V V", False), # 150
-       "NORMSDIST": (0x126,  1,  1,   "V",             "V", False), # 151
-             "NOT": (0x026,  1,  1,   "V",             "V", False), # 152
-             "NOW": (0x04a,  0,  0,   "V",             "-",  True), # 153
-            "NPER": (0x03a,  3,  5,   "V",     "V V V V V", False), # 154
-             "NPV": (0x00b,  2, 30,   "V",       "V R ...", False), # 155
-    "NUMBERSTRING": (0x161,  2,  2,   "V",           "V V", False), # 156
-             "ODD": (0x12a,  1,  1,   "V",             "V", False), # 157
-          "OFFSET": (0x04e,  3,  5,   "R",     "R V V V V",  True), # 158
-              "OR": (0x025,  1, 30,   "V",         "R ...", False), # 159
-         "PEARSON": (0x138,  2,  2,   "V",           "A A", False), # 160
-      "PERCENTILE": (0x148,  2,  2,   "V",           "R V", False), # 161
-     "PERCENTRANK": (0x149,  2,  3,   "V",         "R V V", False), # 162
-          "PERMUT": (0x12b,  2,  2,   "V",           "V V", False), # 163
-        "PHONETIC": (0x168,  1,  1,   "V",             "R", False), # 164
-              "PI": (0x013,  0,  0,   "V",             "-", False), # 165
-             "PMT": (0x03b,  3,  5,   "V",     "V V V V V", False), # 166
-         "POISSON": (0x12c,  3,  3,   "V",         "V V V", False), # 167
-           "POWER": (0x151,  2,  2,   "V",           "V V", False), # 168
-            "PPMT": (0x0a8,  4,  6,   "V",   "V V V V V V", False), # 169
-            "PROB": (0x13d,  3,  4,   "V",       "A A V V", False), # 170
-         "PRODUCT": (0x0b7,  0, 30,   "V",         "R ...", False), # 171
-          "PROPER": (0x072,  1,  1,   "V",             "V", False), # 172
-              "PV": (0x038,  3,  5,   "V",     "V V V V V", False), # 173
-        "QUARTILE": (0x147,  2,  2,   "V",           "R V", False), # 174
-         "RADIANS": (0x156,  1,  1,   "V",             "V", False), # 175
-            "RAND": (0x03f,  0,  0,   "V",             "-",  True), # 176
-            "RANK": (0x0d8,  2,  3,   "V",         "V R V", False), # 177
-            "RATE": (0x03c,  3,  6,   "V",   "V V V V V V", False), # 178
-         "REPLACE": (0x077,  4,  4,   "V",       "V V V V", False), # 179
-        "REPLACEB": (0x0cf,  4,  4,   "V",       "V V V V", False), # 180
-            "REPT": (0x01e,  2,  2,   "V",           "V V", False), # 181
-           "RIGHT": (0x074,  1,  2,   "V",           "V V", False), # 182
-          "RIGHTB": (0x0d1,  1,  2,   "V",           "V V", False), # 183
-           "ROMAN": (0x162,  1,  2,   "V",           "V V", False), # 184
-           "ROUND": (0x01b,  2,  2,   "V",           "V V", False), # 185
-       "ROUNDDOWN": (0x0d5,  2,  2,   "V",           "V V", False), # 186
-         "ROUNDUP": (0x0d4,  2,  2,   "V",           "V V", False), # 187
-             "ROW": (0x008,  0,  1,   "V",             "R", False), # 188
-            "ROWS": (0x04c,  1,  1,   "V",             "R", False), # 189
-             "RSQ": (0x139,  2,  2,   "V",           "A A", False), # 190
-          "SEARCH": (0x052,  2,  3,   "V",         "V V V", False), # 191
-         "SEARCHB": (0x0ce,  2,  3,   "V",         "V V V", False), # 192
-          "SECOND": (0x049,  1,  1,   "V",             "V", False), # 193
-            "SIGN": (0x01a,  1,  1,   "V",             "V", False), # 194
-             "SIN": (0x00f,  1,  1,   "V",             "V", False), # 195
-            "SINH": (0x0e5,  1,  1,   "V",             "V", False), # 196
-            "SKEW": (0x143,  1, 30,   "V",         "R ...", False), # 197
-             "SLN": (0x08e,  3,  3,   "V",         "V V V", False), # 198
-           "SLOPE": (0x13b,  2,  2,   "V",           "A A", False), # 199
-           "SMALL": (0x146,  2,  2,   "V",           "R V", False), # 200
-            "SQRT": (0x014,  1,  1,   "V",             "V", False), # 201
-     "STANDARDIZE": (0x129,  3,  3,   "V",         "V V V", False), # 202
-           "STDEV": (0x00c,  1, 30,   "V",         "R ...", False), # 203
-          "STDEVA": (0x16e,  1, 30,   "V",         "R ...", False), # 204
-          "STDEVP": (0x0c1,  1, 30,   "V",         "R ...", False), # 205
-         "STDEVPA": (0x16c,  1, 30,   "V",         "R ...", False), # 206
-           "STEYX": (0x13a,  2,  2,   "V",           "A A", False), # 207
-      "SUBSTITUTE": (0x078,  3,  4,   "V",       "V V V V", False), # 208
-        "SUBTOTAL": (0x158,  2, 30,   "V",       "V R ...", False), # 209
-             "SUM": (0x004,  0, 30,   "V",         "R ...", False), # 210
-           "SUMIF": (0x159,  2,  3,   "V",         "R V R", False), # 211
-      "SUMPRODUCT": (0x0e4,  1, 30,   "V",         "A ...", False), # 212
-           "SUMSQ": (0x141,  0, 30,   "V",         "R ...", False), # 213
-        "SUMX2MY2": (0x130,  2,  2,   "V",           "A A", False), # 214
-        "SUMX2PY2": (0x131,  2,  2,   "V",           "A A", False), # 215
-         "SUMXMY2": (0x12f,  2,  2,   "V",           "A A", False), # 216
-             "SYD": (0x08f,  4,  4,   "V",       "V V V V", False), # 217
-               "T": (0x082,  1,  1,   "V",             "R", False), # 218
-             "TAN": (0x011,  1,  1,   "V",             "V", False), # 219
-            "TANH": (0x0e7,  1,  1,   "V",             "V", False), # 220
-           "TDIST": (0x12d,  3,  3,   "V",         "V V V", False), # 221
-            "TEXT": (0x030,  2,  2,   "V",           "V V", False), # 222
-            "TIME": (0x042,  3,  3,   "V",         "V V V", False), # 223
-       "TIMEVALUE": (0x08d,  1,  1,   "V",             "V", False), # 224
-            "TINV": (0x14c,  2,  2,   "V",           "V V", False), # 225
-           "TODAY": (0x0dd,  0,  0,   "V",             "-",  True), # 226
-       "TRANSPOSE": (0x053,  1,  1,   "A",             "A", False), # 227
-           "TREND": (0x032,  1,  4,   "A",       "R R R V", False), # 228
-            "TRIM": (0x076,  1,  1,   "V",             "V", False), # 229
-        "TRIMMEAN": (0x14b,  2,  2,   "V",           "R V", False), # 230
-            "TRUE": (0x022,  0,  0,   "V",             "-", False), # 231
-           "TRUNC": (0x0c5,  1,  2,   "V",           "V V", False), # 232
-           "TTEST": (0x13c,  4,  4,   "V",       "A A V V", False), # 233
-            "TYPE": (0x056,  1,  1,   "V",             "V", False), # 234
-           "UPPER": (0x071,  1,  1,   "V",             "V", False), # 235
-        "USDOLLAR": (0x0cc,  1,  2,   "V",           "V V", False), # 236
-           "VALUE": (0x021,  1,  1,   "V",             "V", False), # 237
-             "VAR": (0x02e,  1, 30,   "V",         "R ...", False), # 238
-            "VARA": (0x16f,  1, 30,   "V",         "R ...", False), # 239
-            "VARP": (0x0c2,  1, 30,   "V",         "R ...", False), # 240
-           "VARPA": (0x16d,  1, 30,   "V",         "R ...", False), # 241
-             "VDB": (0x0de,  5,  7,   "V", "V V V V V V V", False), # 242
-         "VLOOKUP": (0x066,  3,  4,   "V",       "V R R V", False), # 243
-         "WEEKDAY": (0x046,  1,  2,   "V",           "V V", False), # 244
-         "WEIBULL": (0x12e,  4,  4,   "V",       "V V V V", False), # 245
-            "YEAR": (0x045,  1,  1,   "V",             "V", False), # 246
-           "ZTEST": (0x144,  2,  3,   "V",         "R V V", False)  # 247
-}
-
-
-std_func_by_num = {
-    0x000: (       "COUNT",  0, 30,   "V",         "R ...", False), # 1
-    0x001: (          "IF",  2,  3,   "R",         "V R R", False), # 2
-    0x002: (        "ISNA",  1,  1,   "V",             "V", False), # 3
-    0x003: (     "ISERROR",  1,  1,   "V",             "V", False), # 4
-    0x004: (         "SUM",  0, 30,   "V",         "R ...", False), # 5
-    0x005: (     "AVERAGE",  1, 30,   "V",         "R ...", False), # 6
-    0x006: (         "MIN",  1, 30,   "V",         "R ...", False), # 7
-    0x007: (         "MAX",  1, 30,   "V",         "R ...", False), # 8
-    0x008: (         "ROW",  0,  1,   "V",             "R", False), # 9
-    0x009: (      "COLUMN",  0,  1,   "V",             "R", False), # 10
-    0x00a: (          "NA",  0,  0,   "V",             "-", False), # 11
-    0x00b: (         "NPV",  2, 30,   "V",       "V R ...", False), # 12
-    0x00c: (       "STDEV",  1, 30,   "V",         "R ...", False), # 13
-    0x00d: (      "DOLLAR",  1,  2,   "V",           "V V", False), # 14
-    0x00e: (       "FIXED",  2,  3,   "V",         "V V V", False), # 15
-    0x00f: (         "SIN",  1,  1,   "V",             "V", False), # 16
-    0x010: (         "COS",  1,  1,   "V",             "V", False), # 17
-    0x011: (         "TAN",  1,  1,   "V",             "V", False), # 18
-    0x012: (      "ARCTAN",  1,  1,   "V",             "V", False), # 19
-    0x013: (          "PI",  0,  0,   "V",             "-", False), # 20
-    0x014: (        "SQRT",  1,  1,   "V",             "V", False), # 21
-    0x015: (         "EXP",  1,  1,   "V",             "V", False), # 22
-    0x016: (          "LN",  1,  1,   "V",             "V", False), # 23
-    0x017: (       "LOG10",  1,  1,   "V",             "V", False), # 24
-    0x018: (         "ABS",  1,  1,   "V",             "V", False), # 25
-    0x019: (         "INT",  1,  1,   "V",             "V", False), # 26
-    0x01a: (        "SIGN",  1,  1,   "V",             "V", False), # 27
-    0x01b: (       "ROUND",  2,  2,   "V",           "V V", False), # 28
-    0x01c: (      "LOOKUP",  2,  3,   "V",         "V R R", False), # 29
-    0x01d: (       "INDEX",  2,  4,   "R",       "R V V V", False), # 30
-    0x01e: (        "REPT",  2,  2,   "V",           "V V", False), # 31
-    0x01f: (         "MID",  3,  3,   "V",         "V V V", False), # 32
-    0x020: (         "LEN",  1,  1,   "V",             "V", False), # 33
-    0x021: (       "VALUE",  1,  1,   "V",             "V", False), # 34
-    0x022: (        "TRUE",  0,  0,   "V",             "-", False), # 35
-    0x023: (       "FALSE",  0,  0,   "V",             "-", False), # 36
-    0x024: (         "AND",  1, 30,   "V",         "R ...", False), # 37
-    0x025: (          "OR",  1, 30,   "V",         "R ...", False), # 38
-    0x026: (         "NOT",  1,  1,   "V",             "V", False), # 39
-    0x027: (         "MOD",  2,  2,   "V",           "V V", False), # 40
-    0x028: (      "DCOUNT",  3,  3,   "V",         "R R R", False), # 41
-    0x029: (        "DSUM",  3,  3,   "V",         "R R R", False), # 42
-    0x02a: (    "DAVERAGE",  3,  3,   "V",         "R R R", False), # 43
-    0x02b: (        "DMIN",  3,  3,   "V",         "R R R", False), # 44
-    0x02c: (        "DMAX",  3,  3,   "V",         "R R R", False), # 45
-    0x02d: (      "DSTDEV",  3,  3,   "V",         "R R R", False), # 46
-    0x02e: (         "VAR",  1, 30,   "V",         "R ...", False), # 47
-    0x02f: (        "DVAR",  3,  3,   "V",         "R R R", False), # 48
-    0x030: (        "TEXT",  2,  2,   "V",           "V V", False), # 49
-    0x031: (      "LINEST",  1,  4,   "A",       "R R V V", False), # 50
-    0x032: (       "TREND",  1,  4,   "A",       "R R R V", False), # 51
-    0x033: (      "LOGEST",  1,  4,   "A",       "R R V V", False), # 52
-    0x034: (      "GROWTH",  1,  4,   "A",       "R R R V", False), # 53
-    0x038: (          "PV",  3,  5,   "V",     "V V V V V", False), # 54
-    0x039: (          "FV",  3,  5,   "V",     "V V V V V", False), # 55
-    0x03a: (        "NPER",  3,  5,   "V",     "V V V V V", False), # 56
-    0x03b: (         "PMT",  3,  5,   "V",     "V V V V V", False), # 57
-    0x03c: (        "RATE",  3,  6,   "V",   "V V V V V V", False), # 58
-    0x03d: (        "MIRR",  3,  3,   "V",         "R V V", False), # 59
-    0x03e: (         "IRR",  1,  2,   "V",           "R V", False), # 60
-    0x03f: (        "RAND",  0,  0,   "V",             "-",  True), # 61
-    0x040: (       "MATCH",  2,  3,   "V",         "V R R", False), # 62
-    0x041: (        "DATE",  3,  3,   "V",         "V V V", False), # 63
-    0x042: (        "TIME",  3,  3,   "V",         "V V V", False), # 64
-    0x043: (         "DAY",  1,  1,   "V",             "V", False), # 65
-    0x044: (       "MONTH",  1,  1,   "V",             "V", False), # 66
-    0x045: (        "YEAR",  1,  1,   "V",             "V", False), # 67
-    0x046: (     "WEEKDAY",  1,  2,   "V",           "V V", False), # 68
-    0x047: (        "HOUR",  1,  1,   "V",             "V", False), # 69
-    0x048: (      "MINUTE",  1,  1,   "V",             "V", False), # 70
-    0x049: (      "SECOND",  1,  1,   "V",             "V", False), # 71
-    0x04a: (         "NOW",  0,  0,   "V",             "-",  True), # 72
-    0x04b: (       "AREAS",  1,  1,   "V",             "R", False), # 73
-    0x04c: (        "ROWS",  1,  1,   "V",             "R", False), # 74
-    0x04d: (     "COLUMNS",  1,  1,   "V",             "R", False), # 75
-    0x04e: (      "OFFSET",  3,  5,   "R",     "R V V V V",  True), # 76
-    0x052: (      "SEARCH",  2,  3,   "V",         "V V V", False), # 77
-    0x053: (   "TRANSPOSE",  1,  1,   "A",             "A", False), # 78
-    0x056: (        "TYPE",  1,  1,   "V",             "V", False), # 79
-    0x061: (       "ATAN2",  2,  2,   "V",           "V V", False), # 80
-    0x062: (        "ASIN",  1,  1,   "V",             "V", False), # 81
-    0x063: (        "ACOS",  1,  1,   "V",             "V", False), # 82
-    0x064: (      "CHOOSE",  2, 30,   "R",       "V R ...", False), # 83
-    0x065: (     "HLOOKUP",  3,  4,   "V",       "V R R V", False), # 84
-    0x066: (     "VLOOKUP",  3,  4,   "V",       "V R R V", False), # 85
-    0x069: (       "ISREF",  1,  1,   "V",             "R", False), # 86
-    0x06d: (         "LOG",  1,  2,   "V",           "V V", False), # 87
-    0x06f: (        "CHAR",  1,  1,   "V",             "V", False), # 88
-    0x070: (       "LOWER",  1,  1,   "V",             "V", False), # 89
-    0x071: (       "UPPER",  1,  1,   "V",             "V", False), # 90
-    0x072: (      "PROPER",  1,  1,   "V",             "V", False), # 91
-    0x073: (        "LEFT",  1,  2,   "V",           "V V", False), # 92
-    0x074: (       "RIGHT",  1,  2,   "V",           "V V", False), # 93
-    0x075: (       "EXACT",  2,  2,   "V",           "V V", False), # 94
-    0x076: (        "TRIM",  1,  1,   "V",             "V", False), # 95
-    0x077: (     "REPLACE",  4,  4,   "V",       "V V V V", False), # 96
-    0x078: (  "SUBSTITUTE",  3,  4,   "V",       "V V V V", False), # 97
-    0x079: (        "CODE",  1,  1,   "V",             "V", False), # 98
-    0x07c: (        "FIND",  2,  3,   "V",         "V V V", False), # 99
-    0x07d: (        "CELL",  1,  2,   "V",           "V R",  True), # 100
-    0x07e: (       "ISERR",  1,  1,   "V",             "V", False), # 101
-    0x07f: (      "ISTEXT",  1,  1,   "V",             "V", False), # 102
-    0x080: (    "ISNUMBER",  1,  1,   "V",             "V", False), # 103
-    0x081: (     "ISBLANK",  1,  1,   "V",             "V", False), # 104
-    0x082: (           "T",  1,  1,   "V",             "R", False), # 105
-    0x083: (           "N",  1,  1,   "V",             "R", False), # 106
-    0x08c: (   "DATEVALUE",  1,  1,   "V",             "V", False), # 107
-    0x08d: (   "TIMEVALUE",  1,  1,   "V",             "V", False), # 108
-    0x08e: (         "SLN",  3,  3,   "V",         "V V V", False), # 109
-    0x08f: (         "SYD",  4,  4,   "V",       "V V V V", False), # 110
-    0x090: (         "DDB",  4,  5,   "V",     "V V V V V", False), # 111
-    0x094: (    "INDIRECT",  1,  2,   "R",           "V V",  True), # 112
-    0x0a2: (       "CLEAN",  1,  1,   "V",             "V", False), # 113
-    0x0a3: (     "MDETERM",  1,  1,   "V",             "A", False), # 114
-    0x0a4: (    "MINVERSE",  1,  1,   "A",             "A", False), # 115
-    0x0a5: (       "MMULT",  2,  2,   "A",           "A A", False), # 116
-    0x0a7: (        "IPMT",  4,  6,   "V",   "V V V V V V", False), # 117
-    0x0a8: (        "PPMT",  4,  6,   "V",   "V V V V V V", False), # 118
-    0x0a9: (      "COUNTA",  0, 30,   "V",         "R ...", False), # 119
-    0x0b7: (     "PRODUCT",  0, 30,   "V",         "R ...", False), # 120
-    0x0b8: (        "FACT",  1,  1,   "V",             "V", False), # 121
-    0x0bf: (    "DPRODUCT",  3,  3,   "V",         "R R R", False), # 122
-    0x0c0: (   "ISNONTEXT",  1,  1,   "V",             "V", False), # 123
-    0x0c1: (      "STDEVP",  1, 30,   "V",         "R ...", False), # 124
-    0x0c2: (        "VARP",  1, 30,   "V",         "R ...", False), # 125
-    0x0c3: (     "DSTDEVP",  3,  3,   "V",         "R R R", False), # 126
-    0x0c4: (       "DVARP",  3,  3,   "V",         "R R R", False), # 127
-    0x0c5: (       "TRUNC",  1,  2,   "V",           "V V", False), # 128
-    0x0c6: (   "ISLOGICAL",  1,  1,   "V",             "V", False), # 129
-    0x0c7: (     "DCOUNTA",  3,  3,   "V",         "R R R", False), # 130
-    0x0cc: (    "USDOLLAR",  1,  2,   "V",           "V V", False), # 131
-    0x0cd: (       "FINDB",  2,  3,   "V",         "V V V", False), # 132
-    0x0ce: (     "SEARCHB",  2,  3,   "V",         "V V V", False), # 133
-    0x0cf: (    "REPLACEB",  4,  4,   "V",       "V V V V", False), # 134
-    0x0d0: (       "LEFTB",  1,  2,   "V",           "V V", False), # 135
-    0x0d1: (      "RIGHTB",  1,  2,   "V",           "V V", False), # 136
-    0x0d2: (        "MIDB",  3,  3,   "V",         "V V V", False), # 137
-    0x0d3: (        "LENB",  1,  1,   "V",             "V", False), # 138
-    0x0d4: (     "ROUNDUP",  2,  2,   "V",           "V V", False), # 139
-    0x0d5: (   "ROUNDDOWN",  2,  2,   "V",           "V V", False), # 140
-    0x0d6: (         "ASC",  1,  1,   "V",             "V", False), # 141
-    0x0d7: (        "DBSC",  1,  1,   "V",             "V", False), # 142
-    0x0d8: (        "RANK",  2,  3,   "V",         "V R V", False), # 143
-    0x0db: (     "ADDRESS",  2,  5,   "V",     "V V V V V", False), # 144
-    0x0dc: (     "DAYS360",  2,  3,   "V",         "V V V", False), # 145
-    0x0dd: (       "TODAY",  0,  0,   "V",             "-",  True), # 146
-    0x0de: (         "VDB",  5,  7,   "V", "V V V V V V V", False), # 147
-    0x0e3: (      "MEDIAN",  1, 30,   "V",         "R ...", False), # 148
-    0x0e4: (  "SUMPRODUCT",  1, 30,   "V",         "A ...", False), # 149
-    0x0e5: (        "SINH",  1,  1,   "V",             "V", False), # 150
-    0x0e6: (        "COSH",  1,  1,   "V",             "V", False), # 151
-    0x0e7: (        "TANH",  1,  1,   "V",             "V", False), # 152
-    0x0e8: (       "ASINH",  1,  1,   "V",             "V", False), # 153
-    0x0e9: (       "ACOSH",  1,  1,   "V",             "V", False), # 154
-    0x0ea: (       "ATANH",  1,  1,   "V",             "V", False), # 155
-    0x0eb: (        "DGET",  3,  3,   "V",         "R R R", False), # 156
-    0x0f4: (        "INFO",  1,  1,   "V",             "V", False), # 157
-    0x0f7: (          "DB",  4,  5,   "V",     "V V V V V", False), # 158
-    0x0fc: (   "FREQUENCY",  2,  2,   "A",           "R R", False), # 159
-    0x105: (  "ERROR.TYPE",  1,  1,   "V",             "V", False), # 160
-    0x10d: (      "AVEDEV",  1, 30,   "V",         "R ...", False), # 161
-    0x10e: (    "BETADIST",  3,  5,   "V",     "V V V V V", False), # 162
-    0x10f: (     "GAMMALN",  1,  1,   "V",             "V", False), # 163
-    0x110: (     "BETAINV",  3,  5,   "V",     "V V V V V", False), # 164
-    0x111: (   "BINOMDIST",  4,  4,   "V",       "V V V V", False), # 165
-    0x112: (     "CHIDIST",  2,  2,   "V",           "V V", False), # 166
-    0x113: (      "CHIINV",  2,  2,   "V",           "V V", False), # 167
-    0x114: (      "COMBIN",  2,  2,   "V",           "V V", False), # 168
-    0x115: (  "CONFIDENCE",  3,  3,   "V",         "V V V", False), # 169
-    0x116: (   "CRITBINOM",  3,  3,   "V",         "V V V", False), # 170
-    0x117: (        "EVEN",  1,  1,   "V",             "V", False), # 171
-    0x118: (   "EXPONDIST",  3,  3,   "V",         "V V V", False), # 172
-    0x119: (       "FDIST",  3,  3,   "V",         "V V V", False), # 173
-    0x11a: (        "FINV",  3,  3,   "V",         "V V V", False), # 174
-    0x11b: (      "FISHER",  1,  1,   "V",             "V", False), # 175
-    0x11c: (   "FISHERINV",  1,  1,   "V",             "V", False), # 176
-    0x11d: (       "FLOOR",  2,  2,   "V",           "V V", False), # 177
-    0x11e: (   "GAMMADIST",  4,  4,   "V",       "V V V V", False), # 178
-    0x11f: (    "GAMMAINV",  3,  3,   "V",         "V V V", False), # 179
-    0x120: (     "CEILING",  2,  2,   "V",           "V V", False), # 180
-    0x121: ( "HYPGEOMVERT",  4,  4,   "V",       "V V V V", False), # 181
-    0x122: ( "LOGNORMDIST",  3,  3,   "V",         "V V V", False), # 182
-    0x123: (      "LOGINV",  3,  3,   "V",         "V V V", False), # 183
-    0x124: ("NEGBINOMDIST",  3,  3,   "V",         "V V V", False), # 184
-    0x125: (    "NORMDIST",  4,  4,   "V",       "V V V V", False), # 185
-    0x126: (   "NORMSDIST",  1,  1,   "V",             "V", False), # 186
-    0x127: (     "NORMINV",  3,  3,   "V",         "V V V", False), # 187
-    0x128: (   "MNORMSINV",  1,  1,   "V",             "V", False), # 188
-    0x129: ( "STANDARDIZE",  3,  3,   "V",         "V V V", False), # 189
-    0x12a: (         "ODD",  1,  1,   "V",             "V", False), # 190
-    0x12b: (      "PERMUT",  2,  2,   "V",           "V V", False), # 191
-    0x12c: (     "POISSON",  3,  3,   "V",         "V V V", False), # 192
-    0x12d: (       "TDIST",  3,  3,   "V",         "V V V", False), # 193
-    0x12e: (     "WEIBULL",  4,  4,   "V",       "V V V V", False), # 194
-    0x12f: (     "SUMXMY2",  2,  2,   "V",           "A A", False), # 195
-    0x130: (    "SUMX2MY2",  2,  2,   "V",           "A A", False), # 196
-    0x131: (    "SUMX2PY2",  2,  2,   "V",           "A A", False), # 197
-    0x132: (     "CHITEST",  2,  2,   "V",           "A A", False), # 198
-    0x133: (      "CORREL",  2,  2,   "V",           "A A", False), # 199
-    0x134: (       "COVAR",  2,  2,   "V",           "A A", False), # 200
-    0x135: (    "FORECAST",  3,  3,   "V",         "V A A", False), # 201
-    0x136: (       "FTEST",  2,  2,   "V",           "A A", False), # 202
-    0x137: (   "INTERCEPT",  2,  2,   "V",           "A A", False), # 203
-    0x138: (     "PEARSON",  2,  2,   "V",           "A A", False), # 204
-    0x139: (         "RSQ",  2,  2,   "V",           "A A", False), # 205
-    0x13a: (       "STEYX",  2,  2,   "V",           "A A", False), # 206
-    0x13b: (       "SLOPE",  2,  2,   "V",           "A A", False), # 207
-    0x13c: (       "TTEST",  4,  4,   "V",       "A A V V", False), # 208
-    0x13d: (        "PROB",  3,  4,   "V",       "A A V V", False), # 209
-    0x13e: (       "DEVSQ",  1, 30,   "V",         "R ...", False), # 210
-    0x13f: (     "GEOMEAN",  1, 30,   "V",         "R ...", False), # 211
-    0x140: (     "HARMEAN",  1, 30,   "V",         "R ...", False), # 212
-    0x141: (       "SUMSQ",  0, 30,   "V",         "R ...", False), # 213
-    0x142: (        "KURT",  1, 30,   "V",         "R ...", False), # 214
-    0x143: (        "SKEW",  1, 30,   "V",         "R ...", False), # 215
-    0x144: (       "ZTEST",  2,  3,   "V",         "R V V", False), # 216
-    0x145: (       "LARGE",  2,  2,   "V",           "R V", False), # 217
-    0x146: (       "SMALL",  2,  2,   "V",           "R V", False), # 218
-    0x147: (    "QUARTILE",  2,  2,   "V",           "R V", False), # 219
-    0x148: (  "PERCENTILE",  2,  2,   "V",           "R V", False), # 220
-    0x149: ( "PERCENTRANK",  2,  3,   "V",         "R V V", False), # 221
-    0x14a: (        "MODE",  1, 30,   "V",         "A ...", False), # 222
-    0x14b: (    "TRIMMEAN",  2,  2,   "V",           "R V", False), # 223
-    0x14c: (        "TINV",  2,  2,   "V",           "V V", False), # 224
-    0x150: ( "CONCATENATE",  0, 30,   "V",         "V ...", False), # 225
-    0x151: (       "POWER",  2,  2,   "V",           "V V", False), # 226
-    0x156: (     "RADIANS",  1,  1,   "V",             "V", False), # 227
-    0x157: (     "DEGREES",  1,  1,   "V",             "V", False), # 228
-    0x158: (    "SUBTOTAL",  2, 30,   "V",       "V R ...", False), # 229
-    0x159: (       "SUMIF",  2,  3,   "V",         "R V R", False), # 230
-    0x15a: (     "COUNTIF",  2,  2,   "V",           "R V", False), # 231
-    0x15b: (  "COUNTBLANK",  1,  1,   "V",             "R", False), # 232
-    0x15e: (       "ISPMT",  4,  4,   "V",       "V V V V", False), # 233
-    0x15f: (     "DATEDIF",  3,  3,   "V",         "V V V", False), # 234
-    0x160: (  "DATESTRING",  1,  1,   "V",             "V", False), # 235
-    0x161: ("NUMBERSTRING",  2,  2,   "V",           "V V", False), # 236
-    0x162: (       "ROMAN",  1,  2,   "V",           "V V", False), # 237
-    0x166: ("GETPIVOTDATA",  2, 30,   "A",             "-", False), # 238
-    0x167: (   "HYPERLINK",  1,  2,   "V",           "V V", False), # 239
-    0x168: (    "PHONETIC",  1,  1,   "V",             "R", False), # 240
-    0x169: (    "AVERAGEA",  1, 30,   "V",         "R ...", False), # 241
-    0x16a: (        "MAXA",  1, 30,   "V",         "R ...", False), # 242
-    0x16b: (        "MINA",  1, 30,   "V",         "R ...", False), # 243
-    0x16c: (     "STDEVPA",  1, 30,   "V",         "R ...", False), # 244
-    0x16d: (       "VARPA",  1, 30,   "V",         "R ...", False), # 245
-    0x16e: (      "STDEVA",  1, 30,   "V",         "R ...", False), # 246
-    0x16f: (        "VARA",  1, 30,   "V",         "R ...", False)  # 247
-}
-
-
-# Formulas Parse things
-
-ptgExp          = 0x01
-ptgTbl          = 0x02
-ptgAdd          = 0x03
-ptgSub          = 0x04
-ptgMul          = 0x05
-ptgDiv          = 0x06
-ptgPower        = 0x07
-ptgConcat       = 0x08
-ptgLT           = 0x09
-ptgLE           = 0x0a
-ptgEQ           = 0x0b
-ptgGE           = 0x0c
-ptgGT           = 0x0d
-ptgNE           = 0x0e
-ptgIsect        = 0x0f
-ptgUnion        = 0x10
-ptgRange        = 0x11
-ptgUplus        = 0x12
-ptgUminus       = 0x13
-ptgPercent      = 0x14
-ptgParen        = 0x15
-ptgMissArg      = 0x16
-ptgStr          = 0x17
-ptgExtend       = 0x18
-ptgAttr         = 0x19
-ptgSheet        = 0x1a
-ptgEndSheet     = 0x1b
-ptgErr          = 0x1c
-ptgBool         = 0x1d
-ptgInt          = 0x1e
-ptgNum          = 0x1f
-
-ptgArrayR       = 0x20
-ptgFuncR        = 0x21
-ptgFuncVarR     = 0x22
-ptgNameR        = 0x23
-ptgRefR         = 0x24
-ptgAreaR        = 0x25
-ptgMemAreaR     = 0x26
-ptgMemErrR      = 0x27
-ptgMemNoMemR    = 0x28
-ptgMemFuncR     = 0x29
-ptgRefErrR      = 0x2a
-ptgAreaErrR     = 0x2b
-ptgRefNR        = 0x2c
-ptgAreaNR       = 0x2d
-ptgMemAreaNR    = 0x2e
-ptgMemNoMemNR   = 0x2f
-ptgNameXR       = 0x39
-ptgRef3dR       = 0x3a
-ptgArea3dR      = 0x3b
-ptgRefErr3dR    = 0x3c
-ptgAreaErr3dR   = 0x3d
-
-ptgArrayV       = 0x40
-ptgFuncV        = 0x41
-ptgFuncVarV     = 0x42
-ptgNameV        = 0x43
-ptgRefV         = 0x44
-ptgAreaV        = 0x45
-ptgMemAreaV     = 0x46
-ptgMemErrV      = 0x47
-ptgMemNoMemV    = 0x48
-ptgMemFuncV     = 0x49
-ptgRefErrV      = 0x4a
-ptgAreaErrV     = 0x4b
-ptgRefNV        = 0x4c
-ptgAreaNV       = 0x4d
-ptgMemAreaNV    = 0x4e
-ptgMemNoMemNV   = 0x4f
-ptgFuncCEV      = 0x58
-ptgNameXV       = 0x59
-ptgRef3dV       = 0x5a
-ptgArea3dV      = 0x5b
-ptgRefErr3dV    = 0x5c
-ptgAreaErr3dV   = 0x5d
-
-ptgArrayA       = 0x60
-ptgFuncA        = 0x61
-ptgFuncVarA     = 0x62
-ptgNameA        = 0x63
-ptgRefA         = 0x64
-ptgAreaA        = 0x65
-ptgMemAreaA     = 0x66
-ptgMemErrA      = 0x67
-ptgMemNoMemA    = 0x68
-ptgMemFuncA     = 0x69
-ptgRefErrA      = 0x6a
-ptgAreaErrA     = 0x6b
-ptgRefNA        = 0x6c
-ptgAreaNA       = 0x6d
-ptgMemAreaNA    = 0x6e
-ptgMemNoMemNA   = 0x6f
-ptgFuncCEA      = 0x78
-ptgNameXA       = 0x79
-ptgRef3dA       = 0x7a
-ptgArea3dA      = 0x7b
-ptgRefErr3dA    = 0x7c
-ptgAreaErr3dA   = 0x7d
-
-
-PtgNames = {
-    ptgExp         : "ptgExp",
-    ptgTbl         : "ptgTbl",
-    ptgAdd         : "ptgAdd",
-    ptgSub         : "ptgSub",
-    ptgMul         : "ptgMul",
-    ptgDiv         : "ptgDiv",
-    ptgPower       : "ptgPower",
-    ptgConcat      : "ptgConcat",
-    ptgLT          : "ptgLT",
-    ptgLE          : "ptgLE",
-    ptgEQ          : "ptgEQ",
-    ptgGE          : "ptgGE",
-    ptgGT          : "ptgGT",
-    ptgNE          : "ptgNE",
-    ptgIsect       : "ptgIsect",
-    ptgUnion       : "ptgUnion",
-    ptgRange       : "ptgRange",
-    ptgUplus       : "ptgUplus",
-    ptgUminus      : "ptgUminus",
-    ptgPercent     : "ptgPercent",
-    ptgParen       : "ptgParen",
-    ptgMissArg     : "ptgMissArg",
-    ptgStr         : "ptgStr",
-    ptgExtend      : "ptgExtend",
-    ptgAttr        : "ptgAttr",
-    ptgSheet       : "ptgSheet",
-    ptgEndSheet    : "ptgEndSheet",
-    ptgErr         : "ptgErr",
-    ptgBool        : "ptgBool",
-    ptgInt         : "ptgInt",
-    ptgNum         : "ptgNum",
-    ptgArrayR      : "ptgArrayR",
-    ptgFuncR       : "ptgFuncR",
-    ptgFuncVarR    : "ptgFuncVarR",
-    ptgNameR       : "ptgNameR",
-    ptgRefR        : "ptgRefR",
-    ptgAreaR       : "ptgAreaR",
-    ptgMemAreaR    : "ptgMemAreaR",
-    ptgMemErrR     : "ptgMemErrR",
-    ptgMemNoMemR   : "ptgMemNoMemR",
-    ptgMemFuncR    : "ptgMemFuncR",
-    ptgRefErrR     : "ptgRefErrR",
-    ptgAreaErrR    : "ptgAreaErrR",
-    ptgRefNR       : "ptgRefNR",
-    ptgAreaNR      : "ptgAreaNR",
-    ptgMemAreaNR   : "ptgMemAreaNR",
-    ptgMemNoMemNR  : "ptgMemNoMemNR",
-    ptgNameXR      : "ptgNameXR",
-    ptgRef3dR      : "ptgRef3dR",
-    ptgArea3dR     : "ptgArea3dR",
-    ptgRefErr3dR   : "ptgRefErr3dR",
-    ptgAreaErr3dR  : "ptgAreaErr3dR",
-    ptgArrayV      : "ptgArrayV",
-    ptgFuncV       : "ptgFuncV",
-    ptgFuncVarV    : "ptgFuncVarV",
-    ptgNameV       : "ptgNameV",
-    ptgRefV        : "ptgRefV",
-    ptgAreaV       : "ptgAreaV",
-    ptgMemAreaV    : "ptgMemAreaV",
-    ptgMemErrV     : "ptgMemErrV",
-    ptgMemNoMemV   : "ptgMemNoMemV",
-    ptgMemFuncV    : "ptgMemFuncV",
-    ptgRefErrV     : "ptgRefErrV",
-    ptgAreaErrV    : "ptgAreaErrV",
-    ptgRefNV       : "ptgRefNV",
-    ptgAreaNV      : "ptgAreaNV",
-    ptgMemAreaNV   : "ptgMemAreaNV",
-    ptgMemNoMemNV  : "ptgMemNoMemNV",
-    ptgFuncCEV     : "ptgFuncCEV",
-    ptgNameXV      : "ptgNameXV",
-    ptgRef3dV      : "ptgRef3dV",
-    ptgArea3dV     : "ptgArea3dV",
-    ptgRefErr3dV   : "ptgRefErr3dV",
-    ptgAreaErr3dV  : "ptgAreaErr3dV",
-    ptgArrayA      : "ptgArrayA",
-    ptgFuncA       : "ptgFuncA",
-    ptgFuncVarA    : "ptgFuncVarA",
-    ptgNameA       : "ptgNameA",
-    ptgRefA        : "ptgRefA",
-    ptgAreaA       : "ptgAreaA",
-    ptgMemAreaA    : "ptgMemAreaA",
-    ptgMemErrA     : "ptgMemErrA",
-    ptgMemNoMemA   : "ptgMemNoMemA",
-    ptgMemFuncA    : "ptgMemFuncA",
-    ptgRefErrA     : "ptgRefErrA",
-    ptgAreaErrA    : "ptgAreaErrA",
-    ptgRefNA       : "ptgRefNA",
-    ptgAreaNA      : "ptgAreaNA",
-    ptgMemAreaNA   : "ptgMemAreaNA",
-    ptgMemNoMemNA  : "ptgMemNoMemNA",
-    ptgFuncCEA     : "ptgFuncCEA",
-    ptgNameXA      : "ptgNameXA",
-    ptgRef3dA      : "ptgRef3dA",
-    ptgArea3dA     : "ptgArea3dA",
-    ptgRefErr3dA   : "ptgRefErr3dA",
-    ptgAreaErr3dA  : "ptgAreaErr3dA"
-}
-
-
-error_msg_by_code = {
-    0x00: u"#NULL!",  # intersection of two cell ranges is empty
-    0x07: u"#DIV/0!", # division by zero
-    0x0F: u"#VALUE!", # wrong type of operand
-    0x17: u"#REF!",   # illegal or deleted cell reference
-    0x1D: u"#NAME?",  # wrong function or range name
-    0x24: u"#NUM!",   # value range overflow
-    0x2A: u"#N/A!"    # argument or function not available
-}

+ 0 - 320
desktop/core/ext-py/pyexcelerator/pyExcelerator/Formatting.py

@@ -1,320 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-'''
-The  XF  record is able to store explicit cell formatting attributes or the
-attributes  of  a cell style. Explicit formatting includes the reference to
-a  cell  style  XF  record. This allows to extend a defined cell style with
-some  explicit  attributes.  The  formatting  attributes  are  divided into
-6 groups:
-
-Group           Attributes
--------------------------------------
-Number format   Number format index (index to FORMAT record)
-Font            Font index (index to FONT record)
-Alignment       Horizontal and vertical alignment, text wrap, indentation, 
-                orientation/rotation, text direction
-Border          Border line styles and colours
-Background      Background area style and colours
-Protection      Cell locked, formula hidden
-
-For  each  group  a flag in the cell XF record specifies whether to use the
-attributes  contained  in  that  XF  record  or  in  the  referenced  style
-XF  record. In style XF records, these flags specify whether the attributes
-will  overwrite  explicit  cell  formatting  when  the  style is applied to
-a  cell. Changing a cell style (without applying this style to a cell) will
-change  all  cells which already use that style and do not contain explicit
-cell  attributes for the changed style attributes. If a cell XF record does
-not  contain  explicit  attributes  in a group (if the attribute group flag
-is not set), it repeats the attributes of its style XF record.
-
-'''
-
-__rev_id__ = """$Id: Formatting.py,v 1.4 2005/07/20 07:24:11 rvk Exp $"""
-
-
-import BIFFRecords
-
-colours = {
-        'aqua'    : 0x0F,
-        'cyan'    : 0x0F,
-        'black'   : 0x08,
-        'blue'    : 0x0C,
-        'brown'   : 0x10,
-        'magenta' : 0x0E,
-        'fuchsia' : 0x0E,
-        'gray'    : 0x17,
-        'grey'    : 0x17,
-        'green'   : 0x11,
-        'lime'    : 0x0B,
-        'navy'    : 0x12,
-        'orange'  : 0x35,
-        'pink'    : 0x21,
-        'purple'  : 0x14,
-        'red'     : 0x0A,
-        'silver'  : 0x16,
-        'white'   : 0x09,
-        'yellow'  : 0x0D,
-}
-
-def get_colour_val(c):
-    if c in colours:
-        return colours[c]
-    return c
-
-class CopyableObject(object):
-    # make sure to override this in the derived class if
-    # copying needs to be more complex
-    def copy(self):
-        cobj = self.__class__()
-        cobj.__dict__.update(self.__dict__)
-        return cobj
-
-class Font(CopyableObject):
-    ESCAPEMENT_NONE         = 0x00
-    ESCAPEMENT_SUPERSCRIPT  = 0x01
-    ESCAPEMENT_SUBSCRIPT    = 0x02
-    
-    UNDERLINE_NONE          = 0x00
-    UNDERLINE_SINGLE        = 0x01
-    UNDERLINE_SINGLE_ACC    = 0x21
-    UNDERLINE_DOUBLE        = 0x02
-    UNDERLINE_DOUBLE_ACC    = 0x22
-    
-    FAMILY_NONE         = 0x00
-    FAMILY_ROMAN        = 0x01
-    FAMILY_SWISS        = 0x02
-    FAMILY_MODERN       = 0x03
-    FAMILY_SCRIPT       = 0x04
-    FAMILY_DECORARTIVE  = 0x05
-    
-    CHARSET_ANSI_LATIN          = 0x00
-    CHARSET_SYS_DEFAULT         = 0x01
-    CHARSET_SYMBOL              = 0x02
-    CHARSET_APPLE_ROMAN         = 0x4D
-    CHARSET_ANSI_JAP_SHIFT_JIS  = 0x80
-    CHARSET_ANSI_KOR_HANGUL     = 0x81
-    CHARSET_ANSI_KOR_JOHAB      = 0x82
-    CHARSET_ANSI_CHINESE_GBK    = 0x86
-    CHARSET_ANSI_CHINESE_BIG5   = 0x88
-    CHARSET_ANSI_GREEK          = 0xA1
-    CHARSET_ANSI_TURKISH        = 0xA2
-    CHARSET_ANSI_VIETNAMESE     = 0xA3
-    CHARSET_ANSI_HEBREW         = 0xB1
-    CHARSET_ANSI_ARABIC         = 0xB2
-    CHARSET_ANSI_BALTIC         = 0xBA
-    CHARSET_ANSI_CYRILLIC       = 0xCC
-    CHARSET_ANSI_THAI           = 0xDE
-    CHARSET_ANSI_LATIN_II       = 0xEE
-    CHARSET_OEM_LATIN_I         = 0xFF   
-    
-    def __init__(self):
-        # twip = 1/20 of a point = 1/1440 of a inch
-        # usually resolution == 96 pixels per 1 inch 
-        # (rarely 120 pixels per 1 inch or another one)
-        
-        self.height = 0x00C8 # 200: this is font with height 10 points
-        self.italic = False
-        self.struck_out = False
-        self.outline = False
-        self.shadow = False
-        self.colour_index = 0x7FFF
-        self.bold = False
-        self._weight = 0x0190 # 0x02BC gives bold font
-        self.escapement = self.ESCAPEMENT_NONE
-        self.underline = self.UNDERLINE_NONE
-        self.family = self.FAMILY_NONE
-        self.charset = self.CHARSET_ANSI_CYRILLIC       
-        self.name = 'Arial'
-                
-    def get_biff_record(self):
-        height = self.height
-        
-        options = 0x00
-        if self.bold:
-            options |= 0x01
-            self._weight = 0x02BC
-        if self.italic:
-            options |= 0x02
-        if self.underline != self.UNDERLINE_NONE:
-            options |= 0x04
-        if self.struck_out:
-            options |= 0x08
-        if self.outline:
-            options |= 0x010
-        if self.shadow:
-            options |= 0x020
-            
-        colour_index = get_colour_val(self.colour_index)
-        weight = self._weight
-        escapement = self.escapement
-        underline = self.underline 
-        family = self.family 
-        charset = self.charset
-        name = self.name
-        
-        return BIFFRecords.FontRecord(height, options, colour_index, weight, escapement, 
-                    underline, family, charset, 
-                    name)
-
-class Alignment(CopyableObject):
-    HORZ_GENERAL                = 0x00
-    HORZ_LEFT                   = 0x01
-    HORZ_CENTER                 = 0x02
-    HORZ_RIGHT                  = 0x03
-    HORZ_FILLED                 = 0x04
-    HORZ_JUSTIFIED              = 0x05 # BIFF4-BIFF8X
-    HORZ_CENTER_ACROSS_SEL      = 0x06 # Centred across selection (BIFF4-BIFF8X)
-    HORZ_DISTRIBUTED            = 0x07 # Distributed (BIFF8X)
-    
-    VERT_TOP                    = 0x00 
-    VERT_CENTER                 = 0x01
-    VERT_BOTTOM                 = 0x02
-    VERT_JUSTIFIED              = 0x03 # Justified (BIFF5-BIFF8X)
-    VERT_DISIRIBUTED            = 0x04 # Distributed (BIFF8X)
-
-    DIRECTION_GENERAL           = 0x00 # BIFF8X
-    DIRECTION_LR                = 0x01
-    DIRECTION_RL                = 0x02
-
-    ORIENTATION_NOT_ROTATED     = 0x00
-    ORIENTATION_STACKED         = 0x01
-    ORIENTATION_90_CC           = 0x02
-    ORIENTATION_90_CW           = 0x03
-
-    ROTATION_0_ANGLE            = 0x00
-    ROTATION_STACKED            = 0xFF
-    
-    WRAP_AT_RIGHT               = 0x01
-    NOT_WRAP_AT_RIGHT           = 0x00
-    
-    SHRINK_TO_FIT               = 0x01
-    NOT_SHRINK_TO_FIT           = 0x00       
-
-    def __init__(self):
-        self.horz = self.HORZ_GENERAL
-        self.vert = self.VERT_BOTTOM
-        self.dire = self.DIRECTION_GENERAL
-        self.orie = self.ORIENTATION_NOT_ROTATED
-        self.rota = self.ROTATION_0_ANGLE
-        self.wrap = self.NOT_WRAP_AT_RIGHT
-        self.shri = self.NOT_SHRINK_TO_FIT
-        self.inde = 0
-        self.merg = 0
-
-class Borders(CopyableObject):
-    NO_LINE = 0x00
-    THIN    = 0x01
-    MEDIUM  = 0x02
-    DASHED  = 0x03
-    DOTTED  = 0x04
-    THICK   = 0x05
-    DOUBLE  = 0x06
-    HAIR    = 0x07
-    #The following for BIFF8
-    MEDIUM_DASHED               = 0x08
-    THIN_DASH_DOTTED            = 0x09
-    MEDIUM_DASH_DOTTED          = 0x0A
-    THIN_DASH_DOT_DOTTED        = 0x0B
-    MEDIUM_DASH_DOT_DOTTED      = 0x0C
-    SLANTED_MEDIUM_DASH_DOTTED  = 0x0D
-    
-    NEED_DIAG1      = 0x01
-    NEED_DIAG2      = 0x01
-    NO_NEED_DIAG1   = 0x00
-    NO_NEED_DIAG2   = 0x00
-
-    def __init__(self):
-        self.left   = self.NO_LINE
-        self.right  = self.NO_LINE
-        self.top    = self.NO_LINE
-        self.bottom = self.NO_LINE
-        self.diag   = self.NO_LINE
-
-        self.left_colour   = 0x40
-        self.right_colour  = 0x40
-        self.top_colour    = 0x40
-        self.bottom_colour = 0x40
-        self.diag_colour   = 0x40
-        
-        self.need_diag1 = self.NO_NEED_DIAG1
-        self.need_diag2 = self.NO_NEED_DIAG2
-
-class Pattern(CopyableObject):
-    # patterns 0x00 - 0x12
-    NO_PATTERN      = 0x00 
-    SOLID_PATTERN   = 0x01 
-    
-    def __init__(self):
-        self.pattern = self.NO_PATTERN
-        self._pattern_fore_colour = 0x40
-        self._pattern_back_colour = 0x41
-    
-    def get_pattern_fore_colour(self): return self._pattern_fore_colour
-    def set_pattern_fore_colour(self, c): self._pattern_fore_colour = get_colour_val(c)
-    pattern_fore_colour = property(get_pattern_fore_colour, set_pattern_fore_colour)
-    
-    def get_pattern_back_colour(self): return self._pattern_back_colour
-    def set_pattern_back_colour(self, c): self._pattern_back_colour = get_colour_val(c)
-    pattern_back_colour = property(get_pattern_back_colour, set_pattern_back_colour)
-
-class Protection(CopyableObject):
-    def __init__(self):
-        self.cell_locked = 1
-        self.formula_hidden = 0
-        
-        
-if __name__ == '__main__':
-    font0 = Font()
-    font0.name = 'Arial'
-    font1 = Font()
-    font1.name = 'Arial Cyr'
-    font2 = Font()
-    font2.name = 'Times New Roman'
-    font3 = Font()
-    font3.name = 'Courier New Cyr'
-    
-    for font, filename in [(font0, 'font0.bin'), (font1, 'font1.bin'), (font2, 'font2.bin'), (font3, 'font3.bin')]:
-        f = file(filename, 'wb')
-        f.write(font.get_biff_record().get_data())
-        f.close

+ 0 - 476
desktop/core/ext-py/pyexcelerator/pyExcelerator/ImportXLS.py

@@ -1,476 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-__rev_id__ = """$Id: ImportXLS.py,v 1.6 2005/10/26 07:44:24 rvk Exp $"""
-
-
-import UnicodeUtils
-import CompoundDoc
-import ExcelMagic
-from struct import pack, unpack
-
-
-def parse_xls(filename, encoding = None):
-    
-    ##########################################################################
-
-    def process_BOUNDSHEET(biff8, rec_data):
-        sheet_stream_pos, visibility, sheet_type = unpack('<I2B', rec_data[:6])
-        sheet_name = rec_data[6:]
-
-        if biff8:
-            chars_num, options = unpack('2B', sheet_name[:2])
-            
-            chars_start = 2
-            runs_num = 0
-            asian_phonetic_size = 0
-
-            result = ''
-
-            compressed = (options & 0x01) == 0
-            has_asian_phonetic = (options & 0x04) != 0
-            has_format_runs = (options & 0x08) != 0
-
-            if has_format_runs:
-                runs_num , = unpack('<H', sheet_name[chars_start:chars_start+2])
-                chars_start += 2
-            if has_asian_phonetic:
-                asian_phonetic_size , = unpack('<I', sheet_name[chars_start:chars_start+4])
-                chars_start += 4
-
-            if compressed:
-                chars_end = chars_start + chars_num
-                result = sheet_name[chars_start:chars_end].decode('latin_1', 'replace')
-            else:
-                chars_end = chars_start + 2*chars_num
-                result = sheet_name[chars_start:chars_end].decode('utf_16_le', 'replace')
-            
-            tail_size = 4*runs_num + asian_phonetic_size
-        else:
-            result = sheet_name[1:].decode(encoding, 'replace')
-        
-        return result
-
-
-    def unpack2str(biff8, label_name): # 2 bytes length str
-        if biff8:
-            chars_num, options = unpack('<HB', label_name[:3])
-            
-            chars_start = 3
-            runs_num = 0
-            asian_phonetic_size = 0
-
-            result = ''
-
-            compressed = (options & 0x01) == 0
-            has_asian_phonetic = (options & 0x04) != 0
-            has_format_runs = (options & 0x08) != 0
-
-            if has_format_runs:
-                runs_num , = unpack('<H', label_name[chars_start:chars_start+2])
-                chars_start += 2
-            if has_asian_phonetic:
-                asian_phonetic_size , = unpack('<I', label_name[chars_start:chars_start+4])
-                chars_start += 4
-
-            if compressed:
-                chars_end = chars_start + chars_num
-                result = label_name[chars_start:chars_end].decode('latin_1', 'replace')
-            else:
-                chars_end = chars_start + 2*chars_num
-                result = label_name[chars_start:chars_end].decode('utf_16_le', 'replace')
-            
-            tail_size = 4*runs_num + asian_phonetic_size
-        else:
-            result = label_name[2:].decode(encoding, 'replace')
-
-        return result
-
-
-    def process_LABEL(biff8, rec_data):
-        row_idx, col_idx, xf_idx = unpack('<3H', rec_data[:6])
-        label_name = rec_data[6:]
-        result = unpack2str(biff8, label_name)
-        return (row_idx, col_idx, result)
-
-
-    def process_LABELSST(rec_data):
-        row_idx, col_idx, xf_idx, sst_idx = unpack('<3HI', rec_data)
-        return (row_idx, col_idx, sst_idx)
-
-
-    def process_RSTRING(biff8, rec_data):
-        if biff8:
-            return process_LABEL(biff8, rec_data)
-        else:
-            row_idx, col_idx, xf_idx, length = unpack('<4H', rec_data[:8])
-            result = rec_data[8:8+length].decode(encoding, 'replace')
-
-        return (row_idx, col_idx, result)
-        
-
-    def decode_rk(encoded):
-        b0, b1, b2, b3 = unpack('4B', encoded)
-        is_multed_100 = (b0 & 0x01) != 0
-        is_integer = (b0 & 0x02) != 0
-
-        if is_integer:
-            result , = unpack('<i', encoded)
-            result >>= 2
-        else:
-            ieee754 = struct.pack('8B', 0, 0, 0, 0, b0 & 0xFC, b1, b2, b3)
-            result , = unpack('<d', ieee754)
-        if is_multed_100:
-            result /= 100.0
-        
-        return result
-
-
-    def process_RK(rec_data):
-        row_idx, col_idx, xf_idx, encoded = unpack('<3H4s', rec_data)
-        result = decode_rk(encoded)
-        return (row_idx, col_idx, result)
-
-
-    def process_MULRK(rec_data):
-        row_idx, first_col_idx = unpack('<2H', rec_data[:4])
-        last_col_idx , = unpack('<H', rec_data[-2:])
-        xf_rk_num = last_col_idx - first_col_idx + 1
-
-        results = []
-        for i in range(xf_rk_num):
-            xf_idx, encoded = unpack('<H4s', rec_data[4+6*i : 4+6*(i+1)])
-            results.append(decode_rk(encoded))
-
-        return zip([row_idx]*xf_rk_num, range(first_col_idx, last_col_idx+1), results)
-
-
-    def process_NUMBER(rec_data):
-        row_idx, col_idx, xf_idx, result = unpack('<3Hd', rec_data)
-        return (row_idx, col_idx, result)
-
-    
-    def process_SST(rec_data, sst_continues):
-        # 0x00FC
-        total_refs, total_str = unpack('<2I', rec_data[:8])
-        #print total_refs, str_num
-
-        pos = 8
-        curr_block = rec_data
-        curr_block_num = -1
-        curr_str_num = 0
-        SST = {}
-
-        while curr_str_num < total_str:
-            if pos >= len(curr_block):
-                curr_block_num += 1
-                curr_block = sst_continues[curr_block_num]
-                pos = 0
-
-            chars_num, options = unpack('<HB', curr_block[pos:pos+3])
-            #print chars_num, options
-            pos += 3
-
-            asian_phonetic_size = 0
-            runs_num = 0
-            has_asian_phonetic = (options & 0x04) != 0
-            has_format_runs = (options & 0x08) != 0
-            if has_format_runs:
-                runs_num , = unpack('<H', curr_block[pos:pos+2])
-                pos += 2
-            if has_asian_phonetic:
-                asian_phonetic_size , = unpack('<I', curr_block[pos:pos+4])
-                pos += 4
-
-            curr_char = 0
-            result = ''
-            while curr_char < chars_num:
-                if pos >= len(curr_block):
-                    curr_block_num += 1
-                    curr_block = sst_continues[curr_block_num]
-                    options = ord(curr_block[0])
-                    pos = 1
-                #print curr_block_num
-
-                compressed = (options & 0x01) == 0
-                if compressed:
-                    chars_end = pos + chars_num - curr_char
-                else:
-                    chars_end = pos + 2*(chars_num - curr_char)
-                #print compressed, has_asian_phonetic, has_format_runs
-
-                splitted = chars_end > len(curr_block)
-                if splitted:
-                    chars_end = len(curr_block)
-                #print splitted, curr_char, pos, chars_end, repr(curr_block[pos:chars_end])
-
-                if compressed:
-                    result += curr_block[pos:chars_end].decode('latin_1', 'replace')
-                else:
-                    result += curr_block[pos:chars_end].decode('utf_16_le', 'replace')
-
-                pos = chars_end
-                curr_char = len(result)
-            # end while
-
-            # TODO: handle spanning format runs over CONTINUE blocks ???
-            tail_size = 4*runs_num + asian_phonetic_size
-            if len(curr_block) < pos + tail_size:
-                pos = pos + tail_size - len(curr_block)
-                curr_block_num += 1
-                curr_block = sst_continues[curr_block_num]
-            else:
-                pos += tail_size
-
-            #print result.encode('cp866')
-
-            SST[curr_str_num] = result
-            curr_str_num += 1
-
-        return SST
-
-
-    #####################################################################################
-    
-    import struct
-
-    encodings = {
-        0x016F: 'ascii',     #ASCII
-        0x01B5: 'cp437',     #IBM PC CP-437 (US)
-        0x02D0: 'cp720',     #IBM PC CP-720 (OEM Arabic)
-        0x02E1: 'cp737',     #IBM PC CP-737 (Greek)
-        0x0307: 'cp775',     #IBM PC CP-775 (Baltic)
-        0x0352: 'cp850',     #IBM PC CP-850 (Latin I)
-        0x0354: 'cp852',     #IBM PC CP-852 (Latin II (Central European))
-        0x0357: 'cp855',     #IBM PC CP-855 (Cyrillic)
-        0x0359: 'cp857',     #IBM PC CP-857 (Turkish)
-        0x035A: 'cp858',     #IBM PC CP-858 (Multilingual Latin I with Euro)
-        0x035C: 'cp860',     #IBM PC CP-860 (Portuguese)
-        0x035D: 'cp861',     #IBM PC CP-861 (Icelandic)
-        0x035E: 'cp862',     #IBM PC CP-862 (Hebrew)
-        0x035F: 'cp863',     #IBM PC CP-863 (Canadian (French))
-        0x0360: 'cp864',     #IBM PC CP-864 (Arabic)
-        0x0361: 'cp865',     #IBM PC CP-865 (Nordic)
-        0x0362: 'cp866',     #IBM PC CP-866 (Cyrillic (Russian))
-        0x0365: 'cp869',     #IBM PC CP-869 (Greek (Modern))
-        0x036A: 'cp874',     #Windows CP-874 (Thai)
-        0x03A4: 'cp932',     #Windows CP-932 (Japanese Shift-JIS)
-        0x03A8: 'cp936',     #Windows CP-936 (Chinese Simplified GBK)
-        0x03B5: 'cp949',     #Windows CP-949 (Korean (Wansung))
-        0x03B6: 'cp950',     #Windows CP-950 (Chinese Traditional BIG5)
-        0x04B0: 'utf_16_le', #UTF-16 (BIFF8)
-        0x04E2: 'cp1250',    #Windows CP-1250 (Latin II) (Central European)
-        0x04E3: 'cp1251',    #Windows CP-1251 (Cyrillic)
-        0x04E4: 'cp1252',    #Windows CP-1252 (Latin I) (BIFF4-BIFF7)
-        0x04E5: 'cp1253',    #Windows CP-1253 (Greek)
-        0x04E6: 'cp1254',    #Windows CP-1254 (Turkish)
-        0x04E7: 'cp1255',    #Windows CP-1255 (Hebrew)
-        0x04E8: 'cp1256',    #Windows CP-1256 (Arabic)
-        0x04E9: 'cp1257',    #Windows CP-1257 (Baltic)
-        0x04EA: 'cp1258',    #Windows CP-1258 (Vietnamese)
-        0x0551: 'cp1361',    #Windows CP-1361 (Korean (Johab))
-        0x2710: 'mac_roman', #Apple Roman
-        0x8000: 'mac_roman', #Apple Roman
-        0x8001: 'cp1252'     #Windows CP-1252 (Latin I) (BIFF2-BIFF3)
-    }
-
-    biff8 = True
-    SST = {}
-    sheets = []
-    sheet_names = []
-    values = {}
-    ws_num = 0
-    BOFs = 0
-    EOFs = 0
-
-    # Inside MS Office document looks like filesystem
-    # We need extract stream named 'Workbook' or 'Book'
-    ole_streams = CompoundDoc.Reader(filename).STREAMS
-
-    if 'Workbook' in ole_streams:
-        workbook_stream = ole_streams['Workbook']
-    elif 'Book' in ole_streams:
-        workbook_stream = ole_streams['Book']
-    else:
-        raise Exception, 'No workbook stream in file.'
-
-    workbook_stream_len = len(workbook_stream)
-    stream_pos = 0
-    
-    # Excel's method of data storing is based on 
-    # ancient technology "TLV" (Type, Length, Value).
-    # In addition, if record size grows to some limit
-    # Excel writes CONTINUE records
-    while stream_pos < workbook_stream_len and EOFs <= ws_num:
-        rec_id, data_size = unpack('<2H', workbook_stream[stream_pos:stream_pos+4])
-        stream_pos += 4
-        
-        rec_data = workbook_stream[stream_pos:stream_pos+data_size]
-        stream_pos += data_size
-
-        if rec_id == 0x0809: # BOF
-            #print 'BOF', 
-            BOFs += 1
-            ver, substream_type = unpack('<2H', rec_data[:4])
-            if substream_type == 0x0005:
-                # workbook global substream
-                biff8 = ver >= 0x0600
-            elif substream_type == 0x0010:
-                # worksheet substream
-                pass
-            else: # skip chart stream or unknown stream
-            # stream offsets may be used from BOUNDSHEET record
-                rec_id, data_size = unpack('<2H', workbook_stream[stream_pos:stream_pos+4])
-                while rec_id != 0x000A: # EOF
-                    #print 'SST CONTINUE'
-                    stream_pos += 4
-                    stream_pos += data_size
-                    rec_id, data_size = unpack('<2H', workbook_stream[stream_pos:stream_pos+4])
-            #print 'BIFF8 == ', biff8
-        elif rec_id == 0x000A: # EOF
-            #print 'EOF'
-            if BOFs > 1:
-                sheets.extend([values])
-                values = {}
-            EOFs += 1
-        elif rec_id == 0x0042: # CODEPAGE
-            cp ,  = unpack('<H', rec_data)
-            #print 'CODEPAGE', hex(cp)
-            if not encoding:
-                encoding = encodings[cp]
-            #print encoding
-        elif rec_id == 0x0085: # BOUNDSHEET
-            #print 'BOUNDSHEET',
-            ws_num += 1
-            b = process_BOUNDSHEET(biff8, rec_data)
-            sheet_names.extend([b])
-            #print b.encode('cp866')
-        elif rec_id == 0x00FC: # SST
-            #print 'SST'
-            sst_data = rec_data
-            sst_continues = []
-            rec_id, data_size = unpack('<2H', workbook_stream[stream_pos:stream_pos+4])
-            while rec_id == 0x003C: # CONTINUE
-                #print 'SST CONTINUE'
-                stream_pos += 4
-                rec_data = workbook_stream[stream_pos:stream_pos+data_size]
-                sst_continues.extend([rec_data])
-                stream_pos += data_size
-                rec_id, data_size = unpack('<2H', workbook_stream[stream_pos:stream_pos+4])
-            SST = process_SST(sst_data, sst_continues)
-        elif rec_id == 0x00FD: # LABELSST
-            #print 'LABELSST',
-            r, c, i = process_LABELSST(rec_data)
-            values[(r, c)] = SST[i]
-            #print r, c, SST[i].encode('cp866')
-        elif rec_id == 0x0204: # LABEL
-            #print 'LABEL',
-            r, c, b = process_LABEL(biff8, rec_data)
-            values[(r, c)] = b
-            #print r, c, b.encode('cp866')
-        elif rec_id == 0x00D6: # RSTRING
-            #print 'RSTRING',
-            r, c, b = process_RSTRING(biff8, rec_data)
-            values[(r, c)] = b
-            #print r, c, b.encode('cp866')
-        elif rec_id == 0x027E: # RK
-            #print 'RK',
-            r, c, b = process_RK(rec_data)
-            values[(r, c)] = b
-            #print r, c, b
-        elif rec_id == 0x00BD: # MULRK
-            #print 'MULRK',
-            for r, c, b in process_MULRK(rec_data):
-                values[(r, c)] = b
-            #print r, c, b
-        elif rec_id == 0x0203: # NUMBER
-            #print 'NUMBER',
-            r, c, b = process_NUMBER(rec_data)
-            values[(r, c)] = b
-            #print r, c, b
-        elif rec_id == 0x0006: # FORMULA
-            #print 'FORMULA',
-            r, c, x = unpack('<3H', rec_data[0:6])
-            if rec_data[12] == '\xFF' and rec_data[13] == '\xFF':
-                if rec_data[6] == '\x00':
-                    got_str = False
-                    if ord(rec_data[14]) & 8:
-                        # part of shared formula
-                        rec_id, data_size = unpack('<2H', workbook_stream[stream_pos:stream_pos+4])
-                        stream_pos += 4                      
-                        rec_data = workbook_stream[stream_pos:stream_pos+data_size]
-                        stream_pos += data_size
-                        if rec_id == 0x0207: # STRING
-                            got_str = True
-                        elif rec_id not in (0x0221, 0x04BC, 0x0236, 0x0037, 0x0036):
-                            raise Exception("Expected ARRAY, SHRFMLA, TABLEOP* or STRING record")
-                    if not got_str:
-                        rec_id, data_size = unpack('<2H', workbook_stream[stream_pos:stream_pos+4])
-                        stream_pos += 4                      
-                        rec_data = workbook_stream[stream_pos:stream_pos+data_size]
-                        stream_pos += data_size
-                        if rec_id != 0x0207: # STRING
-                            raise Exception("Expected STRING record")
-                    values[(r, c)] = unpack2str(biff8, rec_data)
-                elif rec_data[6] == '\x01':
-                    # boolean 
-                    v = ord(rec_data[8])
-                    values[(r, c)] = bool(v)
-                elif rec_data[6] == '\x02':
-                    # error
-                    v = ord(rec_data[8])
-                    if v in ExcelMagic.error_msg_by_code:
-                        values[(r, c)] = ExcelMagic.error_msg_by_code[v]
-                    else:
-                        values[(r, c)] = u'#UNKNOWN ERROR!'
-                elif rec_data[6] == '\x03':
-                    # empty
-                    values[(r, c)] = u''
-                else:
-                    raise Exception("Unknown value for formula result")
-            else:
-                # 64-bit float
-                d, = unpack("<d", rec_data[6:14])
-                values[(r, c)] = d
-
-    encoding = None
-    return zip(sheet_names, sheets)

+ 0 - 255
desktop/core/ext-py/pyexcelerator/pyExcelerator/Row.py

@@ -1,255 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-__rev_id__ = """$Id: Row.py,v 1.6 2005/08/11 08:53:48 rvk Exp $"""
-
-
-import BIFFRecords
-from Deco import *
-from Worksheet import Worksheet
-import Style
-import Cell
-import ExcelFormula
-import datetime as dt
-
-
-class Row(object):
-    __slots__ = ["__init__", 
-                 "__adjust_height",
-                 "__adjust_bound_col_idx",
-                 "__excel_date_dt",
-                 "get_height_in_pixels",
-                 "set_style",
-                 "get_xf_index",
-                 "get_cells_count",
-                 "get_min_col",
-                 "get_max_col",
-                 "get_str_count",
-                 "get_row_biff_data",
-                 "get_cells_biff_data",
-                 "get_index",
-                 "write",
-                 "write_blanks",
-                 # private variables
-                 "__idx",
-                 "__parent",
-                 "__parent_wb",
-                 "__cells",
-                 "__min_col_idx",
-                 "__max_col_idx",
-                 "__total_str",
-                 "__xf_index",
-                 "__has_default_format",
-                 "__has_default_height",
-                 "__height",
-                 "__height_in_pixels",
-                 "__frmla_opts",
-                 # public variables
-                 "level",
-                 "collapse",
-                 "hidden",
-                 "space_above",
-                 "space_below",
-                 "height",
-                 "frmla_opts",]
-
-    #################################################################
-    ## Constructor
-    #################################################################
-    def __init__(self, index, parent_sheet):
-        self.__idx = index
-        self.__parent = parent_sheet
-        self.__parent_wb = parent_sheet.get_parent()
-        self.__cells = []
-        self.__min_col_idx = 0
-        self.__max_col_idx = 0
-        self.__total_str = 0
-        self.__xf_index = 0x0F
-        self.__has_default_format = 0
-        self.__has_default_height = 0x01
-        self.__height = 0x00FF
-        self.__height_in_pixels = 0x11
-        self.__frmla_opts = self.__parent.frmla_opts
-        
-        self.level = 0
-        self.collapse = 0
-        self.hidden = 0
-        self.space_above = 0
-        self.space_below = 0
-
-
-    def __adjust_height(self, style):
-        twips = style.font.height
-        points = float(twips)/20.0
-        # Cell height in pixels can be calcuted by following approx. formula:
-        # cell height in pixels = font height in points * 83/50 + 2/5
-        # It works when screen resolution is 96 dpi 
-        pix = int(round(points*83.0/50.0 + 2.0/5.0))
-        if pix > self.__height_in_pixels:
-            self.__height_in_pixels = pix
-
-
-    def __adjust_bound_col_idx(self, *args):
-        for arg in args:
-            if arg < self.__min_col_idx:
-                self.__min_col_idx = arg
-            elif arg > self.__max_col_idx:
-                self.__max_col_idx = arg
-
-    def __excel_date_dt(self, date):
-        if isinstance(date, dt.date) and (not isinstance(date, dt.datetime)):
-            epoch = dt.date(1899, 12, 31)
-        elif isinstance(date, dt.time):
-            date = dt.datetime.combine(dt.datetime(1900, 1, 1), date)
-            epoch = dt.datetime(1900, 1, 1, 0, 0, 0)
-        else:
-            epoch = dt.datetime(1899, 12, 31, 0, 0, 0)
-        delta = date - epoch
-        xldate = delta.days + float(delta.seconds) / (24*60*60)
-        # Add a day for Excel's missing leap day in 1900
-        if xldate > 59:
-            xldate += 1
-        return xldate
-
-    def get_height_in_pixels(self):
-        return self.__height_in_pixels
-
-
-    @accepts(object, Style.XFStyle)
-    def set_style(self, style):
-        self.__adjust_height(style)
-        self.__xf_index = self.__parent_wb.add_style(style)
-
-            
-    def get_xf_index(self):
-        return self.__xf_index
-
-    
-    def get_cells_count(self):
-        return len(self.__cells)
-
-    
-    def get_min_col(self):
-        return self.__min_col_idx
-
-        
-    def get_max_col(self):
-        return self.__max_col_idx
-
-        
-    def get_str_count(self):
-        return self.__total_str
-
-
-    def get_row_biff_data(self):
-        height_options = (self.__height & 0x07FFF) 
-        height_options |= (self.__has_default_height & 0x01) << 15
-
-        options =  (self.level & 0x07) << 0
-        options |= (self.collapse & 0x01) << 4
-        options |= (self.hidden & 0x01) << 5
-        options |= (0x00 & 0x01) << 6
-        options |= (0x01 & 0x01) << 8
-        if self.__xf_index != 0x0F:
-            options |= (0x01 & 0x01) << 7
-        else:
-            options |= (0x00 & 0x01) << 7
-        options |= (self.__xf_index & 0x0FFF) << 16 
-        options |= (0x00 & self.space_above) << 28
-        options |= (0x00 & self.space_below) << 29
-        
-        return BIFFRecords.RowRecord(self.__idx, self.__min_col_idx, self.__max_col_idx, height_options, options).get()                                              
-                        
-
-    def get_cells_biff_data(self):
-        return ''.join([ cell.get_biff_data() for cell in self.__cells ])
-
-
-    def get_index(self):
-        return self.__idx
-
-
-    def get_height(self):
-        return self.__height
-
-    def set_height(self, h):
-        if h == None:
-            self.__has_default_height = 0x01
-        else: self.__height = h
-    
-    height = property(get_height, set_height)
-
-    @accepts(object, int)
-    def set_frmla_opts(self, value):
-        assert (int(value) & ~(0x0b)) == 0, "Invalid bits set for frmla_opts (%s)"%hex(int(value))
-        self.__frmla_opts = int(value)
-
-    def get_frmla_opts(self):
-        return self.__frmla_opts
-
-    frmla_opts = property(get_frmla_opts, set_frmla_opts)
-
-    @accepts(object, int, (str, unicode, int, long, float, dt.datetime, dt.time, dt.date, ExcelFormula.Formula), (Style.XFStyle, type(None)))
-    def write(self, col, label, style):
-        self.__adjust_height(style)
-        self.__adjust_bound_col_idx(col)
-        if isinstance(label, (str, unicode)):
-            if len(label) > 0:
-                self.__cells.extend([ Cell.StrCell(self, col, self.__parent_wb.add_style(style), self.__parent_wb.add_str(label)) ])
-                self.__total_str += 1
-            else:
-                self.__cells.extend([ Cell.BlankCell(self, col, self.__parent_wb.add_style(style)) ])
-        elif isinstance(label, (int, long, float)):
-            self.__cells.extend([ Cell.NumberCell(self, col, self.__parent_wb.add_style(style), label) ])            
-        elif isinstance(label, (dt.datetime, dt.time)):
-            self.__cells.extend([ Cell.NumberCell(self, col, self.__parent_wb.add_style(style), self.__excel_date_dt(label)) ])
-        else:
-            self.__cells.extend([ Cell.FormulaCell(self, col, self.__parent_wb.add_style(style), label) ])
-
-    @accepts(object, int, int, Style.XFStyle)                        
-    def write_blanks(self, c1, c2, style):
-        self.__adjust_height(style)
-        self.__adjust_bound_col_idx(c1, c2)
-        self.__cells.extend([ Cell.MulBlankCell(self, c1, c2, self.__parent_wb.add_style(style)) ])
-
-        
-        

+ 0 - 197
desktop/core/ext-py/pyexcelerator/pyExcelerator/Style.py

@@ -1,197 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-__rev_id__ = """$Id: Style.py,v 1.4 2005/07/20 07:24:11 rvk Exp $"""
-
-
-import Formatting
-from BIFFRecords import *
-
-
-_default_num_format = 'general'
-_default_font = Formatting.Font()
-_default_alignment = Formatting.Alignment()
-_default_borders = Formatting.Borders()
-_default_pattern = Formatting.Pattern()
-_default_protection = Formatting.Protection()
-
-class XFStyle(object):
-    
-    def __init__(self):
-        self.num_format_str  = _default_num_format
-        self.font            = _default_font.copy()
-        self.alignment       = _default_alignment.copy()
-        self.borders         = _default_borders.copy()
-        self.pattern         = _default_pattern.copy()
-        self.protection      = _default_protection.copy()
-
-class StyleCollection(object):
-    _std_num_fmt_list = [
-            'general',
-            '0',
-            '0.00',
-            '#,##0',
-            '#,##0.00',
-            '"$"#,##0_);("$"#,##',
-            '"$"#,##0_);[Red]("$"#,##',
-            '"$"#,##0.00_);("$"#,##',
-            '"$"#,##0.00_);[Red]("$"#,##',
-            '0%',
-            '0.00%',
-            '0.00E+00',
-            '# ?/?',
-            '# ??/??',
-            'M/D/YY',
-            'D-MMM-YY',
-            'D-MMM',
-            'MMM-YY',
-            'h:mm AM/PM',
-            'h:mm:ss AM/PM',
-            'h:mm',
-            'h:mm:ss',
-            'M/D/YY h:mm',
-            '_(#,##0_);(#,##0)',
-            '_(#,##0_);[Red](#,##0)',
-            '_(#,##0.00_);(#,##0.00)',
-            '_(#,##0.00_);[Red](#,##0.00)',
-            '_("$"* #,##0_);_("$"* (#,##0);_("$"* "-"_);_(@_)',
-            '_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)',
-            '_("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)',
-            '_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',
-            'mm:ss',
-            '[h]:mm:ss',
-            'mm:ss.0',
-            '##0.0E+0',
-            '@'   
-    ]
-
-    def __init__(self):
-        self._fonts = {}
-        self._fonts[Formatting.Font()] = 0
-        self._fonts[Formatting.Font()] = 1
-        self._fonts[Formatting.Font()] = 2
-        self._fonts[Formatting.Font()] = 3
-        # The font with index 4 is omitted in all BIFF versions
-        self._fonts[Formatting.Font()] = 5
-        
-        self._num_formats = {}
-        for fmtidx, fmtstr in zip(range(0, 23), StyleCollection._std_num_fmt_list[0:23]):
-            self._num_formats[fmtstr] = fmtidx 
-        for fmtidx, fmtstr in zip(range(37, 50), StyleCollection._std_num_fmt_list[23:]):
-            self._num_formats[fmtstr] = fmtidx 
-
-        self._xf = {}
-        self.default_style = XFStyle()
-        self._default_xf = self._add_style(self.default_style)[0]
-        
-    def add(self, style): 
-        if style == None:
-            return 0x10
-        return self._add_style(style)[1]
-    
-    def _add_style(self, style):
-        num_format_str = style.num_format_str
-        if num_format_str in self._num_formats:
-            num_format_idx = self._num_formats[num_format_str]
-        else:
-            num_format_idx = 163 + len(self._num_formats) - len(StyleCollection._std_num_fmt_list)
-            self._num_formats[num_format_str] = num_format_idx
-            
-        font = style.font
-        if font in self._fonts:
-            font_idx = self._fonts[font]
-        else:
-            font_idx = len(self._fonts) + 1
-            self._fonts[font] = font_idx
-            
-        xf = (font_idx, num_format_idx, style.alignment, style.borders, style.pattern, style.protection)
-        
-        if xf in self._xf:
-            xf_index = self._xf[xf]
-        else:
-            xf_index = 0x10 + len(self._xf)
-            self._xf[xf] = xf_index
-            
-        return xf, xf_index
-        
-    def get_biff_data(self):
-        result = ''
-        result += self._all_fonts()
-        result += self._all_num_formats()
-        result += self._all_cell_styles()
-        result += self._all_styles()
-        return result 
-            
-    def _all_fonts(self):
-        result = ''
-        i = sorted([(v, k) for k, v in self._fonts.items()])
-        for font_idx, font in i:
-            result += font.get_biff_record().get()
-        return result
-    
-    def _all_num_formats(self):
-        result = ''
-        i = sorted([(v, k) for k, v in self._num_formats.items() if v>=163])
-        for fmtidx, fmtstr in i:
-            result += NumberFormatRecord(fmtidx, fmtstr).get()
-        return result
-    
-    def _all_cell_styles(self):        
-        result = ''
-        for i in range(0, 16):
-            result += XFRecord(self._default_xf, 'style').get()
-            
-        i = sorted([(v, k) for k, v in self._xf.items()])                            
-        for xf_idx, xf in i:
-            result += XFRecord(xf).get()
-        return result
-        
-    def _all_styles(self):
-        return StyleRecord().get()
-        
-if __name__ == '__main__':
-    sc = StyleCollection()
-    f = file('styles.bin', 'wb')
-    f.write(sc.get_biff_data())
-    f.close()
-
-            

+ 0 - 135
desktop/core/ext-py/pyexcelerator/pyExcelerator/UnicodeUtils.py

@@ -1,135 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-'''
-From BIFF8 on, strings are always stored using UTF-16LE  text encoding. The
-character  array  is  a  sequence  of  16-bit  values4.  Additionally it is
-possible  to  use  a  compressed  format, which omits the high bytes of all
-characters, if they are all zero.
-
-The following tables describe the standard format of the entire string, but
-in many records the strings differ from this format. This will be mentioned
-separately. It is possible (but not required) to store Rich-Text formatting
-information  and  Asian  phonetic information inside a Unicode string. This
-results  in  four  different  ways  to  store a string. The character array
-is not zero-terminated.
-
-The  string  consists  of  the  character count (as usual an 8-bit value or
-a  16-bit value), option flags, the character array and optional formatting
-information.  If the string is empty, sometimes the option flags field will
-not occur. This is mentioned at the respective place.
-
-Offset  Size    Contents
-0       1 or 2  Length of the string (character count, ln)
-1 or 2  1       Option flags:
-                  Bit   Mask Contents
-                  0     01H  Character compression (ccompr):
-                               0 = Compressed (8-bit characters)
-                               1 = Uncompressed (16-bit characters)
-                  2     04H  Asian phonetic settings (phonetic):
-                               0 = Does not contain Asian phonetic settings
-                               1 = Contains Asian phonetic settings
-                  3     08H  Rich-Text settings (richtext):
-                               0 = Does not contain Rich-Text settings
-                               1 = Contains Rich-Text settings
-[2 or 3] 2      (optional, only if richtext=1) Number of Rich-Text formatting runs (rt)
-[var.]   4      (optional, only if phonetic=1) Size of Asian phonetic settings block (in bytes, sz)
-var.     ln or 
-         2·ln   Character array (8-bit characters or 16-bit characters, dependent on ccompr)
-[var.]   4·rt   (optional, only if richtext=1) List of rt formatting runs 
-[var.]   sz     (optional, only if phonetic=1) Asian Phonetic Settings Block 
-'''
-
-
-__rev_id__ = """$Id: UnicodeUtils.py,v 1.4 2005/07/20 07:24:11 rvk Exp $"""
-
-
-import struct
-
-
-DEFAULT_ENCODING = 'cp1251'
-
-def u2ints(ustr):
-    ints = [ord(uchr) for uchr in ustr]
-    return ints
-
-def u2bytes(ustr):
-    ints = u2ints(ustr)
-    return struct.pack('<' + 'H'*len(ints), *ints)
-
-def upack2(_str):
-    try:
-        ustr = u2bytes(unicode(_str, 'ascii'))
-        return struct.pack('<HB', len(_str), 0) + _str    
-    except:
-        if isinstance(_str, unicode):
-            ustr = u2bytes(_str)
-        else:
-            ustr = u2bytes(unicode(_str, DEFAULT_ENCODING))
-        return struct.pack('<HB', len(_str), 1) + ustr
-
-def upack1(_str):
-    try:
-        ustr = u2bytes(unicode(_str, 'ascii'))
-        return struct.pack('BB', len(_str), 0) + _str    
-    except:
-        if isinstance(_str, unicode):
-            ustr = u2bytes(_str)
-        else:
-            ustr = u2bytes(unicode(_str, DEFAULT_ENCODING))
-        return struct.pack('BB', len(_str), 1) + ustr
-
-if __name__ == '__main__':   
-    f = file('out0.bin', 'wb')
-    f.write(u2bytes('þíèêîä: unicode'))
-    f.close()
-
-    f = file('out1.bin', 'wb')
-    f.write(upack1('þíèêîä: unicode'))
-    f.close()
-
-    f = file('out2.bin', 'wb')
-    f.write(upack2('þíèêîä: unicode'))
-    f.close()
-
-
-

+ 0 - 170
desktop/core/ext-py/pyexcelerator/pyExcelerator/Utils.py

@@ -1,170 +0,0 @@
-# pyXLWriter: A library for generating Excel Spreadsheets
-# Copyright (c) 2004 Evgeny Filatov <fufff@users.sourceforge.net>
-# Copyright (c) 2002-2004 John McNamara (Perl Spreadsheet::WriteExcel)
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 2.1 of the License, or
-# (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
-# General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-#----------------------------------------------------------------------------
-# This module was written/ported from PERL Spreadsheet::WriteExcel module
-# The author of the PERL Spreadsheet::WriteExcel module is John McNamara
-# <jmcnamara@cpan.org>
-#----------------------------------------------------------------------------
-# See the README.txt distributed with pyXLWriter for more details.
-
-# Portions are (C) Roman V. Kiseliov, 2005
-
-"""pyXLWriter.utilites
-
-Utilities for work with reference to cells
-
-"""
-__rev_id__ = """$Id: Utils.py,v 1.1 2005/08/11 08:53:48 rvk Exp $"""
-
-import re
-from struct import pack
-from ExcelMagic import MAX_ROW, MAX_COL
-
-
-_re_cell_ex = re.compile(r"(\$?)([A-I]?[A-Z])(\$?)(\d+)")
-_re_row_range = re.compile(r"\$?(\d+):\$?(\d+)")
-_re_col_range = re.compile(r"\$?([A-I]?[A-Z]):\$?([A-I]?[A-Z])")
-_re_cell_range = re.compile(r"\$?([A-I]?[A-Z]\$?\d+):\$?([A-I]?[A-Z]\$?\d+)")
-_re_cell_ref = re.compile(r"\$?([A-I]?[A-Z]\$?\d+)")
-
-
-def col_by_name(colname):
-    """
-    """
-    col = 0
-    pow = 1
-    for i in xrange(len(colname)-1, -1, -1):
-        ch = colname[i]
-        col += (ord(ch) - ord('A') + 1) * pow
-        pow *= 26
-    return col - 1
-
-
-def cell_to_rowcol(cell):
-    """Convert an Excel cell reference string in A1 notation
-    to numeric row/col notation.
-  
-    Returns: row, col, row_abs, col_abs
- 
-    """
-    m = _re_cell_ex.match(cell)
-    if not m:
-        raise Exception("Error in cell format")
-    col_abs, col, row_abs, row = m.groups()
-    row_abs = bool(row_abs)
-    col_abs = bool(col_abs)
-    row = int(row) - 1
-    col = col_by_name(col)
-    return row, col, row_abs, col_abs
-
-
-def cell_to_rowcol2(cell):
-    """Convert an Excel cell reference string in A1 notation
-    to numeric row/col notation.
-  
-    Returns: row, col
-    
-    """
-    m = _re_cell_ex.match(cell)
-    if not m:
-        raise Exception("Error in cell format")
-    col_abs, col, row_abs, row = m.groups()
-    # Convert base26 column string to number
-    # All your Base are belong to us.
-    row = int(row) - 1
-    col = col_by_name(col)
-    return row, col
-    
-    
-def rowcol_to_cell(row, col, row_abs=False, col_abs=False):
-    """Convert numeric row/col notation to an Excel cell reference string in
-    A1 notation.
- 
-    """
-    d = col // 26
-    m = col % 26
-    chr1 = ""    # Most significant character in AA1
-    if row_abs:
-        row_abs = '$'
-    else:
-        row_abs = ''
-    if col_abs:
-        col_abs = '$'
-    else:
-        col_abs = ''
-    if d > 0:
-        chr1 = chr(ord('A') + d  - 1)
-    chr2 = chr(ord('A') + m)
-    # Zero index to 1-index
-    return col_abs + chr1 + chr2 + row_abs + str(row + 1)
-
-
-def cellrange_to_rowcol_pair(cellrange):
-    """Convert cell range string in A1 notation to numeric row/col 
-    pair.
-
-    Returns: row1, col1, row2, col2
-    
-    """
-    cellrange = cellrange.upper()
-    # Convert a row range: '1:3'
-    res = _re_row_range.match(cellrange)
-    if res:
-        row1 = int(res.group(1)) - 1
-        col1 = 0
-        row2 = int(res.group(2)) - 1
-        col2 = -1
-        return row1, col1, row2, col2
-    # Convert a column range: 'A:A' or 'B:G'.
-    # A range such as A:A is equivalent to A1:A16384, so add rows as required
-    res = _re_col_range.match(cellrange)
-    if res:
-        col1 = col_by_name(res.group(1))
-        row1 = 0
-        col2 = col_by_name(res.group(2))
-        row2 = -1
-        return row1, col1, row2, col2
-    # Convert a cell range: 'A1:B7'
-    res = _re_cell_range.match(cellrange)
-    if res:
-        row1, col1 = cell_to_rowcol2(res.group(1))
-        row2, col2 = cell_to_rowcol2(res.group(2))
-        return row1, col1, row2, col2
-    # Convert a cell reference: 'A1' or 'AD2000'
-    res = _re_cell_ref.match(cellrange)
-    if res:
-        row1, col1 = cell_to_rowcol2(res.group(1))
-        return row1, col1, row1, col1
-    raise Exception("Unknown cell reference %s" % (cell))
-
-
-def cell_to_packed_rowcol(cell):
-    """ pack row and column into the required 4 byte format """
-    row, col, row_abs, col_abs = cell_to_rowcol(cell)
-    if col >= MAX_COL:
-        raise Exception("Column %s greater than IV in formula" % cell)
-    if row >= MAX_ROW: # this for BIFF8. for BIFF7 available 2^14
-        raise Exception("Row %s greater than %d in formula" % (cell, MAX_ROW))
-    col |= int(not row_abs) << 15
-    col |= int(not col_abs) << 14
-    return row, col
-
-def pts_to_px(pts): return pts*(4.0/3)
-def px_to_pts(px): return px*(3.0/4)
-def tw_to_px(tw): return tw/15.0
-def px_to_tw(px): return px*15

+ 0 - 617
desktop/core/ext-py/pyexcelerator/pyExcelerator/Workbook.py

@@ -1,617 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-'''
-Record Order in BIFF8
-  Workbook Globals Substream
-      BOF Type = workbook globals
-      Interface Header
-      MMS
-      Interface End
-      WRITEACCESS
-      CODEPAGE
-      DSF
-      TABID
-      FNGROUPCOUNT
-      Workbook Protection Block
-            WINDOWPROTECT
-            PROTECT
-            PASSWORD
-            PROT4REV
-            PROT4REVPASS
-      BACKUP
-      HIDEOBJ 
-      WINDOW1 
-      DATEMODE 
-      PRECISION
-      REFRESHALL
-      BOOKBOOL 
-      FONT +
-      FORMAT *
-      XF +
-      STYLE +
-    ? PALETTE
-      USESELFS
-    
-      BOUNDSHEET +
-    
-      COUNTRY 
-    ? Link Table 
-      SST 
-      ExtSST
-      EOF
-'''
-
-
-__rev_id__ = """$Id: Workbook.py,v 1.5 2005/10/26 07:44:24 rvk Exp $"""
-
-
-import BIFFRecords
-import Style
-from Deco import accepts, returns
-
-
-class Workbook(object):
-
-    macros = {
-        'Consolidate_Area' : 0x00,
-        'Auto_Open' : 0x01,
-        'Auto_Close' : 0x02,
-        'Extract' : 0x03,
-        'Database' : 0x04,
-        'Criteria' : 0x05,
-        'Print_Area' : 0x06,
-        'Print_Titles' : 0x07, # in the docs it says Pint_Titles, I think its a mistake
-        'Recorder' : 0x08,
-        'Data_Form' : 0x09,
-        'Auto_Activate' : 0x0A,
-        'Auto_Deactivate' : 0x0B,
-        'Sheet_Title' : 0x0C,
-        '_FilterDatabase' : 0x0D,
-    }
-
-    #################################################################
-    ## Constructor
-    #################################################################
-    @accepts(object)
-    def __init__(self):
-        self.__owner = 'None'       
-        self.__country_code = 0x07 
-        self.__wnd_protect = 0
-        self.__obj_protect = 0
-        self.__protect = 0        
-        self.__backup_on_save = 0
-        # for WINDOW1 record
-        self.__hpos_twips = 0x01E0
-        self.__vpos_twips = 0x005A
-        self.__width_twips = 0x3FCF
-        self.__height_twips = 0x2A4E
-        
-        self.__active_sheet = 0
-        self.__first_tab_index = 0
-        self.__selected_tabs = 0x01
-        self.__tab_width_twips = 0x0258
-        
-        self.__wnd_hidden = 0
-        self.__wnd_mini = 0
-        self.__hscroll_visible = 1
-        self.__vscroll_visible = 1
-        self.__tabs_visible = 1
-
-        self.__styles = Style.StyleCollection()
-         
-        self.__dates_1904 = 0
-        self.__use_cell_values = 1
-        
-        self.__sst = BIFFRecords.SharedStringTable()
-        
-        self.__worksheets = []
-        self.__names = []
-        self.__refs = []
-
-    #################################################################
-    ## Properties, "getters", "setters"
-    #################################################################
-
-    @accepts(object, str)
-    def set_owner(self, value):
-        self.__owner = value
-
-    def get_owner(self):
-        return self.__owner
-
-    owner = property(get_owner, set_owner)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_country_code(self, value):
-        self.__country_code = value
-
-    def get_country_code(self):
-        return self.__country_code
-
-    country_code = property(get_country_code, set_country_code)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_wnd_protect(self, value):
-        self.__wnd_protect = int(value)
-
-    def get_wnd_protect(self):
-        return bool(self.__wnd_protect)
-
-    wnd_protect = property(get_wnd_protect, set_wnd_protect)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_obj_protect(self, value):
-        self.__obj_protect = int(value)
-
-    def get_obj_protect(self):
-        return bool(self.__obj_protect)
-
-    obj_protect = property(get_obj_protect, set_obj_protect)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_protect(self, value):
-        self.__protect = int(value)
-
-    def get_protect(self):
-        return bool(self.__protect)
-
-    protect = property(get_protect, set_protect)
-    
-    #################################################################
-
-    @accepts(object, bool)
-    def set_backup_on_save(self, value):
-        self.__backup_on_save = int(value)
-
-    def get_backup_on_save(self):
-        return bool(self.__backup_on_save)
-
-    backup_on_save = property(get_backup_on_save, set_backup_on_save)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_hpos(self, value):
-        self.__hpos_twips = value & 0xFFFF
-
-    def get_hpos(self):
-        return self.__hpos_twips
-
-    hpos = property(get_hpos, set_hpos)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_vpos(self, value):
-        self.__vpos_twips = value & 0xFFFF
-
-    def get_vpos(self):
-        return self.__vpos_twips
-
-    vpos = property(get_vpos, set_vpos)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_width(self, value):
-        self.__width_twips = value & 0xFFFF
-
-    def get_width(self):
-        return self.__width_twips
-
-    width = property(get_width, set_width)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_height(self, value):
-        self.__height_twips = value & 0xFFFF
-
-    def get_height(self):
-        return self.__height_twips
-
-    height = property(get_height, set_height)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_active_sheet(self, value):
-        self.__active_sheet = value & 0xFFFF
-        self.__first_tab_index = self.__active_sheet
-
-    def get_active_sheet(self):
-        return self.__active_sheet
-
-    active_sheet = property(get_active_sheet, set_active_sheet)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_tab_width(self, value):
-        self.__tab_width_twips = value & 0xFFFF
-
-    def get_tab_width(self):
-        return self.__tab_width_twips
-
-    tab_width = property(get_tab_width, set_tab_width)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_wnd_visible(self, value):
-        self.__wnd_hidden = int(not value)
-
-    def get_wnd_visible(self):
-        return not bool(self.__wnd_hidden)
-
-    wnd_visible = property(get_wnd_visible, set_wnd_visible)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_wnd_mini(self, value):
-        self.__wnd_mini = int(value)
-
-    def get_wnd_mini(self):
-        return bool(self.__wnd_mini)
-
-    wnd_mini = property(get_wnd_mini, set_wnd_mini)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_hscroll_visible(self, value):
-        self.__hscroll_visible = int(value)
-
-    def get_hscroll_visible(self):
-        return bool(self.__hscroll_visible)
-
-    hscroll_visible = property(get_hscroll_visible, set_hscroll_visible)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_vscroll_visible(self, value):
-        self.__vscroll_visible = int(value)
-
-    def get_vscroll_visible(self):
-        return bool(self.__vscroll_visible)
-
-    vscroll_visible = property(get_vscroll_visible, set_vscroll_visible)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_tabs_visible(self, value):
-        self.__tabs_visible = int(value)
-
-    def get_tabs_visible(self):
-        return bool(self.__tabs_visible)
-
-    tabs_visible = property(get_tabs_visible, set_tabs_visible)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_dates_1904(self, value):
-        self.__dates_1904 = int(value)
-
-    def get_dates_1904(self):
-        return bool(self.__dates_1904)
-
-    dates_1904 = property(get_dates_1904, set_dates_1904)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_use_cell_values(self, value):
-        self.__use_cell_values = int(value)
-
-    def get_use_cell_values(self):
-        return bool(self.__use_cell_values)
-
-    use_cell_values = property(get_use_cell_values, set_use_cell_values)
-
-    #################################################################
-
-    def get_default_style(self):
-        return self.__styles.default_style
-
-    default_style = property(get_default_style)
-
-    ##################################################################
-    ## Methods
-    ##################################################################
-
-    @accepts(object, (Style.XFStyle, type(None)))
-    def add_style(self, style):
-        return self.__styles.add(style)
-
-    @accepts(object, (str, unicode))    
-    def add_str(self, s):
-        return self.__sst.add_str(s)
-        
-    @accepts(object, str)    
-    def str_index(self, s):
-        return self.__sst.str_index(s)
-        
-    @accepts(object, (str, unicode))    
-    def add_sheet(self, sheetname):
-        import Worksheet
-        self.__worksheets.append(Worksheet.Worksheet(sheetname, self))
-        return self.__worksheets[-1]
-
-    @accepts(object, int)    
-    def get_sheet(self, sheetnum):
-        return self.__worksheets[sheetnum]
-        
-    @accepts(object, (int, unicode, str), int, int, int, int)    
-    def print_area(self, sheetnum, rstart, rend, cstart, cend):
-        import ExcelFormula
-        from struct import pack
-        if type(sheetnum) != int:
-            for i, ws in enumerate(self.__worksheets):
-                if ws.name == sheetnum: sheetnum = i+1
-        
-        options = 0x0020 # see Options Flags for Name record
-        
-        # FIXME: this is just a bad hack, need to use Formula to make the rpn
-        #~ rpn = ExcelFormula.Formula('').rpn()[2:] # minus the size field
-        rpn = pack('<BHHHHH', 0x3B, 0x0000, rstart, rend, cstart, cend)
-        
-        return self.__names.append(BIFFRecords.NameRecord(options, 0x00, self.macros['Print_Area'], sheetnum, rpn))
-
-    ##################################################################
-    ## BIFF records generation
-    ##################################################################
-
-    def __bof_rec(self):
-        return BIFFRecords.Biff8BOFRecord(BIFFRecords.Biff8BOFRecord.BOOK_GLOBAL).get()
-
-    def __eof_rec(self):
-        return BIFFRecords.EOFRecord().get()
-        
-    def __intf_hdr_rec(self):
-        return BIFFRecords.InteraceHdrRecord().get()
-
-    def __intf_end_rec(self):
-        return BIFFRecords.InteraceEndRecord().get()
-
-    def __intf_mms_rec(self):
-        return BIFFRecords.MMSRecord().get()
-
-    def __write_access_rec(self):
-        return BIFFRecords.WriteAccessRecord(self.__owner).get()
-
-    def __wnd_protect_rec(self):
-        return BIFFRecords.WindowProtectRecord(self.__wnd_protect).get()
-
-    def __obj_protect_rec(self):
-        return BIFFRecords.ObjectProtectRecord(self.__obj_protect).get()
-
-    def __protect_rec(self):
-        return BIFFRecords.ProtectRecord(self.__protect).get()
-
-    def __password_rec(self):
-        return BIFFRecords.PasswordRecord().get()
-
-    def __prot4rev_rec(self):
-        return BIFFRecords.Prot4RevRecord().get()
-
-    def __prot4rev_pass_rec(self):
-        return BIFFRecords.Prot4RevPassRecord().get()
-
-    def __backup_rec(self):
-        return BIFFRecords.BackupRecord(self.__backup_on_save).get()
-        
-    def __hide_obj_rec(self):
-        return BIFFRecords.HideObjRecord().get()
-        
-    def __window1_rec(self):
-        flags = 0
-        flags |= (self.__wnd_hidden) << 0
-        flags |= (self.__wnd_mini) << 1
-        flags |= (self.__hscroll_visible) << 3
-        flags |= (self.__vscroll_visible) << 4
-        flags |= (self.__tabs_visible) << 5
-        
-        return BIFFRecords.Window1Record(self.__hpos_twips, self.__vpos_twips, 
-                                self.__width_twips, self.__height_twips, 
-                                flags,
-                                self.__active_sheet, self.__first_tab_index, 
-                                self.__selected_tabs, self.__tab_width_twips).get()
-        
-    def __codepage_rec(self):
-        return BIFFRecords.CodepageBiff8Record().get()
-        
-    def __country_rec(self):
-        return BIFFRecords.CountryRecord(self.__country_code, self.__country_code).get()
-        
-    def __dsf_rec(self):
-        return BIFFRecords.DSFRecord().get()
-        
-    def __tabid_rec(self):
-        return BIFFRecords.TabIDRecord(len(self.__worksheets)).get()
-        
-    def __fngroupcount_rec(self):
-        return BIFFRecords.FnGroupCountRecord().get()
-        
-    def __datemode_rec(self):
-        return BIFFRecords.DateModeRecord(self.__dates_1904).get()        
-
-    def __precision_rec(self):
-        return BIFFRecords.PrecisionRecord(self.__use_cell_values).get()         
-
-    def __refresh_all_rec(self):
-        return BIFFRecords.RefreshAllRecord().get()        
-
-    def __bookbool_rec(self):
-        return BIFFRecords.BookBoolRecord().get()         
-
-    def __all_fonts_num_formats_xf_styles_rec(self):
-        return self.__styles.get_biff_data()
-
-    def __palette_rec(self):
-        result = ''
-        return result
-        
-    def __useselfs_rec(self):
-        return BIFFRecords.UseSelfsRecord().get()
-        
-    def __names_rec(self):
-        name_records = ''
-        for n in self.__names:
-            name_records += n.get()
-        return name_records
-        
-    def __boundsheets_rec(self, data_len_before, data_len_after, sheet_biff_lens):
-        #  .................................  
-        # BOUNDSEHEET0
-        # BOUNDSEHEET1
-        # BOUNDSEHEET2
-        # ..................................
-        # WORKSHEET0
-        # WORKSHEET1
-        # WORKSHEET2
-        boundsheets_len = 0
-        for sheet in self.__worksheets:
-            boundsheets_len += len(BIFFRecords.BoundSheetRecord(0x00L, sheet.hidden, sheet.name).get())
-        
-        start = data_len_before + boundsheets_len + data_len_after
-        
-        result = ''
-        for sheet_biff_len,  sheet in zip(sheet_biff_lens, self.__worksheets):
-            result += BIFFRecords.BoundSheetRecord(start, sheet.hidden, sheet.name).get()
-            start += sheet_biff_len            
-        return result
-
-    def __all_links_rec(self):
-        supbook_records = ''
-        #~ supbook_records += BIFFRecords.AddInFunctionSupBookRecord(len(self.__worksheets)).get()
-        supbook_records += BIFFRecords.InternalReferenceSupBookRecord(len(self.__worksheets)).get()
-        #~ supbook_records += BIFFRecords.ExternalReferenceSupBookRecord(len(self.__worksheets)).get()
-        externsheet_record = BIFFRecords.ExternSheetRecord(self.__refs).get()
-        return supbook_records + externsheet_record
-        
-    def __sst_rec(self):
-        return self.__sst.get_biff_record()
-        
-    def __ext_sst_rec(self, abs_stream_pos):
-        return ''
-        #return BIFFRecords.ExtSSTRecord(abs_stream_pos, self.sst_record.str_placement,
-        #self.sst_record.portions_len).get()
-
-    def get_biff_data(self):
-        before = ''
-        before += self.__bof_rec()
-        before += self.__intf_hdr_rec()
-        before += self.__intf_mms_rec()
-        before += self.__intf_end_rec()
-        before += self.__write_access_rec()
-        before += self.__codepage_rec()
-        before += self.__dsf_rec() 
-        before += self.__tabid_rec() 
-        before += self.__fngroupcount_rec()
-        #~ before += self.__names_rec()
-        before += self.__wnd_protect_rec()
-        before += self.__protect_rec()
-        before += self.__obj_protect_rec()
-        before += self.__password_rec()
-        before += self.__prot4rev_rec()
-        before += self.__prot4rev_pass_rec()
-        before += self.__backup_rec()        
-        before += self.__hide_obj_rec()        
-        before += self.__window1_rec()
-        before += self.__datemode_rec()
-        before += self.__precision_rec()
-        before += self.__refresh_all_rec()
-        before += self.__bookbool_rec()
-        before += self.__all_fonts_num_formats_xf_styles_rec()
-        before += self.__palette_rec()
-        before += self.__useselfs_rec()
-        
-        country            = self.__country_rec()
-        all_links          = self.__all_links_rec()
-        names              = self.__names_rec()
-        
-        shared_str_table   = self.__sst_rec()        
-        after = country + all_links + names + shared_str_table
-        
-        ext_sst = self.__ext_sst_rec(0) # need fake cause we need calc stream pos
-        eof = self.__eof_rec()
-
-        self.__worksheets[self.__active_sheet].selected = True
-        sheets = ''
-        sheet_biff_lens = []
-        for sheet in self.__worksheets:
-            data = sheet.get_biff_data()
-            sheets += data
-            sheet_biff_lens.append(len(data))
-            
-        bundlesheets = self.__boundsheets_rec(len(before), len(after)+len(ext_sst)+len(eof), sheet_biff_lens)       
-       
-        sst_stream_pos = len(before) + len(bundlesheets) + len(country)  + len(all_links) +  len(names)
-        ext_sst = self.__ext_sst_rec(sst_stream_pos)           
-        
-        return before + bundlesheets + after + ext_sst + eof + sheets
-
-    def save(self, filename):
-        import CompoundDoc
-
-        doc = CompoundDoc.XlsDoc()
-        doc.save(filename, self.get_biff_data())
-
-if __name__ == '__main__':
-    wb = Workbook()
-    f = file('workbook.bin', 'wb')
-    f.write(wb.get_biff_data())
-    f.close()
-    

+ 0 - 1435
desktop/core/ext-py/pyexcelerator/pyExcelerator/Worksheet.py

@@ -1,1435 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-#
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-#
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-#
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-'''
-            BOF
-            UNCALCED
-            INDEX
-            Calculation Settings Block
-            PRINTHEADERS
-            PRINTGRIDLINES
-            GRIDSET
-            GUTS
-            DEFAULTROWHEIGHT
-            WSBOOL
-            Page Settings Block
-            Worksheet Protection Block
-            DEFCOLWIDTH
-            COLINFO
-            SORT
-            DIMENSIONS
-            Row Blocks
-            WINDOW2
-            SCL
-            PANE
-            SELECTION
-            STANDARDWIDTH
-            MERGEDCELLS
-            LABELRANGES
-            PHONETIC
-            Conditional Formatting Table
-            Hyperlink Table
-            Data Validity Table
-            SHEETLAYOUT (BIFF8X only)
-            SHEETPROTECTION (BIFF8X only)
-            RANGEPROTECTION (BIFF8X only)
-            EOF
-'''
-
-__rev_id__ = """$Id: Worksheet.py,v 1.8 2005/10/26 07:44:24 rvk Exp $"""
-
-
-import BIFFRecords
-import Bitmap
-import Formatting
-import Style
-import Utils
-import ExcelFormula
-from Deco import *
-
-class Worksheet(object):
-    from Workbook import Workbook
-
-    #################################################################
-    ## Constructor
-    #################################################################
-    @accepts(object, (str, unicode), Workbook)
-    def __init__(self, sheetname, parent_book):
-        import Row
-        self.Row = Row.Row
-
-        import Column
-        self.Column = Column.Column
-
-        self.__name = sheetname
-        self.__parent = parent_book
-
-        self.__rows = {}
-        self.__cols = {}
-        self.__merged_ranges = []
-        self.__links = {}
-        self.__bmp_rec = ''
-
-        self.__show_formulas = 0
-        self.__show_grid = 1
-        self.__show_headers = 1
-        self.__panes_frozen = 0
-        self.__show_empty_as_zero = 1
-        self.__auto_colour_grid = 1
-        self.__cols_right_to_left = 0
-        self.__show_outline = 1
-        self.__remove_splits = 0
-        self.__selected = 0
-        self.__hidden = 0
-        self.__page_preview = 0
-
-        self.__first_visible_row = 0
-        self.__first_visible_col = 0
-        self.__grid_colour = 0x40
-        self.__preview_magn = 0
-        self.__normal_magn = 0
-
-        self.__vert_split_pos = None
-        self.__horz_split_pos = None
-        self.__vert_split_first_visible = None
-        self.__horz_split_first_visible = None
-        self.__split_active_pane = None
-
-        self.__row_gut_width = 0
-        self.__col_gut_height = 0
-
-        self.__show_auto_page_breaks = 1
-        self.__dialogue_sheet = 0
-        self.__auto_style_outline = 0
-        self.__outline_below = 0
-        self.__outline_right = 0
-        self.__fit_num_pages = 0
-        self.__show_row_outline = 1
-        self.__show_col_outline = 1
-        self.__alt_expr_eval = 0
-        self.__alt_formula_entries = 0
-
-        self.__row_default_height = 0x00FF
-        self.__col_default_width = 0x0008
-
-        self.__default_row_hidden = 0
-        self.__default_row_space_above = 0
-        self.__default_row_space_below = 0
-
-        self.__calc_mode = 1
-        self.__calc_count = 0x0064
-        self.__RC_ref_mode = 1
-        self.__iterations_on = 0
-        self.__delta = 0.001
-        self.__save_recalc = 0
-        self.__frmla_opts = ExcelFormula.RecalcAlways | ExcelFormula.CalcOnOpen
-
-        self.__print_headers = 0
-        self.__print_grid = 0
-        self.__grid_set = 1
-        self.__vert_page_breaks = []
-        self.__horz_page_breaks = []
-        self.__header_str = '&P'
-        self.__footer_str = '&F'
-        self.__print_centered_vert = 0
-        self.__print_centered_horz = 1
-        self.__left_margin = 0.3 #0.5
-        self.__right_margin = 0.3 #0.5
-        self.__top_margin = 0.61 #1.0
-        self.__bottom_margin = 0.37 #1.0
-        self.__paper_size_code = 9 # A4
-        self.__print_scaling = 100
-        self.__start_page_number = 1
-        self.__fit_width_to_pages = 1
-        self.__fit_height_to_pages = 1
-        self.__print_in_rows = 1
-        self.__portrait = 1
-        self.__print_not_colour = 0
-        self.__print_draft = 0
-        self.__print_notes = 0
-        self.__print_notes_at_end = 0
-        self.__print_omit_errors = 0
-        self.__print_hres = 0x012C # 300 dpi
-        self.__print_vres = 0x012C # 300 dpi
-        self.__header_margin = 0.1
-        self.__footer_margin = 0.1
-        self.__copies_num = 1
-
-        self.__wnd_protect = 0
-        self.__obj_protect = 0
-        self.__protect = 0
-        self.__scen_protect = 0
-        self.__password = ''
-
-    #################################################################
-    ## Properties, "getters", "setters"
-    #################################################################
-
-    @accepts(object, (str, unicode))
-    def set_name(self, value):
-        self.__name = value
-
-    def get_name(self):
-        return self.__name
-
-    name = property(get_name, set_name)
-
-    #################################################################
-
-    def get_parent(self):
-        return self.__parent
-
-    parent = property(get_parent)
-
-    #################################################################
-
-    def get_rows(self):
-        return self.__rows
-
-    rows = property(get_rows)
-
-    #################################################################
-
-    def get_cols(self):
-        return self.__cols
-
-    cols = property(get_cols)
-
-    #################################################################
-
-    def get_merged_ranges(self):
-        return self.__merged_ranges
-
-    merged_ranges = property(get_merged_ranges)
-
-    #################################################################
-
-    def get_bmp_rec(self):
-        return self.__bmp_rec
-
-    bmp_rec = property(get_bmp_rec)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_show_formulas(self, value):
-        self.__show_formulas = int(value)
-
-    def get_show_formulas(self):
-        return bool(self.__show_formulas)
-
-    show_formulas = property(get_show_formulas, set_show_formulas)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_show_grid(self, value):
-        self.__show_grid = int(value)
-
-    def get_show_grid(self):
-        return bool(self.__show_grid)
-
-    show_grid = property(get_show_grid, set_show_grid)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_show_headers(self, value):
-        self.__show_headers = int(value)
-
-    def get_show_headers(self):
-        return bool(self.__show_headers)
-
-    show_headers = property(get_show_headers, set_show_headers)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_panes_frozen(self, value):
-        self.__panes_frozen = int(value)
-
-    def get_panes_frozen(self):
-        return bool(self.__panes_frozen)
-
-    panes_frozen = property(get_panes_frozen, set_panes_frozen)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_show_empty_as_zero(self, value):
-        self.__show_empty_as_zero = int(value)
-
-    def get_show_empty_as_zero(self):
-        return bool(self.__show_empty_as_zero)
-
-    show_empty_as_zero = property(get_show_empty_as_zero, set_show_empty_as_zero)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_auto_colour_grid(self, value):
-        self.__auto_colour_grid = int(value)
-
-    def get_auto_colour_grid(self):
-        return bool(self.__auto_colour_grid)
-
-    auto_colour_grid = property(get_auto_colour_grid, set_auto_colour_grid)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_cols_right_to_left(self, value):
-        self.__cols_right_to_left = int(value)
-
-    def get_cols_right_to_left(self):
-        return bool(self.__cols_right_to_left)
-
-    cols_right_to_left = property(get_cols_right_to_left, set_cols_right_to_left)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_show_outline(self, value):
-        self.__show_outline = int(value)
-
-    def get_show_outline(self):
-        return bool(self.__show_outline)
-
-    show_outline = property(get_show_outline, set_show_outline)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_remove_splits(self, value):
-        self.__remove_splits = int(value)
-
-    def get_remove_splits(self):
-        return bool(self.__remove_splits)
-
-    remove_splits = property(get_remove_splits, set_remove_splits)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_selected(self, value):
-        self.__selected = int(value)
-
-    def get_selected(self):
-        return bool(self.__selected)
-
-    selected = property(get_selected, set_selected)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_hidden(self, value):
-        self.__hidden = int(value)
-
-    def get_hidden(self):
-        return bool(self.__hidden)
-
-    hidden = property(get_hidden, set_hidden)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_page_preview(self, value):
-        self.__page_preview = int(value)
-
-    def get_page_preview(self):
-        return bool(self.__page_preview)
-
-    page_preview = property(get_page_preview, set_page_preview)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_first_visible_row(self, value):
-        self.__first_visible_row = value
-
-    def get_first_visible_row(self):
-        return self.__first_visible_row
-
-    first_visible_row = property(get_first_visible_row, set_first_visible_row)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_first_visible_col(self, value):
-        self.__first_visible_col = value
-
-    def get_first_visible_col(self):
-        return self.__first_visible_col
-
-    first_visible_col = property(get_first_visible_col, set_first_visible_col)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_grid_colour(self, value):
-        self.__grid_colour = value
-
-    def get_grid_colour(self):
-        return self.__grid_colour
-
-    grid_colour = property(get_grid_colour, set_grid_colour)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_preview_magn(self, value):
-        self.__preview_magn = value
-
-    def get_preview_magn(self):
-        return self.__preview_magn
-
-    preview_magn = property(get_preview_magn, set_preview_magn)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_normal_magn(self, value):
-        self.__normal_magn = value
-
-    def get_normal_magn(self):
-        return self.__normal_magn
-
-    normal_magn = property(get_normal_magn, set_normal_magn)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_vert_split_pos(self, value):
-        self.__vert_split_pos = abs(value)
-
-    def get_vert_split_pos(self):
-        return self.__vert_split_pos
-
-    vert_split_pos = property(get_vert_split_pos, set_vert_split_pos)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_horz_split_pos(self, value):
-        self.__horz_split_pos = abs(value)
-
-    def get_horz_split_pos(self):
-        return self.__horz_split_pos
-
-    horz_split_pos = property(get_horz_split_pos, set_horz_split_pos)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_vert_split_first_visible(self, value):
-        self.__vert_split_first_visible = abs(value)
-
-    def get_vert_split_first_visible(self):
-        return self.__vert_split_first_visible
-
-    vert_split_first_visible = property(get_vert_split_first_visible, set_vert_split_first_visible)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_horz_split_first_visible(self, value):
-        self.__horz_split_first_visible = abs(value)
-
-    def get_horz_split_first_visible(self):
-        return self.__horz_split_first_visible
-
-    horz_split_first_visible = property(get_horz_split_first_visible, set_horz_split_first_visible)
-
-    #################################################################
-
-    #@accepts(object, int)
-    #def set_split_active_pane(self, value):
-    #    self.__split_active_pane = abs(value) & 0x03
-    #
-    #def get_split_active_pane(self):
-    #    return self.__split_active_pane
-    #
-    #split_active_pane = property(get_split_active_pane, set_split_active_pane)
-
-    #################################################################
-
-    #@accepts(object, int)
-    #def set_row_gut_width(self, value):
-    #    self.__row_gut_width = value
-    #
-    #def get_row_gut_width(self):
-    #    return self.__row_gut_width
-    #
-    #row_gut_width = property(get_row_gut_width, set_row_gut_width)
-    #
-    #################################################################
-    #
-    #@accepts(object, int)
-    #def set_col_gut_height(self, value):
-    #    self.__col_gut_height = value
-    #
-    #def get_col_gut_height(self):
-    #    return self.__col_gut_height
-    #
-    #col_gut_height = property(get_col_gut_height, set_col_gut_height)
-    #
-    #################################################################
-
-    @accepts(object, bool)
-    def set_show_auto_page_breaks(self, value):
-        self.__show_auto_page_breaks = int(value)
-
-    def get_show_auto_page_breaks(self):
-        return bool(self.__show_auto_page_breaks)
-
-    show_auto_page_breaks = property(get_show_auto_page_breaks, set_show_auto_page_breaks)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_dialogue_sheet(self, value):
-        self.__dialogue_sheet = int(value)
-
-    def get_dialogue_sheet(self):
-        return bool(self.__dialogue_sheet)
-
-    dialogue_sheet = property(get_dialogue_sheet, set_dialogue_sheet)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_auto_style_outline(self, value):
-        self.__auto_style_outline = int(value)
-
-    def get_auto_style_outline(self):
-        return bool(self.__auto_style_outline)
-
-    auto_style_outline = property(get_auto_style_outline, set_auto_style_outline)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_outline_below(self, value):
-        self.__outline_below = int(value)
-
-    def get_outline_below(self):
-        return bool(self.__outline_below)
-
-    outline_below = property(get_outline_below, set_outline_below)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_outline_right(self, value):
-        self.__outline_right = int(value)
-
-    def get_outline_right(self):
-        return bool(self.__outline_right)
-
-    outline_right = property(get_outline_right, set_outline_right)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_fit_num_pages(self, value):
-        self.__fit_num_pages = value
-
-    def get_fit_num_pages(self):
-        return self.__fit_num_pages
-
-    fit_num_pages = property(get_fit_num_pages, set_fit_num_pages)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_show_row_outline(self, value):
-        self.__show_row_outline = int(value)
-
-    def get_show_row_outline(self):
-        return bool(self.__show_row_outline)
-
-    show_row_outline = property(get_show_row_outline, set_show_row_outline)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_show_col_outline(self, value):
-        self.__show_col_outline = int(value)
-
-    def get_show_col_outline(self):
-        return bool(self.__show_col_outline)
-
-    show_col_outline = property(get_show_col_outline, set_show_col_outline)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_alt_expr_eval(self, value):
-        self.__alt_expr_eval = int(value)
-
-    def get_alt_expr_eval(self):
-        return bool(self.__alt_expr_eval)
-
-    alt_expr_eval = property(get_alt_expr_eval, set_alt_expr_eval)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_alt_formula_entries(self, value):
-        self.__alt_formula_entries = int(value)
-
-    def get_alt_formula_entries(self):
-        return bool(self.__alt_formula_entries)
-
-    alt_formula_entries = property(get_alt_formula_entries, set_alt_formula_entries)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_row_default_height(self, value):
-        ''' set default row height in pixels '''
-        self.__row_default_height = Utils.px_to_tw(value)
-
-    def get_row_default_height(self):
-        return Utils.tw_to_px(self.__row_default_height)
-
-    row_default_height = property(get_row_default_height, set_row_default_height)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_col_default_width(self, value):
-        self.__col_default_width = value
-
-    def get_col_default_width(self):
-        return self.__col_default_width
-
-    col_default_width = property(get_col_default_width, set_col_default_width)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_calc_mode(self, value):
-        self.__calc_mode = (value == 0xFFFF and value) or value & 0x01
-
-    def get_calc_mode(self):
-        return self.__calc_mode
-
-    calc_mode = property(get_calc_mode, set_calc_mode)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_calc_count(self, value):
-        self.__calc_count = value
-
-    def get_calc_count(self):
-        return self.__calc_count
-
-    calc_count = property(get_calc_count, set_calc_count)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_RC_ref_mode(self, value):
-        self.__RC_ref_mode = int(value)
-
-    def get_RC_ref_mode(self):
-        return bool(self.__RC_ref_mode)
-
-    RC_ref_mode = property(get_RC_ref_mode, set_RC_ref_mode)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_iterations_on(self, value):
-        self.__iterations_on = int(value)
-
-    def get_iterations_on(self):
-        return bool(self.__iterations_on)
-
-    iterations_on = property(get_iterations_on, set_iterations_on)
-
-    #################################################################
-
-    @accepts(object, float)
-    def set_delta(self, value):
-        self.__delta = value
-
-    def get_delta(self):
-        return self.__delta
-
-    delta = property(get_delta, set_delta)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_save_recalc(self, value):
-        self.__save_recalc = int(value)
-
-    def get_save_recalc(self):
-        return bool(self.__save_recalc)
-
-    save_recalc = property(get_save_recalc, set_save_recalc)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_frmla_opts(self, value):
-        assert (int(value) & ~(0x0b)) == 0, "Invalid bits set for frmla_opts (%s)"%hex(int(value))
-        self.__frmla_opts = int(value)
-
-    def get_frmla_opts(self):
-        return self.__frmla_opts
-
-    frmla_opts = property(get_frmla_opts, set_frmla_opts)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_headers(self, value):
-        self.__print_headers = int(value)
-
-    def get_print_headers(self):
-        return bool(self.__print_headers)
-
-    print_headers = property(get_print_headers, set_print_headers)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_grid(self, value):
-        self.__print_grid = int(value)
-
-    def get_print_grid(self):
-        return bool(self.__print_grid)
-
-    print_grid = property(get_print_grid, set_print_grid)
-
-    #################################################################
-    #
-    #@accepts(object, bool)
-    #def set_grid_set(self, value):
-    #    self.__grid_set = int(value)
-    #
-    #def get_grid_set(self):
-    #    return bool(self.__grid_set)
-    #
-    #grid_set = property(get_grid_set, set_grid_set)
-    #
-    #################################################################
-
-    @accepts(object, list)
-    def set_vert_page_breaks(self, value):
-        self.__vert_page_breaks = value
-
-    def get_vert_page_breaks(self):
-        return self.__vert_page_breaks
-
-    vert_page_breaks = property(get_vert_page_breaks, set_vert_page_breaks)
-
-    #################################################################
-
-    @accepts(object, list)
-    def set_horz_page_breaks(self, value):
-        self.__horz_page_breaks = value
-
-    def get_horz_page_breaks(self):
-        return self.__horz_page_breaks
-
-    horz_page_breaks = property(get_horz_page_breaks, set_horz_page_breaks)
-
-    #################################################################
-
-    @accepts(object, (str, unicode))
-    def set_header_str(self, value):
-        self.__header_str = value
-
-    def get_header_str(self):
-        return self.__header_str
-
-    header_str = property(get_header_str, set_header_str)
-
-    #################################################################
-
-    @accepts(object, (str, unicode))
-    def set_footer_str(self, value):
-        self.__footer_str = value
-
-    def get_footer_str(self):
-        return self.__footer_str
-
-    footer_str = property(get_footer_str, set_footer_str)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_centered_vert(self, value):
-        self.__print_centered_vert = int(value)
-
-    def get_print_centered_vert(self):
-        return bool(self.__print_centered_vert)
-
-    print_centered_vert = property(get_print_centered_vert, set_print_centered_vert)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_centered_horz(self, value):
-        self.__print_centered_horz = int(value)
-
-    def get_print_centered_horz(self):
-        return bool(self.__print_centered_horz)
-
-    print_centered_horz = property(get_print_centered_horz, set_print_centered_horz)
-
-    #################################################################
-
-    @accepts(object, float)
-    def set_left_margin(self, value):
-        self.__left_margin = value
-
-    def get_left_margin(self):
-        return self.__left_margin
-
-    left_margin = property(get_left_margin, set_left_margin)
-
-    #################################################################
-
-    @accepts(object, float)
-    def set_right_margin(self, value):
-        self.__right_margin = value
-
-    def get_right_margin(self):
-        return self.__right_margin
-
-    right_margin = property(get_right_margin, set_right_margin)
-
-    #################################################################
-
-    @accepts(object, float)
-    def set_top_margin(self, value):
-        self.__top_margin = value
-
-    def get_top_margin(self):
-        return self.__top_margin
-
-    top_margin = property(get_top_margin, set_top_margin)
-
-    #################################################################
-
-    @accepts(object, float)
-    def set_bottom_margin(self, value):
-        self.__bottom_margin = value
-
-    def get_bottom_margin(self):
-        return self.__bottom_margin
-
-    bottom_margin = property(get_bottom_margin, set_bottom_margin)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_paper_size_code(self, value):
-        self.__paper_size_code = value
-
-    def get_paper_size_code(self):
-        return self.__paper_size_code
-
-    paper_size_code = property(get_paper_size_code, set_paper_size_code)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_print_scaling(self, value):
-        self.__print_scaling = value
-
-    def get_print_scaling(self):
-        return self.__print_scaling
-
-    print_scaling = property(get_print_scaling, set_print_scaling)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_start_page_number(self, value):
-        self.__start_page_number = value
-
-    def get_start_page_number(self):
-        return self.__start_page_number
-
-    start_page_number = property(get_start_page_number, set_start_page_number)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_fit_width_to_pages(self, value):
-        self.__fit_width_to_pages = value
-
-    def get_fit_width_to_pages(self):
-        return self.__fit_width_to_pages
-
-    fit_width_to_pages = property(get_fit_width_to_pages, set_fit_width_to_pages)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_fit_height_to_pages(self, value):
-        self.__fit_height_to_pages = value
-
-    def get_fit_height_to_pages(self):
-        return self.__fit_height_to_pages
-
-    fit_height_to_pages = property(get_fit_height_to_pages, set_fit_height_to_pages)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_in_rows(self, value):
-        self.__print_in_rows = int(value)
-
-    def get_print_in_rows(self):
-        return bool(self.__print_in_rows)
-
-    print_in_rows = property(get_print_in_rows, set_print_in_rows)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_portrait(self, value):
-        self.__portrait = int(value)
-
-    def get_portrait(self):
-        return bool(self.__portrait)
-
-    portrait = property(get_portrait, set_portrait)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_colour(self, value):
-        self.__print_not_colour = int(not value)
-
-    def get_print_colour(self):
-        return not bool(self.__print_not_colour)
-
-    print_colour = property(get_print_colour, set_print_colour)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_draft(self, value):
-        self.__print_draft = int(value)
-
-    def get_print_draft(self):
-        return bool(self.__print_draft)
-
-    print_draft = property(get_print_draft, set_print_draft)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_notes(self, value):
-        self.__print_notes = int(value)
-
-    def get_print_notes(self):
-        return bool(self.__print_notes)
-
-    print_notes = property(get_print_notes, set_print_notes)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_notes_at_end(self, value):
-        self.__print_notes_at_end = int(value)
-
-    def get_print_notes_at_end(self):
-        return bool(self.__print_notes_at_end)
-
-    print_notes_at_end = property(get_print_notes_at_end, set_print_notes_at_end)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_print_omit_errors(self, value):
-        self.__print_omit_errors = int(value)
-
-    def get_print_omit_errors(self):
-        return bool(self.__print_omit_errors)
-
-    print_omit_errors = property(get_print_omit_errors, set_print_omit_errors)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_print_hres(self, value):
-        self.__print_hres = value
-
-    def get_print_hres(self):
-        return self.__print_hres
-
-    print_hres = property(get_print_hres, set_print_hres)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_print_vres(self, value):
-        self.__print_vres = value
-
-    def get_print_vres(self):
-        return self.__print_vres
-
-    print_vres = property(get_print_vres, set_print_vres)
-
-    #################################################################
-
-    @accepts(object, float)
-    def set_header_margin(self, value):
-        self.__header_margin = value
-
-    def get_header_margin(self):
-        return self.__header_margin
-
-    header_margin = property(get_header_margin, set_header_margin)
-
-    #################################################################
-
-    @accepts(object, float)
-    def set_footer_margin(self, value):
-        self.__footer_margin = value
-
-    def get_footer_margin(self):
-        return self.__footer_margin
-
-    footer_margin = property(get_footer_margin, set_footer_margin)
-
-    #################################################################
-
-    @accepts(object, int)
-    def set_copies_num(self, value):
-        self.__copies_num = value
-
-    def get_copies_num(self):
-        return self.__copies_num
-
-    copies_num = property(get_copies_num, set_copies_num)
-
-    ##################################################################
-
-    @accepts(object, bool)
-    def set_wnd_protect(self, value):
-        self.__wnd_protect = int(value)
-
-    def get_wnd_protect(self):
-        return bool(self.__wnd_protect)
-
-    wnd_protect = property(get_wnd_protect, set_wnd_protect)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_obj_protect(self, value):
-        self.__obj_protect = int(value)
-
-    def get_obj_protect(self):
-        return bool(self.__obj_protect)
-
-    obj_protect = property(get_obj_protect, set_obj_protect)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_protect(self, value):
-        self.__protect = int(value)
-
-    def get_protect(self):
-        return bool(self.__protect)
-
-    protect = property(get_protect, set_protect)
-
-    #################################################################
-
-    @accepts(object, bool)
-    def set_scen_protect(self, value):
-        self.__scen_protect = int(value)
-
-    def get_scen_protect(self):
-        return bool(self.__scen_protect)
-
-    scen_protect = property(get_scen_protect, set_scen_protect)
-
-    #################################################################
-
-    @accepts(object, str)
-    def set_password(self, value):
-        self.__password = value
-
-    def get_password(self):
-        return self.__password
-
-    password = property(get_password, set_password)
-
-    ##################################################################
-    ## Methods
-    ##################################################################
-
-    def get_parent(self):
-        return self.__parent
-
-    def write(self, r, c, label="", style=Style.XFStyle()):
-        self.row(r).write(c, label, style)
-
-    def merge(self, r1, r2, c1, c2, style=Style.XFStyle()):
-        self.row(r1).write_blanks(c1, c2,  style)
-        for r in range(r1+1, r2+1):
-            self.row(r).write_blanks(c1, c2,  style)
-        self.__merged_ranges.append((r1, r2, c1, c2))
-
-    def write_merge(self, r1, r2, c1, c2, label="", style=Style.XFStyle()):
-        self.merge(r1, r2, c1, c2, style)
-        self.write(r1, c1,  label, style)
-
-    def insert_bitmap(self, filename, row, col, x = 0, y = 0, scale_x = 1, scale_y = 1):
-        bmp = Bitmap.ImDataBmpRecord(filename)
-        obj = Bitmap.ObjBmpRecord(row, col, self, bmp, x, y, scale_x, scale_y)
-
-        self.__bmp_rec += obj.get() + bmp.get()
-
-    def col(self, indx):
-        if indx not in self.__cols:
-            self.__cols[indx] = self.Column(indx, self)
-        return self.__cols[indx]
-
-    def row(self, indx):
-        if indx not in self.__rows:
-            self.__rows[indx] = self.Row(indx, self)
-        return self.__rows[indx]
-
-    def row_height(self, row): # in pixels
-        if row in self.__rows:
-            return self.__rows[row].get_height_in_pixels()
-        else:
-            return 17
-
-    def col_width(self, col): # in pixels
-        #if col in self.__cols:
-        #    return self.__cols[col].width_in_pixels()
-        #else:
-            return 64
-
-    def get_labels_count(self):
-        result = 0
-        for r in self.__rows:
-            result += self.__rows[r].get_str_count()
-        return result
-
-    def set_column(self, col_range, width=None, format=Style.XFStyle()):
-        col_by_name = Utils.col_by_name
-        # width is in pixels
-        if col_range.find(':') > -1:
-            start_col, end_col = col_range.split(':')
-            scol_ind, ecol_ind = col_by_name(start_col), col_by_name(end_col)
-            col_range = range(scol_ind, ecol_ind+1)
-        else: col_range = [col_by_name(col_range)]
-        for i in col_range:
-            #~ if width: worksheet.col_default_width = width
-            if width:
-                self.col(i).width = (width*(2962/81.0))
-                #~ print 'setting col %i to width %i'%(i,width*(2962/81.0))
-            #~ if format: worksheet.col(i)._xf_index = worksheet.parent.add_style(format)
-            self.col(i).set_style(format)
-
-    def set_columns(self, col_range, width=None, format=Style.XFStyle()):
-        for r in col_range.split(','):
-            self.set_column(r, width, format)
-
-    def  write_cols(self, r, cstart, cdata, style=Style.XFStyle()):
-        for i, c in enumerate(cdata):
-            self.write(r, cstart+i, c, style)
-
-    def  print_area(self, rstart, rend, cstart, cend):
-        self.__parent.print_area(self.__name, rstart, rend, cstart, cend)
-
-    def set_link(self, x, y, url, target=None, description=None):
-        self.__links[(x,y)] = (url, target, description)
-
-    ##################################################################
-    ## BIFF records generation
-    ##################################################################
-
-    def __bof_rec(self):
-        return BIFFRecords.Biff8BOFRecord(BIFFRecords.Biff8BOFRecord.WORKSHEET).get()
-
-    def __guts_rec(self):
-        row_visible_levels = 0
-        if len(self.__rows) != 0:
-            row_visible_levels = max([self.__rows[r].level for r in self.__rows]) + 1
-
-        col_visible_levels = 0
-        if len(self.__cols) != 0:
-            col_visible_levels = max([self.__cols[c].level for c in self.__cols]) + 1
-
-        return BIFFRecords.GutsRecord(self.__row_gut_width, self.__col_gut_height, row_visible_levels, col_visible_levels).get()
-
-    def __default_row_height_rec(self):
-        options = 0x00
-        options = (0x00 & 0x01) << 0
-        options = (self.__default_row_hidden & 0x01) << 1
-        options = (self.__default_row_space_above & 0x01) << 2
-        options = (self.__default_row_space_below & 0x01) << 3
-        return BIFFRecords.DefaultRowHeight(options, self.__row_default_height).get()
-
-    def __wsbool_rec(self):
-        options = 0x00
-        options |= (self.__show_auto_page_breaks & 0x01) << 0
-        options |= (self.__dialogue_sheet & 0x01) << 4
-        options |= (self.__auto_style_outline & 0x01) << 5
-        options |= (self.__outline_below & 0x01) << 6
-        options |= (self.__outline_right & 0x01) << 7
-        options |= (self.__fit_num_pages & 0x01) << 8
-        options |= (self.__show_row_outline & 0x01) << 10
-        options |= (self.__show_col_outline & 0x01) << 11
-        options |= (self.__alt_expr_eval & 0x01) << 14
-        options |= (self.__alt_formula_entries & 0x01) << 15
-
-        return BIFFRecords.WSBoolRecord(options).get()
-
-    def __eof_rec(self):
-        return BIFFRecords.EOFRecord().get()
-
-    def __colinfo_rec(self):
-        result = ''
-        for col in self.__cols:
-            result += self.__cols[col].get_biff_record()
-        return result
-
-    def __dimensions_rec(self):
-        first_used_row = 0
-        last_used_row = 0
-        first_used_col = 0
-        last_used_col = 0
-        if len(self.__rows) > 0:
-            first_used_row = min(self.__rows)
-            last_used_row = max(self.__rows)
-            first_used_col = 0xFFFFFFFF
-            last_used_col = 0
-            for r in self.__rows:
-                _min = self.__rows[r].get_min_col()
-                _max = self.__rows[r].get_max_col()
-                if _min < first_used_col:
-                    first_used_col = _min
-                if _max > last_used_col:
-                    last_used_col = _max
-
-        return BIFFRecords.DimensionsRecord(first_used_row, last_used_row, first_used_col, last_used_col).get()
-
-    def __window2_rec(self):
-        options = 0
-        options |= (self.__show_formulas        & 0x01) << 0
-        options |= (self.__show_grid            & 0x01) << 1
-        options |= (self.__show_headers         & 0x01) << 2
-        options |= (self.__panes_frozen         & 0x01) << 3
-        options |= (self.__show_empty_as_zero   & 0x01) << 4
-        options |= (self.__auto_colour_grid     & 0x01) << 5
-        options |= (self.__cols_right_to_left   & 0x01) << 6
-        options |= (self.__show_outline         & 0x01) << 7
-        options |= (self.__remove_splits        & 0x01) << 8
-        options |= (self.__selected             & 0x01) << 9
-        options |= (self.__hidden               & 0x01) << 10
-        options |= (self.__page_preview         & 0x01) << 11
-
-        return BIFFRecords.Window2Record(options, self.__first_visible_row, self.__first_visible_col,
-                                        self.__grid_colour,
-                                        self.__preview_magn, self.__normal_magn).get()
-
-    def __panes_rec(self):
-        if self.__vert_split_pos is None and self.__horz_split_pos is None:
-            return ""
-
-        if self.__vert_split_pos is None:
-            self.__vert_split_pos = 0
-        if self.__horz_split_pos is None:
-            self.__horz_split_pos = 0
-
-        if self.__panes_frozen:
-            if self.__vert_split_first_visible is None:
-                self.__vert_split_first_visible = self.__vert_split_pos
-            if self.__horz_split_first_visible is None:
-                self.__horz_split_first_visible = self.__horz_split_pos
-        else:
-            if self.__vert_split_first_visible is None:
-                self.__vert_split_first_visible = 0
-            if self.__horz_split_first_visible is None:
-                self.__horz_split_first_visible = 0
-            # inspired by pyXLWriter
-            self.__horz_split_pos = 20*self.__horz_split_pos + 255
-            self.__vert_split_pos = 113.879*self.__vert_split_pos + 390
-
-        if self.__vert_split_pos > 0 and self.__horz_split_pos > 0:
-            self.__split_active_pane = 0
-        elif self.__vert_split_pos > 0 and self.__horz_split_pos == 0:
-            self.__split_active_pane = 1
-        elif self.__vert_split_pos == 0 and self.__horz_split_pos > 0:
-            self.__split_active_pane = 2
-        else:
-            self.__split_active_pane = 3
-
-        result = BIFFRecords.PanesRecord(self.__vert_split_pos,
-                                         self.__horz_split_pos,
-                                         self.__horz_split_first_visible,
-                                         self.__vert_split_first_visible,
-                                         self.__split_active_pane).get()
-        return result
-
-    def __row_blocks_rec(self):
-        # this function takes almost 99% of overall execution time 
-        # when file is saved
-        # return '' 
-        result = []
-        i = 0
-        used_rows = self.__rows.keys()
-        while i < len(used_rows):
-            j = 0
-            while i < len(used_rows) and (j < 32):
-                result.append(self.__rows[used_rows[i]].get_row_biff_data())
-                result.append(self.__rows[used_rows[i]].get_cells_biff_data())
-                j += 1
-                i += 1
-
-        return ''.join(result)
-
-    def __merged_rec(self):
-        return BIFFRecords.MergedCellsRecord(self.__merged_ranges).get()
-
-    def __bitmaps_rec(self):
-        return self.__bmp_rec
-
-    def __calc_settings_rec(self):
-        result = ''
-        result += BIFFRecords.CalcCountRecord(self.__calc_count & 0xFFFF).get()
-        result += BIFFRecords.CalcModeRecord(self.__calc_mode).get()
-        result += BIFFRecords.RefModeRecord(self.__RC_ref_mode & 0x01).get()
-        result += BIFFRecords.IterationRecord(self.__iterations_on & 0x01).get()
-        result += BIFFRecords.DeltaRecord(self.__delta).get()
-        result += BIFFRecords.SaveRecalcRecord(self.__save_recalc & 0x01).get()
-        return result
-
-    def __print_settings_rec(self):
-        result = ''
-        result += BIFFRecords.PrintHeadersRecord(self.__print_headers).get()
-        result += BIFFRecords.PrintGridLinesRecord(self.__print_grid).get()
-        result += BIFFRecords.GridSetRecord(self.__grid_set).get()
-        result += BIFFRecords.HorizontalPageBreaksRecord([type(b) == int and (b, 0, -1) or b for b in self.__horz_page_breaks]).get()
-        result += BIFFRecords.VerticalPageBreaksRecord([type(b) == int and (b, 0, -1) or b for b in self.__vert_page_breaks]).get()
-        result += BIFFRecords.HeaderRecord(self.__header_str).get()
-        result += BIFFRecords.FooterRecord(self.__footer_str).get()
-        result += BIFFRecords.HCenterRecord(self.__print_centered_horz).get()
-        result += BIFFRecords.VCenterRecord(self.__print_centered_vert).get()
-        result += BIFFRecords.LeftMarginRecord(self.__left_margin).get()
-        result += BIFFRecords.RightMarginRecord(self.__right_margin).get()
-        result += BIFFRecords.TopMarginRecord(self.__top_margin).get()
-        result += BIFFRecords.BottomMarginRecord(self.__bottom_margin).get()
-
-        setup_page_options =  (self.__print_in_rows & 0x01) << 0
-        setup_page_options |=  (self.__portrait & 0x01) << 1
-        setup_page_options |=  (0x00 & 0x01) << 2
-        setup_page_options |=  (self.__print_not_colour & 0x01) << 3
-        setup_page_options |=  (self.__print_draft & 0x01) << 4
-        setup_page_options |=  (self.__print_notes & 0x01) << 5
-        setup_page_options |=  (0x00 & 0x01) << 6
-        setup_page_options |=  (0x01 & 0x01) << 7
-        setup_page_options |=  (self.__print_notes_at_end & 0x01) << 9
-        setup_page_options |=  (self.__print_omit_errors & 0x03) << 10
-
-        result += BIFFRecords.SetupPageRecord(self.__paper_size_code,
-                                self.__print_scaling,
-                                self.__start_page_number,
-                                self.__fit_width_to_pages,
-                                self.__fit_height_to_pages,
-                                setup_page_options,
-                                self.__print_hres,
-                                self.__print_vres,
-                                self.__header_margin,
-                                self.__footer_margin,
-                                self.__copies_num).get()
-        return result
-
-    def __protection_rec(self):
-        result = ''
-        result += BIFFRecords.ProtectRecord(self.__protect).get()
-        result += BIFFRecords.ScenProtectRecord(self.__scen_protect).get()
-        result += BIFFRecords.WindowProtectRecord(self.__wnd_protect).get()
-        result += BIFFRecords.ObjectProtectRecord(self.__obj_protect).get()
-        result += BIFFRecords.PasswordRecord(self.__password).get()
-        return result
-
-    def __hyperlink_table_rec(self):
-        result = ''
-        for (x, y), (url, target, description) in self.__links.items():
-            result += BIFFRecords.HyperlinkRecord(x, x, y, y, url, target=target, description=description).get()
-            if description is not None:
-                result += BIFFRecords.QuicktipRecord(x, x, y, y, description).get()
-        return result
-
-    def get_biff_data(self):
-        result = ''
-        result += self.__bof_rec()
-        result += self.__calc_settings_rec()
-        result += self.__guts_rec()
-        result += self.__default_row_height_rec()
-        result += self.__wsbool_rec()
-        result += self.__colinfo_rec()
-        result += self.__dimensions_rec()
-        result += self.__print_settings_rec()
-        result += self.__protection_rec()
-        result += self.__row_blocks_rec()
-        result += self.__merged_rec()
-        result += self.__bitmaps_rec()
-        result += self.__window2_rec()
-        result += self.__panes_rec()
-        result += self.__hyperlink_table_rec()
-        result += self.__eof_rec()
-
-        return result
-
-
-

+ 0 - 20
desktop/core/ext-py/pyexcelerator/pyExcelerator/__init__.py

@@ -1,20 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-__rev_id__ = """$Id: __init__.py,v 1.6 2005/08/11 08:53:48 rvk Exp $"""
-
-import sys
-if sys.version_info[:2] < (2, 4):
-    print >>sys.stderr, "Sorry, pyExcelerator requires Python 2.4 or later"
-    sys.exit(1)
-
-
-from Workbook import Workbook
-from Worksheet import Worksheet
-from Row import Row
-from Column import Column 
-from Formatting import Font, Alignment, Borders, Pattern, Protection
-from Style import XFStyle 
-from ImportXLS import * 
-
-from ExcelFormula import *

+ 0 - 2800
desktop/core/ext-py/pyexcelerator/pyExcelerator/antlr.py

@@ -1,2800 +0,0 @@
-## This file is part of PyANTLR. See LICENSE.txt for license
-## details..........Copyright (C) Wolfgang Haefelinger, 2004.
-
-## get sys module
-import sys
-
-version = sys.version.split()[0]
-if version < '2.2.1':
-    False = 0
-if version < '2.3':
-    True = not False
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                     global symbols                             ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-### ANTLR Standard Tokens
-SKIP                = -1
-INVALID_TYPE        = 0
-EOF_TYPE            = 1
-EOF                 = 1
-NULL_TREE_LOOKAHEAD = 3
-MIN_USER_TYPE       = 4
-
-### ANTLR's EOF Symbol
-EOF_CHAR            = ''
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                    general functions                           ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-def error(fmt,*args):
-    if fmt:
-        print "error: ", fmt % tuple(args)
-
-def ifelse(cond,_then,_else):
-    if cond :
-        r = _then
-    else:
-        r = _else
-    return r
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                     ANTLR Exceptions                           ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class ANTLRException(Exception):
-
-    def __init__(self, *args):
-        Exception.__init__(self, *args)
-
-
-class RecognitionException(ANTLRException):
-
-    def __init__(self, *args):
-        ANTLRException.__init__(self, *args)
-        self.fileName = None
-        self.line = -1
-        self.column = -1
-        if len(args) >= 2:
-            self.fileName = args[1]
-        if len(args) >= 3:
-            self.line = args[2]
-        if len(args) >= 4:
-            self.column = args[3]
-
-    def __str__(self):
-        buf = ['']
-        if self.fileName:
-            buf.append(self.fileName + ":")
-        if self.line != -1:
-            if not self.fileName:
-                buf.append("line ")
-            buf.append(str(self.line))
-            if self.column != -1:
-                buf.append(":" + str(self.column))
-            buf.append(":")
-        buf.append(" ")
-        return str('').join(buf)
-
-    __repr__ = __str__
-
-
-class NoViableAltException(RecognitionException):
-
-    def __init__(self, *args):
-        RecognitionException.__init__(self, *args)
-        self.token = None
-        self.node  = None
-        if isinstance(args[0],AST):
-            self.node = args[0]
-        elif isinstance(args[0],Token):
-            self.token = args[0]
-        else:
-            raise TypeError("NoViableAltException requires Token or AST argument")
-
-    def __str__(self):
-        if self.token:
-            line = self.token.getLine()
-            col  = self.token.getColumn()
-            text = self.token.getText()
-            return "unexpected symbol at line %s (column %s): \"%s\"" % (line,col,text)
-        if self.node == ASTNULL:
-            return "unexpected end of subtree"
-        assert self.node
-        ### hackish, we assume that an AST contains method getText
-        return "unexpected node: %s" % (self.node.getText())
-
-    __repr__ = __str__
-
-
-class NoViableAltForCharException(RecognitionException):
-
-    def __init__(self, *args):
-        self.foundChar = None
-        if len(args) == 2:
-            self.foundChar = args[0]
-            scanner = args[1]
-            RecognitionException.__init__(self, "NoViableAlt",
-                                          scanner.getFilename(),
-                                          scanner.getLine(),
-                                          scanner.getColumn())
-        elif len(args) == 4:
-            self.foundChar = args[0]
-            fileName = args[1]
-            line = args[2]
-            column = args[3]
-            RecognitionException.__init__(self, "NoViableAlt",
-                                          fileName, line, column)
-        else:
-            RecognitionException.__init__(self, "NoViableAlt",
-                                          '', -1, -1)
-
-    def __str__(self):
-        mesg = "unexpected char: "
-        if self.foundChar >= ' ' and self.foundChar <= '~':
-            mesg += "'" + self.foundChar + "'"
-        elif self.foundChar:
-            mesg += "0x" + hex(ord(self.foundChar)).upper()[2:]
-        else:
-            mesg += "<None>"
-        return mesg
-
-    __repr__ = __str__
-
-
-class SemanticException(RecognitionException):
-
-    def __init__(self, *args):
-        RecognitionException.__init__(self, *args)
-
-
-class MismatchedCharException(RecognitionException):
-
-    NONE = 0
-    CHAR = 1
-    NOT_CHAR = 2
-    RANGE = 3
-    NOT_RANGE = 4
-    SET = 5
-    NOT_SET = 6
-
-    def __init__(self, *args):
-        self.args = args
-        if len(args) == 5:
-            # Expected range / not range
-            if args[3]:
-                self.mismatchType = MismatchedCharException.NOT_RANGE
-            else:
-                self.mismatchType = MismatchedCharException.RANGE
-            self.foundChar = args[0]
-            self.expecting = args[1]
-            self.upper = args[2]
-            self.scanner = args[4]
-            RecognitionException.__init__(self, "Mismatched char range",
-                                          self.scanner.getFilename(),
-                                          self.scanner.getLine(),
-                                          self.scanner.getColumn())
-        elif len(args) == 4 and isinstance(args[1], str):
-            # Expected char / not char
-            if args[2]:
-                self.mismatchType = MismatchedCharException.NOT_CHAR
-            else:
-                self.mismatchType = MismatchedCharException.CHAR
-            self.foundChar = args[0]
-            self.expecting = args[1]
-            self.scanner = args[3]
-            RecognitionException.__init__(self, "Mismatched char",
-                                          self.scanner.getFilename(),
-                                          self.scanner.getLine(),
-                                          self.scanner.getColumn())
-        elif len(args) == 4 and isinstance(args[1], BitSet):
-            # Expected BitSet / not BitSet
-            if args[2]:
-                self.mismatchType = MismatchedCharException.NOT_SET
-            else:
-                self.mismatchType = MismatchedCharException.SET
-            self.foundChar = args[0]
-            self.set = args[1]
-            self.scanner = args[3]
-            RecognitionException.__init__(self, "Mismatched char set",
-                                          self.scanner.getFilename(),
-                                          self.scanner.getLine(),
-                                          self.scanner.getColumn())
-        else:
-            self.mismatchType = MismatchedCharException.NONE
-            RecognitionException.__init__(self, "Mismatched char")
-
-    ## Append a char to the msg buffer.  If special,
-    #  then show escaped version
-    #
-    def appendCharName(self, sb, c):
-        if not c or c == 65535:
-            # 65535 = (char) -1 = EOF
-            sb.append("'<EOF>'")
-        elif c == '\n':
-            sb.append("'\\n'")
-        elif c == '\r':
-            sb.append("'\\r'");
-        elif c == '\t':
-            sb.append("'\\t'")
-        else:
-            sb.append('\'' + c + '\'')
-
-    ##
-    # Returns an error message with line number/column information
-    #
-    def __str__(self):
-        sb = ['']
-        sb.append(RecognitionException.__str__(self))
-
-        if self.mismatchType == MismatchedCharException.CHAR:
-            sb.append("expecting ")
-            self.appendCharName(sb, self.expecting)
-            sb.append(", found ")
-            self.appendCharName(sb, self.foundChar)
-        elif self.mismatchType == MismatchedCharException.NOT_CHAR:
-            sb.append("expecting anything but '")
-            self.appendCharName(sb, self.expecting)
-            sb.append("'; got it anyway")
-        elif self.mismatchType in [MismatchedCharException.RANGE, MismatchedCharException.NOT_RANGE]:
-            sb.append("expecting char ")
-            if self.mismatchType == MismatchedCharException.NOT_RANGE:
-                sb.append("NOT ")
-            sb.append("in range: ")
-            appendCharName(sb, self.expecting)
-            sb.append("..")
-            appendCharName(sb, self.upper)
-            sb.append(", found ")
-            appendCharName(sb, self.foundChar)
-        elif self.mismatchType in [MismatchedCharException.SET, MismatchedCharException.NOT_SET]:
-            sb.append("expecting ")
-            if self.mismatchType == MismatchedCharException.NOT_SET:
-                sb.append("NOT ")
-            sb.append("one of (")
-            for i in range(len(self.set)):
-                self.appendCharName(sb, self.set[i])
-            sb.append("), found ")
-            self.appendCharName(sb, self.foundChar)
-
-        return str().join(sb).strip()
-
-    __repr__ = __str__
-
-
-class MismatchedTokenException(RecognitionException):
-
-    NONE = 0
-    TOKEN = 1
-    NOT_TOKEN = 2
-    RANGE = 3
-    NOT_RANGE = 4
-    SET = 5
-    NOT_SET = 6
-
-    def __init__(self, *args):
-        self.args =  args
-        self.tokenNames = []
-        self.token = None
-        self.tokenText = ''
-        self.node =  None
-        if len(args) == 6:
-            # Expected range / not range
-            if args[3]:
-                self.mismatchType = MismatchedTokenException.NOT_RANGE
-            else:
-                self.mismatchType = MismatchedTokenException.RANGE
-            self.tokenNames = args[0]
-            self.expecting = args[2]
-            self.upper = args[3]
-            self.fileName = args[5]
-
-        elif len(args) == 4 and isinstance(args[2], int):
-            # Expected token / not token
-            if args[3]:
-                self.mismatchType = MismatchedTokenException.NOT_TOKEN
-            else:
-                self.mismatchType = MismatchedTokenException.TOKEN
-            self.tokenNames = args[0]
-            self.expecting = args[2]
-
-        elif len(args) == 4 and isinstance(args[2], BitSet):
-            # Expected BitSet / not BitSet
-            if args[3]:
-                self.mismatchType = MismatchedTokenException.NOT_SET
-            else:
-                self.mismatchType = MismatchedTokenException.SET
-            self.tokenNames = args[0]
-            self.set = args[2]
-
-        else:
-            self.mismatchType = MismatchedTokenException.NONE
-            RecognitionException.__init__(self, "Mismatched Token: expecting any AST node", "<AST>", -1, -1)
-
-        if len(args) >= 2:
-            if isinstance(args[1],Token):
-                self.token = args[1]
-                self.tokenText = self.token.getText()
-                RecognitionException.__init__(self, "Mismatched Token",
-                                              self.fileName,
-                                              self.token.getLine(),
-                                              self.token.getColumn())
-            elif isinstance(args[1],AST):
-                self.node = args[1]
-                self.tokenText = str(self.node)
-                RecognitionException.__init__(self, "Mismatched Token",
-                                              "<AST>",
-                                              self.node.getLine(),
-                                              self.node.getColumn())
-            else:
-                self.tokenText = "<empty tree>"
-                RecognitionException.__init__(self, "Mismatched Token",
-                                              "<AST>", -1, -1)
-
-    def appendTokenName(self, sb, tokenType):
-        if tokenType == INVALID_TYPE:
-            sb.append("<Set of tokens>")
-        elif tokenType < 0 or tokenType >= len(self.tokenNames):
-            sb.append("<" + str(tokenType) + ">")
-        else:
-            sb.append(self.tokenNames[tokenType])
-
-    ##
-    # Returns an error message with line number/column information
-    #
-    def __str__(self):
-        sb = ['']
-        sb.append(RecognitionException.__str__(self))
-
-        if self.mismatchType == MismatchedTokenException.TOKEN:
-            sb.append("expecting ")
-            self.appendTokenName(sb, self.expecting)
-            sb.append(", found " + self.tokenText)
-        elif self.mismatchType == MismatchedTokenException.NOT_TOKEN:
-            sb.append("expecting anything but '")
-            self.appendTokenName(sb, self.expecting)
-            sb.append("'; got it anyway")
-        elif self.mismatchType in [MismatchedTokenException.RANGE, MismatchedTokenException.NOT_RANGE]:
-            sb.append("expecting token ")
-            if self.mismatchType == MismatchedTokenException.NOT_RANGE:
-                sb.append("NOT ")
-            sb.append("in range: ")
-            appendTokenName(sb, self.expecting)
-            sb.append("..")
-            appendTokenName(sb, self.upper)
-            sb.append(", found " + self.tokenText)
-        elif self.mismatchType in [MismatchedTokenException.SET, MismatchedTokenException.NOT_SET]:
-            sb.append("expecting ")
-            if self.mismatchType == MismatchedTokenException.NOT_SET:
-                sb.append("NOT ")
-            sb.append("one of (")
-            for i in range(len(self.set)):
-                self.appendTokenName(sb, self.set[i])
-            sb.append("), found " + self.tokenText)
-
-        return str().join(sb).strip()
-
-    __repr__ = __str__
-
-
-class TokenStreamException(ANTLRException):
-
-    def __init__(self, *args):
-        ANTLRException.__init__(self, *args)
-
-
-# Wraps an Exception in a TokenStreamException
-class TokenStreamIOException(TokenStreamException):
-
-    def __init__(self, *args):
-        if args and isinstance(args[0], Exception):
-            io = args[0]
-            TokenStreamException.__init__(self, str(io))
-            self.io = io
-        else:
-            TokenStreamException.__init__(self, *args)
-            self.io = self
-
-
-# Wraps a RecognitionException in a TokenStreamException
-class TokenStreamRecognitionException(TokenStreamException):
-
-    def __init__(self, *args):
-        if args and isinstance(args[0], RecognitionException):
-            recog = args[0]
-            TokenStreamException.__init__(self, str(recog))
-            self.recog = recog
-        else:
-            raise TypeError("TokenStreamRecognitionException requires RecognitionException argument")
-
-    def __str__(self):
-        return str(self.recog)
-
-    __repr__ = __str__
-
-
-class TokenStreamRetryException(TokenStreamException):
-
-    def __init__(self, *args):
-        TokenStreamException.__init__(self, *args)
-
-
-class CharStreamException(ANTLRException):
-
-    def __init__(self, *args):
-        ANTLRException.__init__(self, *args)
-
-
-# Wraps an Exception in a CharStreamException
-class CharStreamIOException(CharStreamException):
-
-    def __init__(self, *args):
-        if args and isinstance(args[0], Exception):
-            io = args[0]
-            CharStreamException.__init__(self, str(io))
-            self.io = io
-        else:
-            CharStreamException.__init__(self, *args)
-            self.io = self
-
-
-class TryAgain(Exception):
-    pass
-
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       Token                                    ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class Token(object):
-    SKIP                = -1
-    INVALID_TYPE        = 0
-    EOF_TYPE            = 1
-    EOF                 = 1
-    NULL_TREE_LOOKAHEAD = 3
-    MIN_USER_TYPE       = 4
-
-    def __init__(self,**argv):
-        try:
-            self.type = argv['type']
-        except:
-            self.type = INVALID_TYPE
-        try:
-            self.text = argv['text']
-        except:
-            self.text = "<no text>"
-
-    def isEOF(self):
-        return (self.type == EOF_TYPE)
-
-    def getColumn(self):
-        return 0
-
-    def getLine(self):
-        return 0
-
-    def getFilename(self):
-        return None
-
-    def setFilename(self,name):
-        return self
-
-    def getText(self):
-        return "<no text>"
-
-    def setText(self,text):
-        if isinstance(text,str):
-            pass
-        else:
-            raise TypeError("Token.setText requires string argument")
-        return self
-
-    def setColumn(self,column):
-        return self
-
-    def setLine(self,line):
-        return self
-
-    def getType(self):
-        return self.type
-
-    def setType(self,type):
-        if isinstance(type,int):
-            self.type = type
-        else:
-            raise TypeError("Token.setType requires integer argument")
-        return self
-
-    def toString(self):
-        ## not optimal
-        type_ = self.type
-        if type_ == 3:
-            tval = 'NULL_TREE_LOOKAHEAD'
-        elif type_ == 1:
-            tval = 'EOF_TYPE'
-        elif type_ == 0:
-            tval = 'INVALID_TYPE'
-        elif type_ == -1:
-            tval = 'SKIP'
-        else:
-            tval = type_
-        return '["%s",<%s>]' % (self.getText(),tval)
-
-    __str__ = toString
-    __repr__ = toString
-
-### static attribute ..
-Token.badToken = Token( type=INVALID_TYPE, text="<no text>")
-
-if __name__ == "__main__":
-    print "testing .."
-    T = Token.badToken
-    print T
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       CommonToken                              ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class CommonToken(Token):
-
-    def __init__(self,**argv):
-        Token.__init__(self,**argv)
-        self.line = 0
-        self.col  = 0
-        try:
-            self.line = argv['line']
-        except:
-            pass
-        try:
-            self.col = argv['col']
-        except:
-            pass
-
-    def getLine(self):
-        return self.line
-
-    def getText(self):
-        return self.text
-
-    def getColumn(self):
-        return self.col
-
-    def setLine(self,line):
-        self.line = line
-        return self
-
-    def setText(self,text):
-        self.text = text
-        return self
-
-    def setColumn(self,col):
-        self.col = col
-        return self
-
-    def toString(self):
-        ## not optimal
-        type_ = self.type
-        if type_ == 3:
-            tval = 'NULL_TREE_LOOKAHEAD'
-        elif type_ == 1:
-            tval = 'EOF_TYPE'
-        elif type_ == 0:
-            tval = 'INVALID_TYPE'
-        elif type_ == -1:
-            tval = 'SKIP'
-        else:
-            tval = type_
-        d = {
-           'text' : self.text,
-           'type' : tval,
-           'line' : self.line,
-           'colm' : self.col
-           }
-
-        fmt = '["%(text)s",<%(type)s>,line=%(line)s,col=%(colm)s]'
-        return fmt % d
-
-    __str__ = toString
-    __repr__ = toString
-
-
-if __name__ == '__main__' :
-    T = CommonToken()
-    print T
-    T = CommonToken(col=15,line=1,text="some text", type=5)
-    print T
-    T = CommonToken()
-    T.setLine(1).setColumn(15).setText("some text").setType(5)
-    print T
-    print T.getLine()
-    print T.getColumn()
-    print T.getText()
-    print T.getType()
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                    CommonHiddenStreamToken                     ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class CommonHiddenStreamToken(CommonToken):
-    def __init__(self,*args):
-        CommonToken.__init__(self,*args)
-        self.hiddenBefore = None
-        self.hiddenAfter  = None
-
-    def getHiddenAfter(self):
-        return self.hiddenAfter
-
-    def getHiddenBefore(self):
-        return self.hiddenBefore
-
-    def setHiddenAfter(self,t):
-        self.hiddenAfter = t
-
-    def setHiddenBefore(self, t):
-        self.hiddenBefore = t
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       Queue                                    ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-## Shall be a circular buffer on tokens ..
-class Queue(object):
-
-    def __init__(self):
-        self.buffer = [] # empty list
-
-    def append(self,item):
-        self.buffer.append(item)
-
-    def elementAt(self,index):
-        return self.buffer[index]
-
-    def reset(self):
-        self.buffer = []
-
-    def removeFirst(self):
-        self.buffer.pop(0)
-
-    def length(self):
-        return len(self.buffer)
-
-    def __str__(self):
-        return str(self.buffer)
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       InputBuffer                              ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class InputBuffer(object):
-    def __init__(self):
-        self.nMarkers = 0
-        self.markerOffset = 0
-        self.numToConsume = 0
-        self.queue = Queue()
-
-    def __str__(self):
-        return "(%s,%s,%s,%s)" % (
-           self.nMarkers,
-           self.markerOffset,
-           self.numToConsume,
-           self.queue)
-
-    def __repr__(self):
-        return str(self)
-
-    def commit(self):
-        self.nMarkers -= 1
-
-    def consume(self) :
-        self.numToConsume += 1
-
-    ## probably better to return a list of items
-    ## because of unicode. Or return a unicode
-    ## string ..
-    def getLAChars(self) :
-        i = self.markerOffset
-        n = self.queue.length()
-        s = ''
-        while i<n:
-            s += self.queue.elementAt(i)
-        return s
-
-    ## probably better to return a list of items
-    ## because of unicode chars
-    def getMarkedChars(self) :
-        s = ''
-        i = 0
-        n = self.markerOffset
-        while i<n:
-            s += self.queue.elementAt(i)
-        return s
-
-    def isMarked(self) :
-        return self.nMarkers != 0
-
-    def fill(self,k):
-        ### abstract method
-        raise NotImplementedError()
-
-    def LA(self,k) :
-        self.fill(k)
-        return self.queue.elementAt(self.markerOffset + k - 1)
-
-    def mark(self) :
-        self.syncConsume()
-        self.nMarkers += 1
-        return self.markerOffset
-
-    def rewind(self,mark) :
-        self.syncConsume()
-        self.markerOffset = mark
-        self.nMarkers -= 1
-
-    def reset(self) :
-        self.nMarkers = 0
-        self.markerOffset = 0
-        self.numToConsume = 0
-        self.queue.reset()
-
-    def syncConsume(self) :
-        while self.numToConsume > 0:
-            if self.nMarkers > 0:
-                # guess mode -- leave leading characters and bump offset.
-                self.markerOffset += 1
-            else:
-                # normal mode -- remove first character
-                self.queue.removeFirst()
-            self.numToConsume -= 1
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       CharBuffer                               ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class CharBuffer(InputBuffer):
-    def __init__(self,reader):
-        ##assert isinstance(reader,file)
-        super(CharBuffer,self).__init__()
-        ## a reader is supposed to be anything that has
-        ## a method 'read(int)'.
-        self.input = reader
-
-    def __str__(self):
-        base = super(CharBuffer,self).__str__()
-        return "CharBuffer{%s,%s" % (base,str(input))
-
-    def fill(self,amount):
-        try:
-            self.syncConsume()
-            while self.queue.length() < (amount + self.markerOffset) :
-                ## retrieve just one char - what happend at end
-                ## of input?
-                c = self.input.read(1)
-                ### python's behaviour is to return the empty string  on
-                ### EOF, ie. no exception whatsoever is thrown. An empty
-                ### python  string  has  the  nice feature that it is of
-                ### type 'str' and  "not ''" would return true. Contrary,
-                ### one can't  do  this: '' in 'abc'. This should return
-                ### false,  but all we  get  is  then  a TypeError as an
-                ### empty string is not a character.
-
-                ### Let's assure then that we have either seen a
-                ### character or an empty string (EOF).
-                assert len(c) == 0 or len(c) == 1
-
-                ### And it shall be of type string (ASCII or UNICODE).
-                assert isinstance(c,str) or isinstance(c,unicode)
-
-                ### Just append EOF char to buffer. Note that buffer may
-                ### contain then just more than one EOF char ..
-
-                ### use unicode chars instead of ASCII ..
-                self.queue.append(c)
-        except Exception,e:
-            raise CharStreamIOException(e)
-        ##except: # (mk) Cannot happen ...
-            ##error ("unexpected exception caught ..")
-            ##assert 0
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       LexerSharedInputState                    ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class LexerSharedInputState(object):
-    def __init__(self,ibuf):
-        assert isinstance(ibuf,InputBuffer)
-        self.input = ibuf
-        self.column = 1
-        self.line = 1
-        self.tokenStartColumn = 1
-        self.tokenStartLine = 1
-        self.guessing = 0
-        self.filename = None
-
-    def reset(self):
-        self.column = 1
-        self.line = 1
-        self.tokenStartColumn = 1
-        self.tokenStartLine = 1
-        self.guessing = 0
-        self.filename = None
-        self.input.reset()
-
-    def LA(self,k):
-        return self.input.LA(k)
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                    TokenStream                                 ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class TokenStream(object):
-    def nextToken(self):
-        pass
-
-    def __iter__(self):
-        return TokenStreamIterator(self)
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                    TokenStreamIterator                                 ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class TokenStreamIterator(object):
-    def __init__(self,inst):
-        if isinstance(inst,TokenStream):
-            self.inst = inst
-            return
-        raise TypeError("TokenStreamIterator requires TokenStream object")
-
-    def next(self):
-        assert self.inst
-        item = self.inst.nextToken()
-        if not item or item.isEOF():
-            raise StopIteration()
-        return item
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                    TokenStreamSelector                        ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class TokenStreamSelector(TokenStream):
-
-    def __init__(self):
-        self._input = None
-        self._stmap = {}
-        self._stack = []
-
-    def addInputStream(self,stream,key):
-        self._stmap[key] = stream
-
-    def getCurrentStream(self):
-        return self._input
-
-    def getStream(self,sname):
-        try:
-            stream = self._stmap[sname]
-        except:
-            raise ValueError("TokenStream " + sname + " not found");
-        return stream;
-
-    def nextToken(self):
-        while 1:
-            try:
-                return self._input.nextToken()
-            except TokenStreamRetryException,r:
-                ### just retry "forever"
-                pass
-
-    def pop(self):
-        stream = self._stack.pop();
-        self.select(stream);
-        return stream;
-
-    def push(self,arg):
-        self._stack.append(self._input);
-        self.select(arg)
-
-    def retry(self):
-        raise TokenStreamRetryException()
-
-    def select(self,arg):
-        if isinstance(arg,TokenStream):
-            self._input = arg
-            return
-        if isinstance(arg,str):
-            self._input = self.getStream(arg)
-            return
-        raise TypeError("TokenStreamSelector.select requires " +
-                        "TokenStream or string argument")
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                      TokenStreamBasicFilter                    ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class TokenStreamBasicFilter(TokenStream):
-
-    def __init__(self,input):
-
-        self.input = input;
-        self.discardMask = BitSet()
-
-    def discard(self,arg):
-        if isinstance(arg,int):
-            self.discardMask.add(arg)
-            return
-        if isinstance(arg,BitSet):
-            self.discardMark = arg
-            return
-        raise TypeError("TokenStreamBasicFilter.discard requires" +
-                        "integer or BitSet argument")
-
-    def nextToken(self):
-        tok = self.input.nextToken()
-        while tok and self.discardMask.member(tok.getType()):
-            tok = self.input.nextToken()
-        return tok
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                      TokenStreamHiddenTokenFilter              ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class TokenStreamHiddenTokenFilter(TokenStreamBasicFilter):
-
-    def __init__(self,input):
-        TokenStreamBasicFilter.__init__(self,input)
-        self.hideMask = BitSet()
-        self.nextMonitoredToken = None
-        self.lastHiddenToken = None
-        self.firstHidden = None
-
-    def consume(self):
-        self.nextMonitoredToken = self.input.nextToken()
-
-    def consumeFirst(self):
-        self.consume()
-
-        p = None;
-        while self.hideMask.member(self.LA(1).getType()) or \
-              self.discardMask.member(self.LA(1).getType()):
-            if self.hideMask.member(self.LA(1).getType()):
-                if not p:
-                    p = self.LA(1)
-                else:
-                    p.setHiddenAfter(self.LA(1))
-                    self.LA(1).setHiddenBefore(p)
-                    p = self.LA(1)
-                self.lastHiddenToken = p
-                if not self.firstHidden:
-                    self.firstHidden = p
-            self.consume()
-
-    def getDiscardMask(self):
-        return self.discardMask
-
-    def getHiddenAfter(self,t):
-        return t.getHiddenAfter()
-
-    def getHiddenBefore(self,t):
-        return t.getHiddenBefore()
-
-    def getHideMask(self):
-        return self.hideMask
-
-    def getInitialHiddenToken(self):
-        return self.firstHidden
-
-    def hide(self,m):
-        if isinstance(m,int):
-            self.hideMask.add(m)
-            return
-        if isinstance(m.BitMask):
-            self.hideMask = m
-            return
-
-    def LA(self,i):
-        return self.nextMonitoredToken
-
-    def nextToken(self):
-        if not self.LA(1):
-            self.consumeFirst()
-
-        monitored = self.LA(1)
-
-        monitored.setHiddenBefore(self.lastHiddenToken)
-        self.lastHiddenToken = None
-
-        self.consume()
-        p = monitored
-
-        while self.hideMask.member(self.LA(1).getType()) or \
-              self.discardMask.member(self.LA(1).getType()):
-            if self.hideMask.member(self.LA(1).getType()):
-                p.setHiddenAfter(self.LA(1))
-                if p != monitored:
-                    self.LA(1).setHiddenBefore(p)
-                p = self.lastHiddenToken = self.LA(1)
-            self.consume()
-        return monitored
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       StringBuffer                             ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class StringBuffer:
-    def __init__(self,string=None):
-        if string:
-            self.text = list(string)
-        else:
-            self.text = []
-
-    def setLength(self,sz):
-        if not sz :
-            self.text = []
-            return
-        assert sz>0
-        if sz >= self.length():
-            return
-        ### just reset to empty buffer
-        self.text = self.text[0:sz]
-
-    def length(self):
-        return len(self.text)
-
-    def append(self,c):
-        self.text.append(c)
-
-    ### return buffer as string. Arg 'a' is  used  as index
-    ## into the buffer and 2nd argument shall be the length.
-    ## If 2nd args is absent, we return chars till end of
-    ## buffer starting with 'a'.
-    def getString(self,a=None,length=None):
-        if not a :
-            a = 0
-        assert a>=0
-        if a>= len(self.text) :
-            return ""
-
-        if not length:
-            ## no second argument
-            L = self.text[a:]
-        else:
-            assert (a+length) <= len(self.text)
-            b = a + length
-            L = self.text[a:b]
-        s = ""
-        for x in L : s += x
-        return s
-
-    toString = getString ## alias
-
-    def __str__(self):
-        return str(self.text)
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       Reader                                   ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-## When reading Japanese chars, it happens that a stream returns a
-## 'char' of length 2. This looks like  a  bug  in the appropriate
-## codecs - but I'm  rather  unsure about this. Anyway, if this is
-## the case, I'm going to  split  this string into a list of chars
-## and put them  on  hold, ie. on a  buffer. Next time when called
-## we read from buffer until buffer is empty.
-## wh: nov, 25th -> problem does not appear in Python 2.4.0.c1.
-
-class Reader(object):
-    def __init__(self,stream):
-        self.cin = stream
-        self.buf = []
-
-    def read(self,num):
-        assert num==1
-
-        if len(self.buf):
-            return self.buf.pop()
-
-        ## Read a char - this may return a string.
-        ## Is this a bug in codecs/Python?
-        c = self.cin.read(1)
-
-        if not c or len(c)==1:
-            return c
-
-        L = list(c)
-        L.reverse()
-        for x in L:
-            self.buf.append(x)
-
-        ## read one char ..
-        return self.read(1)
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       CharScanner                              ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class CharScanner(TokenStream):
-    ## class members
-    NO_CHAR = 0
-    EOF_CHAR = ''  ### EOF shall be the empty string.
-
-    def __init__(self, *argv, **kwargs):
-        super(CharScanner, self).__init__()
-        self.saveConsumedInput = True
-        self.tokenClass = None
-        self.caseSensitive = True
-        self.caseSensitiveLiterals = True
-        self.literals = None
-        self.tabsize = 8
-        self._returnToken = None
-        self.commitToPath = False
-        self.traceDepth = 0
-        self.text = StringBuffer()
-        self.hashString = hash(self)
-        self.setTokenObjectClass(CommonToken)
-        self.setInput(*argv)
-
-    def __iter__(self):
-        return CharScannerIterator(self)
-
-    def setInput(self,*argv):
-        ## case 1:
-        ## if there's no arg we default to read from
-        ## standard input
-        if not argv:
-            import sys
-            self.setInput(sys.stdin)
-            return
-
-        ## get 1st argument
-        arg1 = argv[0]
-
-        ## case 2:
-        ## if arg1 is a string,  we assume it's a file name
-        ## and  open  a  stream  using 2nd argument as open
-        ## mode. If there's no 2nd argument we fall back to
-        ## mode '+rb'.
-        if isinstance(arg1,str):
-            f = open(arg1,"rb")
-            self.setInput(f)
-            self.setFilename(arg1)
-            return
-
-        ## case 3:
-        ## if arg1 is a file we wrap it by a char buffer (
-        ## some additional checks?? No, can't do this in
-        ## general).
-        if isinstance(arg1,file):
-            self.setInput(CharBuffer(arg1))
-            return
-
-        ## case 4:
-        ## if arg1 is of type SharedLexerInputState we use
-        ## argument as is.
-        if isinstance(arg1,LexerSharedInputState):
-            self.inputState = arg1
-            return
-
-        ## case 5:
-        ## check whether argument type is of type input
-        ## buffer. If so create a SharedLexerInputState and
-        ## go ahead.
-        if isinstance(arg1,InputBuffer):
-            self.setInput(LexerSharedInputState(arg1))
-            return
-
-        ## case 6:
-        ## check whether argument type has a method read(int)
-        ## If so create CharBuffer ...
-        try:
-            if arg1.read:
-                rd = Reader(arg1)
-                cb = CharBuffer(rd)
-                ss = LexerSharedInputState(cb)
-                self.inputState = ss
-            return
-        except:
-            pass
-
-        ## case 7:
-        ## raise wrong argument exception
-        raise TypeError(argv)
-
-    def setTabSize(self,size) :
-        self.tabsize = size
-
-    def getTabSize(self) :
-        return self.tabsize
-
-    def setCaseSensitive(self,t) :
-        self.caseSensitive = t
-
-    def setCommitToPath(self,commit) :
-        self.commitToPath = commit
-
-    def setFilename(self,f) :
-        self.inputState.filename = f
-
-    def setLine(self,line) :
-        self.inputState.line = line
-
-    def setText(self,s) :
-        self.resetText()
-        self.text.append(s)
-
-    def getCaseSensitive(self) :
-        return self.caseSensitive
-
-    def getCaseSensitiveLiterals(self) :
-        return self.caseSensitiveLiterals
-
-    def getColumn(self) :
-        return self.inputState.column
-
-    def setColumn(self,c) :
-        self.inputState.column = c
-
-    def getCommitToPath(self) :
-        return self.commitToPath
-
-    def getFilename(self) :
-        return self.inputState.filename
-
-    def getInputBuffer(self) :
-        return self.inputState.input
-
-    def getInputState(self) :
-        return self.inputState
-
-    def setInputState(self,state) :
-        assert isinstance(state,LexerSharedInputState)
-        self.inputState = state
-
-    def getLine(self) :
-        return self.inputState.line
-
-    def getText(self) :
-        return str(self.text)
-
-    def getTokenObject(self) :
-        return self._returnToken
-
-    def LA(self,i) :
-        c = self.inputState.input.LA(i)
-        if not self.caseSensitive:
-            ### E0006
-            c = c.__class__.lower(c)
-        return c
-
-    def makeToken(self,type) :
-        try:
-            ## dynamically load a class
-            assert self.tokenClass
-            tok = self.tokenClass()
-            tok.setType(type)
-            tok.setColumn(self.inputState.tokenStartColumn)
-            tok.setLine(self.inputState.tokenStartLine)
-            return tok
-        except:
-            self.panic("unable to create new token")
-        return Token.badToken
-
-    def mark(self) :
-        return self.inputState.input.mark()
-
-    def _match_bitset(self,b) :
-        if b.member(self.LA(1)):
-            self.consume()
-        else:
-            raise MismatchedCharException(self.LA(1), b, False, self)
-
-    def _match_string(self,s) :
-        for c in s:
-            if self.LA(1) == c:
-                self.consume()
-            else:
-                raise MismatchedCharException(self.LA(1), c, False, self)
-
-    def match(self,item):
-        if isinstance(item,str) or isinstance(item,unicode):
-            return self._match_string(item)
-        else:
-            return self._match_bitset(item)
-
-    def matchNot(self,c) :
-        if self.LA(1) != c:
-            self.consume()
-        else:
-            raise MismatchedCharException(self.LA(1), c, True, self)
-
-    def matchRange(self,c1,c2) :
-        if self.LA(1) < c1 or self.LA(1) > c2 :
-            raise MismatchedCharException(self.LA(1), c1, c2, False, self)
-        else:
-            self.consume()
-
-    def newline(self) :
-        self.inputState.line += 1
-        self.inputState.column = 1
-
-    def tab(self) :
-        c = self.getColumn()
-        nc = ( ((c-1)/self.tabsize) + 1) * self.tabsize + 1
-        self.setColumn(nc)
-
-    def panic(self,s='') :
-        print "CharScanner: panic: " + s
-        sys.exit(1)
-
-    def reportError(self,ex) :
-        print ex
-
-    def reportError(self,s) :
-        if not self.getFilename():
-            print "error: " + str(s)
-        else:
-            print self.getFilename() + ": error: " + str(s)
-
-    def reportWarning(self,s) :
-        if not self.getFilename():
-            print "warning: " + str(s)
-        else:
-            print self.getFilename() + ": warning: " + str(s)
-
-    def resetText(self) :
-        self.text.setLength(0)
-        self.inputState.tokenStartColumn = self.inputState.column
-        self.inputState.tokenStartLine = self.inputState.line
-
-    def rewind(self,pos) :
-        self.inputState.input.rewind(pos)
-
-    def setTokenObjectClass(self,cl):
-        self.tokenClass = cl
-
-    def testForLiteral(self,token):
-        if not token:
-            return
-        assert isinstance(token,Token)
-
-        _type = token.getType()
-
-        ## special tokens can't be literals
-        if _type in [SKIP,INVALID_TYPE,EOF_TYPE,NULL_TREE_LOOKAHEAD] :
-            return
-
-        _text = token.getText()
-        if not _text:
-            return
-
-        assert isinstance(_text,str) or isinstance(_text,unicode)
-        _type = self.testLiteralsTable(_text,_type)
-        token.setType(_type)
-        return _type
-
-    def testLiteralsTable(self,*args):
-        if isinstance(args[0],str) or isinstance(args[0],unicode):
-            s = args[0]
-            i = args[1]
-        else:
-            s = self.text.getString()
-            i = args[0]
-
-        ## check whether integer has been given
-        if not isinstance(i,int):
-            assert isinstance(i,int)
-
-        ## check whether we have a dict
-        assert isinstance(self.literals,dict)
-        try:
-            ## E0010
-            if not self.caseSensitiveLiterals:
-                s = s.__class__.lower(s)
-            i = self.literals[s]
-        except:
-            pass
-        return i
-
-    def toLower(self,c):
-        return c.__class__.lower()
-
-    def traceIndent(self):
-        print ' ' * self.traceDepth
-
-    def traceIn(self,rname):
-        self.traceDepth += 1
-        self.traceIndent()
-        print "> lexer %s c== %s" % (rname,self.LA(1))
-
-    def traceOut(self,rname):
-        self.traceIndent()
-        print "< lexer %s c== %s" % (rname,self.LA(1))
-        self.traceDepth -= 1
-
-    def uponEOF(self):
-        pass
-
-    def append(self,c):
-        if self.saveConsumedInput :
-            self.text.append(c)
-
-    def commit(self):
-        self.inputState.input.commit()
-
-    def consume(self):
-        if not self.inputState.guessing:
-            c = self.LA(1)
-            if self.caseSensitive:
-                self.append(c)
-            else:
-                # use input.LA(), not LA(), to get original case
-                # CharScanner.LA() would toLower it.
-                c =  self.inputState.input.LA(1)
-                self.append(c)
-
-            if c and c in "\t":
-                self.tab()
-            else:
-                self.inputState.column += 1
-        self.inputState.input.consume()
-
-    ## Consume chars until one matches the given char
-    def consumeUntil_char(self,c):
-        while self.LA(1) != EOF_CHAR and self.LA(1) != c:
-            self.consume()
-
-    ## Consume chars until one matches the given set
-    def consumeUntil_bitset(self,bitset):
-        while self.LA(1) != EOF_CHAR and not self.set.member(self.LA(1)):
-            self.consume()
-
-    ### If symbol seen is EOF then generate and set token, otherwise
-    ### throw exception.
-    def default(self,la1):
-        if not la1 :
-            self.uponEOF()
-            self._returnToken = self.makeToken(EOF_TYPE)
-        else:
-            self.raise_NoViableAlt(la1)
-
-    def filterdefault(self,la1,*args):
-        if not la1:
-            self.uponEOF()
-            self._returnToken = self.makeToken(EOF_TYPE)
-            return
-
-        if not args:
-            self.consume()
-            raise TryAgain()
-        else:
-            ### apply filter object
-            self.commit();
-            try:
-                func=args[0]
-                args=args[1:]
-                apply(func,args)
-            except RecognitionException, e:
-                ## catastrophic failure
-                self.reportError(e);
-                self.consume();
-            raise TryAgain()
-
-    def raise_NoViableAlt(self,la1=None):
-        if not la1: la1 = self.LA(1)
-        fname = self.getFilename()
-        line  = self.getLine()
-        col   = self.getColumn()
-        raise NoViableAltForCharException(la1,fname,line,col)
-
-    def set_return_token(self,_create,_token,_ttype,_offset):
-        if _create and not _token and (not _ttype == SKIP):
-            string = self.text.getString(_offset)
-            _token = self.makeToken(_ttype)
-            _token.setText(string)
-        self._returnToken = _token
-        return _token
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                   CharScannerIterator                          ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class CharScannerIterator:
-
-    def __init__(self,inst):
-        if isinstance(inst,CharScanner):
-            self.inst = inst
-            return
-        raise TypeError("CharScannerIterator requires CharScanner object")
-
-    def next(self):
-        assert self.inst
-        item = self.inst.nextToken()
-        if not item or item.isEOF():
-            raise StopIteration()
-        return item
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       BitSet                                   ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-### I'm assuming here that a long is 64bits. It appears however, that
-### a long is of any size. That means we can use a single long as the
-### bitset (!), ie. Python would do almost all the work (TBD).
-
-class BitSet(object):
-    BITS     = 64
-    NIBBLE   = 4
-    LOG_BITS = 6
-    MOD_MASK = BITS -1
-
-    def __init__(self,data=None):
-        if not data:
-            BitSet.__init__(self,[long(0)])
-            return
-        if isinstance(data,int):
-            BitSet.__init__(self,[long(data)])
-            return
-        if isinstance(data,long):
-            BitSet.__init__(self,[data])
-            return
-        if not isinstance(data,list):
-            raise TypeError("BitSet requires integer, long, or " +
-                            "list argument")
-        for x in data:
-            if not isinstance(x,long):
-                raise TypeError(self,"List argument item is " +
-                                "not a long: %s" % (x))
-        self.data = data
-
-    def __str__(self):
-        bits = len(self.data) * BitSet.BITS
-        s = ""
-        for i in xrange(0,bits):
-            if self.at(i):
-                s += "1"
-            else:
-                s += "o"
-            if not ((i+1) % 10):
-                s += '|%s|' % (i+1)
-        return s
-
-    def __repr__(self):
-        return str(self)
-
-    def member(self,item):
-        if not item:
-            return False
-
-        if isinstance(item,int):
-            return self.at(item)
-
-        if not (isinstance(item,str) or isinstance(item,unicode)):
-            raise TypeError(self,"char or unichar expected: %s" % (item))
-
-        ## char is a (unicode) string with at most lenght 1, ie.
-        ## a char.
-
-        if len(item) != 1:
-            raise TypeError(self,"char expected: %s" % (item))
-
-        ### handle ASCII/UNICODE char
-        num = ord(item)
-
-        ### check whether position num is in bitset
-        return self.at(num)
-
-    def wordNumber(self,bit):
-        return bit >> BitSet.LOG_BITS
-
-    def bitMask(self,bit):
-        pos = bit & BitSet.MOD_MASK  ## bit mod BITS
-        return (1L << pos)
-
-    def set(self,bit,on=True):
-        # grow bitset as required (use with care!)
-        i = self.wordNumber(bit)
-        mask = self.bitMask(bit)
-        if i>=len(self.data):
-            d = i - len(self.data) + 1
-            for x in xrange(0,d):
-                self.data.append(0L)
-            assert len(self.data) == i+1
-        if on:
-            self.data[i] |=  mask
-        else:
-            self.data[i] &= (~mask)
-
-    ### make add an alias for set
-    add = set
-
-    def off(self,bit,off=True):
-        self.set(bit,not off)
-
-    def at(self,bit):
-        i = self.wordNumber(bit)
-        v = self.data[i]
-        m = self.bitMask(bit)
-        return v & m
-
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                      some further funcs                        ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-def illegalarg_ex(func):
-    raise ValueError(
-       "%s is only valid if parser is built for debugging" %
-       (func.func_name))
-
-def runtime_ex(func):
-    raise RuntimeException(
-       "%s is only valid if parser is built for debugging" %
-       (func.func_name))
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       TokenBuffer                              ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class TokenBuffer(object):
-    def __init__(self,stream):
-        self.input = stream
-        self.nMarkers = 0
-        self.markerOffset = 0
-        self.numToConsume = 0
-        self.queue = Queue()
-
-    def reset(self) :
-        self.nMarkers = 0
-        self.markerOffset = 0
-        self.numToConsume = 0
-        self.queue.reset()
-
-    def consume(self) :
-        self.numToConsume += 1
-
-    def fill(self, amount):
-        self.syncConsume()
-        while self.queue.length() < (amount + self.markerOffset):
-            self.queue.append(self.input.nextToken())
-
-    def getInput(self):
-        return self.input
-
-    def LA(self,k) :
-        self.fill(k)
-        return self.queue.elementAt(self.markerOffset + k - 1).type
-
-    def LT(self,k) :
-        self.fill(k)
-        return self.queue.elementAt(self.markerOffset + k - 1)
-
-    def mark(self) :
-        self.syncConsume()
-        self.nMarkers += 1
-        return self.markerOffset
-
-    def rewind(self,mark) :
-        self.syncConsume()
-        self.markerOffset = mark
-        self.nMarkers -= 1
-
-    def syncConsume(self) :
-        while self.numToConsume > 0:
-            if self.nMarkers > 0:
-                # guess mode -- leave leading characters and bump offset.
-                self.markerOffset += 1
-            else:
-                # normal mode -- remove first character
-                self.queue.removeFirst()
-            self.numToConsume -= 1
-
-    def __str__(self):
-        return "(%s,%s,%s,%s,%s)" % (
-           self.input,
-           self.nMarkers,
-           self.markerOffset,
-           self.numToConsume,
-           self.queue)
-
-    def __repr__(self):
-        return str(self)
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       ParserSharedInputState                   ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class ParserSharedInputState(object):
-
-    def __init__(self):
-        self.input = None
-        self.reset()
-
-    def reset(self):
-        self.guessing = 0
-        self.filename = None
-        if self.input:
-            self.input.reset()
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       Parser                                   ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class Parser(object):
-
-    def __init__(self, *args, **kwargs):
-        self.tokenNames = None
-        self.returnAST  = None
-        self.astFactory = None
-        self.tokenTypeToASTClassMap = {}
-        self.ignoreInvalidDebugCalls = False
-        self.traceDepth = 0
-        if not args:
-            self.inputState = ParserSharedInputState()
-            return
-        arg0 = args[0]
-        assert isinstance(arg0,ParserSharedInputState)
-        self.inputState = arg0
-        return
-
-    def getTokenTypeToASTClassMap(self):
-        return self.tokenTypeToASTClassMap
-
-
-    def addMessageListener(self, l):
-        if not self.ignoreInvalidDebugCalls:
-            illegalarg_ex(addMessageListener)
-
-    def addParserListener(self,l) :
-        if (not self.ignoreInvalidDebugCalls) :
-            illegalarg_ex(addParserListener)
-
-    def addParserMatchListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls) :
-            illegalarg_ex(addParserMatchListener)
-
-    def addParserTokenListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            illegalarg_ex(addParserTokenListener)
-
-    def addSemanticPredicateListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            illegalarg_ex(addSemanticPredicateListener)
-
-    def addSyntacticPredicateListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            illegalarg_ex(addSyntacticPredicateListener)
-
-    def addTraceListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            illegalarg_ex(addTraceListener)
-
-    def consume(self):
-        raise NotImplementedError()
-
-    def _consumeUntil_type(self,tokenType):
-        while self.LA(1) != EOF_TYPE and self.LA(1) != tokenType:
-            self.consume()
-
-    def _consumeUntil_bitset(self, set):
-        while self.LA(1) != EOF_TYPE and not set.member(self.LA(1)):
-            self.consume()
-
-    def consumeUntil(self,arg):
-        if isinstance(arg,int):
-            self._consumeUntil_type(arg)
-        else:
-            self._consumeUntil_bitset(arg)
-
-    def defaultDebuggingSetup(self):
-        pass
-
-    def getAST(self) :
-        return self.returnAST
-
-    def getASTFactory(self) :
-        return self.astFactory
-
-    def getFilename(self) :
-        return self.inputState.filename
-
-    def getInputState(self) :
-        return self.inputState
-
-    def setInputState(self, state) :
-        self.inputState = state
-
-    def getTokenName(self,num) :
-        return self.tokenNames[num]
-
-    def getTokenNames(self) :
-        return self.tokenNames
-
-    def isDebugMode(self) :
-        return self.false
-
-    def LA(self, i):
-        raise NotImplementedError()
-
-    def LT(self, i):
-        raise NotImplementedError()
-
-    def mark(self):
-        return self.inputState.input.mark()
-
-    def _match_int(self,t):
-        if (self.LA(1) != t):
-            raise MismatchedTokenException(
-               self.tokenNames, self.LT(1), t, False, self.getFilename())
-        else:
-            self.consume()
-
-    def _match_set(self, b):
-        if (not b.member(self.LA(1))):
-            raise MismatchedTokenException(
-               self.tokenNames,self.LT(1), b, False, self.getFilename())
-        else:
-            self.consume()
-
-    def match(self,set) :
-        if isinstance(set,int):
-            self._match_int(set)
-            return
-        if isinstance(set,BitSet):
-            self._match_set(set)
-            return
-        raise TypeError("Parser.match requires integer ot BitSet argument")
-
-    def matchNot(self,t):
-        if self.LA(1) == t:
-            raise MismatchedTokenException(
-               tokenNames, self.LT(1), t, True, self.getFilename())
-        else:
-            self.consume()
-
-    def removeMessageListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            runtime_ex(removeMessageListener)
-
-    def removeParserListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            runtime_ex(removeParserListener)
-
-    def removeParserMatchListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            runtime_ex(removeParserMatchListener)
-
-    def removeParserTokenListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            runtime_ex(removeParserTokenListener)
-
-    def removeSemanticPredicateListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            runtime_ex(removeSemanticPredicateListener)
-
-    def removeSyntacticPredicateListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            runtime_ex(removeSyntacticPredicateListener)
-
-    def removeTraceListener(self, l) :
-        if (not self.ignoreInvalidDebugCalls):
-            runtime_ex(removeTraceListener)
-
-    def reportError(self,x) :
-        fmt = "syntax error:"
-        f = self.getFilename()
-        if f:
-            fmt = ("%s:" % f) + fmt
-        if isinstance(x,Token):
-            line = x.getColumn()
-            col  = x.getLine()
-            text = x.getText()
-            fmt  = fmt + 'unexpected symbol at line %s (column %s) : "%s"'
-            print >>sys.stderr, fmt % (line,col,text)
-        else:
-            print >>sys.stderr, fmt,str(x)
-
-    def reportWarning(self,s):
-        f = self.getFilename()
-        if f:
-            print "%s:warning: %s" % (f,str(x))
-        else:
-            print "warning: %s" % (str(x))
-
-    def rewind(self, pos) :
-        self.inputState.input.rewind(pos)
-
-    def setASTFactory(self, f) :
-        self.astFactory = f
-
-    def setASTNodeClass(self, cl) :
-        self.astFactory.setASTNodeType(cl)
-
-    def setASTNodeType(self, nodeType) :
-        self.setASTNodeClass(nodeType)
-
-    def setDebugMode(self, debugMode) :
-        if (not self.ignoreInvalidDebugCalls):
-            runtime_ex(setDebugMode)
-
-    def setFilename(self, f) :
-        self.inputState.filename = f
-
-    def setIgnoreInvalidDebugCalls(self, value) :
-        self.ignoreInvalidDebugCalls = value
-
-    def setTokenBuffer(self, t) :
-        self.inputState.input = t
-
-    def traceIndent(self):
-        print " " * self.traceDepth
-
-    def traceIn(self,rname):
-        self.traceDepth += 1
-        self.trace("> ", rname)
-
-    def traceOut(self,rname):
-        self.trace("< ", rname)
-        self.traceDepth -= 1
-
-    ### wh: moved from ASTFactory to Parser
-    def addASTChild(self,currentAST, child):
-        if not child:
-            return
-        if not currentAST.root:
-            currentAST.root = child
-        elif not currentAST.child:
-            currentAST.root.setFirstChild(child)
-        else:
-            currentAST.child.setNextSibling(child)
-        currentAST.child = child
-        currentAST.advanceChildToEnd()
-
-    ### wh: moved from ASTFactory to Parser
-    def makeASTRoot(self,currentAST,root) :
-        if root:
-            ### Add the current root as a child of new root
-            root.addChild(currentAST.root)
-            ### The new current child is the last sibling of the old root
-            currentAST.child = currentAST.root
-            currentAST.advanceChildToEnd()
-            ### Set the new root
-            currentAST.root = root
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       LLkParser                                ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class LLkParser(Parser):
-
-    def __init__(self, *args, **kwargs):
-        try:
-            arg1 = args[0]
-        except:
-            arg1 = 1
-
-        if isinstance(arg1,int):
-            super(LLkParser,self).__init__()
-            self.k = arg1
-            return
-
-        if isinstance(arg1,ParserSharedInputState):
-            super(LLkParser,self).__init__(arg1)
-            self.set_k(1,*args)
-            return
-
-        if isinstance(arg1,TokenBuffer):
-            super(LLkParser,self).__init__()
-            self.setTokenBuffer(arg1)
-            self.set_k(1,*args)
-            return
-
-        if isinstance(arg1,TokenStream):
-            super(LLkParser,self).__init__()
-            tokenBuf = TokenBuffer(arg1)
-            self.setTokenBuffer(tokenBuf)
-            self.set_k(1,*args)
-            return
-
-        ### unknown argument
-        raise TypeError("LLkParser requires integer, " +
-                        "ParserSharedInputStream or TokenStream argument")
-
-    def consume(self):
-        self.inputState.input.consume()
-
-    def LA(self,i):
-        return self.inputState.input.LA(i)
-
-    def LT(self,i):
-        return self.inputState.input.LT(i)
-
-    def set_k(self,index,*args):
-        try:
-            self.k = args[index]
-        except:
-            self.k = 1
-
-    def trace(self,ee,rname):
-        print type(self)
-        self.traceIndent()
-        guess = ""
-        if self.inputState.guessing > 0:
-            guess = " [guessing]"
-        print(ee + rname + guess)
-        for i in xrange(1,self.k+1):
-            if i != 1:
-                print(", ")
-            if self.LT(i) :
-                v = self.LT(i).getText()
-            else:
-                v = "null"
-            print "LA(%s) == %s" % (i,v)
-        print("\n")
-
-    def traceIn(self,rname):
-        self.traceDepth += 1;
-        self.trace("> ", rname);
-
-    def traceOut(self,rname):
-        self.trace("< ", rname);
-        self.traceDepth -= 1;
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                    TreeParserSharedInputState                  ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class TreeParserSharedInputState(object):
-    def __init__(self):
-        self.guessing = 0
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       TreeParser                               ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class TreeParser(object):
-
-    def __init__(self, *args, **kwargs):
-        self.inputState = TreeParserSharedInputState()
-        self._retTree   = None
-        self.tokenNames = []
-        self.returnAST  = None
-        self.astFactory = ASTFactory()
-        self.traceDepth = 0
-
-    def getAST(self):
-        return self.returnAST
-
-    def getASTFactory(self):
-        return self.astFactory
-
-    def getTokenName(self,num) :
-        return self.tokenNames[num]
-
-    def getTokenNames(self):
-        return self.tokenNames
-
-    def match(self,t,set) :
-        assert isinstance(set,int) or isinstance(set,BitSet)
-        if not t or t == ASTNULL:
-            raise MismatchedTokenException(self.getTokenNames(), t,set, False)
-
-        if isinstance(set,int) and t.getType() != set:
-            raise MismatchedTokenException(self.getTokenNames(), t,set, False)
-
-        if isinstance(set,BitSet) and not set.member(t.getType):
-            raise MismatchedTokenException(self.getTokenNames(), t,set, False)
-
-    def matchNot(self,t, ttype) :
-        if not t or (t == ASTNULL) or (t.getType() == ttype):
-            raise MismatchedTokenException(getTokenNames(), t, ttype, True)
-
-    def reportError(self,ex):
-        print >>sys.stderr,"error:",ex
-
-    def  reportWarning(self, s):
-        print "warning:",s
-
-    def setASTFactory(self,f):
-        self.astFactory = f
-
-    def setASTNodeType(self,nodeType):
-        self.setASTNodeClass(nodeType)
-
-    def setASTNodeClass(self,nodeType):
-        self.astFactory.setASTNodeType(nodeType)
-
-    def traceIndent(self):
-        print " " * self.traceDepth
-
-    def traceIn(self,rname,t):
-        self.traceDepth += 1
-        self.traceIndent()
-        print("> " + rname + "(" +
-              ifelse(t,str(t),"null") + ")" +
-              ifelse(self.inputState.guessing>0,"[guessing]",""))
-
-    def traceOut(self,rname,t):
-        self.traceIndent()
-        print("< " + rname + "(" +
-              ifelse(t,str(t),"null") + ")" +
-              ifelse(self.inputState.guessing>0,"[guessing]",""))
-        self.traceDepth -= 1
-
-    ### wh: moved from ASTFactory to TreeParser
-    def addASTChild(self,currentAST, child):
-        if not child:
-            return
-        if not currentAST.root:
-            currentAST.root = child
-        elif not currentAST.child:
-            currentAST.root.setFirstChild(child)
-        else:
-            currentAST.child.setNextSibling(child)
-        currentAST.child = child
-        currentAST.advanceChildToEnd()
-
-    ### wh: moved from ASTFactory to TreeParser
-    def makeASTRoot(self,currentAST,root):
-        if root:
-            ### Add the current root as a child of new root
-            root.addChild(currentAST.root)
-            ### The new current child is the last sibling of the old root
-            currentAST.child = currentAST.root
-            currentAST.advanceChildToEnd()
-            ### Set the new root
-            currentAST.root = root
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###               funcs to work on trees                           ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-def rightmost(ast):
-    if ast:
-        while(ast.right):
-            ast = ast.right
-    return ast
-
-def cmptree(s,t,partial):
-    while(s and t):
-        ### as a quick optimization, check roots first.
-        if not s.equals(t):
-            return False
-
-        ### if roots match, do full list match test on children.
-        if not cmptree(s.getFirstChild(),t.getFirstChild(),partial):
-            return False
-
-        s = s.getNextSibling()
-        t = t.getNextSibling()
-
-    r = ifelse(partial,not t,not s and not t)
-    return r
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                          AST                                   ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class AST(object):
-    def __init__(self):
-        pass
-
-    def addChild(self, c):
-        pass
-
-    def equals(self, t):
-        return False
-
-    def equalsList(self, t):
-        return False
-
-    def equalsListPartial(self, t):
-        return False
-
-    def equalsTree(self, t):
-        return False
-
-    def equalsTreePartial(self, t):
-        return False
-
-    def findAll(self, tree):
-        return None
-
-    def findAllPartial(self, subtree):
-        return None
-
-    def getFirstChild(self):
-        return self
-
-    def getNextSibling(self):
-        return self
-
-    def getText(self):
-        return ""
-
-    def getType(self):
-        return INVALID_TYPE
-
-    def getLine(self):
-        return 0
-
-    def getColumn(self):
-        return 0
-
-    def getNumberOfChildren(self):
-        return 0
-
-    def initialize(self, t, txt):
-        pass
-
-    def initialize(self, t):
-        pass
-
-    def setFirstChild(self, c):
-        pass
-
-    def setNextSibling(self, n):
-        pass
-
-    def setText(self, text):
-        pass
-
-    def setType(self, ttype):
-        pass
-
-    def toString(self):
-        self.getText()
-
-    __str__ = toString
-
-    def toStringList(self):
-        return self.getText()
-
-    def toStringTree(self):
-        return self.getText()
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       ASTNULLType                              ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-### There is only one instance of this class **/
-class ASTNULLType(AST):
-    def __init__(self):
-        AST.__init__(self)
-        pass
-
-    def getText(self):
-        return "<ASTNULL>"
-
-    def getType(self):
-        return NULL_TREE_LOOKAHEAD
-
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       BaseAST                                  ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class BaseAST(AST):
-
-    verboseStringConversion = False
-    tokenNames = None
-
-    def __init__(self):
-        self.down  = None ## kid
-        self.right = None ## sibling
-
-    def addChild(self,node):
-        if node:
-            t = rightmost(self.down)
-            if t:
-                t.right = node
-            else:
-                assert not self.down
-                self.down = node
-
-    def getNumberOfChildren(self):
-        t = self.down
-        n = 0
-        while t:
-            n += 1
-            t = t.right
-        return n
-
-    def doWorkForFindAll(self,v,target,partialMatch):
-        sibling = self
-
-        while sibling:
-            c1 = partialMatch and sibling.equalsTreePartial(target)
-            if c1:
-                v.append(sibling)
-            else:
-                c2 = not partialMatch and sibling.equalsTree(target)
-                if c2:
-                    v.append(sibling)
-
-            ### regardless of match or not, check any children for matches
-            if sibling.getFirstChild():
-                sibling.getFirstChild().doWorkForFindAll(v,target,partialMatch)
-
-            sibling = sibling.getNextSibling()
-
-    ### Is node t equal to 'self' in terms of token type and text?
-    def equals(self,t):
-        if not t:
-            return False
-        return self.getText() == t.getText() and self.getType() == t.getType()
-
-    ### Is t an exact structural and equals() match of this tree.  The
-    ### 'self' reference is considered the start of a sibling list.
-    ###
-    def equalsList(self, t):
-        return cmptree(self, t, partial=False)
-
-    ### Is 't' a subtree of this list?
-    ### The siblings of the root are NOT ignored.
-    ###
-    def equalsListPartial(self,t):
-        return cmptree(self,t,partial=True)
-
-    ### Is tree rooted at 'self' equal to 't'?  The siblings
-    ### of 'self' are ignored.
-    ###
-    def equalsTree(self, t):
-        return self.equals(t) and \
-               cmptree(self.getFirstChild(), t.getFirstChild(), partial=False)
-
-    ### Is 't' a subtree of the tree rooted at 'self'?  The siblings
-    ### of 'self' are ignored.
-    ###
-    def equalsTreePartial(self, t):
-        if not t:
-            return True
-        return self.equals(t) and cmptree(
-           self.getFirstChild(), t.getFirstChild(), partial=True)
-
-    ### Walk the tree looking for all exact subtree matches.  Return
-    ### an ASTEnumerator that lets the caller walk the list
-    ### of subtree roots found herein.
-    def findAll(self,target):
-        roots = []
-
-        ### the empty tree cannot result in an enumeration
-        if not target:
-            return None
-        # find all matches recursively
-        self.doWorkForFindAll(roots, target, False)
-        return roots
-
-    ### Walk the tree looking for all subtrees.  Return
-    ###  an ASTEnumerator that lets the caller walk the list
-    ###  of subtree roots found herein.
-    def findAllPartial(self,sub):
-        roots = []
-
-        ### the empty tree cannot result in an enumeration
-        if not sub:
-            return None
-
-        self.doWorkForFindAll(roots, sub, True)  ### find all matches recursively
-        return roots
-
-    ### Get the first child of this node None if not children
-    def getFirstChild(self):
-        return self.down
-
-    ### Get the next sibling in line after this one
-    def getNextSibling(self):
-        return self.right
-
-    ### Get the token text for this node
-    def getText(self):
-        return ""
-
-    ### Get the token type for this node
-    def getType(self):
-        return 0
-
-    def getLine(self):
-        return 0
-
-    def getColumn(self):
-        return 0
-
-    ### Remove all children */
-    def removeChildren(self):
-        self.down = None
-
-    def setFirstChild(self,c):
-        self.down = c
-
-    def setNextSibling(self, n):
-        self.right = n
-
-    ### Set the token text for this node
-    def setText(self, text):
-        pass
-
-    ### Set the token type for this node
-    def setType(self, ttype):
-        pass
-
-    ### static
-    def setVerboseStringConversion(verbose,names):
-        verboseStringConversion = verbose
-        tokenNames = names
-    setVerboseStringConversion = staticmethod(setVerboseStringConversion)
-
-    ### Return an array of strings that maps token ID to it's text.
-    ##  @since 2.7.3
-    def getTokenNames():
-        return tokenNames
-
-    def toString(self):
-        return self.getText()
-
-    ### return tree as lisp string - sibling included
-    def toStringList(self):
-        ts = self.toStringTree()
-        sib = self.getNextSibling()
-        if sib:
-            ts += sib.toStringList()
-        return ts
-
-    __str__ = toStringList
-
-    ### return tree as string - siblings ignored
-    def toStringTree(self):
-        ts = ""
-        kid = self.getFirstChild()
-        if kid:
-            ts += " ("
-        ts += " " + self.toString()
-        if kid:
-            ts += kid.toStringList()
-            ts += " )"
-        return ts
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       CommonAST                                ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-### Common AST node implementation
-class CommonAST(BaseAST):
-    def __init__(self,token=None):
-        super(CommonAST,self).__init__()
-        self.ttype = INVALID_TYPE
-        self.text  = "<no text>"
-        self.initialize(token)
-        #assert self.text
-
-    ### Get the token text for this node
-    def getText(self):
-        return self.text
-
-    ### Get the token type for this node
-    def getType(self):
-        return self.ttype
-
-    def initialize(self,*args):
-        if not args:
-            return
-
-        arg0 = args[0]
-
-        if isinstance(arg0,int):
-            arg1 = args[1]
-            self.setType(arg0)
-            self.setText(arg1)
-            return
-
-        if isinstance(arg0,AST) or isinstance(arg0,Token):
-            self.setText(arg0.getText())
-            self.setType(arg0.getType())
-            return
-
-    ### Set the token text for this node
-    def setText(self,text_):
-        assert isinstance(text_,str)
-        self.text = text_
-
-    ### Set the token type for this node
-    def setType(self,ttype_):
-        assert isinstance(ttype_,int)
-        self.ttype = ttype_
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                     CommonASTWithHiddenTokens                  ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class CommonASTWithHiddenTokens(CommonAST):
-
-    def __init__(self,*args):
-        CommonAST.__init__(self,*args)
-        self.hiddenBefore = None
-        self.hiddenAfter  = None
-
-    def getHiddenAfter(self):
-        return self.hiddenAfter
-
-    def getHiddenBefore(self):
-        return self.hiddenBefore
-
-    def initialize(self,*args):
-        CommonAST.initialize(self,*args)
-        if args and isinstance(args[0],Token):
-            assert isinstance(args[0],CommonHiddenStreamToken)
-            self.hideenBefore = args[0].getHiddenBefore()
-            self.hiddenAfter  = args[0].getHiddenAfter()
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       ASTPair                                  ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class ASTPair(object):
-    def __init__(self):
-        self.root = None          ### current root of tree
-        self.child = None         ### current child to which siblings are added
-
-    ### Make sure that child is the last sibling */
-    def advanceChildToEnd(self):
-        if self.child:
-            while self.child.getNextSibling():
-                self.child = self.child.getNextSibling()
-
-    ### Copy an ASTPair.  Don't call it clone() because we want type-safety */
-    def copy(self):
-        tmp = ASTPair()
-        tmp.root = self.root
-        tmp.child = self.child
-        return tmp
-
-    def toString(self):
-        r = ifelse(not root,"null",self.root.getText())
-        c = ifelse(not child,"null",self.child.getText())
-        return "[%s,%s]" % (r,c)
-
-    __str__ = toString
-    __repr__ = toString
-
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       ASTFactory                               ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class ASTFactory(object):
-    def __init__(self,table=None):
-        self._class = None
-        self._classmap = ifelse(table,table,None)
-
-    def create(self,*args):
-        if not args:
-            return self.create(INVALID_TYPE)
-
-        arg0 = args[0]
-        arg1 = None
-        arg2 = None
-
-        try:
-            arg1 = args[1]
-            arg2 = args[2]
-        except:
-            pass
-
-        # ctor(int)
-        if isinstance(arg0,int) and not arg2:
-            ### get class for 'self' type
-            c = self.getASTNodeType(arg0)
-            t = self.create(c)
-            if t:
-                t.initialize(arg0, ifelse(arg1,arg1,""))
-            return t
-
-        # ctor(int,something)
-        if isinstance(arg0,int) and arg2:
-            t = self.create(arg2)
-            if t:
-                t.initialize(arg0,arg1)
-            return t
-
-        # ctor(AST)
-        if isinstance(arg0,AST):
-            t = self.create(arg0.getType())
-            if t:
-                t.initialize(arg0)
-            return t
-
-        # ctor(token)
-        if isinstance(arg0,Token) and not arg1:
-            ttype = arg0.getType()
-            assert isinstance(ttype,int)
-            t = self.create(ttype)
-            if t:
-                t.initialize(arg0)
-            return t
-
-        # ctor(token,class)
-        if isinstance(arg0,Token) and arg1:
-            assert isinstance(arg1,type)
-            assert issubclass(arg1,AST)
-            # this creates instance of 'arg1' using 'arg0' as
-            # argument. Wow, that's magic!
-            t = arg1(arg0)
-            assert t and isinstance(t,AST)
-            return t
-
-        # ctor(class)
-        if isinstance(arg0,type):
-            ### next statement creates instance of type (!)
-            t = arg0()
-            assert isinstance(t,AST)
-            return t
-
-
-    def setASTNodeClass(self,className=None):
-        if not className:
-            return
-        assert isinstance(className,type)
-        assert issubclass(className,AST)
-        self._class = className
-
-    ### kind of misnomer - use setASTNodeClass instead.
-    setASTNodeType = setASTNodeClass
-
-    def getASTNodeClass(self):
-        return self._class
-
-
-
-    def getTokenTypeToASTClassMap(self):
-        return self._classmap
-
-    def setTokenTypeToASTClassMap(self,amap):
-        self._classmap = amap
-
-    def error(self, e):
-        import sys
-        print >> sys.stderr, e
-
-    def setTokenTypeASTNodeType(self, tokenType, className):
-        """
-        Specify a mapping between a token type and a (AST) class.
-        """
-        if not self._classmap:
-            self._classmap = {}
-
-        if not className:
-            try:
-                del self._classmap[tokenType]
-            except:
-                pass
-        else:
-            ### here we should also perform actions to ensure that
-            ### a. class can be loaded
-            ### b. class is a subclass of AST
-            ###
-            assert isinstance(className,type)
-            assert issubclass(className,AST)  ## a & b
-            ### enter the class
-            self._classmap[tokenType] = className
-
-    def getASTNodeType(self,tokenType):
-        """
-        For a given token type return the AST node type. First we
-        lookup a mapping table, second we try _class
-        and finally we resolve to "antlr.CommonAST".
-        """
-
-        # first
-        if self._classmap:
-            try:
-                c = self._classmap[tokenType]
-                if c:
-                    return c
-            except:
-                pass
-        # second
-        if self._class:
-            return self._class
-
-        # default
-        return CommonAST
-
-    ### methods that have been moved to file scope - just listed
-    ### here to be somewhat consistent with original API
-    def dup(self,t):
-        return antlr.dup(t,self)
-
-    def dupList(self,t):
-        return antlr.dupList(t,self)
-
-    def dupTree(self,t):
-        return antlr.dupTree(t,self)
-
-    ### methods moved to other classes
-    ### 1. makeASTRoot  -> Parser
-    ### 2. addASTChild  -> Parser
-
-    ### non-standard: create alias for longish method name
-    maptype = setTokenTypeASTNodeType
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###                       ASTVisitor                               ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-class ASTVisitor(object):
-    def __init__(self,*args):
-        pass
-
-    def visit(self,ast):
-        pass
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-###               static methods and variables                     ###
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
-
-ASTNULL = ASTNULLType()
-
-### wh: moved from ASTFactory as there's nothing ASTFactory-specific
-### in this method.
-def make(*nodes):
-    if not nodes:
-        return None
-
-    for i in xrange(0,len(nodes)):
-        node = nodes[i]
-        if node:
-            assert isinstance(node,AST)
-
-    root = nodes[0]
-    tail = None
-    if root:
-        root.setFirstChild(None)
-
-    for i in xrange(1,len(nodes)):
-        if not nodes[i]:
-            continue
-        if not root:
-            root = tail = nodes[i]
-        elif not tail:
-            root.setFirstChild(nodes[i])
-            tail = root.getFirstChild()
-        else:
-            tail.setNextSibling(nodes[i])
-            tail = tail.getNextSibling()
-
-        ### Chase tail to last sibling
-        while tail.getNextSibling():
-            tail = tail.getNextSibling()
-    return root
-
-def dup(t,factory):
-    if not t:
-        return None
-
-    if factory:
-        dup_t = factory.create(t.__class__)
-    else:
-        raise TypeError("dup function requires ASTFactory argument")
-    dup_t.initialize(t)
-    return dup_t
-
-def dupList(t,factory):
-    result = dupTree(t,factory)
-    nt = result
-    while t:
-        ## for each sibling of the root
-        t = t.getNextSibling()
-        nt.setNextSibling(dupTree(t,factory))
-        nt = nt.getNextSibling()
-    return result
-
-def dupTree(t,factory):
-    result = dup(t,factory)
-    if t:
-        result.setFirstChild(dupList(t.getFirstChild(),factory))
-    return result
-
-###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-### $Id: antlr.py,v 1.2 2005/10/26 07:44:24 rvk Exp $
-
-# Local Variables:    ***
-# mode: python        ***
-# py-indent-offset: 4 ***
-# End:                ***

+ 0 - 249
desktop/core/ext-py/pyexcelerator/pyExcelerator/excel-formula.g

@@ -1,249 +0,0 @@
-/*
- *  $Id: excel-formula.g,v 1.4 2005/08/14 06:40:23 rvk Exp $
- */
-
-header {
-    __rev_id__ = """$Id: excel-formula.g,v 1.4 2005/08/14 06:40:23 rvk Exp $"""
-
-    import struct
-    import Utils
-    from UnicodeUtils import upack1
-    from ExcelMagic import *
-}
-
-header "ExcelFormulaParser.__init__" {
-    self.rpn = ""
-}
-
-options {
-    language  = "Python";
-}
-
-class ExcelFormulaParser extends Parser;
-options {
-    k = 2;
-    defaultErrorHandler = false;
-    buildAST = false;
-}
-
-
-tokens {
-    TRUE_CONST;
-    FALSE_CONST;
-    STR_CONST;
-    NUM_CONST;
-    INT_CONST;
-    
-    NAME;
-
-    EQ;
-    NE;
-    GT;
-    LT;
-    GE;
-    LE;
-
-    ADD;
-    SUB;
-    MUL;
-    DIV;
-
-    POWER;
-    PERCENT;
-
-    LP;
-    RP;
-
-    LB;
-    RB;
-
-    COLON;
-    COMMA;
-    SEMICOLON;
-}
-
-formula
-    : expr["V"]
-    ;
-
-expr[arg_type]
-    : prec0_expr[arg_type]
-        (
-            (
-                  EQ { op = struct.pack('B', ptgEQ) }
-                | NE { op = struct.pack('B', ptgNE) }
-                | GT { op = struct.pack('B', ptgGT) }
-                | LT { op = struct.pack('B', ptgLT) }
-                | GE { op = struct.pack('B', ptgGE) }
-                | LE { op = struct.pack('B', ptgLE) }
-            )
-            prec0_expr[arg_type] { self.rpn += op }
-        )*
-    ;
-
-prec0_expr[arg_type]
-    : prec1_expr[arg_type]
-        (
-            (
-                CONCAT { op = struct.pack('B', ptgConcat) }
-            )
-            prec1_expr[arg_type] { self.rpn += op }
-        )*
-    ;
-
-prec1_expr[arg_type]
-    : prec2_expr[arg_type]
-        (
-            (
-                  ADD { op = struct.pack('B', ptgAdd) }
-                | SUB { op = struct.pack('B', ptgSub) }
-            )
-            prec2_expr[arg_type] { self.rpn += op }
-        )*
-    ;
-
-
-prec2_expr[arg_type]
-    : prec3_expr[arg_type]
-        (
-            (
-                  MUL { op = struct.pack('B', ptgMul) }
-                | DIV { op = struct.pack('B', ptgDiv) }
-            )
-            prec3_expr[arg_type] { self.rpn += op }
-        )*
-    ;
-
-prec3_expr[arg_type]
-    : prec4_expr[arg_type]
-        (
-            (
-                POWER { op = struct.pack('B', ptgPower) }
-            )
-            prec4_expr[arg_type] { self.rpn += op }
-        )*
-    ;
-
-prec4_expr[arg_type]
-    : prec5_expr[arg_type]
-        (
-            PERCENT { self.rpn += struct.pack('B', ptgPercent) }
-        )?
-    ;
-
-prec5_expr[arg_type]
-    : primary[arg_type]
-    | SUB primary[arg_type] { self.rpn += struct.pack('B', ptgUminus) }
-    ;
-
-primary[arg_type]
-    : TRUE_CONST
-        {
-            self.rpn += struct.pack("2B", ptgBool, 1)
-        }
-    | FALSE_CONST
-        {
-            self.rpn += struct.pack("2B", ptgBool, 0)
-        }
-    | str_tok:STR_CONST
-        {
-            self.rpn += struct.pack("B", ptgStr) + upack1(str_tok.text[1:-1])
-        }
-    | int_tok:INT_CONST
-        {
-            self.rpn += struct.pack("<BH", ptgInt, int(int_tok.text))
-        }
-    | num_tok:NUM_CONST
-        {
-            self.rpn += struct.pack("<Bd", ptgNum, float(num_tok.text))
-        }
-    | ref2d_tok:REF2D
-        {
-            r, c = Utils.cell_to_packed_rowcol(ref2d_tok.text)
-            if arg_type == "R":
-                self.rpn += struct.pack("<B2H", ptgRefR, r, c)
-            else:
-                self.rpn += struct.pack("<B2H", ptgRefV, r, c)
-        }
-    | ref2d1_tok:REF2D COLON ref2d2_tok:REF2D
-        {
-            r1, c1 = Utils.cell_to_packed_rowcol(ref2d1_tok.text)
-            r2, c2 = Utils.cell_to_packed_rowcol(ref2d2_tok.text)
-            if arg_type == "R":
-                self.rpn += struct.pack("<B4H", ptgAreaR, r1, r2, c1, c2)
-            else:
-                self.rpn += struct.pack("<B4H", ptgAreaV, r1, r2, c1, c2)
-        }
-    | name_tok:NAME
-        {
-            self.rpn += ""
-        }
-    | func_tok:NAME
-        {
-            if func_tok.text.upper() in std_func_by_name:
-                (opcode,
-                min_argc,
-                max_argc,
-                func_type,
-                arg_type_list,
-                volatile_func) = std_func_by_name[func_tok.text.upper()]
-            else:
-                raise Exception, "unknown function: %s" % func_tok.text
-        }
-        LP arg_count = expr_list[arg_type_list, min_argc, max_argc] RP
-        {
-            if arg_count > max_argc or arg_count < min_argc:
-                raise Exception, "%d parameters for function: %s" % (arg_count, func_tok.text)
-            if min_argc == max_argc:
-                if func_type == "V":
-                    func_ptg = ptgFuncV
-                elif func_type == "R":
-                    func_ptg = ptgFuncR
-                elif func_type == "A":
-                    func_ptg = ptgFuncA
-                else:
-                    raise Exception, "wrong function type"
-                self.rpn += struct.pack("<BH", func_ptg, opcode)
-            else:
-                if func_type == "V":
-                    func_ptg = ptgFuncVarV
-                elif func_type == "R":
-                    func_ptg = ptgFuncVarR
-                elif func_type == "A":
-                    func_ptg = ptgFuncVarA
-                else:
-                    raise Exception, "wrong function type"
-                self.rpn += struct.pack("<2BH", func_ptg, arg_count, opcode)
-        }
-    | LP expr[arg_type] RP
-        {
-            self.rpn += struct.pack("B", ptgParen)
-        }
-    ;
-
-expr_list[arg_type_list, min_argc, max_argc] returns [arg_cnt]
-{
-    arg_cnt = 0
-    arg_type_list = arg_type_list.split()
-    arg_type = arg_type_list[arg_cnt]
-}
-    : expr[arg_type] { arg_cnt += 1 }
-    (
-        {
-            if arg_cnt < len(arg_type_list):
-                arg_type = arg_type_list[arg_cnt]
-            else:
-                arg_type = arg_type_list[-1]
-            if arg_type == "...":
-                arg_type = arg_type_list[-2]
-        }
-        SEMICOLON
-            (
-                  expr[arg_type]
-                | { self.rpn += struct.pack("B", ptgMissArg) }
-            )
-            { arg_cnt += 1 }
-    )*
-    |
-    ;
-

+ 0 - 90
desktop/core/ext-py/pyexcelerator/setup.py

@@ -1,90 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-__rev_id__ = """$Id: setup.py,v 1.10 2005/10/26 07:44:23 rvk Exp $"""
-
-import sys
-from distutils.core import setup
-
-DESCRIPTION = \
-'generating Excel 97+ files; importing Excel 95+ files; Excel files dumper; OLE2 files dumper; xls2txt, xls2csv, xls2html'
-
-LONG_DESCRIPTION = \
-'''pyExcelerator  is a   library  for  generating  Excel  97/2000/XP/2003  and
-OpenOffice    Calc   compatible     spreadsheets.     pyExcelerator     has
-full-blown   support   for  UNICODE  in Excel and Calc spreadsheets, allows
-using variety of formatting features,   provides   interface   to  printing
-options   of   Excel   and OpenOffice  Calc.  pyExcelerator  contains  also
-Excel BIFF8 dumper and MS compound  documents  dumper.  Main  advantage  is
-possibility  of generating Excel  spreadsheets  without  COM  servers.  The
-only requirement -- Python 2.4b2 or higher.
-From version 0.5 pyExcelerator can import data from Excel spreadsheets.'''
-
-CLASSIFIERS = \
-[
- 'Operating System :: OS Independent',
- 'Programming Language :: Python',
- 'License :: OSI Approved :: BSD License',
- 'Development Status :: 3 - Alpha',
- 'Intended Audience :: Developers',
- 'Topic :: Software Development :: Libraries :: Python Modules',
- 'Topic :: Office/Business :: Financial :: Spreadsheet',
- 'Topic :: Database',
- 'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries',
-]
-
-KEYWORDS = \
-'xls openoffice excel spreadsheet workbook database table unicode'
-
-setup(name = 'pyExcelerator',
-      version = '0.6.4.1',
-      author = 'Roman V. Kiseliov',
-      author_email = 'roman@kiseliov.ru',
-      url = 'http://sourceforge.net/projects/pyexcelerator/',
-      download_url='http://sourceforge.net/projects/pyexcelerator/',    
-      description = DESCRIPTION,
-      long_description = LONG_DESCRIPTION,
-      license = 'BSD',
-      platforms = 'Platform Independent',
-      packages = ['pyExcelerator'],
-      keywords = KEYWORDS,
-      classifiers = CLASSIFIERS
-      )

+ 0 - 1687
desktop/core/ext-py/pyexcelerator/tools/Analyzer.py

@@ -1,1687 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-__rev_id__ = """$Id: Analyzer.py,v 1.4 2005/05/12 06:51:17 rvk Exp $"""
-
-
-# total 258 records in database
-import struct
-
-def analyze_1904_record(data):
-    # 0x0022
-    pass
-
-
-def analyze_ADDIN_record(data):
-    # 0x0087
-    pass
-
-
-def analyze_ADDMENU_record(data):
-    # 0x00C2
-    pass
-
-
-def analyze_ARRAY_record(data):
-    # 0x0021, 0x0221
-    pass
-
-
-def analyze_AUTOFILTER_record(data):
-    # 0x009E
-    pass
-
-
-def analyze_AUTOFILTERINFO_record(data):
-    # 0x009D
-    pass
-
-
-def analyze_BACKUP_record(data):
-    # 0x0040
-    pass
-
-
-def analyze_BEGIN_record(data):
-    # 0x1033
-    pass
-
-
-def analyze_BITMAP_record(data):
-    # 0x00E9
-    pass
-
-
-def analyze_BLANK_record(data):
-    # 0x0001, 0x0201
-    pass
-
-
-def analyze_BOF_record(data):
-    # 0x0009, 0x0209, 0x0409, 0x0809
-    pass
-
-
-def analyze_BOOKBOOL_record(data):
-    # 0x00DA
-    pass
-
-
-def analyze_BOOLERR_record(data):
-    # 0x0005, 0x0205
-    pass
-
-
-def analyze_BOTTOMMARGIN_record(data):
-    # 0x0029
-    print struct.unpack('<d', data)[0]
-    pass
-
-
-def analyze_BOUNDSHEET_record(data):
-    # 0x0085
-    pass
-
-
-def analyze_BUILTINFMTCNT_record(data):
-    # 0x0056
-    pass
-
-
-def analyze_BUNDLEHEADER_record(data):
-    # 0x008F
-    pass
-
-
-def analyze_BUNDLESOFFSET_record(data):
-    # 0x008E
-    pass
-
-
-def analyze_CALCCOUNT_record(data):
-    # 0x000C
-    pass
-
-
-def analyze_CALCMODE_record(data):
-    # 0x000D
-    pass
-
-
-def analyze_MERGEDCELLS_record(data):
-    # 0x00E5
-    pass
-
-
-def analyze_CF_record(data):
-    # 0x01B1
-    pass
-
-
-def analyze_CHTRCELLCONTENT_record(data):
-    # 0x013B
-    pass
-
-
-def analyze_CHTRHEADER_record(data):
-    # 0x0196
-    pass
-
-
-def analyze_CHTRINFO_record(data):
-    # 0x0138
-    pass
-
-
-def analyze_CHTRINSERT_record(data):
-    # 0x0137
-    pass
-
-
-def analyze_CHTRINSERTTAB_record(data):
-    # 0x014D
-    pass
-
-
-def analyze_CHTRMOVERANGE_record(data):
-    # 0x0140
-    pass
-
-
-def analyze_CODENAME_record(data):
-    # 0x01BA
-    pass
-
-
-def analyze_CODEPAGE_record(data):
-    # 0x0042
-    pass
-
-
-def analyze_COLINFO_record(data):
-    # 0x007D
-    pass
-
-
-def analyze_COLUMNDEFAULT_record(data):
-    # 0x0020
-    pass
-
-
-def analyze_COLWIDTH_record(data):
-    # 0x0024
-    pass
-
-
-def analyze_CONDFMT_record(data):
-    # 0x01B0
-    pass
-
-
-def analyze_CONTINUE_record(data):
-    # 0x003C
-    pass
-
-
-def analyze_COORDLIST_record(data):
-    # 0x00A9
-    pass
-
-
-def analyze_COUNTRY_record(data):
-    # 0x008C
-    pass
-
-
-def analyze_CRN_record(data):
-    # 0x005A
-    pass
-
-
-def analyze_Chart3D_record(data):
-    # 0x103A
-    pass
-
-
-def analyze_Chart3DDataFormat_record(data):
-    # 0x105F
-    pass
-
-
-def analyze_ChartAI_record(data):
-    # 0x1051
-    pass
-
-
-def analyze_ChartAlruns_record(data):
-    # 0x1050
-    pass
-
-
-def analyze_ChartArea_record(data):
-    # 0x101A
-    pass
-
-
-def analyze_ChartAreaformat_record(data):
-    # 0x100A
-    pass
-
-
-def analyze_ChartAttachedlabel_record(data):
-    # 0x100C
-    pass
-
-
-def analyze_ChartAxcext_record(data):
-    # 0x1062
-    pass
-
-
-def analyze_ChartAxesused_record(data):
-    # 0x1046
-    pass
-
-
-def analyze_ChartAxis_record(data):
-    # 0x101D
-    pass
-
-
-def analyze_ChartAxislineformat_record(data):
-    # 0x1021
-    pass
-
-
-def analyze_ChartAxisparent_record(data):
-    # 0x1041
-    pass
-
-
-def analyze_ChartBar_record(data):
-    # 0x1017
-    pass
-
-
-def analyze_ChartBoppcustom_record(data):
-    # 0x1067
-    pass
-
-
-def analyze_ChartBoppop_record(data):
-    # 0x1061
-    pass
-
-
-def analyze_ChartCatserrange_record(data):
-    # 0x1020
-    pass
-
-
-def analyze_ChartChart_record(data):
-    # 0x1002
-    pass
-
-
-def analyze_ChartChartformat_record(data):
-    # 0x1014
-    pass
-
-
-def analyze_ChartChartline_record(data):
-    # 0x101C
-    pass
-
-
-def analyze_ChartDat_record(data):
-    # 0x1063
-    pass
-
-
-def analyze_ChartDataformat_record(data):
-    # 0x1006
-    pass
-
-
-def analyze_ChartDefaulttext_record(data):
-    # 0x1024
-    pass
-
-
-def analyze_ChartDropbar_record(data):
-    # 0x103D
-    pass
-
-
-def analyze_ChartFbi_record(data):
-    # 0x1060
-    pass
-
-
-def analyze_ChartFontx_record(data):
-    # 0x1026
-    pass
-
-
-def analyze_ChartFormatlink_record(data):
-    # 0x1022
-    pass
-
-
-def analyze_ChartFrame_record(data):
-    # 0x1032
-    pass
-
-
-def analyze_ChartGelframe_record(data):
-    # 0x1066
-    pass
-
-
-def analyze_ChartIfmt_record(data):
-    # 0x104E
-    pass
-
-
-def analyze_ChartLegend_record(data):
-    # 0x1015
-    pass
-
-
-def analyze_ChartLegendxn_record(data):
-    # 0x1043
-    pass
-
-
-def analyze_ChartLine_record(data):
-    # 0x1018
-    pass
-
-
-def analyze_ChartLineformat_record(data):
-    # 0x1007
-    pass
-
-
-def analyze_ChartMarkerformat_record(data):
-    # 0x1009
-    pass
-
-
-def analyze_ChartObjectLink_record(data):
-    # 0x1027
-    pass
-
-
-def analyze_ChartPicf_record(data):
-    # 0x103C
-    pass
-
-
-def analyze_ChartPie_record(data):
-    # 0x1019
-    pass
-
-
-def analyze_ChartPieformat_record(data):
-    # 0x100B
-    pass
-
-
-def analyze_ChartPlotarea_record(data):
-    # 0x1035
-    pass
-
-
-def analyze_ChartPlotgrowth_record(data):
-    # 0x1064
-    pass
-
-
-def analyze_ChartPos_record(data):
-    # 0x104F
-    pass
-
-
-def analyze_ChartRadar_record(data):
-    # 0x103E
-    pass
-
-
-def analyze_ChartRadararea_record(data):
-    # 0x1040
-    pass
-
-
-def analyze_ChartSbaseref_record(data):
-    # 0x1048
-    pass
-
-
-def analyze_ChartScatter_record(data):
-    # 0x101B
-    pass
-
-
-def analyze_ChartSerauxerrbar_record(data):
-    # 0x105B
-    pass
-
-
-def analyze_ChartSerauxtrend_record(data):
-    # 0x104B
-    pass
-
-
-def analyze_ChartSerfmt_record(data):
-    # 0x105D
-    pass
-
-
-def analyze_ChartSeries_record(data):
-    # 0x1003
-    pass
-
-
-def analyze_ChartSerieslist_record(data):
-    # 0x1016
-    pass
-
-
-def analyze_ChartSeriestext_record(data):
-    # 0x100D
-    pass
-
-
-def analyze_ChartSerparent_record(data):
-    # 0x104A
-    pass
-
-
-def analyze_ChartSertocrt_record(data):
-    # 0x1045
-    pass
-
-
-def analyze_ChartShtprops_record(data):
-    # 0x1044
-    pass
-
-
-def analyze_ChartSiindex_record(data):
-    # 0x1065
-    pass
-
-
-def analyze_ChartSurface_record(data):
-    # 0x103F
-    pass
-
-
-def analyze_ChartText_record(data):
-    # 0x1025
-    pass
-
-
-def analyze_ChartTick_record(data):
-    # 0x101E
-    pass
-
-
-def analyze_ChartValuerange_record(data):
-    # 0x101F
-    pass
-
-
-def analyze_DBCELL_record(data):
-    # 0x00D7
-    pass
-
-
-def analyze_DCON_record(data):
-    # 0x0050
-    pass
-
-
-def analyze_DCONBIN_record(data):
-    # 0x01B5
-    pass
-
-
-def analyze_DCONNAME_record(data):
-    # 0x0053
-    pass
-
-
-def analyze_DCONREF_record(data):
-    # 0x0051
-    pass
-
-
-def analyze_DEFAULTROWHEIGHT_record(data):
-    # 0x0025, 0x0225
-    pass
-
-
-def analyze_DEFCOLWIDTH_record(data):
-    # 0x0055
-    pass
-
-
-def analyze_DELMENU_record(data):
-    # 0x00C3
-    pass
-
-
-def analyze_DELTA_record(data):
-    # 0x0010
-    pass
-
-
-def analyze_DIMENSIONS_record(data):
-    # 0x0000, 0x0200
-    pass
-
-
-def analyze_DOCROUTE_record(data):
-    # 0x00B8
-    pass
-
-
-def analyze_DSF_record(data):
-    # 0x0161
-    pass
-
-
-def analyze_DV_record(data):
-    # 0x01BE
-    pass
-
-
-def analyze_DVAL_record(data):
-    # 0x01B2
-    pass
-
-
-def analyze_EDG_record(data):
-    # 0x0088
-    pass
-
-
-def analyze_EFONT_record(data):
-    # 0x0045
-    pass
-
-
-def analyze_END_record(data):
-    # 0x1034
-    pass
-
-
-def analyze_EOF_record(data):
-    # 0x000A
-    pass
-
-
-def analyze_EXTERNCOUNT_record(data):
-    # 0x0016
-    pass
-
-
-def analyze_EXTERNNAME_record(data):
-    # 0x0023, 0x0223
-    pass
-
-
-def analyze_EXTERNSHEET_record(data):
-    # 0x0017
-    pass
-
-
-def analyze_EXTSST_record(data):
-    # 0x00FF
-    pass
-
-
-def analyze_FILEPASS_record(data):
-    # 0x002F
-    pass
-
-
-def analyze_FILESHARING_record(data):
-    # 0x005B
-    pass
-
-
-def analyze_FILTERMODE_record(data):
-    # 0x009B
-    pass
-
-
-def analyze_FNGROUPCOUNT_record(data):
-    # 0x009C
-    pass
-
-
-def analyze_FNGROUPNAME_record(data):
-    # 0x009A
-    pass
-
-
-def analyze_FONT_record(data):
-    # 0x0031, 0x0231
-    pass
-
-
-def analyze_FOOTER_record(data):
-    # 0x0015
-    pass
-
-
-def analyze_FORMAT_record(data):
-    # 0x001E, 0x041E
-    fmt_idx = struct.unpack('<H', data[0:2])
-    name_len = struct.unpack('<H', data[2:4])
-    compressed = data[4] == '\x00'
-    print 'format index      : 0x%04X' % fmt_idx
-    print 'format name len   : 0x%04X' % name_len
-    print 'compressed UNICODE:', compressed
-
-    name = data[5:]
-    if not compressed:
-        name = [c for c in name if c != '\x00']    
-        name = ''.join(name)
-    print 'format str        :', name            
-    pass
-
-
-def analyze_FORMATCOUNT_record(data):
-    # 0x001F
-    pass
-
-
-def analyze_FORMULA_record(data):
-    # 0x0006, 0x0206, 0x0406
-    pass
-
-
-def analyze_GCW_record(data):
-    # 0x00AB
-    pass
-
-
-def analyze_GRIDSET_record(data):
-    # 0x0082
-    pass
-
-
-def analyze_GUTS_record(data):
-    # 0x0080
-    pass
-
-
-def analyze_HCENTER_record(data):
-    # 0x0083
-    pass
-
-
-def analyze_HEADER_record(data):
-    # 0x0014
-    pass
-
-
-def analyze_HIDEOBJ_record(data):
-    # 0x008D
-    pass
-
-
-def analyze_HLINK_record(data):
-    # 0x01B8
-    pass
-
-
-def analyze_HORIZONTALPAGEBREAKS_record(data):
-    # 0x001B
-    pass
-
-
-def analyze_IMDATA_record(data):
-    # 0x007F
-    pass
-
-
-def analyze_INDEX_record(data):
-    # 0x000B, 0x020B
-    pass
-
-
-def analyze_INTEGER_record(data):
-    # 0x0002
-    pass
-
-
-def analyze_INTERFACEEND_record(data):
-    # 0x00E2
-    pass
-
-
-def analyze_INTERFACEHDR_record(data):
-    # 0x00E1
-    pass
-
-
-def analyze_ITERATION_record(data):
-    # 0x0011
-    pass
-
-
-def analyze_IXFE_record(data):
-    # 0x0044
-    pass
-
-
-def analyze_LABEL_record(data):
-    # 0x0004, 0x0204
-    pass
-
-
-def analyze_LABELRANGES_record(data):
-    # 0x015F
-    pass
-
-
-def analyze_LABELSST_record(data):
-    # 0x00FD
-    row, col, xf_idx, sst_idx = struct.unpack('<3HL', data)
-    print 'row     : 0x%000X'  % row
-    print 'col     : 0x%000X'  % col
-    print 'xf  idx : 0x%000X'  % xf_idx
-    print 'sst idx : 0x%000X'  % sst_idx
-
-    pass
-
-
-def analyze_LEFTMARGIN_record(data):
-    # 0x0026
-    print struct.unpack('<d', data)[0]
-    pass
-
-
-def analyze_LHNGRAPH_record(data):
-    # 0x0095
-    pass
-
-
-def analyze_LHRECORD_record(data):
-    # 0x0094
-    pass
-
-
-def analyze_LPR_record(data):
-    # 0x0098
-    pass
-
-
-def analyze_MMS_record(data):
-    # 0x00C1
-    pass
-
-
-def analyze_MSODRAWING_record(data):
-    # 0x00EC
-    pass
-
-
-def analyze_MSODRAWINGGROUP_record(data):
-    # 0x00EB
-    pass
-
-
-def analyze_MSODRAWINGSELECTION_record(data):
-    # 0x00ED
-    pass
-
-
-def analyze_MULBLANK_record(data):
-    # 0x00BE
-    pass
-
-
-def analyze_MULRK_record(data):
-    # 0x00BD
-    pass
-
-
-def analyze_NAME_record(data):
-    # 0x0018, 0x0218
-    pass
-
-
-def analyze_NOTE_record(data):
-    # 0x001C
-    pass
-
-
-def analyze_NUMBER_record(data):
-    # 0x0003, 0x0203
-    pass
-
-
-def analyze_OBJ_record(data):
-    # 0x005D
-    pass
-
-
-def analyze_OBJPROTECT_record(data):
-    # 0x0063
-    pass
-
-
-def analyze_OBPROJ_record(data):
-    # 0x00D3
-    pass
-
-
-def analyze_OLESIZE_record(data):
-    # 0x00DE
-    pass
-
-
-def analyze_PALETTE_record(data):
-    # 0x0092
-    pass
-
-
-def analyze_PANE_record(data):
-    # 0x0041
-    pass
-
-
-def analyze_PASSWORD_record(data):
-    # 0x0013
-    pass
-
-
-def analyze_PLS_record(data):
-    # 0x004D
-    pass
-
-
-def analyze_PRECISION_record(data):
-    # 0x000E
-    pass
-
-
-def analyze_PRINTGRIDLINES_record(data):
-    # 0x002B
-    pass
-
-
-def analyze_PRINTHEADERS_record(data):
-    # 0x002A
-    pass
-
-
-def analyze_PROT4REV_record(data):
-    # 0x01AF
-    pass
-
-
-def analyze_PROT4REVPASS_record(data):
-    # 0x01BC
-    pass
-
-
-def analyze_PROTECT_record(data):
-    # 0x0012
-    pass
-
-
-def analyze_PUB_record(data):
-    # 0x0089
-    pass
-
-
-def analyze_QSI_record(data):
-    # 0x01AD
-    pass
-
-def analyze_RECALCID_record(data):
-    # 0x01C1: 
-    pass
-
-
-def analyze_RECIPNAME_record(data):
-    # 0x00B9
-    pass
-
-
-def analyze_REFMODE_record(data):
-    # 0x000F
-    pass
-
-
-def analyze_REFRESHALL_record(data):
-    # 0x01B7
-    pass
-
-
-def analyze_RIGHTMARGIN_record(data):
-    # 0x0027
-    print struct.unpack('<d', data)[0]
-    pass
-
-
-def analyze_RK_record(data):
-    # 0x007E, 0x027E
-    pass
-
-
-def analyze_ROW_record(data):
-    # 0x0008, 0x0208
-    idx, col1, col2, height_options, not_used, not_used, options = \
-        struct.unpack('<6HL', data)
-    print 'row index        : 0x%000X'  % idx
-    print 'start col        : 0x%000X'  % col1
-    print 'last col + 1     : 0x%000X'  % col2
-    print 'height           : 0x%000X'  % (height_options & 0x7FFF)
-    print 'height is custom : 0x%000X'  % ((height_options & 0x8000) >> 15)
-    print 'outline level    : 0x%000X'  % ((options & 0x00000007L) >> 0)
-    print 'level collapsed  : 0x%000X'  % ((options & 0x00000010L) >> 4)
-    print 'row is hidden    : 0x%000X'  % ((options & 0x00000020L) >> 5)
-    print 'font height match: 0x%000X'  % ((options & 0x00000040L) >> 6)
-    print 'default format   : 0x%000X'  % ((options & 0x00000080L) >> 7)
-    print 'default xf index : 0x%000X'  % ((options & 0x0FFF0000L) >> 16)
-    print 'add space above  : 0x%000X'  % ((options & 0x10000000L) >> 28)
-    print 'add space below  : 0x%000X'  % ((options & 0x20000000L) >> 29)
-
-
-def analyze_RSTRING_record(data):
-    # 0x00D6
-    pass
-
-
-def analyze_SAFERECALC_record(data):
-    # 0x005F
-    pass
-
-
-def analyze_SCENARIO_record(data):
-    # 0x00AF
-    pass
-
-
-def analyze_SCENMAN_record(data):
-    # 0x00AE
-    pass
-
-
-def analyze_SCENPROTECT_record(data):
-    # 0x00DD
-    pass
-
-
-def analyze_SCL_record(data):
-    # 0x00A0
-    pass
-
-
-def analyze_SCREENTIP_record(data):
-    # 0x0800
-    pass
-
-
-def analyze_SELECTION_record(data):
-    # 0x001D
-    pass
-
-
-def analyze_SETUP_record(data):
-    # 0x00A1
-    pass
-
-
-def analyze_SHEETLAYOUT_record(data):
-    # 0x0862
-    pass
-
-
-def analyze_SHEETPROTECTION_record(data):
-    # 0x0867
-    pass
-
-
-def analyze_SHRFMLA_record(data):
-    # 0x00BC, 0x04BC
-    pass
-
-
-def analyze_SORT_record(data):
-    # 0x0090
-    pass
-
-
-def analyze_SOUND_record(data):
-    # 0x0096
-    pass
-
-
-def analyze_SST_record(data):
-    # 0x00FC
-    pass
-
-
-def analyze_STANDARDWIDTH_record(data):
-    # 0x0099
-    pass
-
-
-def analyze_STRING_record(data):
-    # 0x0007, 0x0207
-    pass
-
-
-def analyze_STYLE_record(data):
-    # 0x0093, 0x0293
-    pass
-
-
-def analyze_SUB_record(data):
-    # 0x0091
-    pass
-
-
-def analyze_SUPBOOK_record(data):
-    # 0x01AE
-    pass
-
-
-def analyze_SXDATETIME_record(data):
-    # 0x00CE
-    pass
-
-
-def analyze_SXDB_record(data):
-    # 0x00C6
-    pass
-
-
-def analyze_SXDBEX_record(data):
-    # 0x0122
-    pass
-
-
-def analyze_SXDI_record(data):
-    # 0x00C5
-    pass
-
-
-def analyze_SXDOUBLE_record(data):
-    # 0x00C9
-    pass
-
-
-def analyze_SXEX_record(data):
-    # 0x00F1
-    pass
-
-
-def analyze_SXEXT_PARAMQRY_record(data):
-    # 0x00DC
-    pass
-
-
-def analyze_SXFDBTYPE_record(data):
-    # 0x01BB
-    pass
-
-
-def analyze_SXFIELD_record(data):
-    # 0x00C7
-    pass
-
-
-def analyze_SXFILT_record(data):
-    # 0x00F2
-    pass
-
-
-def analyze_SXFMLA_record(data):
-    # 0x00F9
-    pass
-
-
-def analyze_SXFORMAT_record(data):
-    # 0x00FB
-    pass
-
-
-def analyze_SXFORMULA_record(data):
-    # 0x0103
-    pass
-
-
-def analyze_SXIDSTM_record(data):
-    # 0x00D5
-    pass
-
-
-def analyze_SXINDEXLIST_record(data):
-    # 0x00C8
-    pass
-
-
-def analyze_SXIVD_record(data):
-    # 0x00B4
-    pass
-
-
-def analyze_SXLI_record(data):
-    # 0x00B5
-    pass
-
-
-def analyze_SXNAME_record(data):
-    # 0x00F6
-    pass
-
-
-def analyze_SXPAIR_record(data):
-    # 0x00F8
-    pass
-
-
-def analyze_SXPI_record(data):
-    # 0x00B6
-    pass
-
-
-def analyze_SXRULE_record(data):
-    # 0x00F0
-    pass
-
-
-def analyze_SXSELECT_record(data):
-    # 0x00F7
-    pass
-
-
-def analyze_SXSTRING_record(data):
-    # 0x00CD
-    pass
-
-
-def analyze_SXTBL_record(data):
-    # 0x00D0
-    pass
-
-
-def analyze_SXTBPG_record(data):
-    # 0x00D2
-    pass
-
-
-def analyze_SXTBRGITEM_record(data):
-    # 0x00D1
-    pass
-
-
-def analyze_SXVD_record(data):
-    # 0x00B1
-    pass
-
-
-def analyze_SXVDEX_record(data):
-    # 0x0100
-    pass
-
-
-def analyze_SXVI_record(data):
-    # 0x00B2
-    pass
-
-
-def analyze_SXVIEW_record(data):
-    # 0x00B0
-    pass
-
-
-def analyze_SXVS_record(data):
-    # 0x00E3
-    pass
-
-
-def analyze_TABID_record(data):
-    # 0x013D
-    pass
-
-
-def analyze_TABLE_record(data):
-    # 0x0036, 0x0236
-    pass
-
-
-def analyze_TEMPLATE_record(data):
-    # 0x0060
-    pass
-
-
-def analyze_TOPMARGIN_record(data):
-    # 0x0028
-    print struct.unpack('<d', data)[0]
-    pass
-
-
-def analyze_TXO_record(data):
-    # 0x01B6
-    pass
-
-
-def analyze_UDDESC_record(data):
-    # 0x00DF
-    pass
-
-
-def analyze_UNCALCED_record(data):
-    # 0x005E
-    pass
-
-
-def analyze_UNITS_record(data):
-    # 0x1001
-    pass
-
-
-def analyze_USERBVIEW_record(data):
-    # 0x01A9
-    pass
-
-
-def analyze_USERSVIEWBEGIN_record(data):
-    # 0x01AA
-    pass
-
-
-def analyze_USERSVIEWEND_record(data):
-    # 0x01AB
-    pass
-
-
-def analyze_USESELFS_record(data):
-    # 0x0160
-    pass
-
-
-def analyze_VCENTER_record(data):
-    # 0x0084
-    pass
-
-
-def analyze_VERTICALPAGEBREAKS_record(data):
-    # 0x001A
-    pass
-
-
-def analyze_WEBQRYSETTINGS_record(data):
-    # 0x0803
-    pass
-
-
-def analyze_WEBQRYTABLES_record(data):
-    # 0x0804
-    pass
-
-
-def analyze_WINDOW1_record(data):
-    # 0x003D
-    pass
-
-
-def analyze_WINDOW2_record(data):
-    # 0x003E, 0x023E
-    pass
-
-
-def analyze_WINDOWPROTECT_record(data):
-    # 0x0019
-    pass
-
-
-def analyze_WRITEACCESS_record(data):
-    # 0x005C
-    pass
-
-
-def analyze_WRITEPROT_record(data):
-    # 0x0086
-    pass
-
-
-def analyze_WSBOOL_record(data):
-    # 0x0081
-    pass
-
-
-def analyze_XCT_record(data):
-    # 0x0059
-    pass
-
-
-def analyze_XF_record(data):
-    # 0x0043, 0x00E0, 0x0243, 0x0443
-    #fnt_idx, num_ftm_idx, \
-    #    cell_prot,         \
-    #    align, rotation, txt_format, \
-    #    used_attrib, \
-    #    border0, border1, border2 = struct.unpack('<3H4B2LH', data)
-    #print 'fnt idx                 : 0x%000X'  % fnt_idx
-    #print 'num fmt idx             : 0x%000X'  % num_ftm_idx
-    #print 'cell is locked          : 0x%0X  '  % ((cell_prot) & 0x01)
-    #print 'format is hidden        : 0x%0X  '  % ((cell_prot & 0x02) >> 1)
-    #print 'style XF(1), cell XF(0) : 0x%0X  '  % ((cell_prot & 0x03) >> 3)
-    #print 'Index to parent style XF: 0x%0000X' % ((cell_prot & 0xFFF0) >> 4)
-
-    pass
-
-
-def analyze_XL5MODIFY_record(data):
-    # 0x0162
-    pass
-
-def analyze_XL9FILE_record(data):
-    # 0x01C0: 
-    pass
-
-all_records = {
-    0x0000: ('DIMENSIONS', analyze_DIMENSIONS_record),
-    0x0001: ('BLANK', analyze_BLANK_record),
-    0x0002: ('INTEGER', analyze_INTEGER_record),
-    0x0003: ('NUMBER', analyze_NUMBER_record),
-    0x0004: ('LABEL', analyze_LABEL_record),
-    0x0005: ('BOOLERR', analyze_BOOLERR_record),
-    0x0006: ('FORMULA', analyze_FORMULA_record),
-    0x0007: ('STRING', analyze_STRING_record),
-    0x0008: ('ROW', analyze_ROW_record),
-    0x0009: ('BOF', analyze_BOF_record),
-    0x000A: ('EOF', analyze_EOF_record),
-    0x000B: ('INDEX', analyze_INDEX_record),
-    0x000C: ('CALCCOUNT', analyze_CALCCOUNT_record),
-    0x000D: ('CALCMODE', analyze_CALCMODE_record),
-    0x000E: ('PRECISION', analyze_PRECISION_record),
-    0x000F: ('REFMODE', analyze_REFMODE_record),
-    0x0010: ('DELTA', analyze_DELTA_record),
-    0x0011: ('ITERATION', analyze_ITERATION_record),
-    0x0012: ('PROTECT', analyze_PROTECT_record),
-    0x0013: ('PASSWORD', analyze_PASSWORD_record),
-    0x0014: ('HEADER', analyze_HEADER_record),
-    0x0015: ('FOOTER', analyze_FOOTER_record),
-    0x0016: ('EXTERNCOUNT', analyze_EXTERNCOUNT_record),
-    0x0017: ('EXTERNSHEET', analyze_EXTERNSHEET_record),
-    0x0018: ('NAME', analyze_NAME_record),
-    0x0019: ('WINDOWPROTECT', analyze_WINDOWPROTECT_record),
-    0x001A: ('VERTICALPAGEBREAKS', analyze_VERTICALPAGEBREAKS_record),
-    0x001B: ('HORIZONTALPAGEBREAKS', analyze_HORIZONTALPAGEBREAKS_record),
-    0x001C: ('NOTE', analyze_NOTE_record),
-    0x001D: ('SELECTION', analyze_SELECTION_record),
-    0x001E: ('FORMAT', analyze_FORMAT_record),
-    0x001F: ('FORMATCOUNT', analyze_FORMATCOUNT_record),
-    0x0020: ('COLUMNDEFAULT', analyze_COLUMNDEFAULT_record),
-    0x0021: ('ARRAY', analyze_ARRAY_record),
-    0x0022: ('1904', analyze_1904_record),
-    0x0023: ('EXTERNNAME', analyze_EXTERNNAME_record),
-    0x0024: ('COLWIDTH', analyze_COLWIDTH_record),
-    0x0025: ('DEFAULTROWHEIGHT', analyze_DEFAULTROWHEIGHT_record),
-    0x0026: ('LEFTMARGIN', analyze_LEFTMARGIN_record),
-    0x0027: ('RIGHTMARGIN', analyze_RIGHTMARGIN_record),
-    0x0028: ('TOPMARGIN', analyze_TOPMARGIN_record),
-    0x0029: ('BOTTOMMARGIN', analyze_BOTTOMMARGIN_record),
-    0x002A: ('PRINTHEADERS', analyze_PRINTHEADERS_record),
-    0x002B: ('PRINTGRIDLINES', analyze_PRINTGRIDLINES_record),
-    0x002F: ('FILEPASS', analyze_FILEPASS_record),
-    0x0031: ('FONT', analyze_FONT_record),
-    0x0036: ('TABLE', analyze_TABLE_record),
-    0x003C: ('CONTINUE', analyze_CONTINUE_record),
-    0x003D: ('WINDOW1', analyze_WINDOW1_record),
-    0x003E: ('WINDOW2', analyze_WINDOW2_record),
-    0x0040: ('BACKUP', analyze_BACKUP_record),
-    0x0041: ('PANE', analyze_PANE_record),
-    0x0042: ('CODEPAGE', analyze_CODEPAGE_record),
-    0x0043: ('XF', analyze_XF_record),
-    0x0044: ('IXFE', analyze_IXFE_record),
-    0x0045: ('EFONT', analyze_EFONT_record),
-    0x004D: ('PLS', analyze_PLS_record),
-    0x0050: ('DCON', analyze_DCON_record),
-    0x0051: ('DCONREF', analyze_DCONREF_record),
-    0x0053: ('DCONNAME', analyze_DCONNAME_record),
-    0x0055: ('DEFCOLWIDTH', analyze_DEFCOLWIDTH_record),
-    0x0056: ('BUILTINFMTCNT', analyze_BUILTINFMTCNT_record),
-    0x0059: ('XCT', analyze_XCT_record),
-    0x005A: ('CRN', analyze_CRN_record),
-    0x005B: ('FILESHARING', analyze_FILESHARING_record),
-    0x005C: ('WRITEACCESS', analyze_WRITEACCESS_record),
-    0x005D: ('OBJ', analyze_OBJ_record),
-    0x005E: ('UNCALCED', analyze_UNCALCED_record),
-    0x005F: ('SAFERECALC', analyze_SAFERECALC_record),
-    0x0060: ('TEMPLATE', analyze_TEMPLATE_record),
-    0x0063: ('OBJPROTECT', analyze_OBJPROTECT_record),
-    0x007D: ('COLINFO', analyze_COLINFO_record),
-    0x007E: ('RK', analyze_RK_record),
-    0x007F: ('IMDATA', analyze_IMDATA_record),
-    0x0080: ('GUTS', analyze_GUTS_record),
-    0x0081: ('WSBOOL', analyze_WSBOOL_record),
-    0x0082: ('GRIDSET', analyze_GRIDSET_record),
-    0x0083: ('HCENTER', analyze_HCENTER_record),
-    0x0084: ('VCENTER', analyze_VCENTER_record),
-    0x0085: ('BOUNDSHEET', analyze_BOUNDSHEET_record),
-    0x0086: ('WRITEPROT', analyze_WRITEPROT_record),
-    0x0087: ('ADDIN', analyze_ADDIN_record),
-    0x0088: ('EDG', analyze_EDG_record),
-    0x0089: ('PUB', analyze_PUB_record),
-    0x008C: ('COUNTRY', analyze_COUNTRY_record),
-    0x008D: ('HIDEOBJ', analyze_HIDEOBJ_record),
-    0x008E: ('BUNDLESOFFSET', analyze_BUNDLESOFFSET_record),
-    0x008F: ('BUNDLEHEADER', analyze_BUNDLEHEADER_record),
-    0x0090: ('SORT', analyze_SORT_record),
-    0x0091: ('SUB', analyze_SUB_record),
-    0x0092: ('PALETTE', analyze_PALETTE_record),
-    0x0093: ('STYLE', analyze_STYLE_record),
-    0x0094: ('LHRECORD', analyze_LHRECORD_record),
-    0x0095: ('LHNGRAPH', analyze_LHNGRAPH_record),
-    0x0096: ('SOUND', analyze_SOUND_record),
-    0x0098: ('LPR', analyze_LPR_record),
-    0x0099: ('STANDARDWIDTH', analyze_STANDARDWIDTH_record),
-    0x009A: ('FNGROUPNAME', analyze_FNGROUPNAME_record),
-    0x009B: ('FILTERMODE', analyze_FILTERMODE_record),
-    0x009C: ('FNGROUPCOUNT', analyze_FNGROUPCOUNT_record),
-    0x009D: ('AUTOFILTERINFO', analyze_AUTOFILTERINFO_record),
-    0x009E: ('AUTOFILTER', analyze_AUTOFILTER_record),
-    0x00A0: ('SCL', analyze_SCL_record),
-    0x00A1: ('SETUP', analyze_SETUP_record),
-    0x00A9: ('COORDLIST', analyze_COORDLIST_record),
-    0x00AB: ('GCW', analyze_GCW_record),
-    0x00AE: ('SCENMAN', analyze_SCENMAN_record),
-    0x00AF: ('SCENARIO', analyze_SCENARIO_record),
-    0x00B0: ('SXVIEW', analyze_SXVIEW_record),
-    0x00B1: ('SXVD', analyze_SXVD_record),
-    0x00B2: ('SXVI', analyze_SXVI_record),
-    0x00B4: ('SXIVD', analyze_SXIVD_record),
-    0x00B5: ('SXLI', analyze_SXLI_record),
-    0x00B6: ('SXPI', analyze_SXPI_record),
-    0x00B8: ('DOCROUTE', analyze_DOCROUTE_record),
-    0x00B9: ('RECIPNAME', analyze_RECIPNAME_record),
-    0x00BC: ('SHRFMLA', analyze_SHRFMLA_record),
-    0x00BD: ('MULRK', analyze_MULRK_record),
-    0x00BE: ('MULBLANK', analyze_MULBLANK_record),
-    0x00C1: ('MMS', analyze_MMS_record),
-    0x00C2: ('ADDMENU', analyze_ADDMENU_record),
-    0x00C3: ('DELMENU', analyze_DELMENU_record),
-    0x00C5: ('SXDI', analyze_SXDI_record),
-    0x00C6: ('SXDB', analyze_SXDB_record),
-    0x00C7: ('SXFIELD', analyze_SXFIELD_record),
-    0x00C8: ('SXINDEXLIST', analyze_SXINDEXLIST_record),
-    0x00C9: ('SXDOUBLE', analyze_SXDOUBLE_record),
-    0x00CD: ('SXSTRING', analyze_SXSTRING_record),
-    0x00CE: ('SXDATETIME', analyze_SXDATETIME_record),
-    0x00D0: ('SXTBL', analyze_SXTBL_record),
-    0x00D1: ('SXTBRGITEM', analyze_SXTBRGITEM_record),
-    0x00D2: ('SXTBPG', analyze_SXTBPG_record),
-    0x00D3: ('OBPROJ', analyze_OBPROJ_record),
-    0x00D5: ('SXIDSTM', analyze_SXIDSTM_record),
-    0x00D6: ('RSTRING', analyze_RSTRING_record),
-    0x00D7: ('DBCELL', analyze_DBCELL_record),
-    0x00DA: ('BOOKBOOL', analyze_BOOKBOOL_record),
-    0x00DC: ('SXEXT|PARAMQRY', analyze_SXEXT_PARAMQRY_record),
-    0x00DD: ('SCENPROTECT', analyze_SCENPROTECT_record),
-    0x00DE: ('OLESIZE', analyze_OLESIZE_record),
-    0x00DF: ('UDDESC', analyze_UDDESC_record),
-    0x00E0: ('XF', analyze_XF_record),
-    0x00E1: ('INTERFACEHDR', analyze_INTERFACEHDR_record),
-    0x00E2: ('INTERFACEEND', analyze_INTERFACEEND_record),
-    0x00E3: ('SXVS', analyze_SXVS_record),
-    0x00E5: ('MERGEDCELLS', analyze_MERGEDCELLS_record),
-    0x00E9: ('BITMAP', analyze_BITMAP_record),
-    0x00EB: ('MSODRAWINGGROUP', analyze_MSODRAWINGGROUP_record),
-    0x00EC: ('MSODRAWING', analyze_MSODRAWING_record),
-    0x00ED: ('MSODRAWINGSELECTION', analyze_MSODRAWINGSELECTION_record),
-    0x00F0: ('SXRULE', analyze_SXRULE_record),
-    0x00F1: ('SXEX', analyze_SXEX_record),
-    0x00F2: ('SXFILT', analyze_SXFILT_record),
-    0x00F6: ('SXNAME', analyze_SXNAME_record),
-    0x00F7: ('SXSELECT', analyze_SXSELECT_record),
-    0x00F8: ('SXPAIR', analyze_SXPAIR_record),
-    0x00F9: ('SXFMLA', analyze_SXFMLA_record),
-    0x00FB: ('SXFORMAT', analyze_SXFORMAT_record),
-    0x00FC: ('SST', analyze_SST_record),
-    0x00FD: ('LABELSST', analyze_LABELSST_record),
-    0x00FF: ('EXTSST', analyze_EXTSST_record),
-    0x0100: ('SXVDEX', analyze_SXVDEX_record),
-    0x0103: ('SXFORMULA', analyze_SXFORMULA_record),
-    0x0122: ('SXDBEX', analyze_SXDBEX_record),
-    0x0137: ('CHTRINSERT', analyze_CHTRINSERT_record),
-    0x0138: ('CHTRINFO', analyze_CHTRINFO_record),
-    0x013B: ('CHTRCELLCONTENT', analyze_CHTRCELLCONTENT_record),
-    0x013D: ('TABID', analyze_TABID_record),
-    0x0140: ('CHTRMOVERANGE', analyze_CHTRMOVERANGE_record),
-    0x014D: ('CHTRINSERTTAB', analyze_CHTRINSERTTAB_record),
-    0x015F: ('LABELRANGES', analyze_LABELRANGES_record),
-    0x0160: ('USESELFS', analyze_USESELFS_record),
-    0x0161: ('DSF', analyze_DSF_record),
-    0x0162: ('XL5MODIFY', analyze_XL5MODIFY_record),
-    0x0196: ('CHTRHEADER', analyze_CHTRHEADER_record),
-    0x01A9: ('USERBVIEW', analyze_USERBVIEW_record),
-    0x01AA: ('USERSVIEWBEGIN', analyze_USERSVIEWBEGIN_record),
-    0x01AB: ('USERSVIEWEND', analyze_USERSVIEWEND_record),
-    0x01AD: ('QSI', analyze_QSI_record),
-    0x01AE: ('SUPBOOK', analyze_SUPBOOK_record),
-    0x01AF: ('PROT4REV', analyze_PROT4REV_record),
-    0x01B0: ('CONDFMT', analyze_CONDFMT_record),
-    0x01B1: ('CF', analyze_CF_record),
-    0x01B2: ('DVAL', analyze_DVAL_record),
-    0x01B5: ('DCONBIN', analyze_DCONBIN_record),
-    0x01B6: ('TXO', analyze_TXO_record),
-    0x01B7: ('REFRESHALL', analyze_REFRESHALL_record),
-    0x01B8: ('HLINK', analyze_HLINK_record),
-    0x01BA: ('CODENAME', analyze_CODENAME_record),
-    0x01BB: ('SXFDBTYPE', analyze_SXFDBTYPE_record),
-    0x01BC: ('PROT4REVPASS', analyze_PROT4REVPASS_record),
-    0x01BE: ('DV', analyze_DV_record),
-    0x01C0: ('XL9FILE', analyze_XL9FILE_record),
-    0x01C1: ('RECALCID',analyze_RECALCID_record),
-    0x0200: ('DIMENSIONS', analyze_DIMENSIONS_record),
-    0x0201: ('BLANK', analyze_BLANK_record),
-    0x0203: ('NUMBER', analyze_NUMBER_record),
-    0x0204: ('LABEL', analyze_LABEL_record),
-    0x0205: ('BOOLERR', analyze_BOOLERR_record),
-    0x0206: ('FORMULA', analyze_FORMULA_record),
-    0x0207: ('STRING', analyze_STRING_record),
-    0x0208: ('ROW', analyze_ROW_record),
-    0x0209: ('BOF', analyze_BOF_record),
-    0x020B: ('INDEX', analyze_INDEX_record),
-    0x0218: ('NAME', analyze_NAME_record),
-    0x0221: ('ARRAY', analyze_ARRAY_record),
-    0x0223: ('EXTERNNAME', analyze_EXTERNNAME_record),
-    0x0225: ('DEFAULTROWHEIGHT', analyze_DEFAULTROWHEIGHT_record),
-    0x0231: ('FONT', analyze_FONT_record),
-    0x0236: ('TABLE', analyze_TABLE_record),
-    0x023E: ('WINDOW2', analyze_WINDOW2_record),
-    0x0243: ('XF', analyze_XF_record),
-    0x027E: ('RK', analyze_RK_record),
-    0x0293: ('STYLE', analyze_STYLE_record),
-    0x0406: ('FORMULA', analyze_FORMULA_record),
-    0x0409: ('BOF', analyze_BOF_record),
-    0x041E: ('FORMAT', analyze_FORMAT_record),
-    0x0443: ('XF', analyze_XF_record),
-    0x04BC: ('SHRFMLA', analyze_SHRFMLA_record),
-    0x0800: ('SCREENTIP', analyze_SCREENTIP_record),
-    0x0803: ('WEBQRYSETTINGS', analyze_WEBQRYSETTINGS_record),
-    0x0804: ('WEBQRYTABLES', analyze_WEBQRYTABLES_record),
-    0x0809: ('BOF', analyze_BOF_record),
-    0x0862: ('SHEETLAYOUT', analyze_SHEETLAYOUT_record),
-    0x0867: ('SHEETPROTECTION', analyze_SHEETPROTECTION_record),
-    0x1001: ('UNITS', analyze_UNITS_record),
-    0x1002: ('ChartChart', analyze_ChartChart_record),
-    0x1003: ('ChartSeries', analyze_ChartSeries_record),
-    0x1006: ('ChartDataformat', analyze_ChartDataformat_record),
-    0x1007: ('ChartLineformat', analyze_ChartLineformat_record),
-    0x1009: ('ChartMarkerformat', analyze_ChartMarkerformat_record),
-    0x100A: ('ChartAreaformat', analyze_ChartAreaformat_record),
-    0x100B: ('ChartPieformat', analyze_ChartPieformat_record),
-    0x100C: ('ChartAttachedlabel', analyze_ChartAttachedlabel_record),
-    0x100D: ('ChartSeriestext', analyze_ChartSeriestext_record),
-    0x1014: ('ChartChartformat', analyze_ChartChartformat_record),
-    0x1015: ('ChartLegend', analyze_ChartLegend_record),
-    0x1016: ('ChartSerieslist', analyze_ChartSerieslist_record),
-    0x1017: ('ChartBar', analyze_ChartBar_record),
-    0x1018: ('ChartLine', analyze_ChartLine_record),
-    0x1019: ('ChartPie', analyze_ChartPie_record),
-    0x101A: ('ChartArea', analyze_ChartArea_record),
-    0x101B: ('ChartScatter', analyze_ChartScatter_record),
-    0x101C: ('ChartChartline', analyze_ChartChartline_record),
-    0x101D: ('ChartAxis', analyze_ChartAxis_record),
-    0x101E: ('ChartTick', analyze_ChartTick_record),
-    0x101F: ('ChartValuerange', analyze_ChartValuerange_record),
-    0x1020: ('ChartCatserrange', analyze_ChartCatserrange_record),
-    0x1021: ('ChartAxislineformat', analyze_ChartAxislineformat_record),
-    0x1022: ('ChartFormatlink', analyze_ChartFormatlink_record),
-    0x1024: ('ChartDefaulttext', analyze_ChartDefaulttext_record),
-    0x1025: ('ChartText', analyze_ChartText_record),
-    0x1026: ('ChartFontx', analyze_ChartFontx_record),
-    0x1027: ('ChartObjectLink', analyze_ChartObjectLink_record),
-    0x1032: ('ChartFrame', analyze_ChartFrame_record),
-    0x1033: ('BEGIN', analyze_BEGIN_record),
-    0x1034: ('END', analyze_END_record),
-    0x1035: ('ChartPlotarea', analyze_ChartPlotarea_record),
-    0x103A: ('Chart3D', analyze_Chart3D_record),
-    0x103C: ('ChartPicf', analyze_ChartPicf_record),
-    0x103D: ('ChartDropbar', analyze_ChartDropbar_record),
-    0x103E: ('ChartRadar', analyze_ChartRadar_record),
-    0x103F: ('ChartSurface', analyze_ChartSurface_record),
-    0x1040: ('ChartRadararea', analyze_ChartRadararea_record),
-    0x1041: ('ChartAxisparent', analyze_ChartAxisparent_record),
-    0x1043: ('ChartLegendxn', analyze_ChartLegendxn_record),
-    0x1044: ('ChartShtprops', analyze_ChartShtprops_record),
-    0x1045: ('ChartSertocrt', analyze_ChartSertocrt_record),
-    0x1046: ('ChartAxesused', analyze_ChartAxesused_record),
-    0x1048: ('ChartSbaseref', analyze_ChartSbaseref_record),
-    0x104A: ('ChartSerparent', analyze_ChartSerparent_record),
-    0x104B: ('ChartSerauxtrend', analyze_ChartSerauxtrend_record),
-    0x104E: ('ChartIfmt', analyze_ChartIfmt_record),
-    0x104F: ('ChartPos', analyze_ChartPos_record),
-    0x1050: ('ChartAlruns', analyze_ChartAlruns_record),
-    0x1051: ('ChartAI', analyze_ChartAI_record),
-    0x105B: ('ChartSerauxerrbar', analyze_ChartSerauxerrbar_record),
-    0x105D: ('ChartSerfmt', analyze_ChartSerfmt_record),
-    0x105F: ('Chart3DDataFormat', analyze_Chart3DDataFormat_record),
-    0x1060: ('ChartFbi', analyze_ChartFbi_record),
-    0x1061: ('ChartBoppop', analyze_ChartBoppop_record),
-    0x1062: ('ChartAxcext', analyze_ChartAxcext_record),
-    0x1063: ('ChartDat', analyze_ChartDat_record),
-    0x1064: ('ChartPlotgrowth', analyze_ChartPlotgrowth_record),
-    0x1065: ('ChartSiindex', analyze_ChartSiindex_record),
-    0x1066: ('ChartGelframe', analyze_ChartGelframe_record),
-    0x1067: ('ChartBoppcustom', analyze_ChartBoppcustom_record),
-    0xFFFF: ('', None)
-}
-if __name__ == '__main__':
-    for r in all_records:
-        if all_records[r][1]:
-            all_records[r][1]('analyze it!')
-            

+ 0 - 143
desktop/core/ext-py/pyexcelerator/tools/biff-dumper.py

@@ -1,143 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-__rev_id__ = """$Id: biff-dumper.py,v 1.5 2005/10/26 07:44:24 rvk Exp $"""
-
-
-import Analyzer
-from pyExcelerator import *
-import sys
-from struct import unpack
-
-
-def print_bin_data(data):
-    print
-    i = 0
-    while i < len(data):
-        j = 0
-        while (i < len(data)) and (j < 16):
-            c = '0x%02X' % ord(data[i])
-            sys.stdout.write(c)
-            sys.stdout.write(' ')
-            i += 1
-            j += 1
-        print
-    if i == 0:
-        print '<NO DATA>'
-
-
-def print_ASCII_data(data):
-    print
-    i = 0
-    while i < len(data):
-        j = 0
-        while (i < len(data)) and (j < 16):
-            if data[i] < ' ':
-                c = '.'
-            else:
-                c = data[i]
-            sys.stdout.write(c)
-            i += 1
-            j += 1
-        print
-    if i == 0:
-        print '<NO DATA>'
-
-
-def main():
-    if len(sys.argv) < 2:
-        print 'no input files.'
-        sys.exit(1)
-
-    # Inside MS Office document looks like filesystem
-    # We need extract stream named 'Workbook' or 'Book'
-    ole_streams = CompoundDoc.Reader(sys.argv[1], True).STREAMS
-
-    if 'Workbook' in ole_streams:
-        workbook_stream = ole_streams['Workbook']
-    elif 'Book' in ole_streams:
-        workbook_stream = ole_streams['Book']
-    else:
-        raise Exception, 'No workbook stream in file.'
-
-    wb_bin_data_len = len(workbook_stream)
-    stream_pos = 0
-    
-    print 'workbook stream size 0x%X bytes '% len(workbook_stream)
-
-    # Excel's method of data storing is based on 
-    # ancient technology "TLV" (Type, Length, Value).
-    # In addition, if record size grows to some limit
-    # Excel writes CONTINUE records
-    ws_num = 0
-    EOFs = 0
-    while stream_pos < len(workbook_stream) and EOFs <= ws_num:
-        # header size == 4
-        print 'stream position:', '0x%08X' % stream_pos
-        header = workbook_stream[stream_pos:stream_pos+4]
-        rec_id, data_size = unpack('<2H', header)
-        print 'rec id:', '0x%04X' % rec_id
-        print 'rec data size:', '0x%04X' % data_size
-        stream_pos += 4
-        rec_data = workbook_stream[stream_pos:stream_pos+data_size]
-        stream_pos += data_size
-
-        if rec_id == 0x000A:   # EOF 
-            EOFs += 1
-        elif rec_id == 0x0085: # BOUNDSHEET
-            ws_num += 1
-        
-        if rec_id in Analyzer.all_records:
-            rec_name, analyzer_func = Analyzer.all_records[rec_id]
-
-            print 'rec name:', rec_name
-            print 'rec data:',
-            print_bin_data(rec_data)
-            print 'ASCII data:',
-            print_ASCII_data(rec_data)
-            print 'analyzing...'
-            analyzer_func(rec_data)
-        else:
-            print '<UNKNOWN RECORD>: rec_id == 0x%04X, size 0x%04X bytes' % (rec_id, data_size)
-        print '---------------'
-
-
-main()

+ 0 - 55
desktop/core/ext-py/pyexcelerator/tools/compdoc-dumper.py

@@ -1,55 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-
-#  Copyright (C) 2005 Roman V. Kiseliov
-#  All rights reserved.
-# 
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-# 
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-# 
-#  3. All advertising materials mentioning features or use of this
-#     software must display the following acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  4. Redistributions of any form whatsoever must retain the following
-#     acknowledgment:
-#     "This product includes software developed by
-#      Roman V. Kiseliov <roman@kiseliov.ru>."
-# 
-#  THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
-#  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Roman V. Kiseliov OR
-#  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-#  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-#  OF THE POSSIBILITY OF SUCH DAMAGE.
-
-__rev_id__ = """$Id: compdoc-dumper.py,v 1.10 2005/10/26 07:44:24 rvk Exp $"""
-
-
-import sys, struct
-from pyExcelerator import *
-
-def main():
-    if len(sys.argv) < 2:
-        print 'no input files.'
-        print sys.exit(1)
-
-    CompoundDoc.Reader(sys.argv[1], True)        
-
-main()

+ 0 - 79
desktop/core/ext-py/pyexcelerator/tools/xls2csv-gerry.py

@@ -1,79 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: xls2csv-gerry.py,v 1.1 2005/10/26 07:44:24 rvk Exp $"""
-
-###--xls2csv.py
-###--modified by gerry 10/5/2005
-###--with args, processes just those files
-###--with no args, processes all csvs in the current directory
-###--args may include or exclude the .xls suffix
-###--no files are written for empty sheets
-
-from    pyExcelerator import *
-import  re
-import  os
-import  sys
-
-def process(fname):
-    
-    if fname[-4:] != ".xls": 
-        fname = fname + ".xls"    
-   
-    print "processing", fname
-    
-    for sheet_name, values in parse_xls(fname, 'cp1251'): # parse_xls(arg) -- default encoding
-        print "     starting", sheet_name,
-        
-        keys = values.keys()
-        
-        rows    = []
-        cols    = []
-        for key in keys:
-            row, col = key
-            if not col in cols: cols.append(col)
-            if not row in rows: rows.append(row)
-        
-        try:    n_rows = max(rows)
-        except:
-            print "which is null." 
-            continue
-        n_cols = max(cols)
-        print "which has", n_rows+1, "rows, and", n_cols+1, "columns."
-        
-        ofile = open(fname + "." + sheet_name + ".csv",     "w")
-        
-        for row in range(n_rows+1):
-            line = ""
-            for col in range(n_cols+1):
-                try:    cell = str(values[(row, col)])
-                except: cell = ""
-                if commas.search(cell) != None: cell = '"' + cell + '"'
-                line = line + cell + ","
-            print >> ofile, line[:-1]
-            
-        ofile.close()
-        
-    print '----------------'
-
-commas = re.compile(",")
-
-try:    args = sys.argv[1:]
-except: args = []
-
-if len(args) < 1:
-    fnames = os.listdir(".")
-    fnames.sort()
-    for fname in fnames:
-        parts = fname.split(".")
-        if parts[-1] != "xls": continue
-        process(fname) 
-    sys.exit()
-else:
-    for arg in args:
-        process(arg)
-
-    
-    
-    

+ 0 - 45
desktop/core/ext-py/pyexcelerator/tools/xls2csv.py

@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: xls2csv.py,v 1.1 2005/10/26 07:44:24 rvk Exp $"""
-
-
-from pyExcelerator import *
-import sys
-
-me, args = sys.argv[0], sys.argv[1:]
-
-
-if args:
-    for arg in args:
-        print >>sys.stderr, 'extracting data from', arg
-        for sheet_name, values in parse_xls(arg, 'cp1251'): # parse_xls(arg) -- default encoding
-            matrix = [[]]
-            print 'Sheet = "%s"' % sheet_name.encode('cp866', 'backslashreplace')
-            print '----------------'
-            for row_idx, col_idx in sorted(values.keys()):
-                v = values[(row_idx, col_idx)]
-                if isinstance(v, unicode):
-                    v = v.encode('cp866', 'backslashreplace')
-                else:
-                    v = `v`
-                v = '"%s"' % v.strip()
-                last_row, last_col = len(matrix), len(matrix[-1])
-                while last_row <= row_idx:
-                    matrix.extend([[]])
-                    last_row = len(matrix)
-
-                while last_col < col_idx:
-                    matrix[-1].extend([''])
-                    last_col = len(matrix[-1])
-
-                matrix[-1].extend([v])
-                    
-            for row in matrix:
-                csv_row = ', '.join(row)
-                print csv_row
-
-else:
-    print 'usage: %s (inputfile)+' % me
-

+ 0 - 52
desktop/core/ext-py/pyexcelerator/tools/xls2html.py

@@ -1,52 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: xls2html.py,v 1.1 2005/10/26 07:44:24 rvk Exp $"""
-
-
-from pyExcelerator import *
-import sys
-
-me, args = sys.argv[0], sys.argv[1:]
-
-
-if args:
-    for arg in args:
-        print >>sys.stderr, 'extracting data from', arg
-        print '<html>'
-        for sheet_name, values in parse_xls(arg, 'cp1251'): # parse_xls(arg) -- default encoding
-            matrix = [[]]
-            print 'Sheet = "%s"' % sheet_name.encode('cp1251', 'backslashreplace')
-            print '<table border="2" cellpadding="1" cellspacing="1" >'
-
-            for row_idx, col_idx in sorted(values.keys()):
-                v = values[(row_idx, col_idx)]
-                if isinstance(v, unicode):
-                    v = v.encode('cp1251', 'backslashreplace')
-                else:
-                    v = `v`
-                v = '"%s"' % v.strip()
-                last_row, last_col = len(matrix), len(matrix[-1])
-                while last_row <= row_idx:
-                    matrix.extend([[]])
-                    last_row = len(matrix)
-
-                while last_col < col_idx:
-                    matrix[-1].extend([''])
-                    last_col = len(matrix[-1])
-
-                matrix[-1].extend([v])
-                    
-            for row in matrix:
-                print '<tr>'
-                for col in row:
-                    print '<td> %s </td>' % col
-                print '</tr>'
-
-            print '</table>'
-        print '</html>'
-
-else:
-    print 'usage: %s (inputfile)+' % me
-

+ 0 - 29
desktop/core/ext-py/pyexcelerator/tools/xls2txt.py

@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: windows-1251 -*-
-# Copyright (C) 2005 Kiseliov Roman
-
-__rev_id__ = """$Id: xls2txt.py,v 1.1 2005/10/26 07:44:24 rvk Exp $"""
-
-
-from pyExcelerator import *
-import sys
-
-me, args = sys.argv[0], sys.argv[1:]
-
-if args:
-    for arg in args:
-        print >>sys.stderr, 'extracting data from', arg
-        for sheet_name, values in parse_xls(arg, 'cp1251'): # parse_xls(arg) -- default encoding
-            print 'Sheet = "%s"' % sheet_name.encode('cp866', 'backslashreplace')
-            print '----------------'
-            for row_idx, col_idx in sorted(values.keys()):
-                v = values[(row_idx, col_idx)]
-                if isinstance(v, unicode):
-                    v = v.encode('cp866', 'backslashreplace')
-                else:
-                    v = `v`
-                print '(%d, %d) =' % (row_idx, col_idx), v
-            print '----------------'
-else:
-    print 'usage: %s (inputfile)+' % me
-

+ 2 - 51
desktop/core/src/desktop/lib/export_csvxls.py

@@ -17,13 +17,12 @@
 """
 Common library to export either CSV or XLS.
 """
-import pyExcelerator as xl
 import cStringIO
 import csv
 import logging
 
 from django.http import HttpResponse
-from django.utils.encoding import smart_str, force_unicode
+from django.utils.encoding import smart_str
 from desktop.lib import i18n
 
 LOG = logging.getLogger(__name__)
@@ -102,7 +101,7 @@ def make_response(header, data, format, name, encoding=None):
     formatter = CSVformatter(encoding)
     mimetype = 'application/csv'
   elif format == 'xls':
-    formatter = XLSformatter(encoding)
+    formatter = CSVformatter(encoding)
     mimetype = 'application/xls'
   else:
     raise Exception("Unknown format: %s" % (format,))
@@ -137,51 +136,3 @@ class CSVformatter(Formatter):
 
   def fini_doc(self):
     return ""
-
-class XLSformatter(Formatter):
-  """Unfortunately, pyExcelerator can't stream."""
-  def __init__(self, encoding=None):
-    super(XLSformatter, self).__init__()
-    self._encoding = encoding or i18n.get_site_encoding()
-    self._book = xl.Workbook()
-    self._sheet = self._book.add_sheet("Sheet 1")
-    self._row = 0
-    self._size = 0
-
-  def init_doc(self):
-    return ''
-
-  def _decode_cell(self, cell):
-    """PyExcelerator happily takes unicode. So first decode binary data."""
-    return force_unicode(cell, self._encoding, strings_only=True, errors='replace')
-
-  def format_header(self, header):
-    for i, cell in enumerate(header):
-      self._sheet.write(self._row, i, self._decode_cell(cell))
-    self._row += 1
-    return ''
-
-  def format_row(self, row):
-    for i, cell in enumerate(row):
-      self._sheet.write(self._row, i, self._decode_cell(cell))
-      self._limit_size(cell)
-    self._row += 1
-    return ''
-
-  def fini_doc(self):
-    string_io = cStringIO.StringIO()
-    self._book.save(string_io)
-    res = string_io.getvalue()
-    string_io.close()
-    return res
-
-  def _limit_size(self, cell):
-    # Coerce cell to a string
-    if not isinstance(cell, basestring):
-      cell = str(cell)
-    self._size += len(cell)
-    if self._size > XLS_SIZE_LIMIT:
-      msg = 'ERROR: Data too large to be downloaded as XLS file.'
-      self._row += 1
-      self._sheet.write(self._row, 0, msg)
-      raise TooBigToDownloadException(msg)

+ 2 - 40
desktop/core/src/desktop/lib/test_export_csvxls.py

@@ -15,7 +15,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import pyExcelerator as xl
 import cStringIO
 from desktop.lib.export_csvxls import make_response
 from nose.tools import assert_true, assert_equal, assert_false
@@ -31,45 +30,8 @@ def test_export_csvxls():
   assert_equal("attachment; filename=foo.csv", response["content-disposition"])
 
   # Check XLS
+  # Should be same as CSV
   response = make_response(header, data, "xls", "bar")
   assert_equal("application/xls", response["content-type"])
   assert_equal("attachment; filename=bar.xls", response["content-disposition"])
-  assert_equal('"x","y"\r\n"1","2"\r\n"3","4"\r\n', xls2csv(response.content))
-
-
-
-def xls2csv(data_str):
-  """
-  Modification of xls2csv.py from pyExcelerator. BSD license.
-  Copyright (C) 2005 Kiseliov Roman
-  """
-  buf_in = cStringIO.StringIO(data_str)
-  buf_out = cStringIO.StringIO()
-  for sheet_name, values in xl.parse_xls(buf_in, 'cp1251'): # parse_xls(arg) -- default encoding
-    matrix = [[]]
-    for row_idx, col_idx in sorted(values.keys()):
-      v = values[(row_idx, col_idx)]
-      if isinstance(v, unicode):
-        v = v.encode('cp866', 'backslashreplace')
-      else:
-        v = `v`
-      v = '"%s"' % v.strip()
-      last_row, last_col = len(matrix), len(matrix[-1])
-      while last_row <= row_idx:
-        matrix.extend([[]])
-        last_row = len(matrix)
-
-      while last_col < col_idx:
-        matrix[-1].extend([''])
-        last_col = len(matrix[-1])
-
-      matrix[-1].extend([v])
-
-    for row in matrix:
-      csv_row = ','.join(row)
-      buf_out.write(csv_row + '\r\n')
-
-  res = buf_out.getvalue()
-  buf_in.close()
-  buf_out.close()
-  return res
+  assert_equal('"x","y"\r\n"1","2"\r\n"3","4"\r\n', response.content)

+ 0 - 1
ext/thirdparty/README.md

@@ -30,7 +30,6 @@ Checked-in third party dependencies
 |Y|Markdown|2.0.3|BSD|http://pypi.python.org/packages/source/M/Markdown/Markdown-2.0.3.tar.gz|
 |Y|MarkupSafe|0.9.3|BSD|http://pypi.python.org/pypi/MarkupSafe|
 |Y|processing|0.52|BSD|http://developer.berlios.de/projects/pyprocessing|
-|Y|pyexelerator|0.6.4.1|BSD|http://sourceforge.net/projects/pyexcelerator|
 |Y|Pygments|1.3.1|BSD|http://pypi.python.org/pypi/Pygments|
 |Y|pysqlite|2.55|zlib/libpng|http://oss.itsystementwicklung.de/download/pysqlite/2.5/2.5.5/|
 |Y|python-daemon|1.5.1|Python|http://pypi.python.org/pypi/python-daemon/|