 | OO-Snippets: Open Document from URLCommons| Keywords | open, document |
|---|
| Language | Java |
|---|
| Application | Office |
|---|
| Authors | Tobias Krais (www.design-to-use.de)
|
|---|
| Supported Versions | 1.1.x 2.0.x |
|---|
| Supported OS | All |
|---|
| Question | How to open a document?
|
|---|
| Answer | |
|---|
import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.uno.UnoRuntime;
A specified document is loaded.
@param source_File
@return
public void openDocument(String source_File) {
XComponentLoader xComponentLoader = (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class, desktop);
PropertyValue[] myProperties = new PropertyValue[1];
myProperties[0] = new PropertyValue();
myProperties[0].Name = "Hidden";
myProperties[0].Value = new Boolean(false);
try {
XComponent xComponent = xComponentLoader.loadComponentFromURL(
createUNOFileURL(source_File),
"_blank",
0,
myProperties);
}
catch(Exception e) {
}
}
|
Changelog| Date | User | Modification |
|---|
| 2006-12-11 | tobiaskrais | Added Snippet linking features | | 2006-03-27 | tobiaskrais | Initial version |
|