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 x2'
- STRONG_ENCRYPTION_DATA_SPACE_PACKING =
The serialization for the MS-OFF-CRYPTO strong encrytion data space stream
'l3 s26'
- PRIMARY_PACKING =
The serialization for the MS-OFF-CRYPTO primary stream
'l3 s38 l s40 l3 x12 l'
- 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.
-
#encrypted_package ⇒ String
returns the encrypted package from the ms_off_crypt object provided during initalization.
-
#encryption_info ⇒ String
returns the encryption info from the ms_off_crypt object provided during intialization.
-
#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.
30 31 32 33 34 35 36 37 38 |
# File 'lib/axlsx/util/cbf.rb', line 30 def initialize(ms_off_crypto) @file_name = ms_off_crypto.file_name @ms_off_crypto = ms_off_crypto create_storages mini_fat_stream mini_fat fat header end |
Instance Method Details
#data_space_map ⇒ Storage
returns the data space map storage
48 49 50 |
# File 'lib/axlsx/util/cbf.rb', line 48 def data_space_map @data_space_map ||= create_data_space_map end |
#document_summary_information ⇒ Storage
returns the document summary information
66 67 68 |
# File 'lib/axlsx/util/cbf.rb', line 66 def document_summary_information @document_summary_information ||= create_document_summary_information end |
#encrypted_package ⇒ String
returns the encrypted package from the ms_off_crypt object provided during initalization
108 109 110 |
# File 'lib/axlsx/util/cbf.rb', line 108 def encrypted_package @ms_off_crypto.encrypted_package end |
#encryption_info ⇒ String
returns the encryption info from the ms_off_crypt object provided during intialization
102 103 104 |
# File 'lib/axlsx/util/cbf.rb', line 102 def encryption_info @ms_off_crypto.encryption_info end |
#fat ⇒ String
returns the fat
90 91 92 |
# File 'lib/axlsx/util/cbf.rb', line 90 def fat @fat ||= create_fat end |
#fat_stream ⇒ String
returns the stream of data allocated in the fat
72 73 74 |
# File 'lib/axlsx/util/cbf.rb', line 72 def fat_stream @fat_stream ||= create_fat_stream end |
#header ⇒ String
returns the CFB header
96 97 98 |
# File 'lib/axlsx/util/cbf.rb', line 96 def header @header ||= create_header end |
#mini_fat ⇒ Object
returns the mini fat return [String]
84 85 86 |
# File 'lib/axlsx/util/cbf.rb', line 84 def mini_fat @mini_fat ||= create_mini_fat end |
#mini_fat_stream ⇒ Object
returns the stream allocated in the mini fat. return [String]
78 79 80 |
# File 'lib/axlsx/util/cbf.rb', line 78 def mini_fat_stream @mini_fat_stream ||= create_mini_fat_stream end |
#primary ⇒ Storgae
returns the primary storage
54 55 56 |
# File 'lib/axlsx/util/cbf.rb', line 54 def primary @primary ||= create_primary end |
#save ⇒ Object
writes the compound binary file to disk
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/axlsx/util/cbf.rb', line 113 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
60 61 62 |
# File 'lib/axlsx/util/cbf.rb', line 60 def summary_information @summary_information ||= create_summary_information end |
#version ⇒ Storage
creates or returns the version storage
42 43 44 |
# File 'lib/axlsx/util/cbf.rb', line 42 def version @version ||= create_version end |