id
int32 0
24.9k
| repo
stringlengths 5
58
| path
stringlengths 9
168
| func_name
stringlengths 9
130
| original_string
stringlengths 66
10.5k
| language
stringclasses 1
value | code
stringlengths 66
10.5k
| code_tokens
list | docstring
stringlengths 8
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 94
266
|
|---|---|---|---|---|---|---|---|---|---|---|---|
17,800
|
sparkleformation/sfn
|
lib/sfn/cache.rb
|
Sfn.Cache.get_local_storage
|
def get_local_storage(data_type, full_name, args = {})
@storage ||= {}
@storage[full_name] ||= case data_type.to_sym
when :array
[]
when :hash
{}
when :value
LocalValue.new
when :lock
LocalLock.new(full_name, {:expiration => 60, :timeout => 0.1}.merge(args))
when :stamped
Stamped.new(full_name.sub("#{key}_", "").to_sym, get_local_storage(:value, full_name), self)
else
raise TypeError.new("Unsupported caching data type encountered: #{data_type}")
end
end
|
ruby
|
def get_local_storage(data_type, full_name, args = {})
@storage ||= {}
@storage[full_name] ||= case data_type.to_sym
when :array
[]
when :hash
{}
when :value
LocalValue.new
when :lock
LocalLock.new(full_name, {:expiration => 60, :timeout => 0.1}.merge(args))
when :stamped
Stamped.new(full_name.sub("#{key}_", "").to_sym, get_local_storage(:value, full_name), self)
else
raise TypeError.new("Unsupported caching data type encountered: #{data_type}")
end
end
|
[
"def",
"get_local_storage",
"(",
"data_type",
",",
"full_name",
",",
"args",
"=",
"{",
"}",
")",
"@storage",
"||=",
"{",
"}",
"@storage",
"[",
"full_name",
"]",
"||=",
"case",
"data_type",
".",
"to_sym",
"when",
":array",
"[",
"]",
"when",
":hash",
"{",
"}",
"when",
":value",
"LocalValue",
".",
"new",
"when",
":lock",
"LocalLock",
".",
"new",
"(",
"full_name",
",",
"{",
":expiration",
"=>",
"60",
",",
":timeout",
"=>",
"0.1",
"}",
".",
"merge",
"(",
"args",
")",
")",
"when",
":stamped",
"Stamped",
".",
"new",
"(",
"full_name",
".",
"sub",
"(",
"\"#{key}_\"",
",",
"\"\"",
")",
".",
"to_sym",
",",
"get_local_storage",
"(",
":value",
",",
"full_name",
")",
",",
"self",
")",
"else",
"raise",
"TypeError",
".",
"new",
"(",
"\"Unsupported caching data type encountered: #{data_type}\"",
")",
"end",
"end"
] |
Fetch item from local storage
@param data_type [Symbol]
@param full_name [Symbol]
@param args [Hash]
@return [Object]
@todo make proper singleton for local storage
|
[
"Fetch",
"item",
"from",
"local",
"storage"
] |
68dacff9b9a9cb3389d4b763566ca1e94659104b
|
https://github.com/sparkleformation/sfn/blob/68dacff9b9a9cb3389d4b763566ca1e94659104b/lib/sfn/cache.rb#L184-L200
|
17,801
|
sparkleformation/sfn
|
lib/sfn/cache.rb
|
Sfn.Cache.time_check_allow?
|
def time_check_allow?(key, stamp)
Time.now.to_i - stamp.to_i > apply_limit(key)
end
|
ruby
|
def time_check_allow?(key, stamp)
Time.now.to_i - stamp.to_i > apply_limit(key)
end
|
[
"def",
"time_check_allow?",
"(",
"key",
",",
"stamp",
")",
"Time",
".",
"now",
".",
"to_i",
"-",
"stamp",
".",
"to_i",
">",
"apply_limit",
"(",
"key",
")",
"end"
] |
Check if cache time has expired
@param key [String, Symbol] value key
@param stamp [Time, Integer]
@return [TrueClass, FalseClass]
|
[
"Check",
"if",
"cache",
"time",
"has",
"expired"
] |
68dacff9b9a9cb3389d4b763566ca1e94659104b
|
https://github.com/sparkleformation/sfn/blob/68dacff9b9a9cb3389d4b763566ca1e94659104b/lib/sfn/cache.rb#L238-L240
|
17,802
|
sparkleformation/sfn
|
lib/sfn/cache.rb
|
Sfn.Cache.apply_limit
|
def apply_limit(kind, seconds = nil)
@apply_limit ||= {}
if seconds
@apply_limit[kind.to_sym] = seconds.to_i
end
@apply_limit[kind.to_sym].to_i
end
|
ruby
|
def apply_limit(kind, seconds = nil)
@apply_limit ||= {}
if seconds
@apply_limit[kind.to_sym] = seconds.to_i
end
@apply_limit[kind.to_sym].to_i
end
|
[
"def",
"apply_limit",
"(",
"kind",
",",
"seconds",
"=",
"nil",
")",
"@apply_limit",
"||=",
"{",
"}",
"if",
"seconds",
"@apply_limit",
"[",
"kind",
".",
"to_sym",
"]",
"=",
"seconds",
".",
"to_i",
"end",
"@apply_limit",
"[",
"kind",
".",
"to_sym",
"]",
".",
"to_i",
"end"
] |
Apply time limit for data type
@param kind [String, Symbol] data type
@param seconds [Integer]
return [Integer]
|
[
"Apply",
"time",
"limit",
"for",
"data",
"type"
] |
68dacff9b9a9cb3389d4b763566ca1e94659104b
|
https://github.com/sparkleformation/sfn/blob/68dacff9b9a9cb3389d4b763566ca1e94659104b/lib/sfn/cache.rb#L247-L253
|
17,803
|
sparkleformation/sfn
|
lib/sfn/cache.rb
|
Sfn.Cache.locked_action
|
def locked_action(lock_name, raise_on_locked = false)
begin
self[lock_name].lock do
yield
end
rescue => e
if e.class.to_s.end_with?("Timeout")
raise if raise_on_locked
else
raise
end
end
end
|
ruby
|
def locked_action(lock_name, raise_on_locked = false)
begin
self[lock_name].lock do
yield
end
rescue => e
if e.class.to_s.end_with?("Timeout")
raise if raise_on_locked
else
raise
end
end
end
|
[
"def",
"locked_action",
"(",
"lock_name",
",",
"raise_on_locked",
"=",
"false",
")",
"begin",
"self",
"[",
"lock_name",
"]",
".",
"lock",
"do",
"yield",
"end",
"rescue",
"=>",
"e",
"if",
"e",
".",
"class",
".",
"to_s",
".",
"end_with?",
"(",
"\"Timeout\"",
")",
"raise",
"if",
"raise_on_locked",
"else",
"raise",
"end",
"end",
"end"
] |
Perform action within lock
@param lock_name [String, Symbol] name of lock
@param raise_on_locked [TrueClass, FalseClass] raise execption if lock wait times out
@return [Object] result of yield
|
[
"Perform",
"action",
"within",
"lock"
] |
68dacff9b9a9cb3389d4b763566ca1e94659104b
|
https://github.com/sparkleformation/sfn/blob/68dacff9b9a9cb3389d4b763566ca1e94659104b/lib/sfn/cache.rb#L260-L272
|
17,804
|
liufengyun/hashdiff
|
lib/hashdiff/linear_compare_array.rb
|
HashDiff.LinearCompareArray.index_of_match_after_additions
|
def index_of_match_after_additions
return unless expected_additions > 0
(1..expected_additions).each do |i|
next_difference = item_difference(
old_array[old_index],
new_array[new_index + i],
old_index
)
return new_index + i if next_difference.empty?
end
nil
end
|
ruby
|
def index_of_match_after_additions
return unless expected_additions > 0
(1..expected_additions).each do |i|
next_difference = item_difference(
old_array[old_index],
new_array[new_index + i],
old_index
)
return new_index + i if next_difference.empty?
end
nil
end
|
[
"def",
"index_of_match_after_additions",
"return",
"unless",
"expected_additions",
">",
"0",
"(",
"1",
"..",
"expected_additions",
")",
".",
"each",
"do",
"|",
"i",
"|",
"next_difference",
"=",
"item_difference",
"(",
"old_array",
"[",
"old_index",
"]",
",",
"new_array",
"[",
"new_index",
"+",
"i",
"]",
",",
"old_index",
")",
"return",
"new_index",
"+",
"i",
"if",
"next_difference",
".",
"empty?",
"end",
"nil",
"end"
] |
look ahead in the new array to see if the current item appears later
thereby having new items added
|
[
"look",
"ahead",
"in",
"the",
"new",
"array",
"to",
"see",
"if",
"the",
"current",
"item",
"appears",
"later",
"thereby",
"having",
"new",
"items",
"added"
] |
ab58c062f4d0651d84e3f48d544ea88fd85aae54
|
https://github.com/liufengyun/hashdiff/blob/ab58c062f4d0651d84e3f48d544ea88fd85aae54/lib/hashdiff/linear_compare_array.rb#L89-L103
|
17,805
|
liufengyun/hashdiff
|
lib/hashdiff/linear_compare_array.rb
|
HashDiff.LinearCompareArray.index_of_match_after_deletions
|
def index_of_match_after_deletions
return unless expected_additions < 0
(1..(expected_additions.abs)).each do |i|
next_difference = item_difference(
old_array[old_index + i],
new_array[new_index],
old_index
)
return old_index + i if next_difference.empty?
end
nil
end
|
ruby
|
def index_of_match_after_deletions
return unless expected_additions < 0
(1..(expected_additions.abs)).each do |i|
next_difference = item_difference(
old_array[old_index + i],
new_array[new_index],
old_index
)
return old_index + i if next_difference.empty?
end
nil
end
|
[
"def",
"index_of_match_after_deletions",
"return",
"unless",
"expected_additions",
"<",
"0",
"(",
"1",
"..",
"(",
"expected_additions",
".",
"abs",
")",
")",
".",
"each",
"do",
"|",
"i",
"|",
"next_difference",
"=",
"item_difference",
"(",
"old_array",
"[",
"old_index",
"+",
"i",
"]",
",",
"new_array",
"[",
"new_index",
"]",
",",
"old_index",
")",
"return",
"old_index",
"+",
"i",
"if",
"next_difference",
".",
"empty?",
"end",
"nil",
"end"
] |
look ahead in the old array to see if the current item appears later
thereby having items removed
|
[
"look",
"ahead",
"in",
"the",
"old",
"array",
"to",
"see",
"if",
"the",
"current",
"item",
"appears",
"later",
"thereby",
"having",
"items",
"removed"
] |
ab58c062f4d0651d84e3f48d544ea88fd85aae54
|
https://github.com/liufengyun/hashdiff/blob/ab58c062f4d0651d84e3f48d544ea88fd85aae54/lib/hashdiff/linear_compare_array.rb#L107-L121
|
17,806
|
nedap/mysql-binuuid-rails
|
lib/mysql-binuuid/type.rb
|
MySQLBinUUID.Type.cast
|
def cast(value)
if value.is_a?(MySQLBinUUID::Type::Data)
# It could be a Data object, in which case we should add dashes to the
# string value from there.
add_dashes(value.to_s)
elsif value.is_a?(String) && value.encoding == Encoding::ASCII_8BIT && strip_dashes(value).length != 32
# We cannot unpack something that looks like a UUID, with or without
# dashes. Not entirely sure why ActiveRecord does a weird combination of
# cast and serialize before anything needs to be saved..
undashed_uuid = value.unpack1('H*')
add_dashes(undashed_uuid.to_s)
else
super
end
end
|
ruby
|
def cast(value)
if value.is_a?(MySQLBinUUID::Type::Data)
# It could be a Data object, in which case we should add dashes to the
# string value from there.
add_dashes(value.to_s)
elsif value.is_a?(String) && value.encoding == Encoding::ASCII_8BIT && strip_dashes(value).length != 32
# We cannot unpack something that looks like a UUID, with or without
# dashes. Not entirely sure why ActiveRecord does a weird combination of
# cast and serialize before anything needs to be saved..
undashed_uuid = value.unpack1('H*')
add_dashes(undashed_uuid.to_s)
else
super
end
end
|
[
"def",
"cast",
"(",
"value",
")",
"if",
"value",
".",
"is_a?",
"(",
"MySQLBinUUID",
"::",
"Type",
"::",
"Data",
")",
"# It could be a Data object, in which case we should add dashes to the",
"# string value from there.",
"add_dashes",
"(",
"value",
".",
"to_s",
")",
"elsif",
"value",
".",
"is_a?",
"(",
"String",
")",
"&&",
"value",
".",
"encoding",
"==",
"Encoding",
"::",
"ASCII_8BIT",
"&&",
"strip_dashes",
"(",
"value",
")",
".",
"length",
"!=",
"32",
"# We cannot unpack something that looks like a UUID, with or without",
"# dashes. Not entirely sure why ActiveRecord does a weird combination of",
"# cast and serialize before anything needs to be saved..",
"undashed_uuid",
"=",
"value",
".",
"unpack1",
"(",
"'H*'",
")",
"add_dashes",
"(",
"undashed_uuid",
".",
"to_s",
")",
"else",
"super",
"end",
"end"
] |
Invoked when a value that is returned from the database needs to be
displayed into something readable again.
|
[
"Invoked",
"when",
"a",
"value",
"that",
"is",
"returned",
"from",
"the",
"database",
"needs",
"to",
"be",
"displayed",
"into",
"something",
"readable",
"again",
"."
] |
d418e1cee3a58ad3f222054f92d0404dc19ef464
|
https://github.com/nedap/mysql-binuuid-rails/blob/d418e1cee3a58ad3f222054f92d0404dc19ef464/lib/mysql-binuuid/type.rb#L11-L25
|
17,807
|
nedap/mysql-binuuid-rails
|
lib/mysql-binuuid/type.rb
|
MySQLBinUUID.Type.serialize
|
def serialize(value)
return if value.nil?
undashed_uuid = strip_dashes(value)
# To avoid SQL injection, verify that it looks like a UUID. ActiveRecord
# does not explicity escape the Binary data type. escaping is implicit as
# the Binary data type always converts its value to a hex string.
unless valid_undashed_uuid?(undashed_uuid)
raise MySQLBinUUID::InvalidUUID, "#{value} is not a valid UUID"
end
Data.new(undashed_uuid)
end
|
ruby
|
def serialize(value)
return if value.nil?
undashed_uuid = strip_dashes(value)
# To avoid SQL injection, verify that it looks like a UUID. ActiveRecord
# does not explicity escape the Binary data type. escaping is implicit as
# the Binary data type always converts its value to a hex string.
unless valid_undashed_uuid?(undashed_uuid)
raise MySQLBinUUID::InvalidUUID, "#{value} is not a valid UUID"
end
Data.new(undashed_uuid)
end
|
[
"def",
"serialize",
"(",
"value",
")",
"return",
"if",
"value",
".",
"nil?",
"undashed_uuid",
"=",
"strip_dashes",
"(",
"value",
")",
"# To avoid SQL injection, verify that it looks like a UUID. ActiveRecord",
"# does not explicity escape the Binary data type. escaping is implicit as",
"# the Binary data type always converts its value to a hex string.",
"unless",
"valid_undashed_uuid?",
"(",
"undashed_uuid",
")",
"raise",
"MySQLBinUUID",
"::",
"InvalidUUID",
",",
"\"#{value} is not a valid UUID\"",
"end",
"Data",
".",
"new",
"(",
"undashed_uuid",
")",
"end"
] |
Invoked when the provided value needs to be serialized before storing
it to the database.
|
[
"Invoked",
"when",
"the",
"provided",
"value",
"needs",
"to",
"be",
"serialized",
"before",
"storing",
"it",
"to",
"the",
"database",
"."
] |
d418e1cee3a58ad3f222054f92d0404dc19ef464
|
https://github.com/nedap/mysql-binuuid-rails/blob/d418e1cee3a58ad3f222054f92d0404dc19ef464/lib/mysql-binuuid/type.rb#L29-L41
|
17,808
|
nedap/mysql-binuuid-rails
|
lib/mysql-binuuid/type.rb
|
MySQLBinUUID.Type.add_dashes
|
def add_dashes(uuid)
return uuid if uuid =~ /\-/
[uuid[0..7], uuid[8..11], uuid[12..15], uuid[16..19], uuid[20..-1]].join("-")
end
|
ruby
|
def add_dashes(uuid)
return uuid if uuid =~ /\-/
[uuid[0..7], uuid[8..11], uuid[12..15], uuid[16..19], uuid[20..-1]].join("-")
end
|
[
"def",
"add_dashes",
"(",
"uuid",
")",
"return",
"uuid",
"if",
"uuid",
"=~",
"/",
"\\-",
"/",
"[",
"uuid",
"[",
"0",
"..",
"7",
"]",
",",
"uuid",
"[",
"8",
"..",
"11",
"]",
",",
"uuid",
"[",
"12",
"..",
"15",
"]",
",",
"uuid",
"[",
"16",
"..",
"19",
"]",
",",
"uuid",
"[",
"20",
"..",
"-",
"1",
"]",
"]",
".",
"join",
"(",
"\"-\"",
")",
"end"
] |
A UUID consists of 5 groups of characters.
8 chars - 4 chars - 4 chars - 4 chars - 12 characters
This function re-introduces the dashes since we removed them during
serialization, so:
add_dashes("2b4a233152694c6e9d1e098804ab812b")
=> "2b4a2331-5269-4c6e-9d1e-098804ab812b"
|
[
"A",
"UUID",
"consists",
"of",
"5",
"groups",
"of",
"characters",
".",
"8",
"chars",
"-",
"4",
"chars",
"-",
"4",
"chars",
"-",
"4",
"chars",
"-",
"12",
"characters"
] |
d418e1cee3a58ad3f222054f92d0404dc19ef464
|
https://github.com/nedap/mysql-binuuid-rails/blob/d418e1cee3a58ad3f222054f92d0404dc19ef464/lib/mysql-binuuid/type.rb#L69-L72
|
17,809
|
halogenandtoast/oath
|
lib/oath/controller_helpers.rb
|
Oath.ControllerHelpers.sign_in
|
def sign_in user
Oath.config.sign_in_service.new(user, warden).perform.tap do |status|
if status && block_given?
yield
end
end
end
|
ruby
|
def sign_in user
Oath.config.sign_in_service.new(user, warden).perform.tap do |status|
if status && block_given?
yield
end
end
end
|
[
"def",
"sign_in",
"user",
"Oath",
".",
"config",
".",
"sign_in_service",
".",
"new",
"(",
"user",
",",
"warden",
")",
".",
"perform",
".",
"tap",
"do",
"|",
"status",
"|",
"if",
"status",
"&&",
"block_given?",
"yield",
"end",
"end",
"end"
] |
Sign in a user
@note Uses the {Oath::Services::SignIn} service to create a session
@param user [User] the user object to sign in
@yield Yields to the block if the user is successfully signed in
@return [Object] returns the value from calling perform on the {Oath::Services::SignIn} service
|
[
"Sign",
"in",
"a",
"user"
] |
f850ea5122d37285f0377675b9c084942086280f
|
https://github.com/halogenandtoast/oath/blob/f850ea5122d37285f0377675b9c084942086280f/lib/oath/controller_helpers.rb#L22-L28
|
17,810
|
halogenandtoast/oath
|
lib/oath/controller_helpers.rb
|
Oath.ControllerHelpers.sign_up
|
def sign_up user_params
Oath.config.sign_up_service.new(user_params).perform.tap do |status|
if status && block_given?
yield
end
end
end
|
ruby
|
def sign_up user_params
Oath.config.sign_up_service.new(user_params).perform.tap do |status|
if status && block_given?
yield
end
end
end
|
[
"def",
"sign_up",
"user_params",
"Oath",
".",
"config",
".",
"sign_up_service",
".",
"new",
"(",
"user_params",
")",
".",
"perform",
".",
"tap",
"do",
"|",
"status",
"|",
"if",
"status",
"&&",
"block_given?",
"yield",
"end",
"end",
"end"
] |
Sign up a user
@note Uses the {Oath::Services::SignUp} service to create a user
@param user_params [Hash] params containing lookup and token fields
@yield Yields to the block if the user is signed up successfully
@return [Object] returns the value from calling perform on the {Oath::Services::SignUp} service
|
[
"Sign",
"up",
"a",
"user"
] |
f850ea5122d37285f0377675b9c084942086280f
|
https://github.com/halogenandtoast/oath/blob/f850ea5122d37285f0377675b9c084942086280f/lib/oath/controller_helpers.rb#L46-L52
|
17,811
|
halogenandtoast/oath
|
lib/oath/controller_helpers.rb
|
Oath.ControllerHelpers.authenticate_session
|
def authenticate_session session_params, field_map = nil
token_field = Oath.config.user_token_field
params_hash = Oath.transform_params(session_params).symbolize_keys
password = params_hash.fetch(token_field)
user = Oath.lookup(params_hash.except(token_field), field_map)
authenticate(user, password)
end
|
ruby
|
def authenticate_session session_params, field_map = nil
token_field = Oath.config.user_token_field
params_hash = Oath.transform_params(session_params).symbolize_keys
password = params_hash.fetch(token_field)
user = Oath.lookup(params_hash.except(token_field), field_map)
authenticate(user, password)
end
|
[
"def",
"authenticate_session",
"session_params",
",",
"field_map",
"=",
"nil",
"token_field",
"=",
"Oath",
".",
"config",
".",
"user_token_field",
"params_hash",
"=",
"Oath",
".",
"transform_params",
"(",
"session_params",
")",
".",
"symbolize_keys",
"password",
"=",
"params_hash",
".",
"fetch",
"(",
"token_field",
")",
"user",
"=",
"Oath",
".",
"lookup",
"(",
"params_hash",
".",
"except",
"(",
"token_field",
")",
",",
"field_map",
")",
"authenticate",
"(",
"user",
",",
"password",
")",
"end"
] |
Authenticates a session.
@note Uses the {Oath::Services::Authentication} service to verify the user's details
@param session_params [Hash] params containing lookup and token fields
@param field_map [Hash] Field map used for allowing users to sign in with multiple fields e.g. email and username
@return [User] if authentication succeeded
@return [nil] if authentication failed
@example Basic usage
class SessionsController < ApplicationController
def create
user = authenticate_session(session_params)
if sign_in(user)
redirect_to(root_path)
else
render :new
end
end
private
def session_params
params.require(:session).permit(:email, :password)
end
end
@example Using the field map to authenticate using multiple lookup fields
class SessionsController < ApplicationController
def create
user = authenticate_session(session_params, email_or_username: [:email, :username])
if sign_in(user)
redirect_to(root_path)
else
render :new
end
end
private
def session_params
params.require(:session).permit(:email_or_username, :password)
end
end
|
[
"Authenticates",
"a",
"session",
"."
] |
f850ea5122d37285f0377675b9c084942086280f
|
https://github.com/halogenandtoast/oath/blob/f850ea5122d37285f0377675b9c084942086280f/lib/oath/controller_helpers.rb#L101-L107
|
17,812
|
halogenandtoast/oath
|
lib/oath/controller_helpers.rb
|
Oath.ControllerHelpers.authenticate
|
def authenticate user, password
Oath.config.authentication_service.new(user, password).perform
end
|
ruby
|
def authenticate user, password
Oath.config.authentication_service.new(user, password).perform
end
|
[
"def",
"authenticate",
"user",
",",
"password",
"Oath",
".",
"config",
".",
"authentication_service",
".",
"new",
"(",
"user",
",",
"password",
")",
".",
"perform",
"end"
] |
Authenticates a user given a password
@note Uses the {Oath::Services::Authentication} service to verify the user's credentials
@param user [User] the user
@param password [String] the password
@return [User] if authentication succeeded
@return [nil] if authentication failed
|
[
"Authenticates",
"a",
"user",
"given",
"a",
"password"
] |
f850ea5122d37285f0377675b9c084942086280f
|
https://github.com/halogenandtoast/oath/blob/f850ea5122d37285f0377675b9c084942086280f/lib/oath/controller_helpers.rb#L117-L119
|
17,813
|
halogenandtoast/oath
|
lib/oath/controller_helpers.rb
|
Oath.ControllerHelpers.reset_password
|
def reset_password user, password
Oath.config.password_reset_service.new(user, password).perform
end
|
ruby
|
def reset_password user, password
Oath.config.password_reset_service.new(user, password).perform
end
|
[
"def",
"reset_password",
"user",
",",
"password",
"Oath",
".",
"config",
".",
"password_reset_service",
".",
"new",
"(",
"user",
",",
"password",
")",
".",
"perform",
"end"
] |
Resets a user's password
@note Uses the {Oath::Services::PasswordReset} service to change a user's password
@param user [User] the user
@param password [String] the password
|
[
"Resets",
"a",
"user",
"s",
"password"
] |
f850ea5122d37285f0377675b9c084942086280f
|
https://github.com/halogenandtoast/oath/blob/f850ea5122d37285f0377675b9c084942086280f/lib/oath/controller_helpers.rb#L127-L129
|
17,814
|
halogenandtoast/oath
|
lib/oath/param_transformer.rb
|
Oath.ParamTransformer.to_h
|
def to_h
sanitized_params.each_with_object({}) do |(key, value), hash|
hash[key] = transform(key, value)
end
end
|
ruby
|
def to_h
sanitized_params.each_with_object({}) do |(key, value), hash|
hash[key] = transform(key, value)
end
end
|
[
"def",
"to_h",
"sanitized_params",
".",
"each_with_object",
"(",
"{",
"}",
")",
"do",
"|",
"(",
"key",
",",
"value",
")",
",",
"hash",
"|",
"hash",
"[",
"key",
"]",
"=",
"transform",
"(",
"key",
",",
"value",
")",
"end",
"end"
] |
Initialize parameter transformer
@param params [ActionController::Parameters] parameters to be altered
Returns the transformed parameters
|
[
"Initialize",
"parameter",
"transformer"
] |
f850ea5122d37285f0377675b9c084942086280f
|
https://github.com/halogenandtoast/oath/blob/f850ea5122d37285f0377675b9c084942086280f/lib/oath/param_transformer.rb#L14-L18
|
17,815
|
Skalar/google_distance_matrix
|
lib/google_distance_matrix/client.rb
|
GoogleDistanceMatrix.Client.get
|
def get(url, instrumentation: {}, **_options)
uri = URI.parse url
response = ActiveSupport::Notifications.instrument(
'client_request_matrix_data.google_distance_matrix', instrumentation
) do
Net::HTTP.get_response uri
end
handle response, url
rescue Timeout::Error => error
raise ServerError, error
end
|
ruby
|
def get(url, instrumentation: {}, **_options)
uri = URI.parse url
response = ActiveSupport::Notifications.instrument(
'client_request_matrix_data.google_distance_matrix', instrumentation
) do
Net::HTTP.get_response uri
end
handle response, url
rescue Timeout::Error => error
raise ServerError, error
end
|
[
"def",
"get",
"(",
"url",
",",
"instrumentation",
":",
"{",
"}",
",",
"**",
"_options",
")",
"uri",
"=",
"URI",
".",
"parse",
"url",
"response",
"=",
"ActiveSupport",
"::",
"Notifications",
".",
"instrument",
"(",
"'client_request_matrix_data.google_distance_matrix'",
",",
"instrumentation",
")",
"do",
"Net",
"::",
"HTTP",
".",
"get_response",
"uri",
"end",
"handle",
"response",
",",
"url",
"rescue",
"Timeout",
"::",
"Error",
"=>",
"error",
"raise",
"ServerError",
",",
"error",
"end"
] |
Make a GET request to given URL
@param url The URL to Google's API we'll make a request to
@param instrumentation A hash with instrumentation payload
@param options Other options we don't care about, for example we'll capture
`configuration` option which we are not using, but the ClientCache
is using.
@return Hash with data from parsed response body
|
[
"Make",
"a",
"GET",
"request",
"to",
"given",
"URL"
] |
2bd0eb8eaa430d0a3fa3c047dab303683e7692fe
|
https://github.com/Skalar/google_distance_matrix/blob/2bd0eb8eaa430d0a3fa3c047dab303683e7692fe/lib/google_distance_matrix/client.rb#L23-L35
|
17,816
|
Skalar/google_distance_matrix
|
lib/google_distance_matrix/polyline_encoder.rb
|
GoogleDistanceMatrix.PolylineEncoder.encode
|
def encode
return @encoded if @encoded
deltas = @delta.deltas_rounded @array_of_lat_lng_pairs
chars_array = deltas.map { |v| @value_encoder.encode v }
@encoded = chars_array.join
end
|
ruby
|
def encode
return @encoded if @encoded
deltas = @delta.deltas_rounded @array_of_lat_lng_pairs
chars_array = deltas.map { |v| @value_encoder.encode v }
@encoded = chars_array.join
end
|
[
"def",
"encode",
"return",
"@encoded",
"if",
"@encoded",
"deltas",
"=",
"@delta",
".",
"deltas_rounded",
"@array_of_lat_lng_pairs",
"chars_array",
"=",
"deltas",
".",
"map",
"{",
"|",
"v",
"|",
"@value_encoder",
".",
"encode",
"v",
"}",
"@encoded",
"=",
"chars_array",
".",
"join",
"end"
] |
Initialize a new encoder
Arguments
array_of_lat_lng_pairs - The array of lat/lng pairs, like [[lat, lng], [lat, lng], ..etc]
delta - An object responsible for rounding and calculate the deltas
between the given lat/lng pairs.
value_encoder - After deltas are calculated each value is passed to the encoder
to be encoded in to ASCII characters
@see ::encode
Encode and returns the encoded string
|
[
"Initialize",
"a",
"new",
"encoder"
] |
2bd0eb8eaa430d0a3fa3c047dab303683e7692fe
|
https://github.com/Skalar/google_distance_matrix/blob/2bd0eb8eaa430d0a3fa3c047dab303683e7692fe/lib/google_distance_matrix/polyline_encoder.rb#L38-L45
|
17,817
|
rocketjob/rocketjob_mission_control
|
app/models/rocket_job_mission_control/query.rb
|
RocketJobMissionControl.Query.unsorted_query
|
def unsorted_query
records = scope
# Text Search
if search_term
escaped = Regexp.escape(search_term)
regexp = Regexp.new(escaped, Regexp::IGNORECASE)
if search_columns.size == 1
records = records.where(search_columns.first => regexp)
else
cols = search_columns.collect { |col| {col => regexp} }
records = records.where('$or' => cols)
end
end
# Pagination
if start && page_size
records = records.skip(start).limit(page_size)
end
records
end
|
ruby
|
def unsorted_query
records = scope
# Text Search
if search_term
escaped = Regexp.escape(search_term)
regexp = Regexp.new(escaped, Regexp::IGNORECASE)
if search_columns.size == 1
records = records.where(search_columns.first => regexp)
else
cols = search_columns.collect { |col| {col => regexp} }
records = records.where('$or' => cols)
end
end
# Pagination
if start && page_size
records = records.skip(start).limit(page_size)
end
records
end
|
[
"def",
"unsorted_query",
"records",
"=",
"scope",
"# Text Search",
"if",
"search_term",
"escaped",
"=",
"Regexp",
".",
"escape",
"(",
"search_term",
")",
"regexp",
"=",
"Regexp",
".",
"new",
"(",
"escaped",
",",
"Regexp",
"::",
"IGNORECASE",
")",
"if",
"search_columns",
".",
"size",
"==",
"1",
"records",
"=",
"records",
".",
"where",
"(",
"search_columns",
".",
"first",
"=>",
"regexp",
")",
"else",
"cols",
"=",
"search_columns",
".",
"collect",
"{",
"|",
"col",
"|",
"{",
"col",
"=>",
"regexp",
"}",
"}",
"records",
"=",
"records",
".",
"where",
"(",
"'$or'",
"=>",
"cols",
")",
"end",
"end",
"# Pagination",
"if",
"start",
"&&",
"page_size",
"records",
"=",
"records",
".",
"skip",
"(",
"start",
")",
".",
"limit",
"(",
"page_size",
")",
"end",
"records",
"end"
] |
Returns the filtered query expression
|
[
"Returns",
"the",
"filtered",
"query",
"expression"
] |
5b740662e97bbdcd4d9c3de4909a8e56149469f5
|
https://github.com/rocketjob/rocketjob_mission_control/blob/5b740662e97bbdcd4d9c3de4909a8e56149469f5/app/models/rocket_job_mission_control/query.rb#L35-L54
|
17,818
|
rocketjob/rocketjob_mission_control
|
app/helpers/rocket_job_mission_control/application_helper.rb
|
RocketJobMissionControl.ApplicationHelper.editable_field_html
|
def editable_field_html(klass, field_name, value, f, include_nil_selectors = false)
# When editing a job the values are of the correct type.
# When editing a dirmon entry values are strings.
field = klass.fields[field_name.to_s]
return unless field && field.type
placeholder = field.default_val
placeholder = nil if placeholder.is_a?(Proc)
case field.type.name
when 'Symbol', 'String', 'Integer'
options = extract_inclusion_values(klass, field_name)
str = "[#{field.type.name}]\n".html_safe
if options
str + f.select(field_name, options, { include_blank: options.include?(nil) || include_nil_selectors, selected: value }, { class: 'selectize form-control' })
else
if field.type.name == 'Integer'
str + f.number_field(field_name, value: value, class: 'form-control', placeholder: placeholder)
else
str + f.text_field(field_name, value: value, class: 'form-control', placeholder: placeholder)
end
end
when 'Hash'
"[JSON Hash]\n".html_safe +
f.text_field(field_name, value: value ? value.to_json : '', class: 'form-control', placeholder: '{"key1":"value1", "key2":"value2", "key3":"value3"}')
when 'Array'
options = Array(value)
"[Array]\n".html_safe +
f.select(field_name, options_for_select(options, options), { include_hidden: false }, { class: 'selectize form-control', multiple: true })
when 'Mongoid::Boolean'
name = "#{field_name}_true".to_sym
value = value.to_s
str = '<div class="radio-buttons">'.html_safe
str << f.radio_button(field_name, 'true', checked: value == 'true')
str << ' '.html_safe + f.label(name, 'true')
str << ' '.html_safe + f.radio_button(field_name, 'false', checked: value == 'false')
str << ' '.html_safe + f.label(name, 'false')
# Allow this field to be unset (nil).
if include_nil_selectors
str << ' '.html_safe + f.radio_button(field_name, '', checked: value == '')
str << ' '.html_safe + f.label(name, 'nil')
end
str << '</div>'.html_safe
else
"[#{field.type.name}]".html_safe +
f.text_field(field_name, value: value, class: 'form-control', placeholder: placeholder)
end
end
|
ruby
|
def editable_field_html(klass, field_name, value, f, include_nil_selectors = false)
# When editing a job the values are of the correct type.
# When editing a dirmon entry values are strings.
field = klass.fields[field_name.to_s]
return unless field && field.type
placeholder = field.default_val
placeholder = nil if placeholder.is_a?(Proc)
case field.type.name
when 'Symbol', 'String', 'Integer'
options = extract_inclusion_values(klass, field_name)
str = "[#{field.type.name}]\n".html_safe
if options
str + f.select(field_name, options, { include_blank: options.include?(nil) || include_nil_selectors, selected: value }, { class: 'selectize form-control' })
else
if field.type.name == 'Integer'
str + f.number_field(field_name, value: value, class: 'form-control', placeholder: placeholder)
else
str + f.text_field(field_name, value: value, class: 'form-control', placeholder: placeholder)
end
end
when 'Hash'
"[JSON Hash]\n".html_safe +
f.text_field(field_name, value: value ? value.to_json : '', class: 'form-control', placeholder: '{"key1":"value1", "key2":"value2", "key3":"value3"}')
when 'Array'
options = Array(value)
"[Array]\n".html_safe +
f.select(field_name, options_for_select(options, options), { include_hidden: false }, { class: 'selectize form-control', multiple: true })
when 'Mongoid::Boolean'
name = "#{field_name}_true".to_sym
value = value.to_s
str = '<div class="radio-buttons">'.html_safe
str << f.radio_button(field_name, 'true', checked: value == 'true')
str << ' '.html_safe + f.label(name, 'true')
str << ' '.html_safe + f.radio_button(field_name, 'false', checked: value == 'false')
str << ' '.html_safe + f.label(name, 'false')
# Allow this field to be unset (nil).
if include_nil_selectors
str << ' '.html_safe + f.radio_button(field_name, '', checked: value == '')
str << ' '.html_safe + f.label(name, 'nil')
end
str << '</div>'.html_safe
else
"[#{field.type.name}]".html_safe +
f.text_field(field_name, value: value, class: 'form-control', placeholder: placeholder)
end
end
|
[
"def",
"editable_field_html",
"(",
"klass",
",",
"field_name",
",",
"value",
",",
"f",
",",
"include_nil_selectors",
"=",
"false",
")",
"# When editing a job the values are of the correct type.",
"# When editing a dirmon entry values are strings.",
"field",
"=",
"klass",
".",
"fields",
"[",
"field_name",
".",
"to_s",
"]",
"return",
"unless",
"field",
"&&",
"field",
".",
"type",
"placeholder",
"=",
"field",
".",
"default_val",
"placeholder",
"=",
"nil",
"if",
"placeholder",
".",
"is_a?",
"(",
"Proc",
")",
"case",
"field",
".",
"type",
".",
"name",
"when",
"'Symbol'",
",",
"'String'",
",",
"'Integer'",
"options",
"=",
"extract_inclusion_values",
"(",
"klass",
",",
"field_name",
")",
"str",
"=",
"\"[#{field.type.name}]\\n\"",
".",
"html_safe",
"if",
"options",
"str",
"+",
"f",
".",
"select",
"(",
"field_name",
",",
"options",
",",
"{",
"include_blank",
":",
"options",
".",
"include?",
"(",
"nil",
")",
"||",
"include_nil_selectors",
",",
"selected",
":",
"value",
"}",
",",
"{",
"class",
":",
"'selectize form-control'",
"}",
")",
"else",
"if",
"field",
".",
"type",
".",
"name",
"==",
"'Integer'",
"str",
"+",
"f",
".",
"number_field",
"(",
"field_name",
",",
"value",
":",
"value",
",",
"class",
":",
"'form-control'",
",",
"placeholder",
":",
"placeholder",
")",
"else",
"str",
"+",
"f",
".",
"text_field",
"(",
"field_name",
",",
"value",
":",
"value",
",",
"class",
":",
"'form-control'",
",",
"placeholder",
":",
"placeholder",
")",
"end",
"end",
"when",
"'Hash'",
"\"[JSON Hash]\\n\"",
".",
"html_safe",
"+",
"f",
".",
"text_field",
"(",
"field_name",
",",
"value",
":",
"value",
"?",
"value",
".",
"to_json",
":",
"''",
",",
"class",
":",
"'form-control'",
",",
"placeholder",
":",
"'{\"key1\":\"value1\", \"key2\":\"value2\", \"key3\":\"value3\"}'",
")",
"when",
"'Array'",
"options",
"=",
"Array",
"(",
"value",
")",
"\"[Array]\\n\"",
".",
"html_safe",
"+",
"f",
".",
"select",
"(",
"field_name",
",",
"options_for_select",
"(",
"options",
",",
"options",
")",
",",
"{",
"include_hidden",
":",
"false",
"}",
",",
"{",
"class",
":",
"'selectize form-control'",
",",
"multiple",
":",
"true",
"}",
")",
"when",
"'Mongoid::Boolean'",
"name",
"=",
"\"#{field_name}_true\"",
".",
"to_sym",
"value",
"=",
"value",
".",
"to_s",
"str",
"=",
"'<div class=\"radio-buttons\">'",
".",
"html_safe",
"str",
"<<",
"f",
".",
"radio_button",
"(",
"field_name",
",",
"'true'",
",",
"checked",
":",
"value",
"==",
"'true'",
")",
"str",
"<<",
"' '",
".",
"html_safe",
"+",
"f",
".",
"label",
"(",
"name",
",",
"'true'",
")",
"str",
"<<",
"' '",
".",
"html_safe",
"+",
"f",
".",
"radio_button",
"(",
"field_name",
",",
"'false'",
",",
"checked",
":",
"value",
"==",
"'false'",
")",
"str",
"<<",
"' '",
".",
"html_safe",
"+",
"f",
".",
"label",
"(",
"name",
",",
"'false'",
")",
"# Allow this field to be unset (nil).",
"if",
"include_nil_selectors",
"str",
"<<",
"' '",
".",
"html_safe",
"+",
"f",
".",
"radio_button",
"(",
"field_name",
",",
"''",
",",
"checked",
":",
"value",
"==",
"''",
")",
"str",
"<<",
"' '",
".",
"html_safe",
"+",
"f",
".",
"label",
"(",
"name",
",",
"'nil'",
")",
"end",
"str",
"<<",
"'</div>'",
".",
"html_safe",
"else",
"\"[#{field.type.name}]\"",
".",
"html_safe",
"+",
"f",
".",
"text_field",
"(",
"field_name",
",",
"value",
":",
"value",
",",
"class",
":",
"'form-control'",
",",
"placeholder",
":",
"placeholder",
")",
"end",
"end"
] |
Returns the editable field as html for use in editing dynamic fields from a Job class.
|
[
"Returns",
"the",
"editable",
"field",
"as",
"html",
"for",
"use",
"in",
"editing",
"dynamic",
"fields",
"from",
"a",
"Job",
"class",
"."
] |
5b740662e97bbdcd4d9c3de4909a8e56149469f5
|
https://github.com/rocketjob/rocketjob_mission_control/blob/5b740662e97bbdcd4d9c3de4909a8e56149469f5/app/helpers/rocket_job_mission_control/application_helper.rb#L59-L107
|
17,819
|
rocketjob/rocketjob_mission_control
|
app/datatables/rocket_job_mission_control/jobs_datatable.rb
|
RocketJobMissionControl.JobsDatatable.map
|
def map(job)
index = 0
h = {}
@columns.each do |column|
h[index.to_s] = send(column[:value], job)
index += 1
end
h['DT_RowClass'] = "card callout callout-#{job_state(job)}"
h
end
|
ruby
|
def map(job)
index = 0
h = {}
@columns.each do |column|
h[index.to_s] = send(column[:value], job)
index += 1
end
h['DT_RowClass'] = "card callout callout-#{job_state(job)}"
h
end
|
[
"def",
"map",
"(",
"job",
")",
"index",
"=",
"0",
"h",
"=",
"{",
"}",
"@columns",
".",
"each",
"do",
"|",
"column",
"|",
"h",
"[",
"index",
".",
"to_s",
"]",
"=",
"send",
"(",
"column",
"[",
":value",
"]",
",",
"job",
")",
"index",
"+=",
"1",
"end",
"h",
"[",
"'DT_RowClass'",
"]",
"=",
"\"card callout callout-#{job_state(job)}\"",
"h",
"end"
] |
Map the values for each column
|
[
"Map",
"the",
"values",
"for",
"each",
"column"
] |
5b740662e97bbdcd4d9c3de4909a8e56149469f5
|
https://github.com/rocketjob/rocketjob_mission_control/blob/5b740662e97bbdcd4d9c3de4909a8e56149469f5/app/datatables/rocket_job_mission_control/jobs_datatable.rb#L82-L91
|
17,820
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb
|
OoxmlParser.SharedStringTable.parse
|
def parse(file)
return nil unless File.exist?(file)
document = parse_xml(file)
node = document.xpath('*').first
node.attributes.each do |key, value|
case key
when 'count'
@count = value.value.to_i
when 'uniqueCount'
@unique_count = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'si'
@string_indexes << StringIndex.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(file)
return nil unless File.exist?(file)
document = parse_xml(file)
node = document.xpath('*').first
node.attributes.each do |key, value|
case key
when 'count'
@count = value.value.to_i
when 'uniqueCount'
@unique_count = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'si'
@string_indexes << StringIndex.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"file",
")",
"return",
"nil",
"unless",
"File",
".",
"exist?",
"(",
"file",
")",
"document",
"=",
"parse_xml",
"(",
"file",
")",
"node",
"=",
"document",
".",
"xpath",
"(",
"'*'",
")",
".",
"first",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'count'",
"@count",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'uniqueCount'",
"@unique_count",
"=",
"value",
".",
"value",
".",
"to_i",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'si'",
"@string_indexes",
"<<",
"StringIndex",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse Shared string table file
@param file [String] path to file
@return [SharedStringTable]
|
[
"Parse",
"Shared",
"string",
"table",
"file"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb#L20-L42
|
17,821
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb
|
OoxmlParser.OldDocxGroup.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'shape'
element = OldDocxGroupElement.new(:shape)
element.object = OldDocxShape.new(parent: self).parse(node_child)
@elements << element
when 'wrap'
@properties.wrap = node_child.attribute('type').value.to_sym unless node_child.attribute('type').nil?
when 'group'
@elements << OldDocxGroup.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'shape'
element = OldDocxGroupElement.new(:shape)
element.object = OldDocxShape.new(parent: self).parse(node_child)
@elements << element
when 'wrap'
@properties.wrap = node_child.attribute('type').value.to_sym unless node_child.attribute('type').nil?
when 'group'
@elements << OldDocxGroup.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'shape'",
"element",
"=",
"OldDocxGroupElement",
".",
"new",
"(",
":shape",
")",
"element",
".",
"object",
"=",
"OldDocxShape",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"@elements",
"<<",
"element",
"when",
"'wrap'",
"@properties",
".",
"wrap",
"=",
"node_child",
".",
"attribute",
"(",
"'type'",
")",
".",
"value",
".",
"to_sym",
"unless",
"node_child",
".",
"attribute",
"(",
"'type'",
")",
".",
"nil?",
"when",
"'group'",
"@elements",
"<<",
"OldDocxGroup",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse OldDocxGroup object
@param node [Nokogiri::XML:Element] node to parse
@return [OldDocxGroup] result of parsing
|
[
"Parse",
"OldDocxGroup",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb#L17-L31
|
17,822
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/plot_area.rb
|
OoxmlParser.PlotArea.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'barChart'
@bar_chart = CommonChartData.new(parent: self).parse(node_child)
when 'lineChart'
@line_chart = CommonChartData.new(parent: self).parse(node_child)
when 'areaChart'
@area_chart = CommonChartData.new(parent: self).parse(node_child)
when 'bubbleChart'
@bubble_chart = CommonChartData.new(parent: self).parse(node_child)
when 'doughnutChart'
@doughnut_chart = CommonChartData.new(parent: self).parse(node_child)
when 'pieChart'
@pie_chart = CommonChartData.new(parent: self).parse(node_child)
when 'scatterChart'
@scatter_chart = CommonChartData.new(parent: self).parse(node_child)
when 'radarChart'
@radar_chart = CommonChartData.new(parent: self).parse(node_child)
when 'stockChart'
@stock_chart = CommonChartData.new(parent: self).parse(node_child)
when 'surface3DChart'
@surface_3d_chart = CommonChartData.new(parent: self).parse(node_child)
when 'line3DChart'
@line_3d_chart = CommonChartData.new(parent: self).parse(node_child)
when 'bar3DChart'
@bar_3d_chart = CommonChartData.new(parent: self).parse(node_child)
when 'pie3DChart'
@pie_3d_chart = CommonChartData.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'barChart'
@bar_chart = CommonChartData.new(parent: self).parse(node_child)
when 'lineChart'
@line_chart = CommonChartData.new(parent: self).parse(node_child)
when 'areaChart'
@area_chart = CommonChartData.new(parent: self).parse(node_child)
when 'bubbleChart'
@bubble_chart = CommonChartData.new(parent: self).parse(node_child)
when 'doughnutChart'
@doughnut_chart = CommonChartData.new(parent: self).parse(node_child)
when 'pieChart'
@pie_chart = CommonChartData.new(parent: self).parse(node_child)
when 'scatterChart'
@scatter_chart = CommonChartData.new(parent: self).parse(node_child)
when 'radarChart'
@radar_chart = CommonChartData.new(parent: self).parse(node_child)
when 'stockChart'
@stock_chart = CommonChartData.new(parent: self).parse(node_child)
when 'surface3DChart'
@surface_3d_chart = CommonChartData.new(parent: self).parse(node_child)
when 'line3DChart'
@line_3d_chart = CommonChartData.new(parent: self).parse(node_child)
when 'bar3DChart'
@bar_3d_chart = CommonChartData.new(parent: self).parse(node_child)
when 'pie3DChart'
@pie_3d_chart = CommonChartData.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'barChart'",
"@bar_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'lineChart'",
"@line_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'areaChart'",
"@area_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'bubbleChart'",
"@bubble_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'doughnutChart'",
"@doughnut_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'pieChart'",
"@pie_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'scatterChart'",
"@scatter_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'radarChart'",
"@radar_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'stockChart'",
"@stock_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'surface3DChart'",
"@surface_3d_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'line3DChart'",
"@line_3d_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'bar3DChart'",
"@bar_3d_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'pie3DChart'",
"@pie_3d_chart",
"=",
"CommonChartData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse View3D object
@param node [Nokogiri::XML:Element] node to parse
@return [View3D] result of parsing
|
[
"Parse",
"View3D",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/plot_area.rb#L31-L63
|
17,823
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb
|
OoxmlParser.DisplayLabelsProperties.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'dLblPos'
@position = value_to_symbol(node_child.attribute('val'))
when 'showLegendKey'
@show_legend_key = true if node_child.attribute('val').value == '1'
when 'showVal'
@show_values = true if node_child.attribute('val').value == '1'
when 'showCatName'
@show_category_name = option_enabled?(node_child)
when 'showSerName'
@show_series_name = option_enabled?(node_child)
when 'delete'
@delete = option_enabled?(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'dLblPos'
@position = value_to_symbol(node_child.attribute('val'))
when 'showLegendKey'
@show_legend_key = true if node_child.attribute('val').value == '1'
when 'showVal'
@show_values = true if node_child.attribute('val').value == '1'
when 'showCatName'
@show_category_name = option_enabled?(node_child)
when 'showSerName'
@show_series_name = option_enabled?(node_child)
when 'delete'
@delete = option_enabled?(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'dLblPos'",
"@position",
"=",
"value_to_symbol",
"(",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
")",
"when",
"'showLegendKey'",
"@show_legend_key",
"=",
"true",
"if",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"==",
"'1'",
"when",
"'showVal'",
"@show_values",
"=",
"true",
"if",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"==",
"'1'",
"when",
"'showCatName'",
"@show_category_name",
"=",
"option_enabled?",
"(",
"node_child",
")",
"when",
"'showSerName'",
"@show_series_name",
"=",
"option_enabled?",
"(",
"node_child",
")",
"when",
"'delete'",
"@delete",
"=",
"option_enabled?",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse DisplayLabelsProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [DisplayLabelsProperties] result of parsing
|
[
"Parse",
"DisplayLabelsProperties",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb#L21-L39
|
17,824
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_pattern_fill.rb
|
OoxmlParser.DocxPatternFill.parse
|
def parse(node)
@preset = node.attribute('prst').value.to_sym
node.xpath('*').each do |node_child|
case node_child.name
when 'fgClr'
@foreground_color = Color.new(parent: self).parse_color_model(node_child)
when 'bgClr'
@background_color = Color.new(parent: self).parse_color_model(node_child)
end
end
self
end
|
ruby
|
def parse(node)
@preset = node.attribute('prst').value.to_sym
node.xpath('*').each do |node_child|
case node_child.name
when 'fgClr'
@foreground_color = Color.new(parent: self).parse_color_model(node_child)
when 'bgClr'
@background_color = Color.new(parent: self).parse_color_model(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"@preset",
"=",
"node",
".",
"attribute",
"(",
"'prst'",
")",
".",
"value",
".",
"to_sym",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'fgClr'",
"@foreground_color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_color_model",
"(",
"node_child",
")",
"when",
"'bgClr'",
"@background_color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_color_model",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse DocxPatternFill object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxPatternFill] result of parsing
|
[
"Parse",
"DocxPatternFill",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_pattern_fill.rb#L9-L20
|
17,825
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_fill.rb
|
OoxmlParser.OldDocxShapeFill.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'id'
@file_reference = FileReference.new(parent: self).parse(node)
when 'type'
@stretching_type = case value.value
when 'frame'
:stretch
else
value.value.to_sym
end
when 'title'
@title = value.value.to_s
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'id'
@file_reference = FileReference.new(parent: self).parse(node)
when 'type'
@stretching_type = case value.value
when 'frame'
:stretch
else
value.value.to_sym
end
when 'title'
@title = value.value.to_s
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'id'",
"@file_reference",
"=",
"FileReference",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"when",
"'type'",
"@stretching_type",
"=",
"case",
"value",
".",
"value",
"when",
"'frame'",
":stretch",
"else",
"value",
".",
"value",
".",
"to_sym",
"end",
"when",
"'title'",
"@title",
"=",
"value",
".",
"value",
".",
"to_s",
"end",
"end",
"self",
"end"
] |
Parse OldDocxShapeFill object
@param node [Nokogiri::XML:Element] node to parse
@return [OldDocxShapeFill] result of parsing
|
[
"Parse",
"OldDocxShapeFill",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_fill.rb#L11-L28
|
17,826
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb
|
OoxmlParser.ParagraphBorders.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'bottom'
@bottom = BordersProperties.new(parent: self).parse(node_child)
when 'left'
@left = BordersProperties.new(parent: self).parse(node_child)
when 'top'
@top = BordersProperties.new(parent: self).parse(node_child)
when 'right'
@right = BordersProperties.new(parent: self).parse(node_child)
when 'between'
@between = BordersProperties.new(parent: self).parse(node_child)
when 'bar'
@bar = BordersProperties.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'bottom'
@bottom = BordersProperties.new(parent: self).parse(node_child)
when 'left'
@left = BordersProperties.new(parent: self).parse(node_child)
when 'top'
@top = BordersProperties.new(parent: self).parse(node_child)
when 'right'
@right = BordersProperties.new(parent: self).parse(node_child)
when 'between'
@between = BordersProperties.new(parent: self).parse(node_child)
when 'bar'
@bar = BordersProperties.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'bottom'",
"@bottom",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'left'",
"@left",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'top'",
"@top",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'right'",
"@right",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'between'",
"@between",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'bar'",
"@bar",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse Paragraph Borders data
@param [Nokogiri::XML:Element] node with Paragraph Borders data
@return [ParagraphBorders] value of Paragraph Borders data
|
[
"Parse",
"Paragraph",
"Borders",
"data"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb#L34-L52
|
17,827
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb
|
OoxmlParser.PresentationAlternateContent.parse
|
def parse(node)
node.xpath('mc:Choice/*', 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006').each do |node_child|
case node_child.name
when 'timing'
@timing = Timing.new(parent: self).parse(node_child)
when 'transition'
@transition = Transition.new(parent: self).parse(node_child)
when 'sp'
@elements << DocxShape.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('mc:Choice/*', 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006').each do |node_child|
case node_child.name
when 'timing'
@timing = Timing.new(parent: self).parse(node_child)
when 'transition'
@transition = Transition.new(parent: self).parse(node_child)
when 'sp'
@elements << DocxShape.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'mc:Choice/*'",
",",
"'xmlns:mc'",
"=>",
"'http://schemas.openxmlformats.org/markup-compatibility/2006'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'timing'",
"@timing",
"=",
"Timing",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'transition'",
"@transition",
"=",
"Transition",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'sp'",
"@elements",
"<<",
"DocxShape",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse PresentationAlternateContent object
@param node [Nokogiri::XML:Element] node to parse
@return [PresentationAlternateContent] result of parsing
|
[
"Parse",
"PresentationAlternateContent",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb#L15-L27
|
17,828
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb
|
OoxmlParser.DocxColorScheme.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'solidFill'
@type = :solid
@color = Color.new(parent: self).parse_color_model(node_child)
when 'gradFill'
@type = :gradient
@color = GradientColor.new(parent: self).parse(node_child)
when 'noFill'
@color = :none
@type = :none
when 'srgbClr'
@color = Color.new(parent: self).parse_hex_string(node_child.attribute('val').value)
when 'schemeClr'
@color = Color.new(parent: self).parse_scheme_color(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'solidFill'
@type = :solid
@color = Color.new(parent: self).parse_color_model(node_child)
when 'gradFill'
@type = :gradient
@color = GradientColor.new(parent: self).parse(node_child)
when 'noFill'
@color = :none
@type = :none
when 'srgbClr'
@color = Color.new(parent: self).parse_hex_string(node_child.attribute('val').value)
when 'schemeClr'
@color = Color.new(parent: self).parse_scheme_color(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'solidFill'",
"@type",
"=",
":solid",
"@color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_color_model",
"(",
"node_child",
")",
"when",
"'gradFill'",
"@type",
"=",
":gradient",
"@color",
"=",
"GradientColor",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'noFill'",
"@color",
"=",
":none",
"@type",
"=",
":none",
"when",
"'srgbClr'",
"@color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_hex_string",
"(",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
")",
"when",
"'schemeClr'",
"@color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_scheme_color",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse DocxColorScheme object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxColorScheme] result of parsing
|
[
"Parse",
"DocxColorScheme",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb#L15-L34
|
17,829
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
|
OoxmlParser.DocumentBackground.parse
|
def parse(node)
@color1 = Color.new(parent: self).parse_hex_string(node.attribute('color').value)
node.xpath('v:background').each do |second_color|
@size = second_color.attribute('targetscreensize').value.sub(',', 'x') unless second_color.attribute('targetscreensize').nil?
second_color.xpath('*').each do |node_child|
case node_child.name
when 'fill'
@fill = Fill.new(parent: self).parse(node_child)
end
end
end
self
end
|
ruby
|
def parse(node)
@color1 = Color.new(parent: self).parse_hex_string(node.attribute('color').value)
node.xpath('v:background').each do |second_color|
@size = second_color.attribute('targetscreensize').value.sub(',', 'x') unless second_color.attribute('targetscreensize').nil?
second_color.xpath('*').each do |node_child|
case node_child.name
when 'fill'
@fill = Fill.new(parent: self).parse(node_child)
end
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"@color1",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_hex_string",
"(",
"node",
".",
"attribute",
"(",
"'color'",
")",
".",
"value",
")",
"node",
".",
"xpath",
"(",
"'v:background'",
")",
".",
"each",
"do",
"|",
"second_color",
"|",
"@size",
"=",
"second_color",
".",
"attribute",
"(",
"'targetscreensize'",
")",
".",
"value",
".",
"sub",
"(",
"','",
",",
"'x'",
")",
"unless",
"second_color",
".",
"attribute",
"(",
"'targetscreensize'",
")",
".",
"nil?",
"second_color",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'fill'",
"@fill",
"=",
"Fill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"end",
"self",
"end"
] |
Parse DocumentBackground object
@param node [Nokogiri::XML:Element] node to parse
@return [DocumentBackground] result of parsing
|
[
"Parse",
"DocumentBackground",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb#L19-L31
|
17,830
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/ole_objects.rb
|
OoxmlParser.OleObjects.parse
|
def parse(node)
list = []
node.xpath('*').each do |node_child|
case node_child.name
when 'AlternateContent'
list << AlternateContent.new(parent: self).parse(node_child)
end
end
list
end
|
ruby
|
def parse(node)
list = []
node.xpath('*').each do |node_child|
case node_child.name
when 'AlternateContent'
list << AlternateContent.new(parent: self).parse(node_child)
end
end
list
end
|
[
"def",
"parse",
"(",
"node",
")",
"list",
"=",
"[",
"]",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'AlternateContent'",
"list",
"<<",
"AlternateContent",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"list",
"end"
] |
Parse OleObjects object
@param node [Nokogiri::XML:Element] node to parse
@return [Array] list of OleObjects
|
[
"Parse",
"OleObjects",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/ole_objects.rb#L7-L16
|
17,831
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb
|
OoxmlParser.DocumentStyle.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'type'
@type = value.value.to_sym
when 'styleId'
@style_id = value.value
when 'default'
@default = attribute_enabled?(value.value)
end
end
node.xpath('*').each do |subnode|
case subnode.name
when 'name'
@name = subnode.attribute('val').value
when 'basedOn'
@based_on = subnode.attribute('val').value
when 'next'
@next_style = subnode.attribute('val').value
when 'rPr'
@run_properties = DocxParagraphRun.new(parent: self).parse_properties(subnode)
when 'pPr'
@paragraph_properties = ParagraphProperties.new(parent: self).parse(subnode)
when 'tblPr'
@table_properties = TableProperties.new(parent: self).parse(subnode)
when 'trPr'
@table_row_properties = TableRowProperties.new(parent: self).parse(subnode)
when 'tcPr'
@table_cell_properties = CellProperties.new(parent: self).parse(subnode)
when 'tblStylePr'
@table_style_properties_list << TableStyleProperties.new(parent: self).parse(subnode)
when 'qFormat'
@q_format = true
end
end
fill_empty_table_styles
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'type'
@type = value.value.to_sym
when 'styleId'
@style_id = value.value
when 'default'
@default = attribute_enabled?(value.value)
end
end
node.xpath('*').each do |subnode|
case subnode.name
when 'name'
@name = subnode.attribute('val').value
when 'basedOn'
@based_on = subnode.attribute('val').value
when 'next'
@next_style = subnode.attribute('val').value
when 'rPr'
@run_properties = DocxParagraphRun.new(parent: self).parse_properties(subnode)
when 'pPr'
@paragraph_properties = ParagraphProperties.new(parent: self).parse(subnode)
when 'tblPr'
@table_properties = TableProperties.new(parent: self).parse(subnode)
when 'trPr'
@table_row_properties = TableRowProperties.new(parent: self).parse(subnode)
when 'tcPr'
@table_cell_properties = CellProperties.new(parent: self).parse(subnode)
when 'tblStylePr'
@table_style_properties_list << TableStyleProperties.new(parent: self).parse(subnode)
when 'qFormat'
@q_format = true
end
end
fill_empty_table_styles
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'type'",
"@type",
"=",
"value",
".",
"value",
".",
"to_sym",
"when",
"'styleId'",
"@style_id",
"=",
"value",
".",
"value",
"when",
"'default'",
"@default",
"=",
"attribute_enabled?",
"(",
"value",
".",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"subnode",
"|",
"case",
"subnode",
".",
"name",
"when",
"'name'",
"@name",
"=",
"subnode",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"when",
"'basedOn'",
"@based_on",
"=",
"subnode",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"when",
"'next'",
"@next_style",
"=",
"subnode",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"when",
"'rPr'",
"@run_properties",
"=",
"DocxParagraphRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_properties",
"(",
"subnode",
")",
"when",
"'pPr'",
"@paragraph_properties",
"=",
"ParagraphProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"subnode",
")",
"when",
"'tblPr'",
"@table_properties",
"=",
"TableProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"subnode",
")",
"when",
"'trPr'",
"@table_row_properties",
"=",
"TableRowProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"subnode",
")",
"when",
"'tcPr'",
"@table_cell_properties",
"=",
"CellProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"subnode",
")",
"when",
"'tblStylePr'",
"@table_style_properties_list",
"<<",
"TableStyleProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"subnode",
")",
"when",
"'qFormat'",
"@q_format",
"=",
"true",
"end",
"end",
"fill_empty_table_styles",
"self",
"end"
] |
Parse single document style
@return [DocumentStyle]
|
[
"Parse",
"single",
"document",
"style"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb#L54-L91
|
17,832
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb
|
OoxmlParser.Worksheet.parse_drawing
|
def parse_drawing
drawing_node = parse_xml(OOXMLDocumentObject.current_xml)
drawing_node.xpath('xdr:wsDr/*').each do |drawing_node_child|
@drawings << XlsxDrawing.new(parent: self).parse(drawing_node_child)
end
end
|
ruby
|
def parse_drawing
drawing_node = parse_xml(OOXMLDocumentObject.current_xml)
drawing_node.xpath('xdr:wsDr/*').each do |drawing_node_child|
@drawings << XlsxDrawing.new(parent: self).parse(drawing_node_child)
end
end
|
[
"def",
"parse_drawing",
"drawing_node",
"=",
"parse_xml",
"(",
"OOXMLDocumentObject",
".",
"current_xml",
")",
"drawing_node",
".",
"xpath",
"(",
"'xdr:wsDr/*'",
")",
".",
"each",
"do",
"|",
"drawing_node_child",
"|",
"@drawings",
"<<",
"XlsxDrawing",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"drawing_node_child",
")",
"end",
"end"
] |
Parse list of drawings in file
|
[
"Parse",
"list",
"of",
"drawings",
"in",
"file"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb#L59-L64
|
17,833
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb
|
OoxmlParser.Worksheet.parse_comments
|
def parse_comments
return unless relationships
comments_target = relationships.target_by_type('comment')
return if comments_target.empty?
comments_file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/#{comments_target.first.gsub('..', '')}"
@comments = ExcelComments.new(parent: self).parse(comments_file)
end
|
ruby
|
def parse_comments
return unless relationships
comments_target = relationships.target_by_type('comment')
return if comments_target.empty?
comments_file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/#{comments_target.first.gsub('..', '')}"
@comments = ExcelComments.new(parent: self).parse(comments_file)
end
|
[
"def",
"parse_comments",
"return",
"unless",
"relationships",
"comments_target",
"=",
"relationships",
".",
"target_by_type",
"(",
"'comment'",
")",
"return",
"if",
"comments_target",
".",
"empty?",
"comments_file",
"=",
"\"#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/#{comments_target.first.gsub('..', '')}\"",
"@comments",
"=",
"ExcelComments",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"comments_file",
")",
"end"
] |
Do work for parsing shared comments file
|
[
"Do",
"work",
"for",
"parsing",
"shared",
"comments",
"file"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb#L128-L136
|
17,834
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table/string_index.rb
|
OoxmlParser.StringIndex.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 't'
@text = node_child.text
when 'r'
@run = ParagraphRun.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 't'
@text = node_child.text
when 'r'
@run = ParagraphRun.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'t'",
"@text",
"=",
"node_child",
".",
"text",
"when",
"'r'",
"@run",
"=",
"ParagraphRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse StringIndex data
@param [Nokogiri::XML:Element] node with StringIndex data
@return [StringIndex] value of StringIndex data
|
[
"Parse",
"StringIndex",
"data"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table/string_index.rb#L12-L22
|
17,835
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/bookmark_start.rb
|
OoxmlParser.BookmarkStart.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'id'
@id = value.value.to_i
when 'name'
@name = value.value
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'id'
@id = value.value.to_i
when 'name'
@name = value.value
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'id'",
"@id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'name'",
"@name",
"=",
"value",
".",
"value",
"end",
"end",
"self",
"end"
] |
Parse BookmarkStart object
@param node [Nokogiri::XML:Element] node to parse
@return [BookmarkStart] result of parsing
|
[
"Parse",
"BookmarkStart",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/bookmark_start.rb#L12-L22
|
17,836
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb
|
OoxmlParser.Behavior.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'cTn'
@common_time_node = CommonTiming.new(parent: self).parse(node_child)
when 'tgtEl'
@target = TargetElement.new(parent: self).parse(node_child)
when 'attrNameLst'
node_child.xpath('p:attrName').each do |attribute_name_node|
@attribute_name_list << attribute_name_node.text
end
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'cTn'
@common_time_node = CommonTiming.new(parent: self).parse(node_child)
when 'tgtEl'
@target = TargetElement.new(parent: self).parse(node_child)
when 'attrNameLst'
node_child.xpath('p:attrName').each do |attribute_name_node|
@attribute_name_list << attribute_name_node.text
end
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'cTn'",
"@common_time_node",
"=",
"CommonTiming",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tgtEl'",
"@target",
"=",
"TargetElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'attrNameLst'",
"node_child",
".",
"xpath",
"(",
"'p:attrName'",
")",
".",
"each",
"do",
"|",
"attribute_name_node",
"|",
"@attribute_name_list",
"<<",
"attribute_name_node",
".",
"text",
"end",
"end",
"end",
"self",
"end"
] |
Parse Behavior object
@param node [Nokogiri::XML:Element] node to parse
@return [Behavior] result of parsing
|
[
"Parse",
"Behavior",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb#L14-L28
|
17,837
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering.rb
|
OoxmlParser.AbstractNumbering.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'abstractNumId'
@id = value.value.to_f
end
end
node.xpath('*').each do |numbering_child_node|
case numbering_child_node.name
when 'multiLevelType'
@multilevel_type = MultilevelType.new(parent: self).parse(numbering_child_node)
when 'lvl'
@level_list << NumberingLevel.new(parent: self).parse(numbering_child_node)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'abstractNumId'
@id = value.value.to_f
end
end
node.xpath('*').each do |numbering_child_node|
case numbering_child_node.name
when 'multiLevelType'
@multilevel_type = MultilevelType.new(parent: self).parse(numbering_child_node)
when 'lvl'
@level_list << NumberingLevel.new(parent: self).parse(numbering_child_node)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'abstractNumId'",
"@id",
"=",
"value",
".",
"value",
".",
"to_f",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"numbering_child_node",
"|",
"case",
"numbering_child_node",
".",
"name",
"when",
"'multiLevelType'",
"@multilevel_type",
"=",
"MultilevelType",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"numbering_child_node",
")",
"when",
"'lvl'",
"@level_list",
"<<",
"NumberingLevel",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"numbering_child_node",
")",
"end",
"end",
"self",
"end"
] |
Parse Abstract Numbering data
@param [Nokogiri::XML:Element] node with Abstract Numbering data
@return [AbstractNumbering] value of Abstract Numbering data
|
[
"Parse",
"Abstract",
"Numbering",
"data"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering.rb#L23-L40
|
17,838
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb
|
OoxmlParser.XlsxRow.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'customHeight'
@custom_height = option_enabled?(node, 'customHeight')
when 'ht'
@height = OoxmlSize.new(value.value.to_f, :point)
when 'hidden'
@hidden = option_enabled?(node, 'hidden')
when 'r'
@index = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'c'
@cells[Coordinates.parse_coordinates_from_string(node_child.attribute('r').value.to_s).column_number.to_i - 1] = XlsxCell.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'customHeight'
@custom_height = option_enabled?(node, 'customHeight')
when 'ht'
@height = OoxmlSize.new(value.value.to_f, :point)
when 'hidden'
@hidden = option_enabled?(node, 'hidden')
when 'r'
@index = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'c'
@cells[Coordinates.parse_coordinates_from_string(node_child.attribute('r').value.to_s).column_number.to_i - 1] = XlsxCell.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'customHeight'",
"@custom_height",
"=",
"option_enabled?",
"(",
"node",
",",
"'customHeight'",
")",
"when",
"'ht'",
"@height",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
",",
":point",
")",
"when",
"'hidden'",
"@hidden",
"=",
"option_enabled?",
"(",
"node",
",",
"'hidden'",
")",
"when",
"'r'",
"@index",
"=",
"value",
".",
"value",
".",
"to_i",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'c'",
"@cells",
"[",
"Coordinates",
".",
"parse_coordinates_from_string",
"(",
"node_child",
".",
"attribute",
"(",
"'r'",
")",
".",
"value",
".",
"to_s",
")",
".",
"column_number",
".",
"to_i",
"-",
"1",
"]",
"=",
"XlsxCell",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse XlsxRow object
@param node [Nokogiri::XML:Element] node to parse
@return [XlsxRow] result of parsing
|
[
"Parse",
"XlsxRow",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb#L19-L39
|
17,839
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/accent.rb
|
OoxmlParser.Accent.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'accPr'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'chr'
@symbol = node_child_child.attribute('val').value
end
end
end
end
@element = DocxFormula.new(parent: self).parse(node)
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'accPr'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'chr'
@symbol = node_child_child.attribute('val').value
end
end
end
end
@element = DocxFormula.new(parent: self).parse(node)
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'accPr'",
"node_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child_child",
"|",
"case",
"node_child_child",
".",
"name",
"when",
"'chr'",
"@symbol",
"=",
"node_child_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"end",
"end",
"end",
"end",
"@element",
"=",
"DocxFormula",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"self",
"end"
] |
Parse Accent object
@param node [Nokogiri::XML:Element] node to parse
@return [Accent] result of parsing
|
[
"Parse",
"Accent",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/accent.rb#L9-L23
|
17,840
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/color.rb
|
OoxmlParser.Color.looks_like?
|
def looks_like?(color_to_check = nil, delta = 8)
color_to_check = color_to_check.converted_color if color_to_check.is_a?(SchemeColor)
color_to_check = color_to_check.pattern_fill.foreground_folor if color_to_check.is_a?(Fill)
color_to_check = color_to_check.color.converted_color if color_to_check.is_a?(PresentationFill)
color_to_check = Color.parse(color_to_check) if color_to_check.is_a?(String)
color_to_check = Color.parse(color_to_check.to_s) if color_to_check.is_a?(Symbol)
color_to_check = Color.parse(color_to_check.value) if color_to_check.is_a?(DocxColor)
return true if none? && color_to_check.nil?
return true if none? && color_to_check.none?
return false if none? && color_to_check.any?
return false if !none? && color_to_check.none?
return true if self == color_to_check
red = color_to_check.red
green = color_to_check.green
blue = color_to_check.blue
(self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta ? true : false
end
|
ruby
|
def looks_like?(color_to_check = nil, delta = 8)
color_to_check = color_to_check.converted_color if color_to_check.is_a?(SchemeColor)
color_to_check = color_to_check.pattern_fill.foreground_folor if color_to_check.is_a?(Fill)
color_to_check = color_to_check.color.converted_color if color_to_check.is_a?(PresentationFill)
color_to_check = Color.parse(color_to_check) if color_to_check.is_a?(String)
color_to_check = Color.parse(color_to_check.to_s) if color_to_check.is_a?(Symbol)
color_to_check = Color.parse(color_to_check.value) if color_to_check.is_a?(DocxColor)
return true if none? && color_to_check.nil?
return true if none? && color_to_check.none?
return false if none? && color_to_check.any?
return false if !none? && color_to_check.none?
return true if self == color_to_check
red = color_to_check.red
green = color_to_check.green
blue = color_to_check.blue
(self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta ? true : false
end
|
[
"def",
"looks_like?",
"(",
"color_to_check",
"=",
"nil",
",",
"delta",
"=",
"8",
")",
"color_to_check",
"=",
"color_to_check",
".",
"converted_color",
"if",
"color_to_check",
".",
"is_a?",
"(",
"SchemeColor",
")",
"color_to_check",
"=",
"color_to_check",
".",
"pattern_fill",
".",
"foreground_folor",
"if",
"color_to_check",
".",
"is_a?",
"(",
"Fill",
")",
"color_to_check",
"=",
"color_to_check",
".",
"color",
".",
"converted_color",
"if",
"color_to_check",
".",
"is_a?",
"(",
"PresentationFill",
")",
"color_to_check",
"=",
"Color",
".",
"parse",
"(",
"color_to_check",
")",
"if",
"color_to_check",
".",
"is_a?",
"(",
"String",
")",
"color_to_check",
"=",
"Color",
".",
"parse",
"(",
"color_to_check",
".",
"to_s",
")",
"if",
"color_to_check",
".",
"is_a?",
"(",
"Symbol",
")",
"color_to_check",
"=",
"Color",
".",
"parse",
"(",
"color_to_check",
".",
"value",
")",
"if",
"color_to_check",
".",
"is_a?",
"(",
"DocxColor",
")",
"return",
"true",
"if",
"none?",
"&&",
"color_to_check",
".",
"nil?",
"return",
"true",
"if",
"none?",
"&&",
"color_to_check",
".",
"none?",
"return",
"false",
"if",
"none?",
"&&",
"color_to_check",
".",
"any?",
"return",
"false",
"if",
"!",
"none?",
"&&",
"color_to_check",
".",
"none?",
"return",
"true",
"if",
"self",
"==",
"color_to_check",
"red",
"=",
"color_to_check",
".",
"red",
"green",
"=",
"color_to_check",
".",
"green",
"blue",
"=",
"color_to_check",
".",
"blue",
"(",
"self",
".",
"red",
"-",
"red",
")",
".",
"abs",
"<",
"delta",
"&&",
"(",
"self",
".",
"green",
"-",
"green",
")",
".",
"abs",
"<",
"delta",
"&&",
"(",
"self",
".",
"blue",
"-",
"blue",
")",
".",
"abs",
"<",
"delta",
"?",
"true",
":",
"false",
"end"
] |
To compare color, which look alike
@param [String or Color] color_to_check color to compare
@param [Integer] delta max delta for each of specters
|
[
"To",
"compare",
"color",
"which",
"look",
"alike"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/color.rb#L172-L189
|
17,841
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb
|
OoxmlParser.ChartCellsRange.parse
|
def parse(node)
@list = node.xpath('c:f')[0].text.split('!').first
coordinates = Coordinates.parser_coordinates_range(node.xpath('c:f')[0].text) # .split('!')[1].gsub('$', ''))
return self unless coordinates
node.xpath('c:numCache/c:pt').each_with_index do |point_node, index|
point = ChartPoint.new(coordinates[index])
point.value = point_node.xpath('c:v').first.text.to_f unless point_node.xpath('c:v').first.nil?
@points << point
end
self
end
|
ruby
|
def parse(node)
@list = node.xpath('c:f')[0].text.split('!').first
coordinates = Coordinates.parser_coordinates_range(node.xpath('c:f')[0].text) # .split('!')[1].gsub('$', ''))
return self unless coordinates
node.xpath('c:numCache/c:pt').each_with_index do |point_node, index|
point = ChartPoint.new(coordinates[index])
point.value = point_node.xpath('c:v').first.text.to_f unless point_node.xpath('c:v').first.nil?
@points << point
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"@list",
"=",
"node",
".",
"xpath",
"(",
"'c:f'",
")",
"[",
"0",
"]",
".",
"text",
".",
"split",
"(",
"'!'",
")",
".",
"first",
"coordinates",
"=",
"Coordinates",
".",
"parser_coordinates_range",
"(",
"node",
".",
"xpath",
"(",
"'c:f'",
")",
"[",
"0",
"]",
".",
"text",
")",
"# .split('!')[1].gsub('$', ''))",
"return",
"self",
"unless",
"coordinates",
"node",
".",
"xpath",
"(",
"'c:numCache/c:pt'",
")",
".",
"each_with_index",
"do",
"|",
"point_node",
",",
"index",
"|",
"point",
"=",
"ChartPoint",
".",
"new",
"(",
"coordinates",
"[",
"index",
"]",
")",
"point",
".",
"value",
"=",
"point_node",
".",
"xpath",
"(",
"'c:v'",
")",
".",
"first",
".",
"text",
".",
"to_f",
"unless",
"point_node",
".",
"xpath",
"(",
"'c:v'",
")",
".",
"first",
".",
"nil?",
"@points",
"<<",
"point",
"end",
"self",
"end"
] |
Parse ChartCellsRange object
@param node [Nokogiri::XML:Element] node to parse
@return [ChartCellsRange] result of parsing
|
[
"Parse",
"ChartCellsRange",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb#L15-L26
|
17,842
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
|
OoxmlParser.XlsxAlignment.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'horizontal'
@horizontal = value.value.to_sym
@wrap_text = true if @horizontal == :justify
when 'vertical'
@vertical = value.value.to_sym
when 'wrapText'
@wrap_text = value.value.to_s == '1'
when 'textRotation'
@text_rotation = value.value.to_i
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'horizontal'
@horizontal = value.value.to_sym
@wrap_text = true if @horizontal == :justify
when 'vertical'
@vertical = value.value.to_sym
when 'wrapText'
@wrap_text = value.value.to_s == '1'
when 'textRotation'
@text_rotation = value.value.to_i
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'horizontal'",
"@horizontal",
"=",
"value",
".",
"value",
".",
"to_sym",
"@wrap_text",
"=",
"true",
"if",
"@horizontal",
"==",
":justify",
"when",
"'vertical'",
"@vertical",
"=",
"value",
".",
"value",
".",
"to_sym",
"when",
"'wrapText'",
"@wrap_text",
"=",
"value",
".",
"value",
".",
"to_s",
"==",
"'1'",
"when",
"'textRotation'",
"@text_rotation",
"=",
"value",
".",
"value",
".",
"to_i",
"end",
"end",
"self",
"end"
] |
Parse XlsxAlignment object
@param node [Nokogiri::XML:Element] node to parse
@return [XlsxAlignment] result of parsing
|
[
"Parse",
"XlsxAlignment",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb#L16-L31
|
17,843
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb
|
OoxmlParser.TableStyle.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'styleId'
@id = value.value.to_s
when 'styleName'
@name = value.value.to_s
when 'val'
@value = value.value.to_s
end
end
node.xpath('*').each do |style_node_child|
case style_node_child.name
when 'wholeTbl'
@whole_table = TableElement.new(parent: self).parse(style_node_child)
when 'band1H'
@banding_1_horizontal = TableElement.new(parent: self).parse(style_node_child)
when 'band2H', 'band2Horz'
@banding_2_horizontal = TableElement.new(parent: self).parse(style_node_child)
when 'band1V'
@banding_1_vertical = TableElement.new(parent: self).parse(style_node_child)
when 'band2V'
@banding_2_vertical = TableElement.new(parent: self).parse(style_node_child)
when 'lastCol'
@last_column = TableElement.new(parent: self).parse(style_node_child)
when 'firstCol'
@first_column = TableElement.new(parent: self).parse(style_node_child)
when 'lastRow'
@last_row = TableElement.new(parent: self).parse(style_node_child)
when 'firstRow'
@first_row = TableElement.new(parent: self).parse(style_node_child)
when 'seCell'
@southeast_cell = TableElement.new(parent: self).parse(style_node_child)
when 'swCell'
@southwest_cell = TableElement.new(parent: self).parse(style_node_child)
when 'neCell'
@northeast_cell = TableElement.new(parent: self).parse(style_node_child)
when 'nwCell'
@northwest_cell = TableElement.new(parent: self).parse(style_node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'styleId'
@id = value.value.to_s
when 'styleName'
@name = value.value.to_s
when 'val'
@value = value.value.to_s
end
end
node.xpath('*').each do |style_node_child|
case style_node_child.name
when 'wholeTbl'
@whole_table = TableElement.new(parent: self).parse(style_node_child)
when 'band1H'
@banding_1_horizontal = TableElement.new(parent: self).parse(style_node_child)
when 'band2H', 'band2Horz'
@banding_2_horizontal = TableElement.new(parent: self).parse(style_node_child)
when 'band1V'
@banding_1_vertical = TableElement.new(parent: self).parse(style_node_child)
when 'band2V'
@banding_2_vertical = TableElement.new(parent: self).parse(style_node_child)
when 'lastCol'
@last_column = TableElement.new(parent: self).parse(style_node_child)
when 'firstCol'
@first_column = TableElement.new(parent: self).parse(style_node_child)
when 'lastRow'
@last_row = TableElement.new(parent: self).parse(style_node_child)
when 'firstRow'
@first_row = TableElement.new(parent: self).parse(style_node_child)
when 'seCell'
@southeast_cell = TableElement.new(parent: self).parse(style_node_child)
when 'swCell'
@southwest_cell = TableElement.new(parent: self).parse(style_node_child)
when 'neCell'
@northeast_cell = TableElement.new(parent: self).parse(style_node_child)
when 'nwCell'
@northwest_cell = TableElement.new(parent: self).parse(style_node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'styleId'",
"@id",
"=",
"value",
".",
"value",
".",
"to_s",
"when",
"'styleName'",
"@name",
"=",
"value",
".",
"value",
".",
"to_s",
"when",
"'val'",
"@value",
"=",
"value",
".",
"value",
".",
"to_s",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"style_node_child",
"|",
"case",
"style_node_child",
".",
"name",
"when",
"'wholeTbl'",
"@whole_table",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'band1H'",
"@banding_1_horizontal",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'band2H'",
",",
"'band2Horz'",
"@banding_2_horizontal",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'band1V'",
"@banding_1_vertical",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'band2V'",
"@banding_2_vertical",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'lastCol'",
"@last_column",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'firstCol'",
"@first_column",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'lastRow'",
"@last_row",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'firstRow'",
"@first_row",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'seCell'",
"@southeast_cell",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'swCell'",
"@southwest_cell",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'neCell'",
"@northeast_cell",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"when",
"'nwCell'",
"@northwest_cell",
"=",
"TableElement",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"style_node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse TableStyle object
@param node [Nokogiri::XML:Element] node to parse
@return [TableStyle] result of parsing
|
[
"Parse",
"TableStyle",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb#L14-L57
|
17,844
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb
|
OoxmlParser.ParagraphRun.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'rPr'
@properties = RunProperties.new(parent: self).parse(node_child)
when 't'
@t = Text.new(parent: self).parse(node_child)
@text = t.text
when 'tab'
@tab = Tab.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'rPr'
@properties = RunProperties.new(parent: self).parse(node_child)
when 't'
@t = Text.new(parent: self).parse(node_child)
@text = t.text
when 'tab'
@tab = Tab.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'rPr'",
"@properties",
"=",
"RunProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'t'",
"@t",
"=",
"Text",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"@text",
"=",
"t",
".",
"text",
"when",
"'tab'",
"@tab",
"=",
"Tab",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse ParagraphRun object
@param node [Nokogiri::XML:Element] node to parse
@return [ParagraphRun] result of parsing
|
[
"Parse",
"ParagraphRun",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb#L21-L34
|
17,845
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb
|
OoxmlParser.XLSXWorkbook.all_formula_values
|
def all_formula_values(precision = 14)
formulas = []
worksheets.each do |c_sheet|
next unless c_sheet
c_sheet.rows.each do |c_row|
next unless c_row
c_row.cells.each do |c_cell|
next unless c_cell
next unless c_cell.formula
next if c_cell.formula.empty?
text = c_cell.raw_text
if StringHelper.numeric?(text)
text = text.to_f.round(10).to_s[0..precision]
elsif StringHelper.complex?(text)
complex_number = Complex(text.tr(',', '.'))
real_part = complex_number.real
real_rounded = real_part.to_f.round(10).to_s[0..precision].to_f
imag_part = complex_number.imag
imag_rounded = imag_part.to_f.round(10).to_s[0..precision].to_f
complex_rounded = Complex(real_rounded, imag_rounded)
text = complex_rounded.to_s
end
formulas << text
end
end
end
formulas
end
|
ruby
|
def all_formula_values(precision = 14)
formulas = []
worksheets.each do |c_sheet|
next unless c_sheet
c_sheet.rows.each do |c_row|
next unless c_row
c_row.cells.each do |c_cell|
next unless c_cell
next unless c_cell.formula
next if c_cell.formula.empty?
text = c_cell.raw_text
if StringHelper.numeric?(text)
text = text.to_f.round(10).to_s[0..precision]
elsif StringHelper.complex?(text)
complex_number = Complex(text.tr(',', '.'))
real_part = complex_number.real
real_rounded = real_part.to_f.round(10).to_s[0..precision].to_f
imag_part = complex_number.imag
imag_rounded = imag_part.to_f.round(10).to_s[0..precision].to_f
complex_rounded = Complex(real_rounded, imag_rounded)
text = complex_rounded.to_s
end
formulas << text
end
end
end
formulas
end
|
[
"def",
"all_formula_values",
"(",
"precision",
"=",
"14",
")",
"formulas",
"=",
"[",
"]",
"worksheets",
".",
"each",
"do",
"|",
"c_sheet",
"|",
"next",
"unless",
"c_sheet",
"c_sheet",
".",
"rows",
".",
"each",
"do",
"|",
"c_row",
"|",
"next",
"unless",
"c_row",
"c_row",
".",
"cells",
".",
"each",
"do",
"|",
"c_cell",
"|",
"next",
"unless",
"c_cell",
"next",
"unless",
"c_cell",
".",
"formula",
"next",
"if",
"c_cell",
".",
"formula",
".",
"empty?",
"text",
"=",
"c_cell",
".",
"raw_text",
"if",
"StringHelper",
".",
"numeric?",
"(",
"text",
")",
"text",
"=",
"text",
".",
"to_f",
".",
"round",
"(",
"10",
")",
".",
"to_s",
"[",
"0",
"..",
"precision",
"]",
"elsif",
"StringHelper",
".",
"complex?",
"(",
"text",
")",
"complex_number",
"=",
"Complex",
"(",
"text",
".",
"tr",
"(",
"','",
",",
"'.'",
")",
")",
"real_part",
"=",
"complex_number",
".",
"real",
"real_rounded",
"=",
"real_part",
".",
"to_f",
".",
"round",
"(",
"10",
")",
".",
"to_s",
"[",
"0",
"..",
"precision",
"]",
".",
"to_f",
"imag_part",
"=",
"complex_number",
".",
"imag",
"imag_rounded",
"=",
"imag_part",
".",
"to_f",
".",
"round",
"(",
"10",
")",
".",
"to_s",
"[",
"0",
"..",
"precision",
"]",
".",
"to_f",
"complex_rounded",
"=",
"Complex",
"(",
"real_rounded",
",",
"imag_rounded",
")",
"text",
"=",
"complex_rounded",
".",
"to_s",
"end",
"formulas",
"<<",
"text",
"end",
"end",
"end",
"formulas",
"end"
] |
Get all values of formulas.
@param [Fixnum] precision of formulas counting
@return [Array, String] all formulas
|
[
"Get",
"all",
"values",
"of",
"formulas",
"."
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb#L51-L82
|
17,846
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb
|
OoxmlParser.XLSXWorkbook.parse_shared_strings
|
def parse_shared_strings
shared_strings_target = relationships.target_by_type('sharedString')
return if shared_strings_target.empty?
shared_string_file = "#{OOXMLDocumentObject.path_to_folder}/xl/#{shared_strings_target.first}"
@shared_strings_table = SharedStringTable.new(parent: self).parse(shared_string_file)
end
|
ruby
|
def parse_shared_strings
shared_strings_target = relationships.target_by_type('sharedString')
return if shared_strings_target.empty?
shared_string_file = "#{OOXMLDocumentObject.path_to_folder}/xl/#{shared_strings_target.first}"
@shared_strings_table = SharedStringTable.new(parent: self).parse(shared_string_file)
end
|
[
"def",
"parse_shared_strings",
"shared_strings_target",
"=",
"relationships",
".",
"target_by_type",
"(",
"'sharedString'",
")",
"return",
"if",
"shared_strings_target",
".",
"empty?",
"shared_string_file",
"=",
"\"#{OOXMLDocumentObject.path_to_folder}/xl/#{shared_strings_target.first}\"",
"@shared_strings_table",
"=",
"SharedStringTable",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"shared_string_file",
")",
"end"
] |
Do work for parsing shared strings file
|
[
"Do",
"work",
"for",
"parsing",
"shared",
"strings",
"file"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb#L85-L91
|
17,847
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb
|
OoxmlParser.TablePosition.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'leftFromText'
@left = OoxmlSize.new(value.value.to_f)
when 'rightFromText'
@right = OoxmlSize.new(value.value.to_f)
when 'topFromText'
@top = OoxmlSize.new(value.value.to_f)
when 'bottomFromText'
@bottom = OoxmlSize.new(value.value.to_f)
when 'tblpX'
@position_x = OoxmlSize.new(value.value.to_f)
when 'tblpY'
@position_y = OoxmlSize.new(value.value.to_f)
when 'vertAnchor'
@vertical_anchor = value.value.to_sym
when 'horzAnchor'
@horizontal_anchor = value.value.to_sym
when 'tblpXSpec'
@horizontal_align_from_anchor = value.value.to_sym
when 'tblpYSpec'
@vertical_align_from_anchor = value.value.to_sym
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'leftFromText'
@left = OoxmlSize.new(value.value.to_f)
when 'rightFromText'
@right = OoxmlSize.new(value.value.to_f)
when 'topFromText'
@top = OoxmlSize.new(value.value.to_f)
when 'bottomFromText'
@bottom = OoxmlSize.new(value.value.to_f)
when 'tblpX'
@position_x = OoxmlSize.new(value.value.to_f)
when 'tblpY'
@position_y = OoxmlSize.new(value.value.to_f)
when 'vertAnchor'
@vertical_anchor = value.value.to_sym
when 'horzAnchor'
@horizontal_anchor = value.value.to_sym
when 'tblpXSpec'
@horizontal_align_from_anchor = value.value.to_sym
when 'tblpYSpec'
@vertical_align_from_anchor = value.value.to_sym
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'leftFromText'",
"@left",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
")",
"when",
"'rightFromText'",
"@right",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
")",
"when",
"'topFromText'",
"@top",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
")",
"when",
"'bottomFromText'",
"@bottom",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
")",
"when",
"'tblpX'",
"@position_x",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
")",
"when",
"'tblpY'",
"@position_y",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
")",
"when",
"'vertAnchor'",
"@vertical_anchor",
"=",
"value",
".",
"value",
".",
"to_sym",
"when",
"'horzAnchor'",
"@horizontal_anchor",
"=",
"value",
".",
"value",
".",
"to_sym",
"when",
"'tblpXSpec'",
"@horizontal_align_from_anchor",
"=",
"value",
".",
"value",
".",
"to_sym",
"when",
"'tblpYSpec'",
"@vertical_align_from_anchor",
"=",
"value",
".",
"value",
".",
"to_sym",
"end",
"end",
"self",
"end"
] |
Parse TablePosition object
@param node [Nokogiri::XML:Element] node to parse
@return [TablePosition] result of parsing
|
[
"Parse",
"TablePosition",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb#L14-L40
|
17,848
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb
|
OoxmlParser.Shape.parse
|
def parse(node, type)
@type = type
node.attribute('style').value.to_s.split(';').each do |property|
if property.include?('margin-top')
@properties.margins.top = property.split(':').last
elsif property.include?('margin-left')
@properties.margins.left = property.split(':').last
elsif property.include?('margin-right')
@properties.margins.right = property.split(':').last
elsif property.include?('width')
@properties.size.width = property.split(':').last
elsif property.include?('height')
@properties.size.height = property.split(':').last
elsif property.include?('z-index')
@properties.z_index = property.split(':').last
elsif property.include?('position')
@properties.position = property.split(':').last
end
end
@properties.fill_color = Color.new(parent: self).parse_hex_string(node.attribute('fillcolor').value.to_s.sub('#', '').split(' ').first) unless node.attribute('fillcolor').nil?
@properties.stroke.weight = node.attribute('strokeweight').value unless node.attribute('strokeweight').nil?
@properties.stroke.color = Color.new(parent: self).parse_hex_string(node.attribute('strokecolor').value.to_s.sub('#', '').split(' ').first) unless node.attribute('strokecolor').nil?
@elements = TextBox.parse_list(node.xpath('v:textbox').first, parent: self) unless node.xpath('v:textbox').first.nil?
self
end
|
ruby
|
def parse(node, type)
@type = type
node.attribute('style').value.to_s.split(';').each do |property|
if property.include?('margin-top')
@properties.margins.top = property.split(':').last
elsif property.include?('margin-left')
@properties.margins.left = property.split(':').last
elsif property.include?('margin-right')
@properties.margins.right = property.split(':').last
elsif property.include?('width')
@properties.size.width = property.split(':').last
elsif property.include?('height')
@properties.size.height = property.split(':').last
elsif property.include?('z-index')
@properties.z_index = property.split(':').last
elsif property.include?('position')
@properties.position = property.split(':').last
end
end
@properties.fill_color = Color.new(parent: self).parse_hex_string(node.attribute('fillcolor').value.to_s.sub('#', '').split(' ').first) unless node.attribute('fillcolor').nil?
@properties.stroke.weight = node.attribute('strokeweight').value unless node.attribute('strokeweight').nil?
@properties.stroke.color = Color.new(parent: self).parse_hex_string(node.attribute('strokecolor').value.to_s.sub('#', '').split(' ').first) unless node.attribute('strokecolor').nil?
@elements = TextBox.parse_list(node.xpath('v:textbox').first, parent: self) unless node.xpath('v:textbox').first.nil?
self
end
|
[
"def",
"parse",
"(",
"node",
",",
"type",
")",
"@type",
"=",
"type",
"node",
".",
"attribute",
"(",
"'style'",
")",
".",
"value",
".",
"to_s",
".",
"split",
"(",
"';'",
")",
".",
"each",
"do",
"|",
"property",
"|",
"if",
"property",
".",
"include?",
"(",
"'margin-top'",
")",
"@properties",
".",
"margins",
".",
"top",
"=",
"property",
".",
"split",
"(",
"':'",
")",
".",
"last",
"elsif",
"property",
".",
"include?",
"(",
"'margin-left'",
")",
"@properties",
".",
"margins",
".",
"left",
"=",
"property",
".",
"split",
"(",
"':'",
")",
".",
"last",
"elsif",
"property",
".",
"include?",
"(",
"'margin-right'",
")",
"@properties",
".",
"margins",
".",
"right",
"=",
"property",
".",
"split",
"(",
"':'",
")",
".",
"last",
"elsif",
"property",
".",
"include?",
"(",
"'width'",
")",
"@properties",
".",
"size",
".",
"width",
"=",
"property",
".",
"split",
"(",
"':'",
")",
".",
"last",
"elsif",
"property",
".",
"include?",
"(",
"'height'",
")",
"@properties",
".",
"size",
".",
"height",
"=",
"property",
".",
"split",
"(",
"':'",
")",
".",
"last",
"elsif",
"property",
".",
"include?",
"(",
"'z-index'",
")",
"@properties",
".",
"z_index",
"=",
"property",
".",
"split",
"(",
"':'",
")",
".",
"last",
"elsif",
"property",
".",
"include?",
"(",
"'position'",
")",
"@properties",
".",
"position",
"=",
"property",
".",
"split",
"(",
"':'",
")",
".",
"last",
"end",
"end",
"@properties",
".",
"fill_color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_hex_string",
"(",
"node",
".",
"attribute",
"(",
"'fillcolor'",
")",
".",
"value",
".",
"to_s",
".",
"sub",
"(",
"'#'",
",",
"''",
")",
".",
"split",
"(",
"' '",
")",
".",
"first",
")",
"unless",
"node",
".",
"attribute",
"(",
"'fillcolor'",
")",
".",
"nil?",
"@properties",
".",
"stroke",
".",
"weight",
"=",
"node",
".",
"attribute",
"(",
"'strokeweight'",
")",
".",
"value",
"unless",
"node",
".",
"attribute",
"(",
"'strokeweight'",
")",
".",
"nil?",
"@properties",
".",
"stroke",
".",
"color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_hex_string",
"(",
"node",
".",
"attribute",
"(",
"'strokecolor'",
")",
".",
"value",
".",
"to_s",
".",
"sub",
"(",
"'#'",
",",
"''",
")",
".",
"split",
"(",
"' '",
")",
".",
"first",
")",
"unless",
"node",
".",
"attribute",
"(",
"'strokecolor'",
")",
".",
"nil?",
"@elements",
"=",
"TextBox",
".",
"parse_list",
"(",
"node",
".",
"xpath",
"(",
"'v:textbox'",
")",
".",
"first",
",",
"parent",
":",
"self",
")",
"unless",
"node",
".",
"xpath",
"(",
"'v:textbox'",
")",
".",
"first",
".",
"nil?",
"self",
"end"
] |
Parse Shape object
@param node [Nokogiri::XML:Element] node to parse
@return [Shape] result of parsing
|
[
"Parse",
"Shape",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb#L20-L44
|
17,849
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/paragraph/text_field.rb
|
OoxmlParser.TextField.parse
|
def parse(node)
@id = node.attribute('id').value
@type = node.attribute('type').value
node.xpath('*').each do |text_field_node_child|
case text_field_node_child.name
when 't'
@text = text_field_node_child.text
end
end
self
end
|
ruby
|
def parse(node)
@id = node.attribute('id').value
@type = node.attribute('type').value
node.xpath('*').each do |text_field_node_child|
case text_field_node_child.name
when 't'
@text = text_field_node_child.text
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"@id",
"=",
"node",
".",
"attribute",
"(",
"'id'",
")",
".",
"value",
"@type",
"=",
"node",
".",
"attribute",
"(",
"'type'",
")",
".",
"value",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"text_field_node_child",
"|",
"case",
"text_field_node_child",
".",
"name",
"when",
"'t'",
"@text",
"=",
"text_field_node_child",
".",
"text",
"end",
"end",
"self",
"end"
] |
Parse TextField object
@param node [Nokogiri::XML:Element] node to parse
@return [TextField] result of parsing
|
[
"Parse",
"TextField",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/paragraph/text_field.rb#L9-L19
|
17,850
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb
|
OoxmlParser.DocxColor.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'blipFill'
@type = :picture
@value = DocxBlip.new(parent: self).parse(node_child)
node_child.xpath('*').each do |fill_type_node_child|
case fill_type_node_child.name
when 'tile'
@stretching_type = :tile
when 'stretch'
@stretching_type = :stretch
when 'blip'
fill_type_node_child.xpath('alphaModFix').each { |alpha_node| @alpha = alpha_node.attribute('amt').value.to_i / 1_000.0 }
end
end
when 'solidFill'
@type = :solid
@value = Color.new(parent: self).parse_color_model(node_child)
when 'gradFill'
@type = :gradient
@value = GradientColor.new(parent: self).parse(node_child)
when 'pattFill'
@type = :pattern
@value = DocxPatternFill.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'blipFill'
@type = :picture
@value = DocxBlip.new(parent: self).parse(node_child)
node_child.xpath('*').each do |fill_type_node_child|
case fill_type_node_child.name
when 'tile'
@stretching_type = :tile
when 'stretch'
@stretching_type = :stretch
when 'blip'
fill_type_node_child.xpath('alphaModFix').each { |alpha_node| @alpha = alpha_node.attribute('amt').value.to_i / 1_000.0 }
end
end
when 'solidFill'
@type = :solid
@value = Color.new(parent: self).parse_color_model(node_child)
when 'gradFill'
@type = :gradient
@value = GradientColor.new(parent: self).parse(node_child)
when 'pattFill'
@type = :pattern
@value = DocxPatternFill.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'blipFill'",
"@type",
"=",
":picture",
"@value",
"=",
"DocxBlip",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"node_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"fill_type_node_child",
"|",
"case",
"fill_type_node_child",
".",
"name",
"when",
"'tile'",
"@stretching_type",
"=",
":tile",
"when",
"'stretch'",
"@stretching_type",
"=",
":stretch",
"when",
"'blip'",
"fill_type_node_child",
".",
"xpath",
"(",
"'alphaModFix'",
")",
".",
"each",
"{",
"|",
"alpha_node",
"|",
"@alpha",
"=",
"alpha_node",
".",
"attribute",
"(",
"'amt'",
")",
".",
"value",
".",
"to_i",
"/",
"1_000.0",
"}",
"end",
"end",
"when",
"'solidFill'",
"@type",
"=",
":solid",
"@value",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_color_model",
"(",
"node_child",
")",
"when",
"'gradFill'",
"@type",
"=",
":gradient",
"@value",
"=",
"GradientColor",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'pattFill'",
"@type",
"=",
":pattern",
"@value",
"=",
"DocxPatternFill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse DocxColor object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxColor] result of parsing
|
[
"Parse",
"DocxColor",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb#L10-L38
|
17,851
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb
|
OoxmlParser.PageProperties.parse
|
def parse(node, default_paragraph, default_character)
node.xpath('*').each do |pg_size_subnode|
case pg_size_subnode.name
when 'pgSz'
@size = PageSize.new.parse(pg_size_subnode)
when 'pgBorders'
page_borders = Borders.new
page_borders.display = pg_size_subnode.attribute('display').value.to_sym unless pg_size_subnode.attribute('display').nil?
page_borders.offset_from = pg_size_subnode.attribute('offsetFrom').value.to_sym unless pg_size_subnode.attribute('offsetFrom').nil?
pg_size_subnode.xpath('w:bottom').each do |bottom|
page_borders.bottom = BordersProperties.new(parent: page_borders).parse(bottom)
end
pg_size_subnode.xpath('w:left').each do |left|
page_borders.bottom = BordersProperties.new(parent: page_borders).parse(left)
end
pg_size_subnode.xpath('w:top').each do |top|
page_borders.bottom = BordersProperties.new(parent: page_borders).parse(top)
end
pg_size_subnode.xpath('w:right').each do |right|
page_borders.bottom = BordersProperties.new(parent: page_borders).parse(right)
end
@page_borders = page_borders
when 'type'
@type = pg_size_subnode.attribute('val').value
when 'pgMar'
@margins = PageMargins.new(parent: self).parse(pg_size_subnode)
when 'pgNumType'
@num_type = pg_size_subnode.attribute('fmt').value unless pg_size_subnode.attribute('fmt').nil?
when 'formProt'
@form_prot = pg_size_subnode.attribute('val').value
when 'textDirection'
@text_direction = pg_size_subnode.attribute('val').value
when 'docGrid'
@document_grid = DocumentGrid.new(parent: self).parse(pg_size_subnode)
when 'titlePg'
@title_page = option_enabled?(pg_size_subnode)
when 'cols'
@columns = Columns.new.parse(pg_size_subnode)
when 'headerReference', 'footerReference'
target = OOXMLDocumentObject.get_link_from_rels(pg_size_subnode.attribute('id').value)
OOXMLDocumentObject.add_to_xmls_stack("word/#{target}")
note = Note.parse(default_paragraph: default_paragraph,
default_character: default_character,
target: target,
assigned_to: pg_size_subnode.attribute('type').value,
type: File.basename(target).sub('.xml', ''),
parent: self)
@notes << note
OOXMLDocumentObject.xmls_stack.pop
when 'footnotePr'
@footnote_properties = FootnoteProperties.new(parent: self).parse(pg_size_subnode)
end
end
self
end
|
ruby
|
def parse(node, default_paragraph, default_character)
node.xpath('*').each do |pg_size_subnode|
case pg_size_subnode.name
when 'pgSz'
@size = PageSize.new.parse(pg_size_subnode)
when 'pgBorders'
page_borders = Borders.new
page_borders.display = pg_size_subnode.attribute('display').value.to_sym unless pg_size_subnode.attribute('display').nil?
page_borders.offset_from = pg_size_subnode.attribute('offsetFrom').value.to_sym unless pg_size_subnode.attribute('offsetFrom').nil?
pg_size_subnode.xpath('w:bottom').each do |bottom|
page_borders.bottom = BordersProperties.new(parent: page_borders).parse(bottom)
end
pg_size_subnode.xpath('w:left').each do |left|
page_borders.bottom = BordersProperties.new(parent: page_borders).parse(left)
end
pg_size_subnode.xpath('w:top').each do |top|
page_borders.bottom = BordersProperties.new(parent: page_borders).parse(top)
end
pg_size_subnode.xpath('w:right').each do |right|
page_borders.bottom = BordersProperties.new(parent: page_borders).parse(right)
end
@page_borders = page_borders
when 'type'
@type = pg_size_subnode.attribute('val').value
when 'pgMar'
@margins = PageMargins.new(parent: self).parse(pg_size_subnode)
when 'pgNumType'
@num_type = pg_size_subnode.attribute('fmt').value unless pg_size_subnode.attribute('fmt').nil?
when 'formProt'
@form_prot = pg_size_subnode.attribute('val').value
when 'textDirection'
@text_direction = pg_size_subnode.attribute('val').value
when 'docGrid'
@document_grid = DocumentGrid.new(parent: self).parse(pg_size_subnode)
when 'titlePg'
@title_page = option_enabled?(pg_size_subnode)
when 'cols'
@columns = Columns.new.parse(pg_size_subnode)
when 'headerReference', 'footerReference'
target = OOXMLDocumentObject.get_link_from_rels(pg_size_subnode.attribute('id').value)
OOXMLDocumentObject.add_to_xmls_stack("word/#{target}")
note = Note.parse(default_paragraph: default_paragraph,
default_character: default_character,
target: target,
assigned_to: pg_size_subnode.attribute('type').value,
type: File.basename(target).sub('.xml', ''),
parent: self)
@notes << note
OOXMLDocumentObject.xmls_stack.pop
when 'footnotePr'
@footnote_properties = FootnoteProperties.new(parent: self).parse(pg_size_subnode)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
",",
"default_paragraph",
",",
"default_character",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"pg_size_subnode",
"|",
"case",
"pg_size_subnode",
".",
"name",
"when",
"'pgSz'",
"@size",
"=",
"PageSize",
".",
"new",
".",
"parse",
"(",
"pg_size_subnode",
")",
"when",
"'pgBorders'",
"page_borders",
"=",
"Borders",
".",
"new",
"page_borders",
".",
"display",
"=",
"pg_size_subnode",
".",
"attribute",
"(",
"'display'",
")",
".",
"value",
".",
"to_sym",
"unless",
"pg_size_subnode",
".",
"attribute",
"(",
"'display'",
")",
".",
"nil?",
"page_borders",
".",
"offset_from",
"=",
"pg_size_subnode",
".",
"attribute",
"(",
"'offsetFrom'",
")",
".",
"value",
".",
"to_sym",
"unless",
"pg_size_subnode",
".",
"attribute",
"(",
"'offsetFrom'",
")",
".",
"nil?",
"pg_size_subnode",
".",
"xpath",
"(",
"'w:bottom'",
")",
".",
"each",
"do",
"|",
"bottom",
"|",
"page_borders",
".",
"bottom",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"page_borders",
")",
".",
"parse",
"(",
"bottom",
")",
"end",
"pg_size_subnode",
".",
"xpath",
"(",
"'w:left'",
")",
".",
"each",
"do",
"|",
"left",
"|",
"page_borders",
".",
"bottom",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"page_borders",
")",
".",
"parse",
"(",
"left",
")",
"end",
"pg_size_subnode",
".",
"xpath",
"(",
"'w:top'",
")",
".",
"each",
"do",
"|",
"top",
"|",
"page_borders",
".",
"bottom",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"page_borders",
")",
".",
"parse",
"(",
"top",
")",
"end",
"pg_size_subnode",
".",
"xpath",
"(",
"'w:right'",
")",
".",
"each",
"do",
"|",
"right",
"|",
"page_borders",
".",
"bottom",
"=",
"BordersProperties",
".",
"new",
"(",
"parent",
":",
"page_borders",
")",
".",
"parse",
"(",
"right",
")",
"end",
"@page_borders",
"=",
"page_borders",
"when",
"'type'",
"@type",
"=",
"pg_size_subnode",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"when",
"'pgMar'",
"@margins",
"=",
"PageMargins",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"pg_size_subnode",
")",
"when",
"'pgNumType'",
"@num_type",
"=",
"pg_size_subnode",
".",
"attribute",
"(",
"'fmt'",
")",
".",
"value",
"unless",
"pg_size_subnode",
".",
"attribute",
"(",
"'fmt'",
")",
".",
"nil?",
"when",
"'formProt'",
"@form_prot",
"=",
"pg_size_subnode",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"when",
"'textDirection'",
"@text_direction",
"=",
"pg_size_subnode",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"when",
"'docGrid'",
"@document_grid",
"=",
"DocumentGrid",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"pg_size_subnode",
")",
"when",
"'titlePg'",
"@title_page",
"=",
"option_enabled?",
"(",
"pg_size_subnode",
")",
"when",
"'cols'",
"@columns",
"=",
"Columns",
".",
"new",
".",
"parse",
"(",
"pg_size_subnode",
")",
"when",
"'headerReference'",
",",
"'footerReference'",
"target",
"=",
"OOXMLDocumentObject",
".",
"get_link_from_rels",
"(",
"pg_size_subnode",
".",
"attribute",
"(",
"'id'",
")",
".",
"value",
")",
"OOXMLDocumentObject",
".",
"add_to_xmls_stack",
"(",
"\"word/#{target}\"",
")",
"note",
"=",
"Note",
".",
"parse",
"(",
"default_paragraph",
":",
"default_paragraph",
",",
"default_character",
":",
"default_character",
",",
"target",
":",
"target",
",",
"assigned_to",
":",
"pg_size_subnode",
".",
"attribute",
"(",
"'type'",
")",
".",
"value",
",",
"type",
":",
"File",
".",
"basename",
"(",
"target",
")",
".",
"sub",
"(",
"'.xml'",
",",
"''",
")",
",",
"parent",
":",
"self",
")",
"@notes",
"<<",
"note",
"OOXMLDocumentObject",
".",
"xmls_stack",
".",
"pop",
"when",
"'footnotePr'",
"@footnote_properties",
"=",
"FootnoteProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"pg_size_subnode",
")",
"end",
"end",
"self",
"end"
] |
Parse PageProperties data
@param [Nokogiri::XML:Element] node with PageProperties data
@return [PageProperties] value of PageProperties data
|
[
"Parse",
"PageProperties",
"data"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb#L24-L78
|
17,852
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb
|
OoxmlParser.ChartAxisTitle.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'tx'
node_child.xpath('c:rich/*').each do |rich_node_child|
case rich_node_child.name
when 'p'
root_object.default_font_style = FontStyle.new(true) # Default font style for chart title always bold
@elements << Paragraph.new(parent: self).parse(rich_node_child)
root_object.default_font_style = FontStyle.new
end
end
when 'layout'
@layout = option_enabled?(node_child)
when 'overlay'
@overlay = option_enabled?(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'tx'
node_child.xpath('c:rich/*').each do |rich_node_child|
case rich_node_child.name
when 'p'
root_object.default_font_style = FontStyle.new(true) # Default font style for chart title always bold
@elements << Paragraph.new(parent: self).parse(rich_node_child)
root_object.default_font_style = FontStyle.new
end
end
when 'layout'
@layout = option_enabled?(node_child)
when 'overlay'
@overlay = option_enabled?(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'tx'",
"node_child",
".",
"xpath",
"(",
"'c:rich/*'",
")",
".",
"each",
"do",
"|",
"rich_node_child",
"|",
"case",
"rich_node_child",
".",
"name",
"when",
"'p'",
"root_object",
".",
"default_font_style",
"=",
"FontStyle",
".",
"new",
"(",
"true",
")",
"# Default font style for chart title always bold",
"@elements",
"<<",
"Paragraph",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"rich_node_child",
")",
"root_object",
".",
"default_font_style",
"=",
"FontStyle",
".",
"new",
"end",
"end",
"when",
"'layout'",
"@layout",
"=",
"option_enabled?",
"(",
"node_child",
")",
"when",
"'overlay'",
"@overlay",
"=",
"option_enabled?",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse ChartAxisTitle object
@param node [Nokogiri::XML:Element] node to parse
@return [ChartAxisTitle] result of parsing
|
[
"Parse",
"ChartAxisTitle",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb#L19-L38
|
17,853
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb
|
OoxmlParser.XlsxDrawing.parse
|
def parse(node)
node.xpath('*').each do |child_node|
case child_node.name
when 'from'
@from = XlsxDrawingPositionParameters.new(parent: self).parse(child_node)
when 'to'
@to = XlsxDrawingPositionParameters.new(parent: self).parse(child_node)
when 'sp'
@shape = DocxShape.new(parent: self).parse(child_node)
when 'grpSp'
@grouping = ShapesGrouping.new(parent: self).parse(child_node)
when 'pic'
@picture = DocxPicture.new(parent: self).parse(child_node)
when 'graphicFrame'
@graphic_frame = GraphicFrame.new(parent: self).parse(child_node)
when 'cxnSp'
@shape = ConnectionShape.new(parent: self).parse(child_node)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |child_node|
case child_node.name
when 'from'
@from = XlsxDrawingPositionParameters.new(parent: self).parse(child_node)
when 'to'
@to = XlsxDrawingPositionParameters.new(parent: self).parse(child_node)
when 'sp'
@shape = DocxShape.new(parent: self).parse(child_node)
when 'grpSp'
@grouping = ShapesGrouping.new(parent: self).parse(child_node)
when 'pic'
@picture = DocxPicture.new(parent: self).parse(child_node)
when 'graphicFrame'
@graphic_frame = GraphicFrame.new(parent: self).parse(child_node)
when 'cxnSp'
@shape = ConnectionShape.new(parent: self).parse(child_node)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"child_node",
"|",
"case",
"child_node",
".",
"name",
"when",
"'from'",
"@from",
"=",
"XlsxDrawingPositionParameters",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"child_node",
")",
"when",
"'to'",
"@to",
"=",
"XlsxDrawingPositionParameters",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"child_node",
")",
"when",
"'sp'",
"@shape",
"=",
"DocxShape",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"child_node",
")",
"when",
"'grpSp'",
"@grouping",
"=",
"ShapesGrouping",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"child_node",
")",
"when",
"'pic'",
"@picture",
"=",
"DocxPicture",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"child_node",
")",
"when",
"'graphicFrame'",
"@graphic_frame",
"=",
"GraphicFrame",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"child_node",
")",
"when",
"'cxnSp'",
"@shape",
"=",
"ConnectionShape",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"child_node",
")",
"end",
"end",
"self",
"end"
] |
Parse XlsxDrawing object
@param node [Nokogiri::XML:Element] node to parse
@return [XlsxDrawing] result of parsing
|
[
"Parse",
"XlsxDrawing",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb#L15-L35
|
17,854
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb
|
OoxmlParser.Borders.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'lnL', 'left'
@left = TableCellLine.new(parent: self).parse(node_child)
when 'lnR', 'right'
@right = TableCellLine.new(parent: self).parse(node_child)
when 'lnT', 'top'
@top = TableCellLine.new(parent: self).parse(node_child)
when 'lnB', 'bottom'
@bottom = TableCellLine.new(parent: self).parse(node_child)
when 'lnTlToBr', 'tl2br'
@top_left_to_bottom_right = TableCellLine.new(parent: self).parse(node_child)
when 'lnBlToTr', 'tr2bl'
@top_right_to_bottom_left = TableCellLine.new(parent: self).parse(node_child)
when 'insideV'
@inner_vertical = TableCellLine.new(parent: self).parse(node_child)
when 'insideH'
@inner_horizontal = TableCellLine.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'lnL', 'left'
@left = TableCellLine.new(parent: self).parse(node_child)
when 'lnR', 'right'
@right = TableCellLine.new(parent: self).parse(node_child)
when 'lnT', 'top'
@top = TableCellLine.new(parent: self).parse(node_child)
when 'lnB', 'bottom'
@bottom = TableCellLine.new(parent: self).parse(node_child)
when 'lnTlToBr', 'tl2br'
@top_left_to_bottom_right = TableCellLine.new(parent: self).parse(node_child)
when 'lnBlToTr', 'tr2bl'
@top_right_to_bottom_left = TableCellLine.new(parent: self).parse(node_child)
when 'insideV'
@inner_vertical = TableCellLine.new(parent: self).parse(node_child)
when 'insideH'
@inner_horizontal = TableCellLine.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'lnL'",
",",
"'left'",
"@left",
"=",
"TableCellLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'lnR'",
",",
"'right'",
"@right",
"=",
"TableCellLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'lnT'",
",",
"'top'",
"@top",
"=",
"TableCellLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'lnB'",
",",
"'bottom'",
"@bottom",
"=",
"TableCellLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'lnTlToBr'",
",",
"'tl2br'",
"@top_left_to_bottom_right",
"=",
"TableCellLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'lnBlToTr'",
",",
"'tr2bl'",
"@top_right_to_bottom_left",
"=",
"TableCellLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'insideV'",
"@inner_vertical",
"=",
"TableCellLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'insideH'",
"@inner_horizontal",
"=",
"TableCellLine",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse Borders object
@param node [Nokogiri::XML:Element] node to parse
@return [Borders] result of parsing
|
[
"Parse",
"Borders",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb#L66-L88
|
17,855
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb
|
OoxmlParser.SlideHelper.transform_of_object
|
def transform_of_object(object)
case object
when :image
elements.find { |e| e.is_a? Picture }.properties.transform
when :chart
elements.find { |e| e.is_a? GraphicFrame }.transform
when :table
elements.find { |e| e.is_a? GraphicFrame }.transform
when :shape
elements.find { |e| !e.shape_properties.preset.nil? }.shape_properties.transform
else
raise "Dont know this type object - #{object}"
end
end
|
ruby
|
def transform_of_object(object)
case object
when :image
elements.find { |e| e.is_a? Picture }.properties.transform
when :chart
elements.find { |e| e.is_a? GraphicFrame }.transform
when :table
elements.find { |e| e.is_a? GraphicFrame }.transform
when :shape
elements.find { |e| !e.shape_properties.preset.nil? }.shape_properties.transform
else
raise "Dont know this type object - #{object}"
end
end
|
[
"def",
"transform_of_object",
"(",
"object",
")",
"case",
"object",
"when",
":image",
"elements",
".",
"find",
"{",
"|",
"e",
"|",
"e",
".",
"is_a?",
"Picture",
"}",
".",
"properties",
".",
"transform",
"when",
":chart",
"elements",
".",
"find",
"{",
"|",
"e",
"|",
"e",
".",
"is_a?",
"GraphicFrame",
"}",
".",
"transform",
"when",
":table",
"elements",
".",
"find",
"{",
"|",
"e",
"|",
"e",
".",
"is_a?",
"GraphicFrame",
"}",
".",
"transform",
"when",
":shape",
"elements",
".",
"find",
"{",
"|",
"e",
"|",
"!",
"e",
".",
"shape_properties",
".",
"preset",
".",
"nil?",
"}",
".",
"shape_properties",
".",
"transform",
"else",
"raise",
"\"Dont know this type object - #{object}\"",
"end",
"end"
] |
Get transform property of object, by object type
@param object [Symbol] type of object: :image, :chart, :table, :shape
@return [OOXMLDocumentObject] needed object
|
[
"Get",
"transform",
"property",
"of",
"object",
"by",
"object",
"type"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb#L15-L28
|
17,856
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill.rb
|
OoxmlParser.BlipFill.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'blip'
@blip = Blip.new(parent: self).parse(node_child)
when 'stretch'
@stretch = Stretch.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'blip'
@blip = Blip.new(parent: self).parse(node_child)
when 'stretch'
@stretch = Stretch.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'blip'",
"@blip",
"=",
"Blip",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'stretch'",
"@stretch",
"=",
"Stretch",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse BlipFill object
@param node [Nokogiri::XML:Element] node to parse
@return [BlipFill] result of parsing
|
[
"Parse",
"BlipFill",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/blip_fill.rb#L12-L22
|
17,857
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb
|
OoxmlParser.OldDocxShapeProperties.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'fillcolor'
@fill_color = Color.new(parent: self).parse_hex_string(value.value.delete('#'))
when 'opacity'
@opacity = value.value.to_f
when 'strokecolor'
@stroke_color = Color.new(parent: self).parse_hex_string(value.value.delete('#'))
when 'strokeweight'
@stroke_weight = value.value.to_f
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'fillcolor'
@fill_color = Color.new(parent: self).parse_hex_string(value.value.delete('#'))
when 'opacity'
@opacity = value.value.to_f
when 'strokecolor'
@stroke_color = Color.new(parent: self).parse_hex_string(value.value.delete('#'))
when 'strokeweight'
@stroke_weight = value.value.to_f
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'fillcolor'",
"@fill_color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_hex_string",
"(",
"value",
".",
"value",
".",
"delete",
"(",
"'#'",
")",
")",
"when",
"'opacity'",
"@opacity",
"=",
"value",
".",
"value",
".",
"to_f",
"when",
"'strokecolor'",
"@stroke_color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_hex_string",
"(",
"value",
".",
"value",
".",
"delete",
"(",
"'#'",
")",
")",
"when",
"'strokeweight'",
"@stroke_weight",
"=",
"value",
".",
"value",
".",
"to_f",
"end",
"end",
"self",
"end"
] |
Parse OldDocxShapeProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [OldDocxShapeProperties] result of parsing
|
[
"Parse",
"OldDocxShapeProperties",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb#L9-L23
|
17,858
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb
|
OoxmlParser.Slide.parse
|
def parse
OOXMLDocumentObject.add_to_xmls_stack(@xml_path)
@name = File.basename(@xml_path, '.*')
node = parse_xml(OOXMLDocumentObject.current_xml)
node.xpath('//p:sld/*').each do |node_child|
case node_child.name
when 'cSld'
@common_slide_data = CommonSlideData.new(parent: self).parse(node_child)
when 'timing'
@timing = Timing.new(parent: self).parse(node_child)
when 'transition'
@transition = Transition.new(parent: self).parse(node_child)
when 'AlternateContent'
@alternate_content = PresentationAlternateContent.new(parent: self).parse(node_child)
end
end
OOXMLDocumentObject.xmls_stack.pop
@relationships = Relationships.new(parent: self).parse_file("#{OOXMLDocumentObject.path_to_folder}#{File.dirname(@xml_path)}/_rels/#{@name}.xml.rels")
parse_note
self
end
|
ruby
|
def parse
OOXMLDocumentObject.add_to_xmls_stack(@xml_path)
@name = File.basename(@xml_path, '.*')
node = parse_xml(OOXMLDocumentObject.current_xml)
node.xpath('//p:sld/*').each do |node_child|
case node_child.name
when 'cSld'
@common_slide_data = CommonSlideData.new(parent: self).parse(node_child)
when 'timing'
@timing = Timing.new(parent: self).parse(node_child)
when 'transition'
@transition = Transition.new(parent: self).parse(node_child)
when 'AlternateContent'
@alternate_content = PresentationAlternateContent.new(parent: self).parse(node_child)
end
end
OOXMLDocumentObject.xmls_stack.pop
@relationships = Relationships.new(parent: self).parse_file("#{OOXMLDocumentObject.path_to_folder}#{File.dirname(@xml_path)}/_rels/#{@name}.xml.rels")
parse_note
self
end
|
[
"def",
"parse",
"OOXMLDocumentObject",
".",
"add_to_xmls_stack",
"(",
"@xml_path",
")",
"@name",
"=",
"File",
".",
"basename",
"(",
"@xml_path",
",",
"'.*'",
")",
"node",
"=",
"parse_xml",
"(",
"OOXMLDocumentObject",
".",
"current_xml",
")",
"node",
".",
"xpath",
"(",
"'//p:sld/*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'cSld'",
"@common_slide_data",
"=",
"CommonSlideData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'timing'",
"@timing",
"=",
"Timing",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'transition'",
"@transition",
"=",
"Transition",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'AlternateContent'",
"@alternate_content",
"=",
"PresentationAlternateContent",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"OOXMLDocumentObject",
".",
"xmls_stack",
".",
"pop",
"@relationships",
"=",
"Relationships",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_file",
"(",
"\"#{OOXMLDocumentObject.path_to_folder}#{File.dirname(@xml_path)}/_rels/#{@name}.xml.rels\"",
")",
"parse_note",
"self",
"end"
] |
Parse Slide object
@return [Slide] result of parsing
|
[
"Parse",
"Slide",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb#L48-L68
|
17,859
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb
|
OoxmlParser.DocxPicture.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'blipFill'
@path_to_image = DocxBlip.new(parent: self).parse(node_child)
when 'spPr'
@properties = DocxShapeProperties.new(parent: self).parse(node_child)
when 'nvPicPr'
@non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'blipFill'
@path_to_image = DocxBlip.new(parent: self).parse(node_child)
when 'spPr'
@properties = DocxShapeProperties.new(parent: self).parse(node_child)
when 'nvPicPr'
@non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'blipFill'",
"@path_to_image",
"=",
"DocxBlip",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'spPr'",
"@properties",
"=",
"DocxShapeProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'nvPicPr'",
"@non_visual_properties",
"=",
"NonVisualShapeProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse DocxPicture object
@param node [Nokogiri::XML:Element] node to parse
@return [DocxPicture] result of parsing
|
[
"Parse",
"DocxPicture",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb#L15-L27
|
17,860
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb
|
OoxmlParser.GradientColor.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'gsLst'
node_child.xpath('*').each do |gradient_stop_node|
@gradient_stops << GradientStop.new(parent: self).parse(gradient_stop_node)
end
when 'path'
@path = node_child.attribute('path').value.to_sym
when 'lin'
@linear_gradient = LinearGradient.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'gsLst'
node_child.xpath('*').each do |gradient_stop_node|
@gradient_stops << GradientStop.new(parent: self).parse(gradient_stop_node)
end
when 'path'
@path = node_child.attribute('path').value.to_sym
when 'lin'
@linear_gradient = LinearGradient.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'gsLst'",
"node_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"gradient_stop_node",
"|",
"@gradient_stops",
"<<",
"GradientStop",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"gradient_stop_node",
")",
"end",
"when",
"'path'",
"@path",
"=",
"node_child",
".",
"attribute",
"(",
"'path'",
")",
".",
"value",
".",
"to_sym",
"when",
"'lin'",
"@linear_gradient",
"=",
"LinearGradient",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse GradientColor object
@param node [Nokogiri::XML:Element] node to parse
@return [GradientColor] result of parsing
|
[
"Parse",
"GradientColor",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb#L18-L32
|
17,861
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
|
OoxmlParser.Tab.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'algn', 'val'
@value = value_to_symbol(value)
when 'leader'
@leader = value_to_symbol(value)
when 'pos'
@position = OoxmlSize.new(value.value.to_f, position_unit(node))
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'algn', 'val'
@value = value_to_symbol(value)
when 'leader'
@leader = value_to_symbol(value)
when 'pos'
@position = OoxmlSize.new(value.value.to_f, position_unit(node))
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'algn'",
",",
"'val'",
"@value",
"=",
"value_to_symbol",
"(",
"value",
")",
"when",
"'leader'",
"@leader",
"=",
"value_to_symbol",
"(",
"value",
")",
"when",
"'pos'",
"@position",
"=",
"OoxmlSize",
".",
"new",
"(",
"value",
".",
"value",
".",
"to_f",
",",
"position_unit",
"(",
"node",
")",
")",
"end",
"end",
"self",
"end"
] |
Parse ParagraphTab object
@param node [Nokogiri::XML:Element] node to parse
@return [ParagraphTab] result of parsing
|
[
"Parse",
"ParagraphTab",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb#L16-L28
|
17,862
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/table_style_info.rb
|
OoxmlParser.TableStyleInfo.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'name'
@name = value.value.to_s
when 'showColumnStripes'
@show_column_stripes = attribute_enabled?(value)
when 'showFirstColumn'
@show_first_column = attribute_enabled?(value)
when 'showLastColumn'
@show_last_column = attribute_enabled?(value)
when 'showRowStripes'
@show_row_stripes = attribute_enabled?(value)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'name'
@name = value.value.to_s
when 'showColumnStripes'
@show_column_stripes = attribute_enabled?(value)
when 'showFirstColumn'
@show_first_column = attribute_enabled?(value)
when 'showLastColumn'
@show_last_column = attribute_enabled?(value)
when 'showRowStripes'
@show_row_stripes = attribute_enabled?(value)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'name'",
"@name",
"=",
"value",
".",
"value",
".",
"to_s",
"when",
"'showColumnStripes'",
"@show_column_stripes",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'showFirstColumn'",
"@show_first_column",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'showLastColumn'",
"@show_last_column",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'showRowStripes'",
"@show_row_stripes",
"=",
"attribute_enabled?",
"(",
"value",
")",
"end",
"end",
"self",
"end"
] |
Parse TableStyleInfo data
@param [Nokogiri::XML:Element] node with TableStyleInfo data
@return [TableStyleInfo] value of TableStyleInfo data
|
[
"Parse",
"TableStyleInfo",
"data"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/table_style_info.rb#L23-L39
|
17,863
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/field_simple.rb
|
OoxmlParser.FieldSimple.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'instr'
@instruction = value.value.to_s
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'r'
@runs << ParagraphRun.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'instr'
@instruction = value.value.to_s
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'r'
@runs << ParagraphRun.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'instr'",
"@instruction",
"=",
"value",
".",
"value",
".",
"to_s",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'r'",
"@runs",
"<<",
"ParagraphRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse FieldSimple object
@param node [Nokogiri::XML:Element] node to parse
@return [FieldSimple] result of parsing
|
[
"Parse",
"FieldSimple",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/field_simple.rb#L17-L32
|
17,864
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb
|
OoxmlParser.PresentationPattern.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'prst'
@preset = value.value.to_sym
end
end
node.xpath('*').each do |color_node|
case color_node.name
when 'fgClr'
@foreground_color = Color.new(parent: self).parse_color(color_node.xpath('*').first)
when 'bgClr'
@background_color = Color.new(parent: self).parse_color(color_node.xpath('*').first)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'prst'
@preset = value.value.to_sym
end
end
node.xpath('*').each do |color_node|
case color_node.name
when 'fgClr'
@foreground_color = Color.new(parent: self).parse_color(color_node.xpath('*').first)
when 'bgClr'
@background_color = Color.new(parent: self).parse_color(color_node.xpath('*').first)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'prst'",
"@preset",
"=",
"value",
".",
"value",
".",
"to_sym",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"color_node",
"|",
"case",
"color_node",
".",
"name",
"when",
"'fgClr'",
"@foreground_color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_color",
"(",
"color_node",
".",
"xpath",
"(",
"'*'",
")",
".",
"first",
")",
"when",
"'bgClr'",
"@background_color",
"=",
"Color",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse_color",
"(",
"color_node",
".",
"xpath",
"(",
"'*'",
")",
".",
"first",
")",
"end",
"end",
"self",
"end"
] |
Parse PresentationPattern object
@param node [Nokogiri::XML:Element] node to parse
@return [PresentationPattern] result of parsing
|
[
"Parse",
"PresentationPattern",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb#L9-L26
|
17,865
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/document_settings.rb
|
OoxmlParser.DocumentSettings.parse
|
def parse
settings_path = OOXMLDocumentObject.path_to_folder + 'word/settings.xml'
return nil unless File.exist?(settings_path)
doc = parse_xml(settings_path)
doc.xpath('w:settings/*').each do |node_child|
case node_child.name
when 'defaultTabStop'
@default_tab_stop = OoxmlSize.new.parse(node_child)
end
end
self
end
|
ruby
|
def parse
settings_path = OOXMLDocumentObject.path_to_folder + 'word/settings.xml'
return nil unless File.exist?(settings_path)
doc = parse_xml(settings_path)
doc.xpath('w:settings/*').each do |node_child|
case node_child.name
when 'defaultTabStop'
@default_tab_stop = OoxmlSize.new.parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"settings_path",
"=",
"OOXMLDocumentObject",
".",
"path_to_folder",
"+",
"'word/settings.xml'",
"return",
"nil",
"unless",
"File",
".",
"exist?",
"(",
"settings_path",
")",
"doc",
"=",
"parse_xml",
"(",
"settings_path",
")",
"doc",
".",
"xpath",
"(",
"'w:settings/*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'defaultTabStop'",
"@default_tab_stop",
"=",
"OoxmlSize",
".",
"new",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse Settings object
@return [DocumentSettings] result of parsing
|
[
"Parse",
"Settings",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_settings.rb#L9-L21
|
17,866
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line/line_join.rb
|
OoxmlParser.LineJoin.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'round', 'bevel'
@type = node_child.name.to_sym
when 'miter'
@type = :miter
@limit = node_child.attribute('lim').value.to_f
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'round', 'bevel'
@type = node_child.name.to_sym
when 'miter'
@type = :miter
@limit = node_child.attribute('lim').value.to_f
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'round'",
",",
"'bevel'",
"@type",
"=",
"node_child",
".",
"name",
".",
"to_sym",
"when",
"'miter'",
"@type",
"=",
":miter",
"@limit",
"=",
"node_child",
".",
"attribute",
"(",
"'lim'",
")",
".",
"value",
".",
"to_f",
"end",
"end",
"self",
"end"
] |
Parse LineJoin object
@param node [Nokogiri::XML:Element] node to parse
@return [LineJoin] result of parsing
|
[
"Parse",
"LineJoin",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line/line_join.rb#L8-L19
|
17,867
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb
|
OoxmlParser.ExtensionList.parse
|
def parse(node)
node.xpath('*').each do |column_node|
case column_node.name
when 'ext'
@extension_array << Extension.new(parent: self).parse(column_node)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |column_node|
case column_node.name
when 'ext'
@extension_array << Extension.new(parent: self).parse(column_node)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"column_node",
"|",
"case",
"column_node",
".",
"name",
"when",
"'ext'",
"@extension_array",
"<<",
"Extension",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"column_node",
")",
"end",
"end",
"self",
"end"
] |
Parse ExtensionList data
@param [Nokogiri::XML:Element] node with ExtensionList data
@return [ExtensionList] value of ExtensionList data
|
[
"Parse",
"ExtensionList",
"data"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb#L20-L28
|
17,868
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb
|
OoxmlParser.XlsxCell.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 's'
@style_index = value.value.to_i
when 't'
@type = value.value.to_s
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'f'
@formula = Formula.new(parent: self).parse(node_child)
when 'v'
@value = TextValue.new(parent: self).parse(node_child)
end
end
parse_text_data
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 's'
@style_index = value.value.to_i
when 't'
@type = value.value.to_s
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'f'
@formula = Formula.new(parent: self).parse(node_child)
when 'v'
@value = TextValue.new(parent: self).parse(node_child)
end
end
parse_text_data
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'s'",
"@style_index",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'t'",
"@type",
"=",
"value",
".",
"value",
".",
"to_s",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'f'",
"@formula",
"=",
"Formula",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'v'",
"@value",
"=",
"TextValue",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"parse_text_data",
"self",
"end"
] |
Parse XlsxCell object
@param node [Nokogiri::XML:Element] node to parse
@return [XlsxCell] result of parsing
|
[
"Parse",
"XlsxCell",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb#L25-L44
|
17,869
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb
|
OoxmlParser.XlsxCell.get_shared_string
|
def get_shared_string(value)
return '' if value == ''
string = root_object.shared_strings_table.string_indexes[value.to_i]
@character = string.run
@raw_text = string.text
end
|
ruby
|
def get_shared_string(value)
return '' if value == ''
string = root_object.shared_strings_table.string_indexes[value.to_i]
@character = string.run
@raw_text = string.text
end
|
[
"def",
"get_shared_string",
"(",
"value",
")",
"return",
"''",
"if",
"value",
"==",
"''",
"string",
"=",
"root_object",
".",
"shared_strings_table",
".",
"string_indexes",
"[",
"value",
".",
"to_i",
"]",
"@character",
"=",
"string",
".",
"run",
"@raw_text",
"=",
"string",
".",
"text",
"end"
] |
Get shared string by it's number
@return [Nothing]
|
[
"Get",
"shared",
"string",
"by",
"it",
"s",
"number"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb#L74-L80
|
17,870
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb
|
OoxmlParser.ShapeTree.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'sp'
@elements << DocxShape.new(parent: self).parse(node_child).dup
when 'pic'
@elements << DocxPicture.new(parent: self).parse(node_child)
when 'graphicFrame'
@elements << GraphicFrame.new(parent: self).parse(node_child)
when 'grpSp'
@elements << ShapesGrouping.new(parent: self).parse(node_child)
when 'cxnSp'
@elements << ConnectionShape.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'sp'
@elements << DocxShape.new(parent: self).parse(node_child).dup
when 'pic'
@elements << DocxPicture.new(parent: self).parse(node_child)
when 'graphicFrame'
@elements << GraphicFrame.new(parent: self).parse(node_child)
when 'grpSp'
@elements << ShapesGrouping.new(parent: self).parse(node_child)
when 'cxnSp'
@elements << ConnectionShape.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'sp'",
"@elements",
"<<",
"DocxShape",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
".",
"dup",
"when",
"'pic'",
"@elements",
"<<",
"DocxPicture",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'graphicFrame'",
"@elements",
"<<",
"GraphicFrame",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'grpSp'",
"@elements",
"<<",
"ShapesGrouping",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'cxnSp'",
"@elements",
"<<",
"ConnectionShape",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse ShapeTree object
@param node [Nokogiri::XML:Element] node to parse
@return [ShapeTree] result of parsing
|
[
"Parse",
"ShapeTree",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb#L15-L31
|
17,871
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_notes.rb
|
OoxmlParser.PresentationNotes.parse
|
def parse(file)
node = parse_xml(file)
node.xpath('p:notes/*').each do |node_child|
case node_child.name
when 'cSld'
@common_slide_data = CommonSlideData.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(file)
node = parse_xml(file)
node.xpath('p:notes/*').each do |node_child|
case node_child.name
when 'cSld'
@common_slide_data = CommonSlideData.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"file",
")",
"node",
"=",
"parse_xml",
"(",
"file",
")",
"node",
".",
"xpath",
"(",
"'p:notes/*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'cSld'",
"@common_slide_data",
"=",
"CommonSlideData",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse PresentationNotes object
@param file [String] file to parse
@return [PresentationNotes] result of parsing
|
[
"Parse",
"PresentationNotes",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_notes.rb#L10-L19
|
17,872
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb
|
OoxmlParser.TargetElement.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'sldTgt'
@type = :slide
when 'sndTgt'
@type = :sound
@name = node_child.attribute('name').value
@built_in = node_child.attribute('builtIn').value ? StringHelper.to_bool(node_child.attribute('builtIn').value) : false
when 'spTgt'
@type = :shape
@id = node_child.attribute('spid').value
when 'inkTgt'
@type = :ink
@id = node_child.attribute('spid').value
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'sldTgt'
@type = :slide
when 'sndTgt'
@type = :sound
@name = node_child.attribute('name').value
@built_in = node_child.attribute('builtIn').value ? StringHelper.to_bool(node_child.attribute('builtIn').value) : false
when 'spTgt'
@type = :shape
@id = node_child.attribute('spid').value
when 'inkTgt'
@type = :ink
@id = node_child.attribute('spid').value
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'sldTgt'",
"@type",
"=",
":slide",
"when",
"'sndTgt'",
"@type",
"=",
":sound",
"@name",
"=",
"node_child",
".",
"attribute",
"(",
"'name'",
")",
".",
"value",
"@built_in",
"=",
"node_child",
".",
"attribute",
"(",
"'builtIn'",
")",
".",
"value",
"?",
"StringHelper",
".",
"to_bool",
"(",
"node_child",
".",
"attribute",
"(",
"'builtIn'",
")",
".",
"value",
")",
":",
"false",
"when",
"'spTgt'",
"@type",
"=",
":shape",
"@id",
"=",
"node_child",
".",
"attribute",
"(",
"'spid'",
")",
".",
"value",
"when",
"'inkTgt'",
"@type",
"=",
":ink",
"@id",
"=",
"node_child",
".",
"attribute",
"(",
"'spid'",
")",
".",
"value",
"end",
"end",
"self",
"end"
] |
Parse TargetElement object
@param node [Nokogiri::XML:Element] node to parse
@return [TargetElement] result of parsing
|
[
"Parse",
"TargetElement",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb#L14-L32
|
17,873
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/table.rb
|
OoxmlParser.Table.parse
|
def parse(node,
number = 0,
default_table_properties = TableProperties.new)
table_properties = default_table_properties.dup
table_properties.jc = :left
node.xpath('*').each do |node_child|
case node_child.name
when 'tblGrid'
@grid = TableGrid.new(parent: self).parse(node_child)
when 'tr'
@rows << TableRow.new(parent: self).parse(node_child)
when 'tblPr'
@properties = TableProperties.new(parent: self).parse(node_child)
end
end
@number = number
self
end
|
ruby
|
def parse(node,
number = 0,
default_table_properties = TableProperties.new)
table_properties = default_table_properties.dup
table_properties.jc = :left
node.xpath('*').each do |node_child|
case node_child.name
when 'tblGrid'
@grid = TableGrid.new(parent: self).parse(node_child)
when 'tr'
@rows << TableRow.new(parent: self).parse(node_child)
when 'tblPr'
@properties = TableProperties.new(parent: self).parse(node_child)
end
end
@number = number
self
end
|
[
"def",
"parse",
"(",
"node",
",",
"number",
"=",
"0",
",",
"default_table_properties",
"=",
"TableProperties",
".",
"new",
")",
"table_properties",
"=",
"default_table_properties",
".",
"dup",
"table_properties",
".",
"jc",
"=",
":left",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'tblGrid'",
"@grid",
"=",
"TableGrid",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tr'",
"@rows",
"<<",
"TableRow",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblPr'",
"@properties",
"=",
"TableProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"@number",
"=",
"number",
"self",
"end"
] |
Parse Table object
@param node [Nokogiri::XML:Element] node to parse
@return [Table] result of parsing
|
[
"Parse",
"Table",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table.rb#L28-L45
|
17,874
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb
|
OoxmlParser.Matrix.parse
|
def parse(node)
columns_count = 1
j = 0
node.xpath('m:mPr').each do |m_pr|
m_pr.xpath('m:mcs').each do |mcs|
mcs.xpath('m:mc').each do |mc|
mc.xpath('m:mcPr').each do |mc_pr|
mc_pr.xpath('m:count').each do |count|
columns_count = count.attribute('val').value.to_i
end
end
end
end
end
node.xpath('m:mr').each do |mr|
i = 0
@rows << MatrixRow.new(columns_count, parent: self)
mr.xpath('m:e').each do |e|
@rows[j].columns[i] = DocxFormula.new(parent: self).parse(e)
i += 1
end
j += 1
end
self
end
|
ruby
|
def parse(node)
columns_count = 1
j = 0
node.xpath('m:mPr').each do |m_pr|
m_pr.xpath('m:mcs').each do |mcs|
mcs.xpath('m:mc').each do |mc|
mc.xpath('m:mcPr').each do |mc_pr|
mc_pr.xpath('m:count').each do |count|
columns_count = count.attribute('val').value.to_i
end
end
end
end
end
node.xpath('m:mr').each do |mr|
i = 0
@rows << MatrixRow.new(columns_count, parent: self)
mr.xpath('m:e').each do |e|
@rows[j].columns[i] = DocxFormula.new(parent: self).parse(e)
i += 1
end
j += 1
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"columns_count",
"=",
"1",
"j",
"=",
"0",
"node",
".",
"xpath",
"(",
"'m:mPr'",
")",
".",
"each",
"do",
"|",
"m_pr",
"|",
"m_pr",
".",
"xpath",
"(",
"'m:mcs'",
")",
".",
"each",
"do",
"|",
"mcs",
"|",
"mcs",
".",
"xpath",
"(",
"'m:mc'",
")",
".",
"each",
"do",
"|",
"mc",
"|",
"mc",
".",
"xpath",
"(",
"'m:mcPr'",
")",
".",
"each",
"do",
"|",
"mc_pr",
"|",
"mc_pr",
".",
"xpath",
"(",
"'m:count'",
")",
".",
"each",
"do",
"|",
"count",
"|",
"columns_count",
"=",
"count",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
".",
"to_i",
"end",
"end",
"end",
"end",
"end",
"node",
".",
"xpath",
"(",
"'m:mr'",
")",
".",
"each",
"do",
"|",
"mr",
"|",
"i",
"=",
"0",
"@rows",
"<<",
"MatrixRow",
".",
"new",
"(",
"columns_count",
",",
"parent",
":",
"self",
")",
"mr",
".",
"xpath",
"(",
"'m:e'",
")",
".",
"each",
"do",
"|",
"e",
"|",
"@rows",
"[",
"j",
"]",
".",
"columns",
"[",
"i",
"]",
"=",
"DocxFormula",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"e",
")",
"i",
"+=",
"1",
"end",
"j",
"+=",
"1",
"end",
"self",
"end"
] |
Parse Matrix object
@param node [Nokogiri::XML:Element] node to parse
@return [Matrix] result of parsing
|
[
"Parse",
"Matrix",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb#L15-L41
|
17,875
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_properties.rb
|
OoxmlParser.SDTProperties.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'alias'
@alias = ValuedChild.new(:string, parent: self).parse(node_child)
when 'tag'
@tag = ValuedChild.new(:string, parent: self).parse(node_child)
when 'lock'
@lock = ValuedChild.new(:symbol, parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'alias'
@alias = ValuedChild.new(:string, parent: self).parse(node_child)
when 'tag'
@tag = ValuedChild.new(:string, parent: self).parse(node_child)
when 'lock'
@lock = ValuedChild.new(:symbol, parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'alias'",
"@alias",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tag'",
"@tag",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'lock'",
"@lock",
"=",
"ValuedChild",
".",
"new",
"(",
":symbol",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse SDTProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [SDTProperties] result of parsing
|
[
"Parse",
"SDTProperties",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_properties.rb#L14-L26
|
17,876
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb
|
OoxmlParser.TextBody.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'p'
@paragraphs << Paragraph.new(parent: self).parse(node_child)
when 'bodyPr'
@properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'p'
@paragraphs << Paragraph.new(parent: self).parse(node_child)
when 'bodyPr'
@properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'p'",
"@paragraphs",
"<<",
"Paragraph",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'bodyPr'",
"@properties",
"=",
"OOXMLShapeBodyProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse TextBody object
@param node [Nokogiri::XML:Element] node to parse
@return [TextBody] result of parsing
|
[
"Parse",
"TextBody",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb#L14-L24
|
17,877
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb
|
OoxmlParser.AnimationEffect.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'transition'
@transition = value.value
when 'filter'
@filter = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'cBhvr'
@behavior = Behavior.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'transition'
@transition = value.value
when 'filter'
@filter = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'cBhvr'
@behavior = Behavior.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'transition'",
"@transition",
"=",
"value",
".",
"value",
"when",
"'filter'",
"@filter",
"=",
"value",
".",
"value",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'cBhvr'",
"@behavior",
"=",
"Behavior",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse AnimationEffect object
@param node [Nokogiri::XML:Element] node to parse
@return [AnimationEffect] result of parsing
|
[
"Parse",
"AnimationEffect",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb#L8-L25
|
17,878
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb
|
OoxmlParser.Xf.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'applyFont'
@apply_font = attribute_enabled?(value)
when 'applyBorder'
@apply_border = attribute_enabled?(value)
when 'applyFill'
@apply_fill = attribute_enabled?(value)
when 'applyNumberFormat'
@apply_number_format = attribute_enabled?(value)
when 'applyAlignment'
@apply_alignment = attribute_enabled?(value)
when 'fontId'
@font_id = value.value.to_i
when 'borderId'
@border_id = value.value.to_i
when 'fillId'
@fill_id = value.value.to_i
when 'numFmtId'
@number_format_id = value.value.to_i
when 'quotePrefix'
@quote_prefix = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'alignment'
@alignment.parse(node_child) if @apply_alignment
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'applyFont'
@apply_font = attribute_enabled?(value)
when 'applyBorder'
@apply_border = attribute_enabled?(value)
when 'applyFill'
@apply_fill = attribute_enabled?(value)
when 'applyNumberFormat'
@apply_number_format = attribute_enabled?(value)
when 'applyAlignment'
@apply_alignment = attribute_enabled?(value)
when 'fontId'
@font_id = value.value.to_i
when 'borderId'
@border_id = value.value.to_i
when 'fillId'
@fill_id = value.value.to_i
when 'numFmtId'
@number_format_id = value.value.to_i
when 'quotePrefix'
@quote_prefix = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'alignment'
@alignment.parse(node_child) if @apply_alignment
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'applyFont'",
"@apply_font",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'applyBorder'",
"@apply_border",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'applyFill'",
"@apply_fill",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'applyNumberFormat'",
"@apply_number_format",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'applyAlignment'",
"@apply_alignment",
"=",
"attribute_enabled?",
"(",
"value",
")",
"when",
"'fontId'",
"@font_id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'borderId'",
"@border_id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'fillId'",
"@fill_id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'numFmtId'",
"@number_format_id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'quotePrefix'",
"@quote_prefix",
"=",
"attribute_enabled?",
"(",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'alignment'",
"@alignment",
".",
"parse",
"(",
"node_child",
")",
"if",
"@apply_alignment",
"end",
"end",
"self",
"end"
] |
Parse Xf object
@param node [Nokogiri::XML:Element] node to parse
@return [Xf] result of parsing
|
[
"Parse",
"Xf",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb#L86-L118
|
17,879
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb
|
OoxmlParser.Pane.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'state'
@state = value.value.to_sym
when 'topLeftCell'
@top_left_cell = Coordinates.parse_coordinates_from_string(value.value)
when 'xSplit'
@x_split = value.value
when 'ySplit'
@y_split = value.value
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'state'
@state = value.value.to_sym
when 'topLeftCell'
@top_left_cell = Coordinates.parse_coordinates_from_string(value.value)
when 'xSplit'
@x_split = value.value
when 'ySplit'
@y_split = value.value
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'state'",
"@state",
"=",
"value",
".",
"value",
".",
"to_sym",
"when",
"'topLeftCell'",
"@top_left_cell",
"=",
"Coordinates",
".",
"parse_coordinates_from_string",
"(",
"value",
".",
"value",
")",
"when",
"'xSplit'",
"@x_split",
"=",
"value",
".",
"value",
"when",
"'ySplit'",
"@y_split",
"=",
"value",
".",
"value",
"end",
"end",
"self",
"end"
] |
Parse Pane object
@param node [Nokogiri::XML:Element] node to parse
@return [Pane] result of parsing
|
[
"Parse",
"Pane",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb#L9-L23
|
17,880
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments/presentation_comment.rb
|
OoxmlParser.PresentationComment.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'authorId'
@author_id = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'pos'
@position = OOXMLCoordinates.parse(node_child, x_attr: 'x', y_attr: 'y')
when 'text'
@text = node_child.text.to_s
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'authorId'
@author_id = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'pos'
@position = OOXMLCoordinates.parse(node_child, x_attr: 'x', y_attr: 'y')
when 'text'
@text = node_child.text.to_s
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'authorId'",
"@author_id",
"=",
"value",
".",
"value",
".",
"to_i",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'pos'",
"@position",
"=",
"OOXMLCoordinates",
".",
"parse",
"(",
"node_child",
",",
"x_attr",
":",
"'x'",
",",
"y_attr",
":",
"'y'",
")",
"when",
"'text'",
"@text",
"=",
"node_child",
".",
"text",
".",
"to_s",
"end",
"end",
"self",
"end"
] |
Parse PresentationComment object
@param node [Nokogiri::XML:Element] node to parse
@return [PresentationComment] result of parsing
|
[
"Parse",
"PresentationComment",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments/presentation_comment.rb#L19-L35
|
17,881
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb
|
OoxmlParser.TableStylePropertiesHelper.fill_empty_table_styles
|
def fill_empty_table_styles
TABLE_STYLES_NAMES_HASH.each_value do |current_table_style|
style_exist = false
@table_style_properties_list.each do |existing_style|
style_exist = true if existing_style.type == current_table_style
end
next if style_exist
@table_style_properties_list << TableStyleProperties.new(type: current_table_style)
end
end
|
ruby
|
def fill_empty_table_styles
TABLE_STYLES_NAMES_HASH.each_value do |current_table_style|
style_exist = false
@table_style_properties_list.each do |existing_style|
style_exist = true if existing_style.type == current_table_style
end
next if style_exist
@table_style_properties_list << TableStyleProperties.new(type: current_table_style)
end
end
|
[
"def",
"fill_empty_table_styles",
"TABLE_STYLES_NAMES_HASH",
".",
"each_value",
"do",
"|",
"current_table_style",
"|",
"style_exist",
"=",
"false",
"@table_style_properties_list",
".",
"each",
"do",
"|",
"existing_style",
"|",
"style_exist",
"=",
"true",
"if",
"existing_style",
".",
"type",
"==",
"current_table_style",
"end",
"next",
"if",
"style_exist",
"@table_style_properties_list",
"<<",
"TableStyleProperties",
".",
"new",
"(",
"type",
":",
"current_table_style",
")",
"end",
"end"
] |
Fill all empty tables styles with default value
To make last changes in parsing table styles compatible
with `ooxml_parser` 0.1.2 and earlier
@return [Nothing]
|
[
"Fill",
"all",
"empty",
"tables",
"styles",
"with",
"default",
"value",
"To",
"make",
"last",
"changes",
"in",
"parsing",
"table",
"styles",
"compatible",
"with",
"ooxml_parser",
"0",
".",
"1",
".",
"2",
"and",
"earlier"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb#L31-L41
|
17,882
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb
|
OoxmlParser.FilterColumn.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'showButton'
@show_button = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'customFilters'
@custom_filters = CustomFilters.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'showButton'
@show_button = attribute_enabled?(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'customFilters'
@custom_filters = CustomFilters.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'showButton'",
"@show_button",
"=",
"attribute_enabled?",
"(",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'customFilters'",
"@custom_filters",
"=",
"CustomFilters",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse FilterColumn data
@param [Nokogiri::XML:Element] node with FilterColumn data
@return [FilterColumn] value of FilterColumn data
|
[
"Parse",
"FilterColumn",
"data"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb#L21-L36
|
17,883
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb
|
OoxmlParser.TableCell.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'gridSpan'
@grid_span = value.value.to_i
when 'hMerge'
@horizontal_merge = value.value.to_i
when 'vMerge'
@vertical_merge = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'txBody'
@text_body = TextBody.new(parent: self).parse(node_child)
when 'tcPr'
@properties = CellProperties.new(parent: self).parse(node_child)
when 'p'
@elements << DocumentStructure.default_table_paragraph_style.dup.parse(node_child,
0,
DocumentStructure.default_table_run_style,
parent: self)
when 'sdt'
@elements << StructuredDocumentTag.new(parent: self).parse(node_child)
when 'tbl'
@elements << Table.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'gridSpan'
@grid_span = value.value.to_i
when 'hMerge'
@horizontal_merge = value.value.to_i
when 'vMerge'
@vertical_merge = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'txBody'
@text_body = TextBody.new(parent: self).parse(node_child)
when 'tcPr'
@properties = CellProperties.new(parent: self).parse(node_child)
when 'p'
@elements << DocumentStructure.default_table_paragraph_style.dup.parse(node_child,
0,
DocumentStructure.default_table_run_style,
parent: self)
when 'sdt'
@elements << StructuredDocumentTag.new(parent: self).parse(node_child)
when 'tbl'
@elements << Table.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'gridSpan'",
"@grid_span",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'hMerge'",
"@horizontal_merge",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'vMerge'",
"@vertical_merge",
"=",
"value",
".",
"value",
".",
"to_i",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'txBody'",
"@text_body",
"=",
"TextBody",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tcPr'",
"@properties",
"=",
"CellProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'p'",
"@elements",
"<<",
"DocumentStructure",
".",
"default_table_paragraph_style",
".",
"dup",
".",
"parse",
"(",
"node_child",
",",
"0",
",",
"DocumentStructure",
".",
"default_table_run_style",
",",
"parent",
":",
"self",
")",
"when",
"'sdt'",
"@elements",
"<<",
"StructuredDocumentTag",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tbl'",
"@elements",
"<<",
"Table",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse TableCell object
@param node [Nokogiri::XML:Element] node to parse
@return [TableCell] result of parsing
|
[
"Parse",
"TableCell",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb#L18-L48
|
17,884
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb
|
OoxmlParser.Delimiter.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'dPr'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'begChr'
@begin_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
when 'endChr'
@end_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
end
end
end
end
@value = DocxFormula.new(parent: self).parse(node)
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'dPr'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'begChr'
@begin_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
when 'endChr'
@end_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
end
end
end
end
@value = DocxFormula.new(parent: self).parse(node)
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'dPr'",
"node_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child_child",
"|",
"case",
"node_child_child",
".",
"name",
"when",
"'begChr'",
"@begin_character",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child_child",
")",
"when",
"'endChr'",
"@end_character",
"=",
"ValuedChild",
".",
"new",
"(",
":string",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child_child",
")",
"end",
"end",
"end",
"end",
"@value",
"=",
"DocxFormula",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node",
")",
"self",
"end"
] |
Parse Delimiter object
@param node [Nokogiri::XML:Element] node to parse
@return [Delimiter] result of parsing
|
[
"Parse",
"Delimiter",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb#L15-L31
|
17,885
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb
|
OoxmlParser.ChartAxis.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'delete'
@display = false if node_child.attribute('val').value == '1'
when 'title'
@title = ChartAxisTitle.new(parent: self).parse(node_child)
when 'majorGridlines'
@major_grid_lines = true
when 'minorGridlines'
@minor_grid_lines = true
when 'scaling'
@scaling = Scaling.new(parent: self).parse(node_child)
when 'tickLblPos'
@tick_label_position = ValuedChild.new(:symbol, parent: self).parse(node_child)
when 'axPos'
@position = value_to_symbol(node_child.attribute('val'))
end
end
@display = false unless @title.visible?
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'delete'
@display = false if node_child.attribute('val').value == '1'
when 'title'
@title = ChartAxisTitle.new(parent: self).parse(node_child)
when 'majorGridlines'
@major_grid_lines = true
when 'minorGridlines'
@minor_grid_lines = true
when 'scaling'
@scaling = Scaling.new(parent: self).parse(node_child)
when 'tickLblPos'
@tick_label_position = ValuedChild.new(:symbol, parent: self).parse(node_child)
when 'axPos'
@position = value_to_symbol(node_child.attribute('val'))
end
end
@display = false unless @title.visible?
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'delete'",
"@display",
"=",
"false",
"if",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
"==",
"'1'",
"when",
"'title'",
"@title",
"=",
"ChartAxisTitle",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'majorGridlines'",
"@major_grid_lines",
"=",
"true",
"when",
"'minorGridlines'",
"@minor_grid_lines",
"=",
"true",
"when",
"'scaling'",
"@scaling",
"=",
"Scaling",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tickLblPos'",
"@tick_label_position",
"=",
"ValuedChild",
".",
"new",
"(",
":symbol",
",",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'axPos'",
"@position",
"=",
"value_to_symbol",
"(",
"node_child",
".",
"attribute",
"(",
"'val'",
")",
")",
"end",
"end",
"@display",
"=",
"false",
"unless",
"@title",
".",
"visible?",
"self",
"end"
] |
Parse ChartAxis object
@param node [Nokogiri::XML:Element] node to parse
@return [ChartAxis] result of parsing
|
[
"Parse",
"ChartAxis",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb#L27-L48
|
17,886
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
|
OoxmlParser.ChartLegend.parse
|
def parse(node)
node.xpath('*').each do |child_node|
case child_node.name
when 'legendPos'
@position = value_to_symbol(child_node.attribute('val'))
when 'overlay'
@overlay = true if child_node.attribute('val').value.to_s == '1'
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |child_node|
case child_node.name
when 'legendPos'
@position = value_to_symbol(child_node.attribute('val'))
when 'overlay'
@overlay = true if child_node.attribute('val').value.to_s == '1'
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"child_node",
"|",
"case",
"child_node",
".",
"name",
"when",
"'legendPos'",
"@position",
"=",
"value_to_symbol",
"(",
"child_node",
".",
"attribute",
"(",
"'val'",
")",
")",
"when",
"'overlay'",
"@overlay",
"=",
"true",
"if",
"child_node",
".",
"attribute",
"(",
"'val'",
")",
".",
"value",
".",
"to_s",
"==",
"'1'",
"end",
"end",
"self",
"end"
] |
Parse ChartLegend object
@param node [Nokogiri::XML:Element] node to parse
@return [ChartLegend] result of parsing
|
[
"Parse",
"ChartLegend",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb#L27-L37
|
17,887
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments.rb
|
OoxmlParser.PresentationComments.parse
|
def parse(file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/comments/comment1.xml")
return nil unless File.exist?(file)
document = parse_xml(File.open(file))
node = document.xpath('*').first
node.xpath('*').each do |node_child|
case node_child.name
when 'cm'
@list << PresentationComment.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/comments/comment1.xml")
return nil unless File.exist?(file)
document = parse_xml(File.open(file))
node = document.xpath('*').first
node.xpath('*').each do |node_child|
case node_child.name
when 'cm'
@list << PresentationComment.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"file",
"=",
"\"#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/comments/comment1.xml\"",
")",
"return",
"nil",
"unless",
"File",
".",
"exist?",
"(",
"file",
")",
"document",
"=",
"parse_xml",
"(",
"File",
".",
"open",
"(",
"file",
")",
")",
"node",
"=",
"document",
".",
"xpath",
"(",
"'*'",
")",
".",
"first",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'cm'",
"@list",
"<<",
"PresentationComment",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse PresentationComments object
@param file [Nokogiri::XML:Element] node to parse
@return [PresentationComments] result of parsing
|
[
"Parse",
"PresentationComments",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments.rb#L16-L29
|
17,888
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb
|
OoxmlParser.OoxmlSize.to_base_unit
|
def to_base_unit
case @unit
when :centimeter
OoxmlSize.new(@value * 360_000)
when :point
OoxmlSize.new(@value * 12_700)
when :half_point
OoxmlSize.new(@value * (12_700 / 2))
when :one_eighth_point
OoxmlSize.new(@value * (12_700 / 8))
when :one_100th_point
OoxmlSize.new(@value * (12_700 / 100))
when :one_240th_cm
OoxmlSize.new(@value * 1500)
when :dxa, :twip
return OoxmlSize.new(@value * 635, :emu)
when :inch
OoxmlSize.new(@value * 914_400, :emu)
when :spacing_point
OoxmlSize.new(@value * (12_700 / 100), :emu)
when :percent
OoxmlSize.new(@value * 100_000, :one_100000th_percent)
when :pct
OoxmlSize.new(@value * 100_000 / 50, :one_100000th_percent)
when :one_1000th_percent
OoxmlSize.new(@value * 100, :one_100000th_percent)
else
self
end
end
|
ruby
|
def to_base_unit
case @unit
when :centimeter
OoxmlSize.new(@value * 360_000)
when :point
OoxmlSize.new(@value * 12_700)
when :half_point
OoxmlSize.new(@value * (12_700 / 2))
when :one_eighth_point
OoxmlSize.new(@value * (12_700 / 8))
when :one_100th_point
OoxmlSize.new(@value * (12_700 / 100))
when :one_240th_cm
OoxmlSize.new(@value * 1500)
when :dxa, :twip
return OoxmlSize.new(@value * 635, :emu)
when :inch
OoxmlSize.new(@value * 914_400, :emu)
when :spacing_point
OoxmlSize.new(@value * (12_700 / 100), :emu)
when :percent
OoxmlSize.new(@value * 100_000, :one_100000th_percent)
when :pct
OoxmlSize.new(@value * 100_000 / 50, :one_100000th_percent)
when :one_1000th_percent
OoxmlSize.new(@value * 100, :one_100000th_percent)
else
self
end
end
|
[
"def",
"to_base_unit",
"case",
"@unit",
"when",
":centimeter",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"360_000",
")",
"when",
":point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"12_700",
")",
"when",
":half_point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"(",
"12_700",
"/",
"2",
")",
")",
"when",
":one_eighth_point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"(",
"12_700",
"/",
"8",
")",
")",
"when",
":one_100th_point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"(",
"12_700",
"/",
"100",
")",
")",
"when",
":one_240th_cm",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"1500",
")",
"when",
":dxa",
",",
":twip",
"return",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"635",
",",
":emu",
")",
"when",
":inch",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"914_400",
",",
":emu",
")",
"when",
":spacing_point",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"(",
"12_700",
"/",
"100",
")",
",",
":emu",
")",
"when",
":percent",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"100_000",
",",
":one_100000th_percent",
")",
"when",
":pct",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"100_000",
"/",
"50",
",",
":one_100000th_percent",
")",
"when",
":one_1000th_percent",
"OoxmlSize",
".",
"new",
"(",
"@value",
"*",
"100",
",",
":one_100000th_percent",
")",
"else",
"self",
"end",
"end"
] |
Convert all values to one same base unit
@return [OoxmlSize] base unit
|
[
"Convert",
"all",
"values",
"to",
"one",
"same",
"base",
"unit"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb#L43-L72
|
17,889
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
|
OoxmlParser.DocumentProperties.parse
|
def parse
properties_file = "#{OOXMLDocumentObject.path_to_folder}docProps/app.xml"
unless File.exist?(properties_file)
warn "There is no 'docProps/app.xml' in docx. It may be some problem with it"
return self
end
node = parse_xml(properties_file)
node.xpath('*').each do |node_child|
case node_child.name
when 'Properties'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'Pages'
@pages = node_child_child.text.to_i
when 'Words'
@words = node_child_child.text.to_i
end
end
end
end
self
end
|
ruby
|
def parse
properties_file = "#{OOXMLDocumentObject.path_to_folder}docProps/app.xml"
unless File.exist?(properties_file)
warn "There is no 'docProps/app.xml' in docx. It may be some problem with it"
return self
end
node = parse_xml(properties_file)
node.xpath('*').each do |node_child|
case node_child.name
when 'Properties'
node_child.xpath('*').each do |node_child_child|
case node_child_child.name
when 'Pages'
@pages = node_child_child.text.to_i
when 'Words'
@words = node_child_child.text.to_i
end
end
end
end
self
end
|
[
"def",
"parse",
"properties_file",
"=",
"\"#{OOXMLDocumentObject.path_to_folder}docProps/app.xml\"",
"unless",
"File",
".",
"exist?",
"(",
"properties_file",
")",
"warn",
"\"There is no 'docProps/app.xml' in docx. It may be some problem with it\"",
"return",
"self",
"end",
"node",
"=",
"parse_xml",
"(",
"properties_file",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'Properties'",
"node_child",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child_child",
"|",
"case",
"node_child_child",
".",
"name",
"when",
"'Pages'",
"@pages",
"=",
"node_child_child",
".",
"text",
".",
"to_i",
"when",
"'Words'",
"@words",
"=",
"node_child_child",
".",
"text",
".",
"to_i",
"end",
"end",
"end",
"end",
"self",
"end"
] |
Parse Document properties
@return [DocumentProperties]
|
[
"Parse",
"Document",
"properties"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb#L8-L29
|
17,890
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/common_non_visual_properties.rb
|
OoxmlParser.CommonNonVisualProperties.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'name'
@name = value.value
when 'id'
@id = value.value
when 'title'
@title = value.value
when 'descr'
@description = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'hlinkClick'
@on_click_hyperlink = Hyperlink.new(parent: self).parse(node_child)
when 'hlinkHover'
@hyperlink_for_hover = Hyperlink.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'name'
@name = value.value
when 'id'
@id = value.value
when 'title'
@title = value.value
when 'descr'
@description = value.value
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'hlinkClick'
@on_click_hyperlink = Hyperlink.new(parent: self).parse(node_child)
when 'hlinkHover'
@hyperlink_for_hover = Hyperlink.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'name'",
"@name",
"=",
"value",
".",
"value",
"when",
"'id'",
"@id",
"=",
"value",
".",
"value",
"when",
"'title'",
"@title",
"=",
"value",
".",
"value",
"when",
"'descr'",
"@description",
"=",
"value",
".",
"value",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'hlinkClick'",
"@on_click_hyperlink",
"=",
"Hyperlink",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'hlinkHover'",
"@hyperlink_for_hover",
"=",
"Hyperlink",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse CommonNonVisualProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [CommonNonVisualProperties] result of parsing
|
[
"Parse",
"CommonNonVisualProperties",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/non_visual_shape_properties/common_non_visual_properties.rb#L13-L36
|
17,891
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb
|
OoxmlParser.HSLColor.to_rgb
|
def to_rgb
chroma = (1 - (2 * @l - 1).abs) * @s
x = chroma * (1 - ((@h / 60.0) % 2.0 - 1).abs)
m = @l - chroma / 2.0
rgb = if @h.zero?
Color.new(0, 0, 0)
elsif @h > 0 && @h < 60
Color.new(chroma, x, 0)
elsif @h > 60 && @h < 120
Color.new(x, chroma, 0)
elsif @h > 120 && @h < 180
Color.new(0, chroma, x)
elsif @h > 180 && @h < 240
Color.new(0, x, chroma)
elsif @h > 240 && @h < 300
Color.new(x, 0, chroma)
else
Color.new(chroma, 0, x)
end
Color.new(((rgb.red + m) * 255.0).round, ((rgb.green + m) * 255.0).round, ((rgb.blue + m) * 255.0).round)
end
|
ruby
|
def to_rgb
chroma = (1 - (2 * @l - 1).abs) * @s
x = chroma * (1 - ((@h / 60.0) % 2.0 - 1).abs)
m = @l - chroma / 2.0
rgb = if @h.zero?
Color.new(0, 0, 0)
elsif @h > 0 && @h < 60
Color.new(chroma, x, 0)
elsif @h > 60 && @h < 120
Color.new(x, chroma, 0)
elsif @h > 120 && @h < 180
Color.new(0, chroma, x)
elsif @h > 180 && @h < 240
Color.new(0, x, chroma)
elsif @h > 240 && @h < 300
Color.new(x, 0, chroma)
else
Color.new(chroma, 0, x)
end
Color.new(((rgb.red + m) * 255.0).round, ((rgb.green + m) * 255.0).round, ((rgb.blue + m) * 255.0).round)
end
|
[
"def",
"to_rgb",
"chroma",
"=",
"(",
"1",
"-",
"(",
"2",
"*",
"@l",
"-",
"1",
")",
".",
"abs",
")",
"*",
"@s",
"x",
"=",
"chroma",
"*",
"(",
"1",
"-",
"(",
"(",
"@h",
"/",
"60.0",
")",
"%",
"2.0",
"-",
"1",
")",
".",
"abs",
")",
"m",
"=",
"@l",
"-",
"chroma",
"/",
"2.0",
"rgb",
"=",
"if",
"@h",
".",
"zero?",
"Color",
".",
"new",
"(",
"0",
",",
"0",
",",
"0",
")",
"elsif",
"@h",
">",
"0",
"&&",
"@h",
"<",
"60",
"Color",
".",
"new",
"(",
"chroma",
",",
"x",
",",
"0",
")",
"elsif",
"@h",
">",
"60",
"&&",
"@h",
"<",
"120",
"Color",
".",
"new",
"(",
"x",
",",
"chroma",
",",
"0",
")",
"elsif",
"@h",
">",
"120",
"&&",
"@h",
"<",
"180",
"Color",
".",
"new",
"(",
"0",
",",
"chroma",
",",
"x",
")",
"elsif",
"@h",
">",
"180",
"&&",
"@h",
"<",
"240",
"Color",
".",
"new",
"(",
"0",
",",
"x",
",",
"chroma",
")",
"elsif",
"@h",
">",
"240",
"&&",
"@h",
"<",
"300",
"Color",
".",
"new",
"(",
"x",
",",
"0",
",",
"chroma",
")",
"else",
"Color",
".",
"new",
"(",
"chroma",
",",
"0",
",",
"x",
")",
"end",
"Color",
".",
"new",
"(",
"(",
"(",
"rgb",
".",
"red",
"+",
"m",
")",
"*",
"255.0",
")",
".",
"round",
",",
"(",
"(",
"rgb",
".",
"green",
"+",
"m",
")",
"*",
"255.0",
")",
".",
"round",
",",
"(",
"(",
"rgb",
".",
"blue",
"+",
"m",
")",
"*",
"255.0",
")",
".",
"round",
")",
"end"
] |
Chroma - The "colorfulness relative to the brightness of a similarly illuminated white".
|
[
"Chroma",
"-",
"The",
"colorfulness",
"relative",
"to",
"the",
"brightness",
"of",
"a",
"similarly",
"illuminated",
"white",
"."
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb#L51-L72
|
17,892
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb
|
OoxmlParser.TransitionProperties.parse
|
def parse(node)
@type = node.name.to_sym
case node.name
when 'blinds', 'checker', 'comb', 'cover', 'pull', 'push', 'randomBar', 'strips', 'wipe', 'zoom', 'warp'
@direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
when 'cut', 'fade'
@through_black = option_enabled?(node, 'thruBlk')
when 'split'
@direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
@orientation = node.attribute('orient').value.to_sym if node.attribute('orient')
when 'wheel', 'wheelReverse'
@spokes = option_enabled?(node, 'spokes')
end
self
end
|
ruby
|
def parse(node)
@type = node.name.to_sym
case node.name
when 'blinds', 'checker', 'comb', 'cover', 'pull', 'push', 'randomBar', 'strips', 'wipe', 'zoom', 'warp'
@direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
when 'cut', 'fade'
@through_black = option_enabled?(node, 'thruBlk')
when 'split'
@direction = value_to_symbol(node.attribute('dir')) if node.attribute('dir')
@orientation = node.attribute('orient').value.to_sym if node.attribute('orient')
when 'wheel', 'wheelReverse'
@spokes = option_enabled?(node, 'spokes')
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"@type",
"=",
"node",
".",
"name",
".",
"to_sym",
"case",
"node",
".",
"name",
"when",
"'blinds'",
",",
"'checker'",
",",
"'comb'",
",",
"'cover'",
",",
"'pull'",
",",
"'push'",
",",
"'randomBar'",
",",
"'strips'",
",",
"'wipe'",
",",
"'zoom'",
",",
"'warp'",
"@direction",
"=",
"value_to_symbol",
"(",
"node",
".",
"attribute",
"(",
"'dir'",
")",
")",
"if",
"node",
".",
"attribute",
"(",
"'dir'",
")",
"when",
"'cut'",
",",
"'fade'",
"@through_black",
"=",
"option_enabled?",
"(",
"node",
",",
"'thruBlk'",
")",
"when",
"'split'",
"@direction",
"=",
"value_to_symbol",
"(",
"node",
".",
"attribute",
"(",
"'dir'",
")",
")",
"if",
"node",
".",
"attribute",
"(",
"'dir'",
")",
"@orientation",
"=",
"node",
".",
"attribute",
"(",
"'orient'",
")",
".",
"value",
".",
"to_sym",
"if",
"node",
".",
"attribute",
"(",
"'orient'",
")",
"when",
"'wheel'",
",",
"'wheelReverse'",
"@spokes",
"=",
"option_enabled?",
"(",
"node",
",",
"'spokes'",
")",
"end",
"self",
"end"
] |
Parse TransitionProperties object
@param node [Nokogiri::XML:Element] node to parse
@return [TransitionProperties] result of parsing
|
[
"Parse",
"TransitionProperties",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb#L8-L22
|
17,893
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/inserted.rb
|
OoxmlParser.Inserted.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'id'
@id = value.value.to_i
when 'author'
@author = value.value.to_s
when 'date'
@date = parse_date(value.value.to_s)
when 'oouserid'
@user_id = value.value.to_s
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'r'
@run = ParagraphRun.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'id'
@id = value.value.to_i
when 'author'
@author = value.value.to_s
when 'date'
@date = parse_date(value.value.to_s)
when 'oouserid'
@user_id = value.value.to_s
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'r'
@run = ParagraphRun.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'id'",
"@id",
"=",
"value",
".",
"value",
".",
"to_i",
"when",
"'author'",
"@author",
"=",
"value",
".",
"value",
".",
"to_s",
"when",
"'date'",
"@date",
"=",
"parse_date",
"(",
"value",
".",
"value",
".",
"to_s",
")",
"when",
"'oouserid'",
"@user_id",
"=",
"value",
".",
"value",
".",
"to_s",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'r'",
"@run",
"=",
"ParagraphRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse Inserted object
@param node [Nokogiri::XML:Element] node to parse
@return [Inserted] result of parsing
|
[
"Parse",
"Inserted",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/inserted.rb#L20-L41
|
17,894
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb
|
OoxmlParser.TableStyleProperties.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'type'
@type = value.value.to_sym
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'rPr'
@run_properties = RunProperties.new(parent: self).parse(node_child)
when 'tcPr'
@table_cell_properties = CellProperties.new(parent: self).parse(node_child)
when 'tblPr'
@table_properties = TableProperties.new(parent: self).parse(node_child)
when 'trPr'
@table_row_properties = TableRowProperties.new(parent: self).parse(node_child)
when 'pPr'
@paragraph_properties = ParagraphProperties.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'type'
@type = value.value.to_sym
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'rPr'
@run_properties = RunProperties.new(parent: self).parse(node_child)
when 'tcPr'
@table_cell_properties = CellProperties.new(parent: self).parse(node_child)
when 'tblPr'
@table_properties = TableProperties.new(parent: self).parse(node_child)
when 'trPr'
@table_row_properties = TableRowProperties.new(parent: self).parse(node_child)
when 'pPr'
@paragraph_properties = ParagraphProperties.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'type'",
"@type",
"=",
"value",
".",
"value",
".",
"to_sym",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'rPr'",
"@run_properties",
"=",
"RunProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tcPr'",
"@table_cell_properties",
"=",
"CellProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'tblPr'",
"@table_properties",
"=",
"TableProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'trPr'",
"@table_row_properties",
"=",
"TableRowProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'pPr'",
"@paragraph_properties",
"=",
"ParagraphProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse table style property
@param node [Nokogiri::XML::Element] node to parse
@return [TableStyleProperties]
|
[
"Parse",
"table",
"style",
"property"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb#L29-L52
|
17,895
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb
|
OoxmlParser.Background.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'bgPr'
@properties = BackgroundProperties.new(parent: self).parse(node_child)
end
end
background_properties_node = node.xpath('p:bgPr').first
if background_properties_node
@shade_to_title = attribute_enabled?(background_properties_node, 'shadeToTitle')
@fill = PresentationFill.new(parent: self).parse(background_properties_node)
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'bgPr'
@properties = BackgroundProperties.new(parent: self).parse(node_child)
end
end
background_properties_node = node.xpath('p:bgPr').first
if background_properties_node
@shade_to_title = attribute_enabled?(background_properties_node, 'shadeToTitle')
@fill = PresentationFill.new(parent: self).parse(background_properties_node)
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'bgPr'",
"@properties",
"=",
"BackgroundProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"background_properties_node",
"=",
"node",
".",
"xpath",
"(",
"'p:bgPr'",
")",
".",
"first",
"if",
"background_properties_node",
"@shade_to_title",
"=",
"attribute_enabled?",
"(",
"background_properties_node",
",",
"'shadeToTitle'",
")",
"@fill",
"=",
"PresentationFill",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"background_properties_node",
")",
"end",
"self",
"end"
] |
Parse Background object
@param node [Nokogiri::XML:Element] node to parse
@return [Background] result of parsing
|
[
"Parse",
"Background",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb#L17-L31
|
17,896
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/structured_document_tag.rb
|
OoxmlParser.StructuredDocumentTag.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'sdtContent'
@sdt_content = SDTContent.new(parent: self).parse(node_child)
when 'sdtPr'
@properties = SDTProperties.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'sdtContent'
@sdt_content = SDTContent.new(parent: self).parse(node_child)
when 'sdtPr'
@properties = SDTProperties.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'sdtContent'",
"@sdt_content",
"=",
"SDTContent",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'sdtPr'",
"@properties",
"=",
"SDTProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse StructuredDocumentTag object
@param node [Nokogiri::XML:Element] node to parse
@return [StructuredDocumentTag] result of parsing
|
[
"Parse",
"StructuredDocumentTag",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/structured_document_tag.rb#L14-L24
|
17,897
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter.rb
|
OoxmlParser.Autofilter.parse
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'ref'
@ref = Coordinates.parser_coordinates_range(value.value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'filterColumn'
@filter_column = FilterColumn.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.attributes.each do |key, value|
case key
when 'ref'
@ref = Coordinates.parser_coordinates_range(value.value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'filterColumn'
@filter_column = FilterColumn.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"case",
"key",
"when",
"'ref'",
"@ref",
"=",
"Coordinates",
".",
"parser_coordinates_range",
"(",
"value",
".",
"value",
")",
"end",
"end",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'filterColumn'",
"@filter_column",
"=",
"FilterColumn",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse Autofilter data
@param [Nokogiri::XML:Element] node with Autofilter data
@return [Autofilter] value of Autofilter data
|
[
"Parse",
"Autofilter",
"data"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter.rb#L17-L32
|
17,898
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/common_parser/common_data/paragraph.rb
|
OoxmlParser.Paragraph.parse
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'pPr'
@properties = ParagraphProperties.new(parent: self).parse(node_child)
when 'fld'
@text_field = TextField.new(parent: self).parse(node_child)
when 'r'
@runs << ParagraphRun.new(parent: self).parse(node_child)
when 'AlternateContent'
@alternate_content = AlternateContent.new(parent: self).parse(node_child)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'pPr'
@properties = ParagraphProperties.new(parent: self).parse(node_child)
when 'fld'
@text_field = TextField.new(parent: self).parse(node_child)
when 'r'
@runs << ParagraphRun.new(parent: self).parse(node_child)
when 'AlternateContent'
@alternate_content = AlternateContent.new(parent: self).parse(node_child)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"node_child",
"|",
"case",
"node_child",
".",
"name",
"when",
"'pPr'",
"@properties",
"=",
"ParagraphProperties",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'fld'",
"@text_field",
"=",
"TextField",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'r'",
"@runs",
"<<",
"ParagraphRun",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"when",
"'AlternateContent'",
"@alternate_content",
"=",
"AlternateContent",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"node_child",
")",
"end",
"end",
"self",
"end"
] |
Parse Paragraph object
@param node [Nokogiri::XML:Element] node to parse
@return [Paragraph] result of parsing
|
[
"Parse",
"Paragraph",
"object"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/common_parser/common_data/paragraph.rb#L28-L42
|
17,899
|
ONLYOFFICE/ooxml_parser
|
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension.rb
|
OoxmlParser.Extension.parse
|
def parse(node)
node.xpath('*').each do |column_node|
case column_node.name
when 'table'
@table = X14Table.new(parent: self).parse(column_node)
when 'sparklineGroups'
@sparkline_groups = SparklineGroups.new(parent: self).parse(column_node)
end
end
self
end
|
ruby
|
def parse(node)
node.xpath('*').each do |column_node|
case column_node.name
when 'table'
@table = X14Table.new(parent: self).parse(column_node)
when 'sparklineGroups'
@sparkline_groups = SparklineGroups.new(parent: self).parse(column_node)
end
end
self
end
|
[
"def",
"parse",
"(",
"node",
")",
"node",
".",
"xpath",
"(",
"'*'",
")",
".",
"each",
"do",
"|",
"column_node",
"|",
"case",
"column_node",
".",
"name",
"when",
"'table'",
"@table",
"=",
"X14Table",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"column_node",
")",
"when",
"'sparklineGroups'",
"@sparkline_groups",
"=",
"SparklineGroups",
".",
"new",
"(",
"parent",
":",
"self",
")",
".",
"parse",
"(",
"column_node",
")",
"end",
"end",
"self",
"end"
] |
Parse Extension data
@param [Nokogiri::XML:Element] node with Extension data
@return [Extension] value of Extension data
|
[
"Parse",
"Extension",
"data"
] |
08452315cde52fa94d8cb3e1eff1db4ea33abc88
|
https://github.com/ONLYOFFICE/ooxml_parser/blob/08452315cde52fa94d8cb3e1eff1db4ea33abc88/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension.rb#L14-L24
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.