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

public Class OOBibBaseConnect

extends Object
Class Inheritance
Imports
java.io.IOException, 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, .OOVoidResult, 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.DisposedException, 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 com.sun.star.uno.XComponentContext
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 com.sun.star.frame.XDesktop
createDesktop(com.sun.star.uno.XComponentContext context)

private void
forgetDocument()

Mark the current document as missing.

pack-priv com.sun.star.uno.XComponentContext
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 org.jabref.model.openoffice.util.OOResult<com.sun.star.text.XTextDocument, OOError>
getXTextDocument()

Returns either a valid XTextDocument in OOResult or a NoDocumentException error

public boolean
isConnectedToDocument()

A simple test for document availability.

public boolean
isDocumentConnectionMissing()

Returns: true if we are connected to a document

public org.jabref.model.openoffice.util.OOVoidResult<OOError>
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

componentContextback to summary
private final com.sun.star.uno.XComponentContext componentContext
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 BootstrapException, org.jabref.model.openoffice.uno.CreationException, IOException, InterruptedException

Method Detail

closeOfficeConnectionback to summary
public static void closeOfficeConnection()

Close any open office connection, if none exists does nothing

createDesktopback to summary
private com.sun.star.frame.XDesktop createDesktop(com.sun.star.uno.XComponentContext context) throws org.jabref.model.openoffice.uno.CreationException
forgetDocumentback to summary
private void forgetDocument()

Mark the current document as missing.

getComponentContextback to summary
pack-priv com.sun.star.uno.XComponentContext getComponentContext()
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 org.jabref.model.openoffice.util.OOResult<com.sun.star.text.XTextDocument, OOError> getXTextDocument()

Returns either a valid XTextDocument in OOResult or a NoDocumentException error

isConnectedToDocumentback to summary
public boolean isConnectedToDocument()

A simple test for document availability.

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

isDocumentConnectionMissingback to summary
public boolean isDocumentConnectionMissing()
Returns:boolean

true if we are connected to a document

selectDocumentback to summary
public org.jabref.model.openoffice.util.OOVoidResult<OOError> selectDocument(boolean autoSelectForSingle)

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.