Hide annotations
This commit is contained in:
parent
faa9cf856d
commit
c1dc50aeaa
2 changed files with 54 additions and 4 deletions
|
@ -10,14 +10,22 @@ import com.sun.star.beans.IllegalTypeException;
|
|||
import com.sun.star.beans.NotRemoveableException;
|
||||
import com.sun.star.beans.Property;
|
||||
import com.sun.star.beans.PropertyExistException;
|
||||
import com.sun.star.beans.PropertyValue;
|
||||
import com.sun.star.beans.PropertyVetoException;
|
||||
import com.sun.star.beans.UnknownPropertyException;
|
||||
import com.sun.star.beans.XPropertyContainer;
|
||||
import com.sun.star.beans.XPropertySet;
|
||||
import com.sun.star.beans.XPropertySetInfo;
|
||||
import com.sun.star.document.XDocumentProperties;
|
||||
import com.sun.star.document.XDocumentPropertiesSupplier;
|
||||
import com.sun.star.frame.XController;
|
||||
import com.sun.star.frame.XDesktop;
|
||||
import com.sun.star.frame.XDispatch;
|
||||
import com.sun.star.frame.XDispatchHelper;
|
||||
import com.sun.star.frame.XDispatchProvider;
|
||||
import com.sun.star.frame.XFrame;
|
||||
import com.sun.star.lang.IllegalArgumentException;
|
||||
import com.sun.star.lang.WrappedTargetException;
|
||||
import com.sun.star.lang.XComponent;
|
||||
import com.sun.star.lang.XMultiComponentFactory;
|
||||
import com.sun.star.lang.XMultiServiceFactory;
|
||||
|
@ -25,6 +33,7 @@ import com.sun.star.text.XText;
|
|||
import com.sun.star.text.XTextDocument;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
import com.sun.star.view.XViewSettingsSupplier;
|
||||
|
||||
import pro.litvinovg.libreoffice.DocumentParser;
|
||||
import pro.litvinovg.libreoffice.MetadataCleaner;
|
||||
|
@ -49,6 +58,9 @@ public class Document {
|
|||
private XDocumentPropertiesSupplier documentPropertiesSupplier;
|
||||
private XText text = null;
|
||||
private ArrayList<OutlineElement> outline = new ArrayList<OutlineElement>();
|
||||
private XFrame frame;
|
||||
private XDispatchProvider dispatchProvider;
|
||||
XTextDocument textDocument;
|
||||
|
||||
public Document(XComponentContext componentContext) {
|
||||
context = componentContext;
|
||||
|
@ -60,6 +72,8 @@ public class Document {
|
|||
getDocumentText();
|
||||
multiServiceFactory = UnoRuntime.queryInterface(XMultiServiceFactory.class, currentDocument);
|
||||
readMetadataInDocument();
|
||||
frame = xDesktop.getCurrentFrame();
|
||||
dispatchProvider = UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class, frame );
|
||||
} catch (Exception e) {
|
||||
System.out.println("xDesktop inaccessible. Can not proceed.");
|
||||
e.printStackTrace();
|
||||
|
@ -68,7 +82,7 @@ public class Document {
|
|||
}
|
||||
|
||||
private void getDocumentText() {
|
||||
XTextDocument textDocument = UnoRuntime.queryInterface(XTextDocument.class,currentDocument);
|
||||
textDocument = UnoRuntime.queryInterface(XTextDocument.class,currentDocument);
|
||||
text = textDocument.getText();
|
||||
}
|
||||
|
||||
|
@ -277,4 +291,37 @@ public class Document {
|
|||
return outline;
|
||||
}
|
||||
|
||||
public void hideAnnotations() {
|
||||
XController controller = textDocument.getCurrentController();
|
||||
XViewSettingsSupplier viewSettings = UnoRuntime.queryInterface( XViewSettingsSupplier.class, controller);
|
||||
XPropertySet properties = viewSettings.getViewSettings();
|
||||
try {
|
||||
properties.setPropertyValue("ShowAnnotations", false);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnknownPropertyException e) {
|
||||
e.printStackTrace();
|
||||
} catch (PropertyVetoException e) {
|
||||
e.printStackTrace();
|
||||
} catch (WrappedTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/*
|
||||
* try { Object dispatchHelperObj =
|
||||
* multiComponentFactory.createInstanceWithContext(
|
||||
* "com.sun.star.frame.DispatchHelper", context); XDispatchHelper dispatchHelper
|
||||
* = UnoRuntime.queryInterface( XDispatchHelper.class, dispatchHelperObj);
|
||||
* PropertyValue empty = new PropertyValue(); PropertyValue[] array = new
|
||||
* PropertyValue[] {empty}; XDispatchProvider dispatchProvider =
|
||||
* UnoRuntime.queryInterface( XDispatchProvider.class, frame);
|
||||
* dispatchHelper.executeDispatch(dispatchProvider, ".uno:ShowAnnotations", "",
|
||||
* 0, array);
|
||||
*
|
||||
*
|
||||
* } catch (com.sun.star.uno.Exception e) { e.printStackTrace(); }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -176,9 +176,9 @@ public class EditorGUI extends JFrame {
|
|||
panelStandardMetadata = new JPanel();
|
||||
tabbedPane.addTab("Метаданные либры", null, panelStandardMetadata, null);
|
||||
tabbedPane.setEnabledAt(0, true);
|
||||
if (true) {
|
||||
addMetadataTab(new OutlineElement(null, "Тестовое название"));
|
||||
}
|
||||
/*
|
||||
* if (true) { addMetadataTab(new OutlineElement(null, "Тестовое название")); }
|
||||
*/
|
||||
for (OutlineElement element : outline) {
|
||||
addMetadataTab(element);
|
||||
}
|
||||
|
@ -418,7 +418,10 @@ public class EditorGUI extends JFrame {
|
|||
document.setCustomDocumentProperties(docCustomProps);
|
||||
updateOutlineMetadata();
|
||||
document.writeOutlineMetadata();
|
||||
document.hideAnnotations();
|
||||
}
|
||||
|
||||
|
||||
private void updateOutlineMetadata() {
|
||||
for (MetadataTableModel table : tableModels) {
|
||||
table.writeToOutline();
|
||||
|
|
Loading…
Add table
Reference in a new issue