Class: ODDB::OdbaExporter::MCMTable

Inherits:
Table show all
Defined in:
ext/export/src/oddbdat.rb

Constant Summary collapse

FILENAME =
's31x'

Constants inherited from Table

Table::CRLF

Instance Method Summary collapse

Methods inherited from Table

#filename

Instance Method Details

#format_line(chapter) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'ext/export/src/oddbdat.rb', line 153

def format_line(chapter)
	string = String.new
	unless((head = chapter.heading).empty?)
		string << '<BI>' << head.to_s << '<E><P>'
	end
	chapter.sections.each { |sec|
		unless((subhead = sec.subheading).empty?)
			subhead = subhead.gsub(/\n/u, "<P>")
			string << '<I>' << subhead.to_s << '<E>'
		end
		sec.paragraphs.each { |par|
         case par
         when ODDB::Text::ImageLink
           string << "<IMG src='http://#{SERVER_NAME}#{par.src}'/>"
         when ODDB::Text::Table
           string << '<N>' << par.to_s << '<E>'
         else
           text = u par.text
				par.formats.each { |format|
					start_tag = ""
					end_tag = ""
					if(format.italic?)
						start_tag = "<I>"
						end_tag = "<E>"
					elsif(format.bold?)
						start_tag = "<B>"
						end_tag = "<E>"
					end
             if formatted = text[format.range]
               string << start_tag << formatted << end_tag
             end
				}
           string << "<P>"
				if(par.preformatted?)
					string.gsub!(/ /, '_')
					string.gsub!(/\n/, "<P>")
				end
         end
		}
	}
	string.gsub(/\n/u, ' ')
end

#lines(fi) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'ext/export/src/oddbdat.rb', line 132

def lines(fi)
	lines = []
	fi.descriptions.each { |lang, doc|
		line = 1
		doc.each_chapter { |chap|
			text = format_line(chap)
			while(text.size > 220)
				pos = text.rindex(' ', 220)
				if(pos.nil?)
					pos = text.rindex('<P>', 220)-1
				end
				txt = text.slice!(0..pos)
				lines << MCMLine.new(fi.oid, line, lang, txt)
				line = line.next
			end
			lines << MCMLine.new(fi.oid, line, lang, text)
			line = line.next
		}	
	}
	lines
end