Andrew Grant 2 недель назад
Родитель
Сommit
fb2ee34470

+ 2 - 0
src/main/java/scot/carricksoftware/grantswriter/constants/LatexConstants.java

@@ -22,6 +22,8 @@ public class LatexConstants {
     public static final String LONG_TABLE_END = "\\end{longtable}";
     @SuppressWarnings("SpellCheckingInspection")
     public static final String LONG_TABLE_START = "\\begin{longtable}{";
+    @SuppressWarnings("SpellCheckingInspection")
+    public static final String SECTION_NUMBERING = "\\setsecnumdepth{subsubsection}";
 
     @SuppressWarnings("SpellCheckingInspection")
     public static final String USE_PACKAGE_TERM = "\\usepackage{";

+ 1 - 2
src/main/java/scot/carricksoftware/grantswriter/writer/latex/LatexDocumentStartImpl.java

@@ -32,8 +32,7 @@ public class LatexDocumentStartImpl implements LatexDocumentStart {
         fileWriter.writeLine(LatexConstants.DOCUMENT_CLASS);
         //noinspection SpellCheckingInspection
         latexPackageDeclaration.write("longtable");
+        fileWriter.writeLine(LatexConstants.SECTION_NUMBERING);
         fileWriter.writeLine(LatexConstants.DOCUMENT_START);
-
-
     }
 }

+ 1 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/LatexPackageDeclarationImpl.java

@@ -25,4 +25,5 @@ public class LatexPackageDeclarationImpl implements LatexPackageDeclaration {
                 LatexConstants.TERM_END;
         fileWriter.writeLine(sb);
     }
+
 }

+ 4 - 2
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/PersonSectionContentsWriterImpl.java

@@ -8,13 +8,13 @@ package scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.springframework.stereotype.Component;
-import scot.carricksoftware.grantswriter.constants.LatexLevels;
 import scot.carricksoftware.grantswriter.domains.people.Person;
 import scot.carricksoftware.grantswriter.domains.text.PersonText;
 import scot.carricksoftware.grantswriter.services.text.PersonTextService;
 import scot.carricksoftware.grantswriter.writer.FileWriter;
 import scot.carricksoftware.grantswriter.writer.latex.LatexDivisionHeader;
 
+import java.util.Comparator;
 import java.util.List;
 
 @Component
@@ -40,15 +40,17 @@ public class PersonSectionContentsWriterImpl implements PersonSectionContentsWri
         logger.info("PersonSectionContentsWriterImpl.write()");
         List<PersonText> contents = personTextService.findAllByPerson(person);
         if (!contents.isEmpty()) {
+            contents.sort(Comparator.comparing(PersonText::getOrder));
             for (PersonText personText : contents) {
                 if (personText.getHeading() != null) {
-                    latexDivisionHeader.write(LatexLevels.LATEX_SECTION, personText.getHeading());
+                    latexDivisionHeader.write(personText.getLevel().intValue(), personText.getHeading());
                 }
                 writeContent (personText);
             }
         }
     }
 
+
     private void writeContent(PersonText personText) {
         logger.info("PersonSectionContentsWriterImpl.writeContent()");
         fileWriter.writeLine(personText.getContent());

+ 5 - 1
src/test/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/PersonSectionContentsWriterOnyContentsTest.java

@@ -14,6 +14,7 @@ import scot.carricksoftware.grantswriter.domains.people.Person;
 import scot.carricksoftware.grantswriter.domains.text.PersonText;
 import scot.carricksoftware.grantswriter.services.text.PersonTextService;
 import scot.carricksoftware.grantswriter.writer.FileWriter;
+import scot.carricksoftware.grantswriter.writer.latex.LatexDivisionHeader;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -35,6 +36,9 @@ class PersonSectionContentsWriterOnyContentsTest {
     @Mock
     private FileWriter fileWriterMock;
 
+    @Mock
+    private LatexDivisionHeader latexDivisionHeader;
+
     private List<PersonText> contents;
 
     private PersonText personText;
@@ -43,7 +47,7 @@ class PersonSectionContentsWriterOnyContentsTest {
 
     @BeforeEach
     void setUp() {
-        writer = new PersonSectionContentsWriterImpl(personTextServiceMock, fileWriterMock);
+        writer = new PersonSectionContentsWriterImpl(personTextServiceMock, fileWriterMock, latexDivisionHeader);
         person = new Person();
         personText = new PersonText();
     }