From cebf79d67e158c1c41162b0e2be8f297634ed005 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Thu, 9 Apr 2020 15:38:37 +0200 Subject: [PATCH] Adding tabs for outline --- source/pro/litvinovg/libreoffice/metadata/Document.java | 7 +++++-- .../litvinovg/libreoffice/metadata/views/EditorGUI.java | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/pro/litvinovg/libreoffice/metadata/Document.java b/source/pro/litvinovg/libreoffice/metadata/Document.java index ce57393..01a6630 100644 --- a/source/pro/litvinovg/libreoffice/metadata/Document.java +++ b/source/pro/litvinovg/libreoffice/metadata/Document.java @@ -50,6 +50,7 @@ public class Document { private XDocumentProperties documentProperties; private XDocumentPropertiesSupplier documentPropertiesSupplier; private XText text = null; + private ArrayList outline = new ArrayList(); 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 getOutline(){ + return outline; + } } diff --git a/source/pro/litvinovg/libreoffice/metadata/views/EditorGUI.java b/source/pro/litvinovg/libreoffice/metadata/views/EditorGUI.java index dbeee76..3d625fc 100644 --- a/source/pro/litvinovg/libreoffice/metadata/views/EditorGUI.java +++ b/source/pro/litvinovg/libreoffice/metadata/views/EditorGUI.java @@ -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 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(); 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);