| View previous topic :: View next topic |
| Author |
Message |
leono Guest
|
Posted: Wed Aug 20, 2003 3:27 pm Post subject: exception on save |
|
|
i got a exception when i want to save a document i just create: this is the code:
public void save(DataOutputStream o, File saveInFile)
throws java.io.IOException {
if (mFrame == null)
throw new java.io.IOException("no document loaded");
XModel xModel = mFrame.getController().getModel();
XStorable xStorable =
(XStorable)UnoRuntime.queryInterface(XStorable.class, xModel);
try {
String saveInFileName = "file:///" + saveInFile.getCanonicalPath();
PropertyValue[] storeProps = new PropertyValue[2];
storeProps[ 0 ] = new PropertyValue();
storeProps[ 0 ].Name = "Overwrite";
storeProps[ 0 ].Value = new Boolean(true);
storeProps[ 1 ] = new PropertyValue();
storeProps[ 1 ].Name = "FilterName";
storeProps[ 1 ].Value = "swriter: StarOffice XML (Writer)";
xStorable.storeToURL(saveInFileName, storeProps);//exception occurs here
byte[] buffer = new byte[1024];
InputStream in = new FileInputStream(saveInFile);
int len = 0;
while ((len = in.read(buffer)) > 0)
o.write(buffer, 0, len);
in.close();
}
catch (com.sun.star.io.IOException e) {
e.printStackTrace();
throw new java.io.IOException(e.getMessage());
}
}
the exception i get is:
com.sun.star.io.IOException:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at com.sun.star.lib.uno.protocols.urp.Unmarshal.readThrowable(Unmarshal.java:315)
at com.sun.star.lib.uno.protocols.urp.Unmarshal.readAny(Unmarshal.java:157)
at com.sun.star.lib.uno.protocols.urp.Unmarshal.readObject(Unmarshal.java:404)
at com.sun.star.lib.uno.protocols.urp.urp.readReply(urp.java:192)
at com.sun.star.lib.uno.protocols.urp.urp.readMessage(urp.java:308)
at com.sun.star.lib.uno.protocols.urp.urp.readMessage(urp.java:607)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge$MessageDispatcher.invoke(java_remote_bridge.java:182)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge$MessageDispatcher.run(java_remote_bridge.java:173)
if someone have any idea please tell me thank u. |
|
| Back to top |
|
 |
Ramesh Guest
|
Posted: Fri Aug 22, 2003 5:12 am Post subject: |
|
|
xStorable.storeToURL(saveInFileName, storeProps);//exception occurs here
Change the property "storeProps" to "storeProps[]"
This will solve your prob .
Ramesh |
|
| Back to top |
|
 |
didierkl Guest
|
Posted: Tue Oct 28, 2003 8:08 am Post subject: Having the same problem! |
|
|
Hi,
I have the same problem ... did you solve this ??
Thanks,
Didier Klein |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Tue Oct 28, 2003 9:38 am Post subject: |
|
|
| Code: | storeProps[ 0 ] = new PropertyValue();
storeProps[ 0 ].Name = "Overwrite";
storeProps[ 0 ].Value = new Boolean(true);
storeProps[ 1 ] = new PropertyValue();
storeProps[ 1 ].Name = "FilterName";
storeProps[ 1 ].Value = "swriter: StarOffice XML (Writer)";
|
| didierkl wrote: | | I have the same problem ... did you solve this ?? |
Notice how the first property value is a Boolean, and the second one a string.
Is it possible that your problem is the wrong type for the Value of one of the two PropertyValue's?
Another possible problem with the above code, is that I am unaware of a filter named.... swriter: StarOffice XML (Writer)
In a previous post I gave the complete list of filters available in 1.1RC1...
http://www.oooforum.org/forum/viewtopic.php?p=11744#11744
http://www.oooforum.org/forum/viewtopic.php?p=10311#10311
(Although you would never guess from the thread's name that you would find a complete filter list here.)
How I get this list of filter names is by dropping into python, and then create a com.sun.star.document.FilterFactory object, and then call getElementNames() on it to return an array of strings. You can do it in OOo Basic like this....
| Code: | Sub Main
oFF = createUnoService( "com.sun.star.document.FilterFactory" )
oFilterNames = oFF.getElementNames()
' Now print the filter names.
' For i = LBound( oFilterNames ) To UBound( oFilterNames )
' Print oFilterNames(i)
' Next
' Create a Writer doc and save the filter names to it.
oDoc = StarDesktop.loadComponentFromURL( "private:factory/swriter", "_blank", 0, Array() )
oText = oDoc.getText()
oCursor = oText.createTextCursor()
oCursor.gotoEnd( False )
' Print the filter names into a Writer document.
For i = LBound( oFilterNames ) To UBound( oFilterNames )
oText.insertString( oCursor, oFilterNames(i), False )
oText.insertControlCharacter( oCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False )
Next
End Sub
|
_________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|