Class: Ole::Types::PropertySet

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/ole/property_set.rb

Overview

The PropertySet class currently supports readonly access to the properties serialized in “property set” streams, such as the file “005SummaryInformation”, in OLE files.

Think has its roots in MFC property set serialization.

See poi.apache.org/hpsf/internals.html for details

Defined Under Namespace

Modules: Constants Classes: Section

Constant Summary collapse

HEADER_SIZE =
28
HEADER_PACK =
"vvVa#{Clsid::SIZE}V"
OS_MAP =
{
	0 => :win16,
	1 => :mac,
	2 => :win32,
	0x20001 => :ooffice, # open office on linux...
}
DATA =

define a smattering of the property set guids. FMTID_SummaryInformation = Clsid.parse ‘f29f85e0-4ff9-1068-ab91-08002b27b3d9’ FMTID_DocSummaryInformation = Clsid.parse ‘d5cdd502-2e9c-101b-9397-08002b2cf9ae’ FMTID_UserDefinedProperties = Clsid.parse ‘d5cdd505-2e9c-101b-9397-08002b2cf9ae’

YAML.load_file(File.dirname(__FILE__) + '/../../data/propids.yaml').
inject({}) { |hash, (key, value)| hash.update Clsid.parse(key) => value }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ PropertySet

Returns a new instance of PropertySet.



108
109
110
111
112
113
114
# File 'lib/ole/property_set.rb', line 108

def initialize io
	@io = io
	load_header io.read(HEADER_SIZE)
	load_section_list io.read(@num_sections * Section::SIZE)
	# expect no gap between last section and start of data.
	#Log.warn "gap between section list and property data" unless io.pos == @sections.map(&:offset).min
end

Instance Attribute Details

#guidObject (readonly)

Returns the value of attribute guid.



107
108
109
# File 'lib/ole/property_set.rb', line 107

def guid
  @guid
end

#ioObject (readonly)

Returns the value of attribute io.



107
108
109
# File 'lib/ole/property_set.rb', line 107

def io
  @io
end

#osObject (readonly)

Returns the value of attribute os.



107
108
109
# File 'lib/ole/property_set.rb', line 107

def os
  @os
end

#sectionsObject (readonly)

Returns the value of attribute sections.



107
108
109
# File 'lib/ole/property_set.rb', line 107

def sections
  @sections
end

#signatureObject (readonly)

Returns the value of attribute signature.



107
108
109
# File 'lib/ole/property_set.rb', line 107

def signature
  @signature
end

#unknownObject (readonly)

Returns the value of attribute unknown.



107
108
109
# File 'lib/ole/property_set.rb', line 107

def unknown
  @unknown
end

Instance Method Details

#load_header(str) ⇒ Object



116
117
118
119
120
121
# File 'lib/ole/property_set.rb', line 116

def load_header str
	@signature, @unknown, @os_id, @guid, @num_sections = str.unpack HEADER_PACK
	# should i check that unknown == 0? it usually is. so is the guid actually
	@guid = Clsid.load @guid
	@os = OS_MAP[@os_id] || Log.warn("unknown operating system id #{@os_id}")
end

#load_section_list(str) ⇒ Object



123
124
125
# File 'lib/ole/property_set.rb', line 123

def load_section_list str
	@sections = str.scan(/.{#{Section::SIZE}}/m).map { |s| Section.new s, self }
end