Top Description Fields Constructors Methods
org.jabref.gui.openoffice

public Class OOBibBaseConnect

extends Object
Class Inheritance
Imports
java.nio.file.Path, java.util.ArrayList, .List, .Optional, java.util.stream.Collectors, org.jabref.gui.DialogService, org.jabref.logic.l10n.Localization, org.jabref.logic.openoffice.NoDocumentFoundException, org.jabref.model.openoffice.uno.CreationException, .NoDocumentException, .UnoCast, .UnoTextDocument, org.jabref.model.openoffice.util.OOResult, com.sun.star.bridge.XBridge, com.sun.star.bridge.XBridgeFactory, com.sun.star.comp.helper.BootstrapException, com.sun.star.container.NoSuchElementException, com.sun.star.container.XEnumeration, com.sun.star.container.XEnumerationAccess, com.sun.star.frame.XDesktop, com.sun.star.lang.WrappedTargetException, com.sun.star.lang.XComponent, com.sun.star.lang.XMultiComponentFactory, com.sun.star.text.XTextDocument, com.sun.star.uno.XComponentContext, org.slf4j.Logger, .LoggerFactory

Establish connection to a document opened in OpenOffice or LibreOffice.

Field Summary

Modifier and TypeField and Description
private final DialogService
private static final Logger
private final com.sun.star.frame.XDesktop
private com.sun.star.text.XTextDocument
xTextDocument

Created when connected to a document.

Constructor Summary

AccessConstructor and Description
public
OOBibBaseConnect(Path loPath, DialogService dialogService)

Method Summary

Modifier and TypeMethod and Description
public static void
closeOfficeConnection()

Close any open office connection, if none exists does nothing

private void
forgetDocument()

Mark the current document as missing.

public Optional<String>
getCurrentDocumentTitle()

The title of the current document, or Optional.empty()

private static List<com.sun.star.text.XTextDocument>
getTextDocuments(com.sun.star.frame.XDesktop desktop)

public OOResult<com.sun.star.text.XTextDocument, OOError>
public com.sun.star.text.XTextDocument
getXTextDocumentOrThrow()

Either return a valid XTextDocument or throw NoDocumentException.

public boolean
isConnectedToDocument()

A simple test for document availability.

public boolean

Returns:

true if we are connected to a document
isDocumentConnectionMissing
()

public void
selectDocument(boolean autoSelectForSingle)

Choose a document to work with.

private static com.sun.star.text.XTextDocument

Returns:

Null if no document was selected. Otherwise the document selected.
selectDocumentDialog
(List<com.sun.star.text.XTextDocument> list, DialogService dialogService)

Run a dialog allowing the user to choose among the documents in `list`.

private com.sun.star.frame.XDesktop
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dialogServiceback to summary
private final DialogService dialogService
LOGGERback to summary
private static final Logger LOGGER
xDesktopback to summary
private final com.sun.star.frame.XDesktop xDesktop
xTextDocumentback to summary
private com.sun.star.text.XTextDocument xTextDocument

Created when connected to a document.

Cleared (to null) when we discover we lost the connection.

Constructor Detail

OOBibBaseConnectback to summary
public OOBibBaseConnect(Path loPath, DialogService dialogService) throws com.sun.star.comp.helper.BootstrapException, CreationException

Method Detail

closeOfficeConnectionback to summary
public static void closeOfficeConnection()

Close any open office connection, if none exists does nothing

forgetDocumentback to summary
private void forgetDocument()

Mark the current document as missing.

getCurrentDocumentTitleback to summary
public Optional<String> getCurrentDocumentTitle()

The title of the current document, or Optional.empty()

getTextDocumentsback to summary
private static List<com.sun.star.text.XTextDocument> getTextDocuments(com.sun.star.frame.XDesktop desktop) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
getXTextDocumentback to summary
public OOResult<com.sun.star.text.XTextDocument, OOError> getXTextDocument()
getXTextDocumentOrThrowback to summary
public com.sun.star.text.XTextDocument getXTextDocumentOrThrow() throws NoDocumentException

Either return a valid XTextDocument or throw NoDocumentException.

isConnectedToDocumentback to summary
public boolean isConnectedToDocument()

A simple test for document availability.

See also `isDocumentConnectionMissing` for a test actually attempting to use teh connection.

isDocumentConnectionMissingback to summary
public boolean isDocumentConnectionMissing()
Returns:boolean

true if we are connected to a document

selectDocumentback to summary
public void selectDocument(boolean autoSelectForSingle) throws NoDocumentFoundException, com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException

Choose a document to work with.

Assumes we have already connected to LibreOffice or OpenOffice.

If there is a single document to choose from, selects that. If there are more than one, shows selection dialog. If there are none, throws NoDocumentFoundException

After successful selection connects to the selected document and extracts some frequently used parts (starting points for managing its content).

Finally initializes this.xTextDocument with the selected document and parts extracted.

selectDocumentDialogback to summary
private static com.sun.star.text.XTextDocument selectDocumentDialog(List<com.sun.star.text.XTextDocument> list, DialogService dialogService)

Run a dialog allowing the user to choose among the documents in `list`.

Returns:com.sun.star.text.XTextDocument

Null if no document was selected. Otherwise the document selected.

simpleBootstrapback to summary
private com.sun.star.frame.XDesktop simpleBootstrap(Path loPath) throws CreationException, com.sun.star.comp.helper.BootstrapException