Class: MSWordDoc::Essence

Inherits:
Object
  • Object
show all
Defined in:
lib/msworddoc/extractor.rb

Constant Summary collapse

PPS_NAME_WORDDOC =
'WordDocument'
PPS_NAME_TABLE_TMPL =
'%dTable'
MAGIC_MSWORD =
0xa5ec
NFIB_MSWORD6 =
101
OFFSET_FIB_IDENT =
0x0000
OFFSET_FIB_FIB =
0x0002
OFFSET_FIB_FLAGS =
0x000a
OFFSET_FIB_FCCLX =
0x01a2
OFFSET_FIB_LCBCLX =
0x01a6
OFFSET_FIB_FCMIN =
0x0018
OFFSET_FIB_FCMAC =
0x001c
OFFSET_FIB_CBMAC =
0x0040
MASK_FIBFLAG_COMPLEX =
0x0004
MASK_FIBFLAG_ENCRYPTED =
0x0100
MASK_FIBFLAG_WHICHTBLSTM =
0x0200
LENGTH_CP =
4
LENGTH_PCD =
8
OFFSET_FIB_CCP_MAP =
{
  :Text    => 0x004c,
  :Ftn     => 0x0050,
  :Hdd     => 0x0054,
  :Mcr     => 0x0058,
  :Atn     => 0x005c,
  :Edn     => 0x0060,
  :Txbx    => 0x0064,
  :HdrTxbx => 0x0068,
}

Instance Method Summary collapse

Constructor Details

#initializeEssence

Returns a new instance of Essence.



65
66
67
68
69
# File 'lib/msworddoc/extractor.rb', line 65

def initialize
  @flag = {}
  @ccp  = {}
  @ole = nil
end

Instance Method Details

#annotation(*args) ⇒ Object



111
112
113
114
# File 'lib/msworddoc/extractor.rb', line 111

def annotation(*args)
  skips = [ :Text, :Ftn, :Hdd, :Mcr ]
  return retrieve_token_and_filter(skips, :Atn, *args)
end

#closeObject



71
72
73
74
# File 'lib/msworddoc/extractor.rb', line 71

def close
  @ole.close()
  @ole = nil
end

#document(*args) ⇒ Object



93
94
95
# File 'lib/msworddoc/extractor.rb', line 93

def document(*args)
  return retrieve_and_filter(0, @ccp[:Text], *args)
end

#endnote(*args) ⇒ Object



116
117
118
119
# File 'lib/msworddoc/extractor.rb', line 116

def endnote(*args)
  skips = [ :Text, :Ftn, :Hdd, :Mcr, :Atn ]
  return retrieve_token_and_filter(skips, :Edn, *args)
end

#footnote(*args) ⇒ Object



97
98
99
# File 'lib/msworddoc/extractor.rb', line 97

def footnote(*args)
  return retrieve_and_filter(@ccp[:Text], @ccp[:Ftn], *args)
end

#header(*args) ⇒ Object



101
102
103
104
# File 'lib/msworddoc/extractor.rb', line 101

def header(*args)
  skips = [ :Text, :Ftn ]
  return retrieve_token_and_filter(skips, :Hdd, *args)
end

#header_textbox(*args) ⇒ Object



126
127
128
129
# File 'lib/msworddoc/extractor.rb', line 126

def header_textbox(*args)
  skips = [ :Text, :Ftn, :Hdd, :Mcr, :Atn, :Edn, :Txbx ]
  return retrieve_token_and_filter(skips, :HdrTxbx, *args)
end

#load_storage(ole) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/msworddoc/extractor.rb', line 76

def load_storage(ole)
  @ole = ole

  @ole.file.open(PPS_NAME_WORDDOC) do |f|
    parse_fib(f)
  end

  name_of_table = PPS_NAME_TABLE_TMPL % (@flag[:fWhichTblStm] ? 1 : 0)
  @ole.file.open name_of_table do |f|
    parse_piece_table(f)
  end
end

#macro(*args) ⇒ Object



106
107
108
109
# File 'lib/msworddoc/extractor.rb', line 106

def macro(*args)
  skips = [ :Text, :Ftn, :Hdd ]
  return retrieve_token_and_filter(skips, :Mcr, *args)
end

#textbox(*args) ⇒ Object



121
122
123
124
# File 'lib/msworddoc/extractor.rb', line 121

def textbox(*args)
  skips = [ :Text, :Ftn, :Hdd, :Mcr, :Atn, :Edn ]
  return retrieve_token_and_filter(skips, :Txbx, *args)
end

#whole_contents(*args) ⇒ Object



89
90
91
# File 'lib/msworddoc/extractor.rb', line 89

def whole_contents(*args)
  return retrieve_and_filter(0, -1, *args)
end