Skip to content

Commit

Permalink
Namespace for all style and svg attributes in header-footer properties
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoarrais committed Nov 3, 2015
1 parent f8245e9 commit 49bfe8a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/odf/property.rb
Expand Up @@ -25,6 +25,7 @@ class Property
:column => 'table-column-properties',
:row => 'table-row-properties',
:page_layout => 'page-layout-properties',
:header_footer => 'header-footer-properties',
:conditional => 'map'}
TRANSLATED_SPECS = [:border_color, :border_style, :border_width]

Expand Down Expand Up @@ -64,7 +65,10 @@ class Property
'layout-grid-print', 'layout-grid-ruby-below', 'layout-grid-ruby-height', 'layout-grid-snap-to',
'layout-grid-standard-mode', 'num-format', 'num-letter-sync', 'num-prefix', 'num-suffix',
'paper-tray-name', 'print', 'print-orientation', 'print-page-order',
'register-truth-ref-style-name', 'scale-to', 'scale-to-pages', 'table-centering']
'register-truth-ref-style-name', 'scale-to', 'scale-to-pages', 'table-centering',
'dynamic-spacing']

SVG_ATTRIBUTES = ['height']

def initialize(type, specs={})
@name = 'style:' + (PROPERTY_NAMES[type] || "#{type}-properties")
Expand All @@ -80,7 +84,8 @@ def xml

class << self
def lookup_namespace_for(property_name)
STYLE_ATTRIBUTES.include?(property_name) ? 'style' : 'fo'
STYLE_ATTRIBUTES.include?(property_name) ? 'style' :
SVG_ATTRIBUTES.include?(property_name) ? 'svg' : 'fo'
end
end
private
Expand Down
19 changes: 18 additions & 1 deletion spec/property_spec.rb
Expand Up @@ -40,7 +40,8 @@
at('style:paragraph-properties')['style:tab-stop-distance'].should == '0.4925in'
Hpricot(ODF::Property.new(:page_layout, 'border-line-width' => '2px').xml).
at('style:page-layout-properties')['style:border-line-width'].should == '2px'
# style:header-footer-properties
Hpricot(ODF::Property.new(:header_footer, 'border-line-width' => '2px').xml).
at('style:header-footer-properties')['style:border-line-width'].should == '2px'
# style:ruby-properties
# style:section-properties
# style:table-properties
Expand Down Expand Up @@ -213,5 +214,21 @@
ODF::Property.lookup_namespace_for(prop).should == 'style'
end
end

it "should know the namespace for style:header-footer-properties style properties" do
# see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416492_253892949
['border-line-width', 'border-line-width-bottom', 'border-line-width-left', 'border-line-width-right',
'border-line-width-top', 'dynamic-spacing', 'shadow'].
each do |prop|
ODF::Property.lookup_namespace_for(prop).should == 'style'
end
end

it "should know the namespace for style:header-footer-properties svg properties" do
# see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416492_253892949
['height'].each do |prop|
ODF::Property.lookup_namespace_for(prop).should == 'svg'
end
end
end

0 comments on commit 49bfe8a

Please sign in to comment.