Class: Uniword::Ooxml::CustomProperty

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/ooxml/custom_properties.rb

Overview

Custom Document Properties (docProps/custom.xml)

XSD: shared-documentPropertiesCustom.xsd Namespace: schemas.openxmlformats.org/officeDocument/2006/custom-properties

Each property has a name, fmtid (GUID), pid (int), and exactly one vt:* value element (lpwstr, i4, bool, etc.).

Examples:

Parse from XML

props = CustomProperties.from_xml(xml_string)
props.properties.first.name  # => "AssetID"
props.properties.first.value # => "TF10002067"

Create programmatically

props = CustomProperties.new
props.properties << CustomProperty.new(
  fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
  pid: 2,
  name: "Department",
  lpwstr: Types::VariantTypes::VtLpwstr.new(value: "Engineering")
)

Instance Method Summary collapse

Instance Method Details

#has_value?Boolean

Check if any variant type value is set

Returns:

  • (Boolean)


110
111
112
# File 'lib/uniword/ooxml/custom_properties.rb', line 110

def has_value?
  !!value || !!empty || !!null || !!vector || !!array
end

#valueObject

Get the value from whichever variant type is set



100
101
102
103
104
105
106
107
# File 'lib/uniword/ooxml/custom_properties.rb', line 100

def value
  lpwstr&.value || lpstr&.value || bstr&.value ||
    i4&.value || i8&.value || i2&.value || i1&.value || int&.value ||
    ui4&.value || ui8&.value || ui2&.value || ui1&.value || uint&.value ||
    r4&.value || r8&.value || decimal&.value ||
    bool&.value || date&.value || filetime&.value ||
    cy&.value || error&.value || clsid&.value
end