I find the "How to reload current opened document via API" thread referenced by Jim K quite vague and not directly related to macros.
However, since both the question and the thread relate to dispatching a .uno:Reload
command, I would like to share my findings related to dispatching a reload using Java code.
The following Java function successfully reloads a component:
/**
* Reloads a document via the dispatch API.
*
* @param component some component previously loaded
*
* @throws Exception
*/
public static void dispatchReload( XComponent component )
throws Exception
{
XController c;
XDispatch d;
XDispatchHelper dh;
XFrame doc;
XNotifyingDispatch dn;
XDispatchProvider dp;
XModel m;
Object o;
PropertyValue[] pv;
/*
* UNO "casting" and obtaining the references required:
*
* a reference to the document as a dispatch provider
* is required to use the dispatch API
*/
m = (XModel)UnoRuntime.queryInterface( XModel.class, component );
c = m.getCurrentController();
doc = c.getFrame();
dp = (XDispatchProvider)UnoRuntime.queryInterface( XDispatchProvider.class, doc );
o = componentFactory.createInstanceWithContext( c, componentContext );
dh = (XDispatchHelper)UnoRuntime.queryInterface( XDispatchHelper.class, o );
pv = new PropertyValue[1];
pv[0] = new PropertyValue();
dh.executeDispatch( dp, ".uno:Reload", "", 0, pv );
}
but after executing the dispatch, an attempt to read from component
results in a com.sun.star.uno.RuntimeException
.