Class: RubyLoader::SingleComponentFactory

Inherits:
Object
  • Object
show all
Includes:
Runo::Com::Sun::Star::Lang::XServiceInfo, Runo::Com::Sun::Star::Lang::XSingleComponentFactory, Uno::UnoBase
Defined in:
lib/rubyloader.rb

Overview

Component factory class wraps your class which implements UNO component.

Instance Method Summary collapse

Methods included from Uno::UnoBase

#getImplementationId, #getTypes

Constructor Details

#initialize(klass, imple_name, url) ⇒ SingleComponentFactory

Returns a new instance of SingleComponentFactory.



123
124
125
126
127
# File 'lib/rubyloader.rb', line 123

def initialize(klass, imple_name, url)
  @klass = klass
  @imple_name = imple_name
  @url = url
end

Instance Method Details

#createInstanceWithArgumentsAndContext(args, ctx) ⇒ Object

Generaly, this method instantiate the class and calls css.lang.XInitialization#initialize method. But Ruby’s initialize method is special one. Therefore additional arguments are passed as second one.



146
147
148
149
150
151
152
153
154
155
156
# File 'lib/rubyloader.rb', line 146

def createInstanceWithArgumentsAndContext(args, ctx)
  begin
    load_class unless @klass
    return @klass.new(ctx, args)
  rescue => e
    RubyLoader.log.error(@klass.to_s) {
      "Error raised at #{self.class.name}##{__method__}\n" + 
      RubyLoader.error_to_str(e)}
    raise
  end
end

#createInstanceWithContext(ctx) ⇒ Object

XSingleComponentFactory



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/rubyloader.rb', line 130

def createInstanceWithContext(ctx)
  begin
    load_class unless @klass
    return @klass.new(ctx)
  rescue => e
    RubyLoader.log.error(@klass.to_s) {
      "Error raised at #{self.class.name}##{__method__}\n" + 
      RubyLoader.error_to_str(e)}
    raise
  end
end

#getImplementationNameObject

XServiceInfo



160
161
162
163
# File 'lib/rubyloader.rb', line 160

def getImplementationName
  return @klass::IMPLE_NAME if @klass
  return @imple_name
end

#getSupportedServiceNamesObject



169
170
171
172
# File 'lib/rubyloader.rb', line 169

def getSupportedServiceNames
  return @klass::SERVICE_NAMES if @klass
  return []
end

#supportsService(name) ⇒ Object



165
166
167
# File 'lib/rubyloader.rb', line 165

def supportsService(name)
  return @klass::SERVICE_NAMES.include?(name)
end