| View previous topic :: View next topic |
| Author |
Message |
JulianUK Newbie

Joined: 29 Mar 2005 Posts: 3
|
Posted: Tue Mar 29, 2005 9:56 am Post subject: Problem with Ruby and COM-UNO bridge |
|
|
I've been trying to drive OOO from Ruby to automate a bunch of document conversions.
Having researched on the web, including here here and here I tried the code below, however whenever I try to save the document with parameters (to set an output filter) I got an error from the bridge.
This is with OOO 1.1.4 and has happened on both W98 and XP.
I tried a quick test using VBScript (fundamentals copied from here) and got the same erors, suggesting it is a bridge problem rather than Ruby.
Any ideas anyone?
| Code: |
require 'win32ole'
$serviceManager = WIN32OLE.new("com.sun.star.ServiceManager")
$desktop = $serviceManager.createInstance("com.sun.star.frame.Desktop")
def newWriterDocument()
document = $desktop.loadComponentFromURL("private:factory/swriter",\"_blank", 0, [])
document
end
def test()
filter = "writer_pdf_Export"
fprops = makeProperties("FilterName" => filter)
document = newWriterDocument
text = document.GetText
cursor = text.createTextCursor
text.insertString(cursor, "Hello World", 0)
oURL = "file:///c|/test.pdf"
document.storeAsUrl(oURL, fprops) # this line fails with OLE error
#store a document in standard format - document.storeAsUrl(oURL, []) - works
end
def makeProperty(name, value)
property = $serviceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
property["Name"] = name
property["Value"] = value
property
end
def makeProperties(hash)
properties = []
hash.each { | key, value |
properties < < makeProperty(key, value)
}
properties
end
begin
test
rescue
ensure
end |
|
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3385 Location: Hamburg, Germany
|
Posted: Tue Mar 29, 2005 12:48 pm Post subject: Re: Problem with Ruby and COM-UNO bridge |
|
|
| JulianUK wrote: | | Any ideas anyone? |
Yes!
| JulianUK wrote: | | Code: | oURL = "file:///c|/test.pdf"
document.storeAsUrl(oURL, fprops) # this line fails with OLE error
|
|
This problem is quite often reported in this forum. You can rewrite this error in all possible languages that are supported bei UNO
To solve the problem, use "storeToUrl" instead of "storeAsUrl". I fixed this problem myself with Java. Look for example at this link: http://www.oooforum.org/forum/viewtopic.phtml?t=13925&highlight=pdf+storetourl
With kind regards
hol.sten |
|
| Back to top |
|
 |
JulianUK Newbie

Joined: 29 Mar 2005 Posts: 3
|
Posted: Tue Mar 29, 2005 1:14 pm Post subject: Re: Problem with Ruby and COM-UNO bridge |
|
|
| hol.sten wrote: |
Yes!
This problem is quite often reported in this forum. You can rewrite this error in all possible languages that are supported bei UNO
To solve the problem, use "storeToUrl" instead of "storeAsUrl". I fixed this problem myself with Java. Look for example at this link: http://www.oooforum.org/forum/viewtopic.phtml?t=13925&highlight=pdf+storetourl
With kind regards
hol.sten |
many thanks!
is this bug documented anywhere at OO do you know?
regards
Julian |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3385 Location: Hamburg, Germany
|
Posted: Tue Mar 29, 2005 1:27 pm Post subject: Re: Problem with Ruby and COM-UNO bridge |
|
|
| JulianUK wrote: | | is this bug documented anywhere at OO do you know? |
Regarding all those threads about this pdf "problem", it's not a bug, it's a feature. The function "storeAsURL" is equivalent to "Save as..." of OOo. You can save this way all the formats that OOo can import. Another function is "storeToURL". You can use it for formats that OOo can't import. It's not the "Save as..." but the "Export..." feature.
With kind regards
hol.sten |
|
| Back to top |
|
 |
JulianUK Newbie

Joined: 29 Mar 2005 Posts: 3
|
Posted: Tue Mar 29, 2005 1:56 pm Post subject: Re: Problem with Ruby and COM-UNO bridge |
|
|
| hol.sten wrote: |
Regarding all those threads about this pdf "problem", it's not a bug, it's a feature. The function "storeAsURL" is equivalent to "Save as..." of OOo. You can save this way all the formats that OOo can import. Another function is "storeToURL". You can use it for formats that OOo can't import. It's not the "Save as..." but the "Export..." feature.
With kind regards
hol.sten |
Thanks - I bet it isn't described as simply as that anywhere in the OO documentation! |
|
| Back to top |
|
 |
|