Class: Axlsx::Cbf

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(ms_off_crypto) ⇒ Cbf

Creates a new Cbf object based on the ms_off_crypto object provided.

Parameters:



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_mapStorage

returns the data space map storage

Returns:



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_informationStorage

returns the document summary information

Returns:



64
65
66
# File 'lib/axlsx/util/cbf.rb', line 64

def document_summary_information
  @document_summary_information ||= create_document_summary_information
end

#fatString

returns the fat

Returns:

  • (String)


88
89
90
# File 'lib/axlsx/util/cbf.rb', line 88

def fat
  @fat ||= create_fat
end

#fat_streamString

returns the stream of data allocated in the fat

Returns:

  • (String)


70
71
72
# File 'lib/axlsx/util/cbf.rb', line 70

def fat_stream 
  @fat_stream ||= create_fat_stream
end

#headerString

returns the CFB header

Returns:

  • (String)


94
95
96
# File 'lib/axlsx/util/cbf.rb', line 94

def header
  @header ||= create_header
end

#mini_fatObject

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_streamObject

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

#primaryStorgae

returns the primary storage

Returns:

  • (Storgae)


52
53
54
# File 'lib/axlsx/util/cbf.rb', line 52

def primary
  @primary ||= create_primary
end

#saveObject

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_informationStorage

returns the summary information storage

Returns:



58
59
60
# File 'lib/axlsx/util/cbf.rb', line 58

def summary_information
  @summary_information ||= create_summary_information
end

#versionStorage

creates or returns the version storage

Returns:



40
41
42
# File 'lib/axlsx/util/cbf.rb', line 40

def version
  @version ||= create_version
end