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.NotRemoveableException;
|
||||||
import com.sun.star.beans.Property;
|
import com.sun.star.beans.Property;
|
||||||
import com.sun.star.beans.PropertyExistException;
|
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.UnknownPropertyException;
|
||||||
import com.sun.star.beans.XPropertyContainer;
|
import com.sun.star.beans.XPropertyContainer;
|
||||||
import com.sun.star.beans.XPropertySet;
|
import com.sun.star.beans.XPropertySet;
|
||||||
import com.sun.star.beans.XPropertySetInfo;
|
import com.sun.star.beans.XPropertySetInfo;
|
||||||
import com.sun.star.document.XDocumentProperties;
|
import com.sun.star.document.XDocumentProperties;
|
||||||
import com.sun.star.document.XDocumentPropertiesSupplier;
|
import com.sun.star.document.XDocumentPropertiesSupplier;
|
||||||
|
import com.sun.star.frame.XController;
|
||||||
import com.sun.star.frame.XDesktop;
|
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.IllegalArgumentException;
|
||||||
|
import com.sun.star.lang.WrappedTargetException;
|
||||||
import com.sun.star.lang.XComponent;
|
import com.sun.star.lang.XComponent;
|
||||||
import com.sun.star.lang.XMultiComponentFactory;
|
import com.sun.star.lang.XMultiComponentFactory;
|
||||||
import com.sun.star.lang.XMultiServiceFactory;
|
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.text.XTextDocument;
|
||||||
import com.sun.star.uno.UnoRuntime;
|
import com.sun.star.uno.UnoRuntime;
|
||||||
import com.sun.star.uno.XComponentContext;
|
import com.sun.star.uno.XComponentContext;
|
||||||
|
import com.sun.star.view.XViewSettingsSupplier;
|
||||||
|
|
||||||
import pro.litvinovg.libreoffice.DocumentParser;
|
import pro.litvinovg.libreoffice.DocumentParser;
|
||||||
import pro.litvinovg.libreoffice.MetadataCleaner;
|
import pro.litvinovg.libreoffice.MetadataCleaner;
|
||||||
|
@ -49,6 +58,9 @@ public class Document {
|
||||||
private XDocumentPropertiesSupplier documentPropertiesSupplier;
|
private XDocumentPropertiesSupplier documentPropertiesSupplier;
|
||||||
private XText text = null;
|
private XText text = null;
|
||||||
private ArrayList<OutlineElement> outline = new ArrayList<OutlineElement>();
|
private ArrayList<OutlineElement> outline = new ArrayList<OutlineElement>();
|
||||||
|
private XFrame frame;
|
||||||
|
private XDispatchProvider dispatchProvider;
|
||||||
|
XTextDocument textDocument;
|
||||||
|
|
||||||
public Document(XComponentContext componentContext) {
|
public Document(XComponentContext componentContext) {
|
||||||
context = componentContext;
|
context = componentContext;
|
||||||
|
@ -60,6 +72,8 @@ public class Document {
|
||||||
getDocumentText();
|
getDocumentText();
|
||||||
multiServiceFactory = UnoRuntime.queryInterface(XMultiServiceFactory.class, currentDocument);
|
multiServiceFactory = UnoRuntime.queryInterface(XMultiServiceFactory.class, currentDocument);
|
||||||
readMetadataInDocument();
|
readMetadataInDocument();
|
||||||
|
frame = xDesktop.getCurrentFrame();
|
||||||
|
dispatchProvider = UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class, frame );
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("xDesktop inaccessible. Can not proceed.");
|
System.out.println("xDesktop inaccessible. Can not proceed.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -68,7 +82,7 @@ public class Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getDocumentText() {
|
private void getDocumentText() {
|
||||||
XTextDocument textDocument = UnoRuntime.queryInterface(XTextDocument.class,currentDocument);
|
textDocument = UnoRuntime.queryInterface(XTextDocument.class,currentDocument);
|
||||||
text = textDocument.getText();
|
text = textDocument.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,4 +291,37 @@ public class Document {
|
||||||
return outline;
|
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();
|
panelStandardMetadata = new JPanel();
|
||||||
tabbedPane.addTab("Метаданные либры", null, panelStandardMetadata, null);
|
tabbedPane.addTab("Метаданные либры", null, panelStandardMetadata, null);
|
||||||
tabbedPane.setEnabledAt(0, true);
|
tabbedPane.setEnabledAt(0, true);
|
||||||
if (true) {
|
/*
|
||||||
addMetadataTab(new OutlineElement(null, "Тестовое название"));
|
* if (true) { addMetadataTab(new OutlineElement(null, "Тестовое название")); }
|
||||||
}
|
*/
|
||||||
for (OutlineElement element : outline) {
|
for (OutlineElement element : outline) {
|
||||||
addMetadataTab(element);
|
addMetadataTab(element);
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,10 @@ public class EditorGUI extends JFrame {
|
||||||
document.setCustomDocumentProperties(docCustomProps);
|
document.setCustomDocumentProperties(docCustomProps);
|
||||||
updateOutlineMetadata();
|
updateOutlineMetadata();
|
||||||
document.writeOutlineMetadata();
|
document.writeOutlineMetadata();
|
||||||
|
document.hideAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateOutlineMetadata() {
|
private void updateOutlineMetadata() {
|
||||||
for (MetadataTableModel table : tableModels) {
|
for (MetadataTableModel table : tableModels) {
|
||||||
table.writeToOutline();
|
table.writeToOutline();
|
||||||
|
|
Loading…
Add table
Reference in a new issue