Class: Docxi::Word::Contents::Table::TableRow::TableCell::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/docxi/word/contents/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(media, options = {}) ⇒ Image

Returns a new instance of Image.



187
188
189
190
# File 'lib/docxi/word/contents/table.rb', line 187

def initialize(media, options={})
  @media = media
  @options = options
end

Instance Attribute Details

#mediaObject

Returns the value of attribute media.



186
187
188
# File 'lib/docxi/word/contents/table.rb', line 186

def media
  @media
end

#optionsObject

Returns the value of attribute options.



186
187
188
# File 'lib/docxi/word/contents/table.rb', line 186

def options
  @options
end

Instance Method Details

#render(xml) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/docxi/word/contents/table.rb', line 192

def render(xml)
  xml['w'].p do
    xml['w'].r do
      xml['w'].rPr do
        xml['w'].noProof
      end
      xml['w'].drawing do
        xml['wp'].inline( 'distT' => 0, 'distB' => 0, 'distL' => 0, 'distR' => 0 ) do
          xml['wp'].extent( 'cx' => ( options[:width] * options[:height] * 14.92 ).to_i, 'cy' => ( options[:width] * options[:height] * 14.92 ).to_i ) if options[:width] && options[:height]
          xml['wp'].effectExtent( 'l' => 0, 't' => 0, 'r' => 0, 'b' => 0 )
          xml['wp'].docPr( 'id' => @media.id, 'name'=> "Image", 'descr' => "image")
          xml['wp'].cNvGraphicFramePr do
            xml.graphicFrameLocks( 'xmlns:a' => "http://schemas.openxmlformats.org/drawingml/2006/main", 'noChangeAspect' => "1" ) do
              xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "a" }
            end
          end
          xml.graphic( 'xmlns:a' => "http://schemas.openxmlformats.org/drawingml/2006/main" ) do
            xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "a" }
            xml['a'].graphicData( 'uri' => "http://schemas.openxmlformats.org/drawingml/2006/picture") do
              xml.pic( 'xmlns:pic' => "http://schemas.openxmlformats.org/drawingml/2006/picture") do
                xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "pic" }
                xml['pic'].nvPicPr do
                  xml['pic'].cNvPr( 'id' => 0, 'name' => "Image", 'descr' => "description" )
                  xml['pic'].cNvPicPr do
                    xml['a'].picLocks( 'noChangeAspect' => "1", 'noChangeArrowheads' => "1" )
                  end
                end
                xml['pic'].blipFill do
                  xml['a'].blip( 'r:embed' => @media.sequence ) do
                    xml['a'].extLst
                  end
                  xml['a'].srcRect
                  xml['a'].stretch do
                    xml['a'].fillRect
                  end
                end
                xml['pic'].spPr( 'bwMode' => "auto" ) do
                  xml['a'].xfrm do
                    xml['a'].off( 'x' => 0, 'y' => 0 )
                    xml['a'].ext( 'cx' => ( options[:width] * options[:height] * 14.92 ).to_i, 'cy' => ( options[:width] * options[:height] * 14.92).to_i ) if options[:width] && options[:height]
                  end
                  xml['a'].prstGeom( 'prst' => "rect" ) do
                    xml['a'].avLst
                  end
                  xml['a'].noFill
                  xml['a'].ln do
                    xml['a'].noFill
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end