PyUNO usability improvements
Matthew J. Francis
mjay.francis at gmail.com
Mon Jun 15 19:27:28 PDT 2015
On 15/06/2015 20:53, Noel Grandin wrote:
> Try this:
> find . -name *.idl | xargs grep 'close()'
> find . -name *.idl | xargs grep 'unlock'
> should find you a bunch like
>
> com::sun::star::connection::XConnection
> com::sun::star::connection::XBroadcaster
So, having searched a bit further along these lines,
com.sun.star.connection.XConnection
- Could technically be done, but I can't see any use of it outside the
bridge code (where block level context management would be fairly pointless)
com.sun.star.connection.XBroadcaster
- Referenced by svx/source/table/tablemodel.cxx, but I see precisely
zero mention of it being used in user code. No UNO service or interface
actually declares its use. Unless anyone can come up with an actual use
case, I'd skip it.
The more likely candidates seem to be:
com.sun.star.sdbc.XCloseable
- This one is on pretty solid ground and covers all sorts of things like
database statements and result sets which could usefully be context
managed at the block level
com.sun.star.frame.XModel
- As previously mentioned, locking/unlocking controllers is a pretty
common thing to do and would benefit from the sugar. Riccardo
Magliocchetti separately pointed out on IRC an example where he used a
wrapper class context manager to control the closing of documents, which
would correspond instead to a controller on com.sun.star.util.XCloseable
- which is also implemented by document components. These two behaviours
wouldn't happily coexist on the same object, and I think in terms of
macro programming at least, the controller locking is more useful. As
(com.sun.star.util.)XCloseable.close() also takes an argument, which
couldn't be supplied using the "with obj: ..." syntax, I think this use
case would be better dealt with by a function or class decorator if it's
generally useful, rather than in the PyUNO core at the interface level.
com.sun.star.frame.XLayoutManager
- Could be used to lock interface updates while changing UI. I see one
or two examples of user code using this.
com.sun.star.drawing.framework.XConfigurationController
- Possible but unsure how useful. I see one example of a user having
(unsuccessfully) attempted to use this. It couldn't in any case be
implemented without a working use case to test.
com.sun.star.registry.XRegistryKey
com.sun.star.registry.XSimpleRegistry
- Could be occasionally useful
Others:
com.sun.star.document.XUndoManager
- Potentially quite useful, but as with com.sun.star.util.XCloseable it
requires an argument on the setup side, and would be better served by a
decorator style controller
Regards
Matthew Francis
More information about the LibreOffice
mailing list