Adding tabs for outline

This commit is contained in:
Georgy Litvinov 2020-04-09 15:38:37 +02:00
parent 71776fa54b
commit cebf79d67e
2 changed files with 13 additions and 2 deletions

View file

@ -50,6 +50,7 @@ public class Document {
private XDocumentProperties documentProperties;
private XDocumentPropertiesSupplier documentPropertiesSupplier;
private XText text = null;
private ArrayList<OutlineElement> outline = new ArrayList<OutlineElement>();
public Document(XComponentContext componentContext) {
context = componentContext;
@ -99,8 +100,7 @@ public class Document {
XTextRange textRange = textContent.getAnchor();
String name = textRange.getString();
System.out.println("Outline element found! " + name);
new OutlineElement(textRange);
//TODO: outline element found. Save outline element name and anchor
outline.add(new OutlineElement(textRange));
}
}
} catch (NoSuchElementException e) {
@ -297,5 +297,8 @@ public class Document {
return info.supportsService(service);
}
public ArrayList<OutlineElement> getOutline(){
return outline;
}
}

View file

@ -27,6 +27,7 @@ import javax.swing.table.TableModel;
import pro.litvinovg.libreoffice.metadata.CustomDocumentProperty;
import pro.litvinovg.libreoffice.metadata.Document;
import pro.litvinovg.libreoffice.metadata.OutlineElement;
import javax.swing.JScrollPane;
import javax.swing.JPopupMenu;
@ -62,6 +63,7 @@ public class EditorGUI extends JFrame {
private Document document = null;
private JButton btnNewButton;
private JMenuItem menuItemPupupDocUserProps;
private ArrayList<OutlineElement> outline;
/**
@ -112,11 +114,13 @@ public class EditorGUI extends JFrame {
this.document = doc;
docProps = document.getDocumentProperties();
docCustomProps = document.getDocumentCustomProperties();
outline = document.getOutline();
initComponents();
createEvents();
}
public EditorGUI() {
outline = new ArrayList<OutlineElement>();
initComponents();
createEvents();
}
@ -176,6 +180,10 @@ public class EditorGUI extends JFrame {
JPanel panel = new JPanel();
tabbedPane.addTab("Документ", null, panel, null);
for (OutlineElement element : outline) {
tabbedPane.addTab(element.getName(), null, new JPanel(), null);
}
tabbedPane.setEnabledAt(0, true);