ooxml_parser 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 152de470eb7ecac05ca2d886b7c7113edb6a2c388fe29491b5b0c4341e771237
4
- data.tar.gz: cf0aa14cc429393d88a2e3a39961242ab740c96a878d149ec74cdaade6fd2587
3
+ metadata.gz: 87857f8a432b1217218ea6780f6a836aa1dc92508623b2f5475b7baac9c488ad
4
+ data.tar.gz: d4f19dd557b08a1f11141d38c13833eee7fa767c5a86e95bd743fe12aaef8982
5
5
  SHA512:
6
- metadata.gz: 34869710a5435a3d26c6b70dd42b1290cd80a1b7dff16582f3d4abaaa765877b69c58a9af5543b86cdbad78c27dd3849daf14f09e8bf0c8e5c4c5bfd3fdb0b8f
7
- data.tar.gz: 538f12d23be8b548ef8bbcfd476f93f4c0926cfbe9c71d7101a97ccf040e8c238dece97f7c04d49bef6dd524e296795c3f1ada9b368016bf6864f9262cfd1dcc
6
+ metadata.gz: f5708ce9c0fb1825dc929c876780a83d96b5b99d8b21df16506eb589a2d6807111e747064bcaa5f5a300fedb6ec8c502bd912ba846ac6d5cd62c35eee23d7870
7
+ data.tar.gz: 564d9a0a2fa4501fb177bf8aeb9e498f7763dd57c30dea0647c5789259877ed7f8fc7d9b2c873e2f3c6ff209f7f7d3ff082f3daf1fb09033c3ea2525b690569e
@@ -94,13 +94,9 @@ module OoxmlParser
94
94
  # @return [True, False] result of comparision
95
95
  def ==(other)
96
96
  if other.is_a?(Color)
97
- if ((@red == other.red) && (@green == other.green) && (@blue == other.blue)) ||
98
- (none? && other.white?) ||
99
- (white? && other.none?)
100
- true
101
- else
102
- false
103
- end
97
+ ((@red == other.red) && (@green == other.green) && (@blue == other.blue)) ||
98
+ (none? && other.white?) ||
99
+ (white? && other.none?)
104
100
  else
105
101
  false
106
102
  end
@@ -125,7 +121,7 @@ module OoxmlParser
125
121
  red = color_to_check.red
126
122
  green = color_to_check.green
127
123
  blue = color_to_check.blue
128
- (self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta ? true : false
124
+ (self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta
129
125
  end
130
126
 
131
127
  # Apply tint to color
@@ -30,6 +30,8 @@ module OoxmlParser
30
30
  attr_accessor :contextual_spacing
31
31
  # @return [Symbol] The alignment or justification to be applied to a paragraph
32
32
  attr_accessor :justification
33
+ # @return [Shade] Shade property
34
+ attr_accessor :shade
33
35
 
34
36
  def initialize(numbering = NumberingProperties.new, parent: nil)
35
37
  @numbering = numbering
@@ -86,6 +88,8 @@ module OoxmlParser
86
88
  @keep_next = true
87
89
  when 'sectPr'
88
90
  @section_properties = PageProperties.new(parent: self).parse(node_child, @parent, DocxParagraphRun.new)
91
+ when 'shd'
92
+ @shade = Shade.new(parent: self).parse(node_child)
89
93
  when 'spacing'
90
94
  @spacing = ParagraphSpacing.new(parent: self).parse(node_child)
91
95
  when 'jc'
@@ -43,5 +43,18 @@ module OoxmlParser
43
43
  end
44
44
  self
45
45
  end
46
+
47
+ # Helper method to get background color
48
+ # @return [OoxmlParser::Color]
49
+ def to_background_color
50
+ return nil unless fill
51
+
52
+ background_color = fill
53
+ background_color.set_style(value) if value
54
+ background_color
55
+ end
56
+
57
+ extend Gem::Deprecate
58
+ deprecate :to_background_color, 'use shade direct methods', 2077, 1
46
59
  end
47
60
  end
@@ -33,14 +33,10 @@ module OoxmlParser
33
33
  other.line_rule = :multiple if other.line_rule == :auto
34
34
  self.line_rule = line_rule.to_sym if line_rule.instance_of?(String)
35
35
 
36
- if @before == other.before &&
37
- @after == other.after &&
38
- @line == other.line &&
39
- @line_rule.to_s == other.line_rule.to_s
40
- true
41
- else
42
- false
43
- end
36
+ @before == other.before &&
37
+ @after == other.after &&
38
+ @line == other.line &&
39
+ @line_rule.to_s == other.line_rule.to_s
44
40
  end
45
41
 
46
42
  # @return [String] result of convert of object to string
@@ -18,7 +18,7 @@ module OoxmlParser
18
18
  # Class for data of DocxParagraph
19
19
  class DocxParagraph < OOXMLDocumentObject
20
20
  include DocxParagraphHelper
21
- attr_accessor :number, :bookmark_start, :bookmark_end, :align, :spacing, :background_color, :ind, :numbering,
21
+ attr_accessor :number, :bookmark_start, :bookmark_end, :align, :spacing, :ind, :numbering,
22
22
  :character_style_array, :page_break, :borders, :keep_lines,
23
23
  :contextual_spacing, :sector_properties, :page_numbering, :section_break, :style, :keep_next,
24
24
  :orphan_control
@@ -129,8 +129,8 @@ module OoxmlParser
129
129
  when 'bookmarkEnd'
130
130
  character_styles_array << BookmarkEnd.new(parent: self).parse(node_child)
131
131
  when 'pPr'
132
- parse_paragraph_style(node_child, custom_character_style)
133
132
  @paragraph_properties = ParagraphProperties.new(parent: self).parse(node_child)
133
+ parse_paragraph_style(node_child, custom_character_style)
134
134
  when 'commentRangeStart'
135
135
  character_styles_array << CommentRangeStart.new(parent: self).parse(node_child)
136
136
  when 'commentRangeEnd'
@@ -206,10 +206,6 @@ module OoxmlParser
206
206
  @keep_next = true
207
207
  when 'contextualSpacing'
208
208
  @contextual_spacing = true
209
- when 'shd'
210
- background_color_string = node_child.attribute('fill').value
211
- @background_color = Color.new(parent: self).parse_hex_string(background_color_string)
212
- @background_color.set_style(node_child.attribute('val').value.to_sym) unless node_child.attribute('val').nil?
213
209
  when 'pStyle'
214
210
  parse_paragraph_style_xml(node_child.attribute('val').value, default_char_style)
215
211
  when 'ind'
@@ -9,5 +9,12 @@ module OoxmlParser
9
9
 
10
10
  root_object.comments_extended.by_id(@paragraph_id)
11
11
  end
12
+
13
+ # Temp method to return background color
14
+ # Need to be compatible with older versions
15
+ # @return [OoxmlParser::Color]
16
+ def background_color
17
+ paragraph_properties.shade.to_background_color
18
+ end
12
19
  end
13
20
  end
@@ -4,6 +4,6 @@ module OoxmlParser
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
6
  # [String] Version of Gem
7
- STRING = '0.11.0'
7
+ STRING = '0.12.0'
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ooxml_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-12-10 00:00:00.000000000 Z
13
+ date: 2021-02-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -572,7 +572,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
572
572
  - !ruby/object:Gem::Version
573
573
  version: '0'
574
574
  requirements: []
575
- rubygems_version: 3.1.4
575
+ rubygems_version: 3.2.9
576
576
  signing_key:
577
577
  specification_version: 4
578
578
  summary: OoxmlParser Gem