Skip to content

Commit bae2f46

Browse files
committed
add first line, left and right indent
1 parent cfee8ae commit bae2f46

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/ruby-rtf/parser.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ def handle_control(name, val, src, current_pos)
137137
when :qr then add_section!(:justification => :right)
138138
when :qj then add_section!(:justification => :full)
139139
when :qc then add_section!(:justification => :center)
140+
when :fi then add_section!(:first_line_indent => RubyRTF.twips_to_points(val))
141+
when :li then add_section!(:left_indent => RubyRTF.twips_to_points(val))
142+
when :ri then add_section!(:right_indent => RubyRTF.twips_to_points(val))
140143
when :cf then add_section!(:foreground_colour => @doc.colour_table[val])
141144
when :cb then add_section!(:background_colour => @doc.colour_table[val])
142145
when :hex then current_section[:text] << val

spec/parser_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,23 @@
550550
parser.current_section[:modifiers][:justification].should == :center
551551
end
552552
end
553+
554+
context 'indenting' do
555+
it 'handles first line indent' do
556+
parser.handle_control(:fi, 1000, nil, 0)
557+
parser.current_section[:modifiers][:first_line_indent].should == 50
558+
end
559+
560+
it 'handles left indent' do
561+
parser.handle_control(:li, 1000, nil, 0)
562+
parser.current_section[:modifiers][:left_indent].should == 50
563+
end
564+
565+
it 'handles right indent' do
566+
parser.handle_control(:ri, 1000, nil, 0)
567+
parser.current_section[:modifiers][:right_indent].should == 50
568+
end
569+
end
553570
end
554571

555572
context 'sections' do

0 commit comments

Comments
 (0)