aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/odf_format.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v0/odf_format.rb')
-rw-r--r--lib/sisu/v0/odf_format.rb100
1 files changed, 62 insertions, 38 deletions
diff --git a/lib/sisu/v0/odf_format.rb b/lib/sisu/v0/odf_format.rb
index 05e4a918..fe94bf5b 100644
--- a/lib/sisu/v0/odf_format.rb
+++ b/lib/sisu/v0/odf_format.rb
@@ -78,19 +78,28 @@ module SiSU_ODF_format
end
class Format_text_object
@@dp=nil
- def initialize(one,two,three)
- one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/
- @one,@two,@three=one,two,three
+ def initialize(md,t_o)
+ @md,@t_o=md,t_o
+ if t_o.class == Hash
+ @txt =t_o[:txt] || nil
+ #elsif t_o.class == Array
+ # @txt =txt[0]
+ #elsif t_o.class == String
+ # @txt =txt
+ else
+ #@one,@two,@three=one,two,three
+ p t_o.class
+ p caller
+ end
rgx=/^#{Mx[:lv_o]}[1-6-]:/
- @one.gsub!(rgx,'') if @one =~rgx
+ @txt.gsub!(rgx,'') if @txt =~rgx
@dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern
rgx=/#{Mx[:en_a_o]}\d+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/
- @one.gsub!(rgx,'\1') if @one =~rgx
- @link,@linkname=one,two
+ @txt.gsub!(rgx,'\1') if @txt =~rgx
@vz=SiSU_Env::Get_init.instance.skin
end
def scr_endnote_body
- "<endnote>#@one</endnote> "
+ "<endnote>#@txt</endnote> "
end
def heading_body1
#%{<text:h text:style-name="Heading_20_1" text:outline-level="1">#@two</text:h>}
@@ -116,8 +125,21 @@ module SiSU_ODF_format
@@tablefoot=[] #watch
@@fns=''
@@dp=nil
- def initialize(md,one)
- @md,@one,@parablock,@vz=md,one,one,SiSU_Env::Get_init.instance.skin
+ def initialize(md,t_o)
+ @md,@t_o,@vz=md,t_o,SiSU_Env::Get_init.instance.skin
+ if t_o.class == Hash
+ @txt =t_o[:txt] || nil
+ @table =t_o[:table] || nil
+ #elsif t_o.class == Array
+ # @txt =txt[0]
+ #elsif t_o.class == String
+ # @txt =txt
+ else
+ if @md.cmd =~/M/
+ p t_o.class
+ p caller
+ end
+ end
if @md.fns != @@fns
@@table_counter=0
@@fns=@md.fns
@@ -177,58 +199,60 @@ module SiSU_ODF_format
%{</table:table-row>#@br}
end
def table
- @parablock='' if @parablock =~/^<!$/
- @parablock.gsub!(/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/,'')
- m=@parablock[/<!f(.+?)!>/,1]
+ @txt='' if @txt =~/^<!$/
+ @txt.gsub!(/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/,'')
+ m=@txt[/<!f(.+?)!>/,1]
@@tablefoot << m if m
- @parablock.gsub!(/<!f.+?!>/,'')
- @@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u
- @@table_counter+=1 if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u
- if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head(@@table_counter,$1,true)
- elsif @parablock =~/#{Mx[:gr_o]}T#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head(@@table_counter,$1)
+ @txt.gsub!(/<!f.+?!>/,'')
+ @@tablehead=1 if @txt =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u
+ @@table_counter+=1 if @txt =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u
+ if @txt =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @txt=table_head(@@table_counter,$1,true)
+ elsif @txt =~/#{Mx[:gr_o]}T#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @txt=table_head(@@table_counter,$1)
end
- if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/
+ if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/
tablefoot=[]
@@tablefoot.each {|x| tablefoot << ''}
@@tablefoot=[]
- if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock=table_end
+ if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @txt=table_end
end
end
if @@tablehead == 1
- if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u
- if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
- @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true))
+ if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u
+ if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
+ @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true))
end
- if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
- @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true))
+ if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
+ @txt.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true))
end
- if @parablock =~/#{Mx[:tc_c]}/
- @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close(true))
+ if @txt =~/#{Mx[:tc_c]}/
+ @txt.gsub!(/#{Mx[:tc_c]}/,table_row_close(true))
end
@@tablehead=0
end
- @parablock
+ @txt
else
- if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
- @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1))
+ if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
+ @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1))
end
- if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
- @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1))
+ if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
+ @txt.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1))
end
- if @parablock =~/#{Mx[:tc_c]}/
- @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close)
+ if @txt =~/#{Mx[:tc_c]}/
+ @txt.gsub!(/#{Mx[:tc_c]}/,table_row_close)
end
- @parablock
+ @txt
end
- @parablock
+ @txt
end
def table_split
@new_content=[]
- @one.split(/\s*#{Mx[:tc_o]}/).each do |parablock|
+ @table.split(/\s*#{Mx[:tc_o]}/).each do |parablock|
table=if parablock =~/#{Mx[:gr_o]}/
- Table.new(@md,"#{parablock}")
+ txt_obj={:txt =>parablock}
+ Table.new(@md,txt_obj)
else
- Table.new(@md,"#{Mx[:tc_o]}#{parablock}")
+ txt_obj={:txt =>"#{Mx[:tc_o]}#{parablock}"}
+ Table.new(@md,txt_obj)
end
@new_content << table.table
end