Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactoring CFB

  • Loading branch information...
commit b58d3ef1e9e45c8bd27e6aec2b9b1c12d426cea1 1 parent 5389155
@Niggler Niggler authored
Showing with 110 additions and 110 deletions.
  1. +0 −1  README.md
  2. +110 −2 cfb.js
  3. +0 −106 consts.js
  4. +0 −1  testxls.html
View
1  README.md
@@ -12,7 +12,6 @@ THERE ARE PLANS FOR AN NPM MODULE (you can just require a few files and magic ha
In the browser:
- <script src="consts.js"></script>
<script src="xlsconsts.js"></script>
<script src="cfb.js"></script>
<script src="xls.js"></script>
View
112 cfb.js
@@ -516,10 +516,118 @@ this.parse = parse;
return this;
})();
+{ /* Constants */
+// Property Types 2.2 Table
+{
+ var VT_EMPTY = 0x0000;
+ var VT_NULL = 0x0001;
+ var VT_I2 = 0x0002;
+ var VT_I4 = 0x0003;
+ var VT_R4 = 0x0004;
+ var VT_R8 = 0x0005;
+ var VT_CY = 0x0006;
+ var VT_DATE = 0x0007;
+ var VT_BSTR = 0x0008;
+ var VT_ERROR = 0x000A;
+ var VT_BOOL = 0x000B;
+ var VT_VARIANT = 0x000C;
+ var VT_DECIMAL = 0x000E;
+ var VT_I1 = 0x0010;
+ var VT_UI1 = 0x0011;
+ var VT_UI2 = 0x0012;
+ var VT_UI4 = 0x0013;
+ var VT_I8 = 0x0014;
+ var VT_UI8 = 0x0015;
+ var VT_INT = 0x0016;
+ var VT_UINT = 0x0017;
+ var VT_LPSTR = 0x001E;
+ var VT_LPWSTR = 0x001F;
+ var VT_FILETIME = 0x0040;
+ var VT_BLOB = 0x0041;
+ var VT_STREAM = 0x0042;
+ var VT_STORAGE = 0x0043;
+ var VT_STREAMED_Object = 0x0044;
+ var VT_STORED_Object = 0x0045;
+ var VT_BLOB_Object = 0x0046;
+ var VT_CF = 0x0047;
+ var VT_CLSID = 0x0048;
+ var VT_VERSIONED_STREAM = 0x0049;
+ var VT_VECTOR = 0x1000;
+ var VT_ARRAY = 0x2000;
+
+ var VT_STRING = 0x0050; // 2.3.3.1.11 VtString
+ var VT_CUSTOM = [VT_STRING];
+}
+
+/* MS-OSHARED 2.3.3.2.2.1 Document Summary Information PIDDSI */
+var DocSummaryPIDDSI = {
+ 0x01: { n: 'CodePage', t: VT_I2 },
+ 0x02: { n: 'Category', t: VT_STRING },
+ 0x03: { n: 'PresentationFormat', t: VT_STRING },
+ 0x04: { n: 'ByteCount', t: VT_I4 },
+ 0x05: { n: 'LineCount', t: VT_I4 },
+ 0x06: { n: 'ParagraphCount', t: VT_I4 },
+ 0x07: { n: 'SlideCount', t: VT_I4 },
+ 0x08: { n: 'NoteCount', t: VT_I4 },
+ 0x09: { n: 'HiddenCount', t: VT_I4 },
+ 0x0a: { n: 'MultimediaClipCount', t: VT_I4 },
+ 0x0b: { n: 'Scale', t: VT_BOOL },
+ 0x0c: { n: 'HeadingPair', t: VT_VECTOR | VT_VARIANT },
+ 0x0d: { n: 'DocParts', t: VT_VECTOR | VT_LPSTR },
+ 0x0e: { n: 'Manager', t: VT_STRING },
+ 0x0f: { n: 'Company', t: VT_STRING },
+ 0x10: { n: 'LinksDirty', t: VT_BOOL },
+ 0x11: { n: 'CharacterCount', t: VT_I4 },
+ 0x13: { n: 'SharedDoc', t: VT_BOOL },
+ 0x16: { n: 'HLinksChanged', t: VT_BOOL },
+ 0x17: { n: 'Version', t: VT_I4 },
+ 0xFF: {}
+};
+
+var SummaryPIDSI = {
+ 0x01: { n: 'CodePage', t: VT_I2 },
+ 0x02: { n: 'Title', t: VT_LPSTR },
+ 0x03: { n: 'Subject', t: VT_LPSTR },
+ 0x04: { n: 'Author', t: VT_LPSTR },
+ 0x05: { n: 'Keywords', t: VT_LPSTR },
+ 0x06: { n: 'Comments', t: VT_LPSTR },
+ 0x07: { n: 'Template', t: VT_LPSTR },
+ 0x08: { n: 'LastAuthor', t: VT_LPSTR },
+ 0x09: { n: 'RevNumber', t: VT_LPSTR },
+ 0x0A: { n: 'EditTime', t: VT_FILETIME },
+ 0x0B: { n: 'LastPrinted', t: VT_FILETIME },
+ 0x0C: { n: 'CreateTime', t: VT_FILETIME },
+ 0x0D: { n: 'SaveTime', t: VT_FILETIME },
+ 0x0E: { n: 'PageCount', t: VT_I4 },
+ 0x0F: { n: 'WordCount', t: VT_I4 },
+ 0x10: { n: 'CharCount', t: VT_I4 },
+ 0x11: { n: 'Thumbnail', t: VT_CF },
+ 0x12: { n: 'ApplicationName', t: VT_LPSTR },
+ 0x13: { n: 'DocumentSecurity', t: VT_I4 },
+ 0xFF: {}
+};
+
+/* CFB Constants */
+{
+ var MAXREGSECT = 0xFFFFFFFA;
+ var DIFSECT = 0xFFFFFFFC;
+ var FATSECT = 0xFFFFFFFD;
+ var ENDOFCHAIN = 0xFFFFFFFE;
+ var FREESECT = 0xFFFFFFFF;
+ var HEADER_SIGNATURE = 'd0cf11e0a1b11ae1';
+ var HEADER_MINOR_VERSION = '3e00';
+ var MAXREGSID = 0xFFFFFFFA;
+ var NOSTREAM = 0xFFFFFFFF;
+ var HEADER_CLSID = '00000000000000000000000000000000';
+
+ var EntryTypes = ['unknown','storage','stream',null,null,'root'];
+}
+
+}
+
if(typeof require !== 'undefined' && typeof exports !== 'undefined') {
Buffers = require('buffers');
- var vm = require('vm'), fs = require('fs');
- vm.runInThisContext(fs.readFileSync(__dirname+'/consts.js'));
+ var fs = require('fs');
exports.read = CFB.read;
exports.parse = CFB.parse;
exports.main = function(args) {
View
106 consts.js
@@ -1,106 +0,0 @@
-var WINDOWS_CONST_SENTINEL = 1;
-// Property Types 2.2 Table
-{
- var VT_EMPTY = 0x0000;
- var VT_NULL = 0x0001;
- var VT_I2 = 0x0002;
- var VT_I4 = 0x0003;
- var VT_R4 = 0x0004;
- var VT_R8 = 0x0005;
- var VT_CY = 0x0006;
- var VT_DATE = 0x0007;
- var VT_BSTR = 0x0008;
- var VT_ERROR = 0x000A;
- var VT_BOOL = 0x000B;
- var VT_VARIANT = 0x000C;
- var VT_DECIMAL = 0x000E;
- var VT_I1 = 0x0010;
- var VT_UI1 = 0x0011;
- var VT_UI2 = 0x0012;
- var VT_UI4 = 0x0013;
- var VT_I8 = 0x0014;
- var VT_UI8 = 0x0015;
- var VT_INT = 0x0016;
- var VT_UINT = 0x0017;
- var VT_LPSTR = 0x001E;
- var VT_LPWSTR = 0x001F;
- var VT_FILETIME = 0x0040;
- var VT_BLOB = 0x0041;
- var VT_STREAM = 0x0042;
- var VT_STORAGE = 0x0043;
- var VT_STREAMED_Object = 0x0044;
- var VT_STORED_Object = 0x0045;
- var VT_BLOB_Object = 0x0046;
- var VT_CF = 0x0047;
- var VT_CLSID = 0x0048;
- var VT_VERSIONED_STREAM = 0x0049;
- var VT_VECTOR = 0x1000;
- var VT_ARRAY = 0x2000;
-
- var VT_STRING = 0x0050; // 2.3.3.1.11 VtString
- var VT_CUSTOM = [VT_STRING];
-}
-
-/* MS-OSHARED 2.3.3.2.2.1 Document Summary Information PIDDSI */
-var DocSummaryPIDDSI = {
- 0x01: { n: 'CodePage', t: VT_I2 },
- 0x02: { n: 'Category', t: VT_STRING },
- 0x03: { n: 'PresentationFormat', t: VT_STRING },
- 0x04: { n: 'ByteCount', t: VT_I4 },
- 0x05: { n: 'LineCount', t: VT_I4 },
- 0x06: { n: 'ParagraphCount', t: VT_I4 },
- 0x07: { n: 'SlideCount', t: VT_I4 },
- 0x08: { n: 'NoteCount', t: VT_I4 },
- 0x09: { n: 'HiddenCount', t: VT_I4 },
- 0x0a: { n: 'MultimediaClipCount', t: VT_I4 },
- 0x0b: { n: 'Scale', t: VT_BOOL },
- 0x0c: { n: 'HeadingPair', t: VT_VECTOR | VT_VARIANT },
- 0x0d: { n: 'DocParts', t: VT_VECTOR | VT_LPSTR },
- 0x0e: { n: 'Manager', t: VT_STRING },
- 0x0f: { n: 'Company', t: VT_STRING },
- 0x10: { n: 'LinksDirty', t: VT_BOOL },
- 0x11: { n: 'CharacterCount', t: VT_I4 },
- 0x13: { n: 'SharedDoc', t: VT_BOOL },
- 0x16: { n: 'HLinksChanged', t: VT_BOOL },
- 0x17: { n: 'Version', t: VT_I4 },
- 0xFF: {}
-};
-
-var SummaryPIDSI = {
- 0x01: { n: 'CodePage', t: VT_I2 },
- 0x02: { n: 'Title', t: VT_LPSTR },
- 0x03: { n: 'Subject', t: VT_LPSTR },
- 0x04: { n: 'Author', t: VT_LPSTR },
- 0x05: { n: 'Keywords', t: VT_LPSTR },
- 0x06: { n: 'Comments', t: VT_LPSTR },
- 0x07: { n: 'Template', t: VT_LPSTR },
- 0x08: { n: 'LastAuthor', t: VT_LPSTR },
- 0x09: { n: 'RevNumber', t: VT_LPSTR },
- 0x0A: { n: 'EditTime', t: VT_FILETIME },
- 0x0B: { n: 'LastPrinted', t: VT_FILETIME },
- 0x0C: { n: 'CreateTime', t: VT_FILETIME },
- 0x0D: { n: 'SaveTime', t: VT_FILETIME },
- 0x0E: { n: 'PageCount', t: VT_I4 },
- 0x0F: { n: 'WordCount', t: VT_I4 },
- 0x10: { n: 'CharCount', t: VT_I4 },
- 0x11: { n: 'Thumbnail', t: VT_CF },
- 0x12: { n: 'ApplicationName', t: VT_LPSTR },
- 0x13: { n: 'DocumentSecurity', t: VT_I4 },
- 0xFF: {}
-};
-
-/* CFB Constants */
-{
- var MAXREGSECT = 0xFFFFFFFA;
- var DIFSECT = 0xFFFFFFFC;
- var FATSECT = 0xFFFFFFFD;
- var ENDOFCHAIN = 0xFFFFFFFE;
- var FREESECT = 0xFFFFFFFF;
- var HEADER_SIGNATURE = 'd0cf11e0a1b11ae1';
- var HEADER_MINOR_VERSION = '3e00';
- var MAXREGSID = 0xFFFFFFFA;
- var NOSTREAM = 0xFFFFFFFF;
- var HEADER_CLSID = '00000000000000000000000000000000';
-
- var EntryTypes = ['unknown','storage','stream',null,null,'root'];
-}
View
1  testxls.html
@@ -12,7 +12,6 @@
<div id="drop">Drop an XLS or DOC file here to see sheet data.</div>
<pre id="out"></pre>
<br />
-<script src="consts.js"></script>
<script src="xlsconsts.js"></script>
<script src="cfb.js"></script>
<script src="xls.js"></script>
Please sign in to comment.
Something went wrong with that request. Please try again.