Class: Axlsx::Cbf
- Inherits:
-
Object
- Object
- Axlsx::Cbf
- Defined in:
- lib/axlsx/util/cbf.rb
Overview
The Cfb class is a MS-OFF-CRYPTOGRAPHY specific OLE (MS-CBF) writer implementation. No attempt is made to re-invent the wheel for read/write of compound binary files.
Constant Summary collapse
- FAT_PACKING =
the serialization for the CBF FAT
"s128"
- VERSION_PACKING =
the serialization for the MS-OFF-CRYPTO version stream
'l s30 l3'
- DATA_SPACE_MAP_PACKING =
The serialization for the MS-OFF-CRYPTO dataspace map stream
'l6 s16 l s25'
- STRONG_ENCRYPTION_DATA_SPACE_PACKING =
The serialization for the MS-OFF-CRYPTO strong encrytion data space stream
'l3 s25'
- PRIMARY_PACKING =
The serialization for the MS-OFF-CRYPTO primary stream
'l3 s38 l s39 l3 x12 l x2'
- MINI_CUTOFF =
The cutoff size that determines if a stream should be in the mini-fat or the fat
4096
- HEADER_PACKING =
The serialization for CBF header
"q x16 l s3 x10 l l x4 l*"
Instance Method Summary collapse
-
#data_space_map ⇒ Storage
returns the data space map storage.
-
#document_summary_information ⇒ Storage
returns the document summary information.
-
#fat ⇒ String
returns the fat.
-
#fat_stream ⇒ String
returns the stream of data allocated in the fat.
-
#header ⇒ String
returns the CFB header.
-
#initialize(ms_off_crypto) ⇒ Cbf
constructor
Creates a new Cbf object based on the ms_off_crypto object provided.
-
#mini_fat ⇒ Object
returns the mini fat return [String].
-
#mini_fat_stream ⇒ Object
returns the stream allocated in the mini fat.
-
#primary ⇒ Storgae
returns the primary storage.
-
#save ⇒ Object
writes the compound binary file to disk.
-
#summary_information ⇒ Storage
returns the summary information storage.
-
#version ⇒ Storage
creates or returns the version storage.
Constructor Details
#initialize(ms_off_crypto) ⇒ Cbf
Creates a new Cbf object based on the ms_off_crypto object provided.
29 30 31 32 33 34 35 36 |
# File 'lib/axlsx/util/cbf.rb', line 29 def initialize(ms_off_crypto) @file_name = ms_off_crypto.file_name create_storages mini_fat_stream mini_fat fat header end |
Instance Method Details
#data_space_map ⇒ Storage
returns the data space map storage
46 47 48 |
# File 'lib/axlsx/util/cbf.rb', line 46 def data_space_map @data_space_map ||= create_data_space_map end |
#document_summary_information ⇒ Storage
returns the document summary information
64 65 66 |
# File 'lib/axlsx/util/cbf.rb', line 64 def document_summary_information @document_summary_information ||= create_document_summary_information end |
#fat ⇒ String
returns the fat
88 89 90 |
# File 'lib/axlsx/util/cbf.rb', line 88 def fat @fat ||= create_fat end |
#fat_stream ⇒ String
returns the stream of data allocated in the fat
70 71 72 |
# File 'lib/axlsx/util/cbf.rb', line 70 def fat_stream @fat_stream ||= create_fat_stream end |
#header ⇒ String
returns the CFB header
94 95 96 |
# File 'lib/axlsx/util/cbf.rb', line 94 def header @header ||= create_header end |
#mini_fat ⇒ Object
returns the mini fat return [String]
82 83 84 |
# File 'lib/axlsx/util/cbf.rb', line 82 def mini_fat @mini_fat ||= create_mini_fat end |
#mini_fat_stream ⇒ Object
returns the stream allocated in the mini fat. return [String]
76 77 78 |
# File 'lib/axlsx/util/cbf.rb', line 76 def mini_fat_stream @mini_fat_stream ||= create_mini_fat_stream end |
#primary ⇒ Storgae
returns the primary storage
52 53 54 |
# File 'lib/axlsx/util/cbf.rb', line 52 def primary @primary ||= create_primary end |
#save ⇒ Object
writes the compound binary file to disk
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/axlsx/util/cbf.rb', line 100 def save ole = File.open(@file_name, 'w') ole << header ole << fat @storages.each { |s| ole << s.to_s } ole << Array.new((512-(ole.pos % 512)), 0).pack('c*') ole << mini_fat ole << mini_fat_stream ole << fat_stream ole.close end |
#summary_information ⇒ Storage
returns the summary information storage
58 59 60 |
# File 'lib/axlsx/util/cbf.rb', line 58 def summary_information @summary_information ||= create_summary_information end |
#version ⇒ Storage
creates or returns the version storage
40 41 42 |
# File 'lib/axlsx/util/cbf.rb', line 40 def version @version ||= create_version end |