@@ -20,9 +20,10 @@ module Docx
2020 # puts d.text
2121 # end
2222 class Document
23- include Docx ::SimpleInspect
2423
25- attr_reader :xml , :doc , :zip , :styles
24+ include Docx ::SimpleInspect
25+
26+ attr_reader :xml , :doc , :zip , :styles , :settings
2627
2728 def initialize ( path_or_io , options = { } )
2829 @replace = { }
@@ -41,6 +42,7 @@ def initialize(path_or_io, options = {})
4142 @document_xml = document . get_input_stream . read
4243 @doc = Nokogiri ::XML ( @document_xml )
4344 load_styles
45+ load_settings
4446 yield ( self ) if block_given?
4547 ensure
4648 @zip . close unless @zip . nil?
@@ -202,6 +204,14 @@ def load_rels
202204 @rels = Nokogiri ::XML ( @rels_xml )
203205 end
204206
207+ def load_settings
208+ @settings_xml = @zip . read ( 'word/settings.xml' )
209+ @settings = Nokogiri ::XML ( @settings_xml )
210+ rescue Errno ::ENOENT => e
211+ warn e . message
212+ nil
213+ end
214+
205215 #--
206216 # TODO: Flesh this out to be compatible with other files
207217 # TODO: Method to set flag on files that have been edited, probably by inserting something at the
@@ -210,6 +220,7 @@ def load_rels
210220 def update
211221 replace_entry 'word/document.xml' , doc . serialize ( save_with : 0 )
212222 replace_entry 'word/styles.xml' , styles_configuration . serialize ( save_with : 0 )
223+ replace_entry 'word/settings.xml' , settings . serialize ( save_with : 0 ) if @settings
213224 end
214225
215226 # generate Elements::Containers::Paragraph from paragraph XML node
0 commit comments