Class: OoxmlParser::SheetProtection

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb

Overview

Class for parsing <sheetProtection> tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ SheetProtection

Returns a new instance of SheetProtection.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 47

def initialize(parent: nil)
  @objects = false
  @scenarios = false
  @select_locked_cells = false
  @select_unlocked_cells = false
  @auto_filter = true
  @delete_columns = true
  @delete_rows = true
  @format_cells = true
  @format_columns = true
  @format_rows = true
  @insert_columns = true
  @insert_rows = true
  @insert_hyperlinks = true
  @pivot_tables = true
  @sort = true
  super
end

Instance Attribute Details

#algorithm_nameString (readonly)

Returns Name of hashing algorithm.

Returns:

  • (String)

    Name of hashing algorithm



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 7

def algorithm_name
  @algorithm_name
end

#auto_filterTrue, False (readonly)

Returns Specifies if using autofilter is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if using autofilter is not allowed on protected sheet



17
18
19
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 17

def auto_filter
  @auto_filter
end

#delete_columnsTrue, False (readonly)

Returns Specifies if deleting columns is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if deleting columns is not allowed on protected sheet



19
20
21
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 19

def delete_columns
  @delete_columns
end

#delete_rowsTrue, False (readonly)

Returns Specifies if deleting rows is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if deleting rows is not allowed on protected sheet



21
22
23
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 21

def delete_rows
  @delete_rows
end

#format_cellsTrue, False (readonly)

Returns Specifies if formatting cells is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if formatting cells is not allowed on protected sheet



23
24
25
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 23

def format_cells
  @format_cells
end

#format_columnsTrue, False (readonly)

Returns Specifies if formatting columns is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if formatting columns is not allowed on protected sheet



25
26
27
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 25

def format_columns
  @format_columns
end

#format_rowsTrue, False (readonly)

Returns Specifies if formatting rows is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if formatting rows is not allowed on protected sheet



27
28
29
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 27

def format_rows
  @format_rows
end

#hash_valueString (readonly)

Returns Hash value for the password.

Returns:

  • (String)

    Hash value for the password



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 9

def hash_value
  @hash_value
end

#insert_columnsTrue, False (readonly)

Returns Specifies if inserting columns is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if inserting columns is not allowed on protected sheet



29
30
31
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 29

def insert_columns
  @insert_columns
end

Returns Specifies if inserting hyperlinks is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if inserting hyperlinks is not allowed on protected sheet



33
34
35
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 33

def insert_hyperlinks
  @insert_hyperlinks
end

#insert_rowsTrue, False (readonly)

Returns Specifies if inserting rows is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if inserting rows is not allowed on protected sheet



31
32
33
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 31

def insert_rows
  @insert_rows
end

#objectsTrue, False (readonly)

Returns Specifies if editing objects is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if editing objects is not allowed on protected sheet



35
36
37
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 35

def objects
  @objects
end

#pivot_tablesTrue, False (readonly)

Returns Specifies if using pivot tables is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if using pivot tables is not allowed on protected sheet



37
38
39
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 37

def pivot_tables
  @pivot_tables
end

#salt_valueString (readonly)

Returns Salt value for the password.

Returns:

  • (String)

    Salt value for the password



11
12
13
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 11

def salt_value
  @salt_value
end

#scenariosTrue, False (readonly)

Returns Specifies if editing scenarios is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if editing scenarios is not allowed on protected sheet



39
40
41
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 39

def scenarios
  @scenarios
end

#select_locked_cellsTrue, False (readonly)

Returns Specifies if selecting locked cells is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if selecting locked cells is not allowed on protected sheet



41
42
43
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 41

def select_locked_cells
  @select_locked_cells
end

#select_unlocked_cellsTrue, False (readonly)

Returns Specifies if selecting unlocked cells is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if selecting unlocked cells is not allowed on protected sheet



43
44
45
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 43

def select_unlocked_cells
  @select_unlocked_cells
end

#sheetTrue, False (readonly)

Returns Specifies if sheet is protected.

Returns:

  • (True, False)

    Specifies if sheet is protected



15
16
17
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 15

def sheet
  @sheet
end

#sortTrue, False (readonly)

Returns Specifies if sorting is not allowed on protected sheet.

Returns:

  • (True, False)

    Specifies if sorting is not allowed on protected sheet



45
46
47
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 45

def sort
  @sort
end

#spin_countInteger (readonly)

Returns Number of times the hashing function shall be iteratively run.

Returns:

  • (Integer)

    Number of times the hashing function shall be iteratively run



13
14
15
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 13

def spin_count
  @spin_count
end

Instance Method Details

#parse(node) ⇒ Sheet

Parse SheetProtection data

Parameters:

  • node (Nokogiri::XML:Element)

    with SheetProtection data

Returns:

  • (Sheet)

    value of SheetProtection



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/sheet_protection.rb', line 69

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'algorithmName'
      @algorithm_name = value.value.to_s
    when 'hashValue'
      @hash_value = value.value.to_s
    when 'saltValue'
      @salt_value = value.value.to_s
    when 'spinCount'
      @spin_count = value.value.to_i
    when 'sheet'
      @sheet = attribute_enabled?(value)
    when 'autoFilter'
      @auto_filter = attribute_enabled?(value)
    when 'deleteColumns'
      @delete_columns = attribute_enabled?(value)
    when 'deleteRows'
      @delete_rows = attribute_enabled?(value)
    when 'formatCells'
      @format_cells = attribute_enabled?(value)
    when 'formatColumns'
      @format_columns = attribute_enabled?(value)
    when 'formatRows'
      @format_rows = attribute_enabled?(value)
    when 'insertColumns'
      @insert_columns = attribute_enabled?(value)
    when 'insertRows'
      @insert_rows = attribute_enabled?(value)
    when 'insertHyperlinks'
      @insert_hyperlinks = attribute_enabled?(value)
    when 'objects'
      @objects = attribute_enabled?(value)
    when 'pivotTables'
      @pivot_tables = attribute_enabled?(value)
    when 'scenarios'
      @scenarios = attribute_enabled?(value)
    when 'selectLockedCells'
      @select_locked_cells = attribute_enabled?(value)
    when 'selectUnlockedCells'
      @select_unlocked_cells = attribute_enabled?(value)
    when 'sort'
      @sort = attribute_enabled?(value)
    end
  end
  self
end