ooxml_parser 0.32.0 → 0.33.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: 7cf7caeb2bfc8c48e6727c5a35c8514e07cf85fe2f528e742dd96be9473b3318
4
- data.tar.gz: 07e1d21315c8dcd83664019f93cc1992926e176024420bd9fcdbc4de0837f9dd
3
+ metadata.gz: 9a2c8bb2410020cc3dfcb2126b9888ef47530fbd761e6167bd917fffee6a1351
4
+ data.tar.gz: 8ae388b40aabe9e72995e1bb5fa747e73253cd4464e414a00db0dcd5a87b0b40
5
5
  SHA512:
6
- metadata.gz: 743b318ed40ff1805d7c6db6f32532dca25c6452be286808fcd52e5992e41bfa0a36de2574fcc828984f4dee095a75ba80cfc2221c49ef923db1880092ff9d83
7
- data.tar.gz: 781db58bd859d241763049196327cfed403d3eb2fbb5288e9018a05eabab1f69b4115783e43166817e08e8e13485c25d1ada81db0cede73b82af38d52c4ca493
6
+ metadata.gz: 3ce96605c0637a4b2865c96088c0c10ddc898e91e7b6d41234bf8da01b598b748416567aff90cfa33b6778b7f16b7bb9397d95e5dde75e551fe524ee6d72dbdb
7
+ data.tar.gz: eee336b02e4bc827de7771f46ebcf53907957af7505c7da806dad589fe79f5de56b56e89206bc0e2df1d523530a9a7b41cd7a2c22095da97e95bde953e7faaa9
@@ -11,6 +11,8 @@ module OoxmlParser
11
11
  attr_reader :theme_shade
12
12
  # @return [Integer] theme index
13
13
  attr_reader :theme
14
+ # @return [Float] theme tint
15
+ attr_reader :theme_tint
14
16
  # @return [Float] tint
15
17
  attr_reader :tint
16
18
  # @return [Float] Indexed id
@@ -58,6 +60,8 @@ module OoxmlParser
58
60
  @indexed = value.value.to_i
59
61
  when 'rgb'
60
62
  @rgb = Color.new.parse_hex_string(value.value)
63
+ when 'themeTint'
64
+ @theme_tint = value.value.hex.to_f
61
65
  end
62
66
  end
63
67
  self
@@ -78,17 +78,15 @@ module OoxmlParser
78
78
  # @param node [Nokogiri::XML:Element] node to parse
79
79
  # @return [nil]
80
80
  def parse_color_tag(node)
81
- node.attributes.each do |key, value|
81
+ color = OoxmlColor.new(parent: self).parse(node)
82
+ node.attributes.sort.to_h.each do |key, value|
82
83
  case key
83
84
  when 'val'
84
85
  self.font_color = Color.new(parent: self).parse_hex_string(value.value)
85
86
  when 'themeColor'
86
- if root_object.theme && root_object.theme.color_scheme[value.value.to_sym]
87
- break if value.value == 'text2' || value.value == 'background2' || value.value.include?('accent') # Don't know why. Just works
88
-
89
- self.font_color = root_object.theme.color_scheme[value.value.to_sym].color.dup
90
- end
87
+ self.font_color = root_object.theme.color_scheme[value.value.to_sym].color.dup if root_object.theme && root_object.theme.color_scheme[value.value.to_sym]
91
88
  when 'themeShade'
89
+ self.font_color = color.value if font_color.none?
92
90
  font_color.calculate_with_shade!(value.value.hex.to_f / 255.0)
93
91
  when 'themeTint'
94
92
  font_color.calculate_with_tint!(1.0 - (value.value.hex.to_f / 255.0))
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `checkedState` tag
5
+ class CheckBoxState < OOXMLDocumentObject
6
+ # @return [Integer] number of state symbol
7
+ attr_reader :value
8
+ # @return [String] font name
9
+ attr_reader :font
10
+
11
+ # Parse CheckBoxState object
12
+ # @param node [Nokogiri::XML:Element] node to parse
13
+ # @return [CheckBoxState] result of parsing
14
+ def parse(node)
15
+ node.attributes.each do |key, value|
16
+ case key
17
+ when 'val'
18
+ @value = value.value.to_i
19
+ when 'font'
20
+ @font = value.value
21
+ end
22
+ end
23
+ self
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'checkbox/checkbox_state'
4
+ module OoxmlParser
5
+ # Class for parsing `checkbox` tag
6
+ class CheckBox < OOXMLDocumentObject
7
+ # @return [True, False] specifies if checkbox is checked
8
+ attr_reader :checked
9
+ # @return [CheckBoxState] options of checked state
10
+ attr_reader :checked_state
11
+ # @return [CheckBoxState] options of unchecked state
12
+ attr_reader :unchecked_state
13
+ # @return [ValuedChild] group key
14
+ attr_reader :group_key
15
+
16
+ # Parse CheckBox object
17
+ # @param node [Nokogiri::XML:Element] node to parse
18
+ # @return [CheckBox] result of parsing
19
+ def parse(node)
20
+ node.xpath('*').each do |node_child|
21
+ case node_child.name
22
+ when 'checked'
23
+ @checked = option_enabled?(node_child, 'hidden')
24
+ when 'checkedState'
25
+ @checked_state = CheckBoxState.new(parent: self).parse(node_child)
26
+ when 'uncheckedState'
27
+ @unchecked_state = CheckBoxState.new(parent: self).parse(node_child)
28
+ when 'groupKey'
29
+ @group_key = ValuedChild.new(:string, parent: self).parse(node_child)
30
+ end
31
+ end
32
+ self
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `listItem` tag
5
+ class ListItem < OOXMLDocumentObject
6
+ # @return [String] item text
7
+ attr_reader :text
8
+ # @return [String] item value
9
+ attr_reader :value
10
+
11
+ # Parse ListItem object
12
+ # @param node [Nokogiri::XML:Element] node to parse
13
+ # @return [ListItem] result of parsing
14
+ def parse(node)
15
+ node.attributes.each do |key, value|
16
+ case key
17
+ when 'displayText'
18
+ @text = value.value
19
+ when 'value'
20
+ @value = value.value
21
+ end
22
+ end
23
+ self
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'combobox/list_item'
4
+ module OoxmlParser
5
+ # Class for parsing `comboBox` tag
6
+ class ComboBox < OOXMLDocumentObject
7
+ # @return [Array<ListItem>] combobox items
8
+ attr_reader :list_items
9
+
10
+ def initialize(parent: nil)
11
+ @list_items = []
12
+ super
13
+ end
14
+
15
+ # Parse ComboBox object
16
+ # @param node [Nokogiri::XML:Element] node to parse
17
+ # @return [ComboBox] result of parsing
18
+ def parse(node)
19
+ node.xpath('*').each do |node_child|
20
+ case node_child.name
21
+ when 'listItem'
22
+ @list_items << ListItem.new(parent: self).parse(node_child)
23
+ end
24
+ end
25
+ self
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `dropDownList` tag
5
+ class DropdownList < OOXMLDocumentObject
6
+ # @return [Array<ListItem>] dropdown items
7
+ attr_reader :list_items
8
+
9
+ def initialize(parent: nil)
10
+ @list_items = []
11
+ super
12
+ end
13
+
14
+ # Parse DropdownList object
15
+ # @param node [Nokogiri::XML:Element] node to parse
16
+ # @return [DropdownList] result of parsing
17
+ def parse(node)
18
+ node.xpath('*').each do |node_child|
19
+ case node_child.name
20
+ when 'listItem'
21
+ @list_items << ListItem.new(parent: self).parse(node_child)
22
+ end
23
+ end
24
+ self
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `formPr` tag
5
+ class FormProperties < OOXMLDocumentObject
6
+ # @return [String] field key
7
+ attr_reader :key
8
+ # @return [String] text of tooltip
9
+ attr_reader :help_text
10
+ # @return [True, False] specifies if field is required
11
+ attr_reader :required
12
+ # @return [Shade] shade of field
13
+ attr_reader :shade
14
+ # @return [BordersProperties] border of field
15
+ attr_reader :border
16
+
17
+ def initialize(parent: nil)
18
+ @required = false
19
+ super
20
+ end
21
+
22
+ # Parse FormProperties object
23
+ # @param node [Nokogiri::XML:Element] node to parse
24
+ # @return [FormProperties] result of parsing
25
+ def parse(node)
26
+ node.attributes.each do |key, value|
27
+ case key
28
+ when 'key'
29
+ @key = value.value
30
+ when 'helpText'
31
+ @help_text = value.value
32
+ when 'required'
33
+ @required = option_enabled?(value)
34
+ end
35
+ end
36
+
37
+ node.xpath('*').each do |node_child|
38
+ case node_child.name
39
+ when 'shd'
40
+ @shade = Shade.new(parent: self).parse(node_child)
41
+ when 'border'
42
+ @border = BordersProperties.new(parent: self).parse(node_child)
43
+ end
44
+ end
45
+ self
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `comb` tag
5
+ class FormTextComb < OOXMLDocumentObject
6
+ # @return [OoxmlSize] field width
7
+ attr_reader :width
8
+ # @return [Symbol] width rule
9
+ attr_reader :width_rule
10
+
11
+ # Parse FormTextComb object
12
+ # @param node [Nokogiri::XML:Element] node to parse
13
+ # @return [FormTextComb] result of parsing
14
+ def parse(node)
15
+ node.attributes.each do |key, value|
16
+ case key
17
+ when 'width'
18
+ @width = OoxmlSize.new(value.value.to_f)
19
+ when 'wRule'
20
+ @width_rule = value.value.to_sym
21
+ end
22
+ end
23
+ self
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `format` tag
5
+ class FormTextFormat < OOXMLDocumentObject
6
+ # @return [Symbol] format type
7
+ attr_reader :type
8
+ # @return [String] value for custom formats
9
+ attr_reader :value
10
+ # @return [String] allowed symbols
11
+ attr_reader :symbols
12
+
13
+ # Parse FormTextFormat object
14
+ # @param node [Nokogiri::XML:Element] node to parse
15
+ # @return [FormTextFormat] result of parsing
16
+ def parse(node)
17
+ node.attributes.each do |key, value|
18
+ case key
19
+ when 'type'
20
+ @type = value.value.to_sym
21
+ when 'val'
22
+ @value = value.value
23
+ when 'symbols'
24
+ @symbols = value.value
25
+ end
26
+ end
27
+ self
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'form_text_properties/form_text_comb'
4
+ require_relative 'form_text_properties/form_text_format'
5
+ module OoxmlParser
6
+ # Class for parsing `textFormPr` tag
7
+ class FormTextProperties < OOXMLDocumentObject
8
+ # @return [True, False] specifies if field is multiline
9
+ attr_reader :multiline
10
+ # @return [True, False] specifies if size of field should be autofit
11
+ attr_reader :autofit
12
+ # @return [FormTextComb] parameters of text justification
13
+ attr_reader :comb
14
+ # @return [ValuedChild] characters limit
15
+ attr_reader :maximum_characters
16
+ # @return [FormTextFormat] text format
17
+ attr_reader :format
18
+
19
+ # Parse FormTextProperties object
20
+ # @param node [Nokogiri::XML:Element] node to parse
21
+ # @return [FormTextProperties] result of parsing
22
+ def parse(node)
23
+ node.attributes.each do |key, value|
24
+ case key
25
+ when 'multiLine'
26
+ @multiline = option_enabled?(value)
27
+ when 'autoFit'
28
+ @autofit = option_enabled?(value)
29
+ end
30
+ end
31
+
32
+ node.xpath('*').each do |node_child|
33
+ case node_child.name
34
+ when 'comb'
35
+ @comb = FormTextComb.new(parent: self).parse(node_child)
36
+ when 'maxCharacters'
37
+ @maximum_characters = ValuedChild.new(:integer, parent: self).parse(node_child)
38
+ when 'format'
39
+ @format = FormTextFormat.new(parent: self).parse(node_child)
40
+ end
41
+ end
42
+ self
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'sdt_properties/form_properties'
4
+ require_relative 'sdt_properties/form_text_properties'
5
+ require_relative 'sdt_properties/combobox'
6
+ require_relative 'sdt_properties/dropdown_list'
7
+ require_relative 'sdt_properties/checkbox'
3
8
  module OoxmlParser
4
9
  # Class for parsing `w:sdtPr` tags
5
10
  class SDTProperties < OOXMLDocumentObject
@@ -9,6 +14,16 @@ module OoxmlParser
9
14
  attr_reader :tag
10
15
  # @return [ValuedChild] Locking Setting
11
16
  attr_reader :lock
17
+ # @return [ComboBox] combobox
18
+ attr_reader :combobox
19
+ # @return [DropdownList] dropdown list
20
+ attr_reader :dropdown_list
21
+ # @return [CheckBox] checkbox
22
+ attr_reader :checkbox
23
+ # @return [FormProperties] form properties
24
+ attr_reader :form_properties
25
+ # @return [FormTextProperties] properties of text in form
26
+ attr_reader :form_text_properties
12
27
 
13
28
  # Parse SDTProperties object
14
29
  # @param node [Nokogiri::XML:Element] node to parse
@@ -22,6 +37,16 @@ module OoxmlParser
22
37
  @tag = ValuedChild.new(:string, parent: self).parse(node_child)
23
38
  when 'lock'
24
39
  @lock = ValuedChild.new(:symbol, parent: self).parse(node_child)
40
+ when 'comboBox'
41
+ @combobox = ComboBox.new(parent: self).parse(node_child)
42
+ when 'dropDownList'
43
+ @dropdown_list = DropdownList.new(parent: self).parse(node_child)
44
+ when 'checkbox'
45
+ @checkbox = CheckBox.new(parent: self).parse(node_child)
46
+ when 'formPr'
47
+ @form_properties = FormProperties.new(parent: self).parse(node_child)
48
+ when 'textFormPr'
49
+ @form_text_properties = FormTextProperties.new(parent: self).parse(node_child)
25
50
  end
26
51
  end
27
52
  self
@@ -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.32.0'
7
+ STRING = '0.33.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.32.0
4
+ version: 0.33.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: 2022-10-03 00:00:00.000000000 Z
13
+ date: 2022-10-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -424,6 +424,15 @@ files:
424
424
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/inserted.rb
425
425
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_content.rb
426
426
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties.rb
427
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/checkbox.rb
428
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/checkbox/checkbox_state.rb
429
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/combobox.rb
430
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/combobox/list_item.rb
431
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/dropdown_list.rb
432
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb
433
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_text_properties.rb
434
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_text_properties/form_text_comb.rb
435
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_text_properties/form_text_format.rb
427
436
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/structured_document_tag.rb
428
437
  - lib/ooxml_parser/docx_parser/document_structure/header_footer.rb
429
438
  - lib/ooxml_parser/docx_parser/document_structure/numbering.rb
@@ -610,7 +619,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
610
619
  - !ruby/object:Gem::Version
611
620
  version: '0'
612
621
  requirements: []
613
- rubygems_version: 3.3.22
622
+ rubygems_version: 3.3.24
614
623
  signing_key:
615
624
  specification_version: 4
616
625
  summary: OoxmlParser Gem