Class: SiSU_XML_ODF_ODT::Source::Output

Inherits:
SiSU_XML_ODF_ODT::Source show all
Defined in:
lib/sisu/xml_odf_odt.rb

Instance Method Summary collapse

Methods inherited from SiSU_XML_ODF_ODT::Source

#read

Constructor Details

#initialize(content, md, env) ⇒ Output

Returns a new instance of Output.



827
828
829
# File 'lib/sisu/xml_odf_odt.rb', line 827

def initialize(content,md,env)
  @content,@md,@env=content,md,env
end

Instance Method Details

#odfObject

%odf output



830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
# File 'lib/sisu/xml_odf_odt.rb', line 830

def odf                                                           #%odf output
  env=SiSU_Env::FileOp.new(@md)
  env.mkdir
  header=SiSU_XML_ODF_ODT_Format::ODT_Head_1_2.new(@md)
  filename="#{@env.processing_path.odt}/manifest.rdf"
  od=File.new(filename,'w+')
  od << header.manifest_rdf
  od.close
  filename="#{@env.processing_path.odt}/META-INF/manifest.xml"
  od=File.new(filename,'w+')
  od << header.meta_inf_manifest_xml(@md)
  od.close
  filename="#{@env.processing_path.odt}/meta.xml"
  od=File.new(filename,'w+')
  od << header.meta_xml
  od.close
  filename="#{@env.processing_path.odt}/settings.xml"
  od=File.new(filename,'w+')
  od << header.settings_xml
  od.close
  filename="#{@env.processing_path.odt}/styles.xml"
  od=File.new(filename,'w+')
  od << header.styles_xml
  od.close
  filename="#{@env.processing_path.odt}/mimetype"
  od=File.new(filename,'w+')
  od << header.mimetype
  od.close
  env.make_path(@env.processing_path.odt)
  env.make_path(@md.file.output_path.odt.dir)
  filename="#{@env.processing_path.odt}/content.xml"
  od=File.new(filename,'w+')
  @content.compact.each do |para|                                                # this is a hack
    od.puts para unless para =~/\A\s*\Z/
  end
  od.close
  opendoc=@md.file.base_filename.odt #watch where output by language
  FileUtils::mkdir_p(@md.file.output_path.odt.dir) \
    unless FileTest.directory?(@md.file.output_path.odt.dir)
  if FileTest.directory?(@env.processing_path.odt) \
  and SiSU_Env::SystemCall.new.zip
    pwd=Dir.pwd
    Dir.chdir(@env.processing_path.odt)
    system("
      zip -qr #{opendoc} *
    ")
    FileUtils::mv(opendoc, @md.file.place_file.odt.dir)
    Dir.chdir(pwd)
  else
    SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('*EXITED odf* zip program not found') unless SiSU_Env::SystemCall.new.zip
  end
end