mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 09:15:33 +00:00
done
This commit is contained in:
@@ -4,7 +4,6 @@ namespace HamannPrinter
|
||||
{
|
||||
public class Confix
|
||||
{
|
||||
public bool? LettersDocx { get; set; }
|
||||
public bool? VolumeDocx { get; set; }
|
||||
public bool? RegisterDocx { get; set; }
|
||||
public string HamannXmlPath { get; set; }
|
||||
|
||||
@@ -8,6 +8,8 @@ using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using HaDocument.Interfaces;
|
||||
using HaDocument.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using static HamannPrinter.Parser;
|
||||
using Comment = HaDocument.Models.Comment;
|
||||
using static HamannPrinter.Helper;
|
||||
@@ -35,6 +37,7 @@ namespace HamannPrinter
|
||||
static public int MarginTop { get; set; }
|
||||
//rechter Rand
|
||||
static public UInt32 MarginRight { get; set; }
|
||||
static public UInt32 MarginRightColumns { get; set; }
|
||||
//unterer Rand
|
||||
static public int MarginBottom { get; set; }
|
||||
// linker Rand
|
||||
@@ -67,9 +70,6 @@ namespace HamannPrinter
|
||||
// Pfad für Ausgabe der Briefe
|
||||
static public List<string> LetterPaths { get; set; }
|
||||
|
||||
|
||||
static bool firstone = false;
|
||||
|
||||
public Hamann2Word(ILibrary lib, DocOptions docxOptions)
|
||||
{
|
||||
// erzeugt neue Instanz von Hamann2Word mit den Erforderlichen Werten aus den DocOptions
|
||||
@@ -96,6 +96,7 @@ namespace HamannPrinter
|
||||
SuperValue = docxOptions.SuperValue;
|
||||
SubValue = docxOptions.SubValue;
|
||||
Diodone = docxOptions.Diodone;
|
||||
MarginRightColumns = docxOptions.MarginRightColumns;
|
||||
RegisterPaths = new List<string>();
|
||||
YearPaths = new List<string>();
|
||||
LetterPaths = new List<string>();
|
||||
@@ -145,6 +146,7 @@ namespace HamannPrinter
|
||||
public List<XElement> HandTags { get; set; }
|
||||
//docx Datei des Briefes
|
||||
public WordprocessingDocument WordDoc { get; set; }
|
||||
public bool stateFirstLine { get; set; } = true;
|
||||
|
||||
public LetterObj(string index, XElement text, Meta meta, string key, string tempDir = null)
|
||||
{
|
||||
@@ -172,7 +174,7 @@ namespace HamannPrinter
|
||||
}
|
||||
|
||||
|
||||
public static void Letter2Docx(LetterObj letter, bool makeVolumes = false)
|
||||
public static void Letter2Docx(LetterObj letter)
|
||||
{
|
||||
/*befüllt ein LetterObj.BriefDocx mit dem "geparsten" Inhalt (xml) des Briefes*/
|
||||
|
||||
@@ -204,11 +206,11 @@ namespace HamannPrinter
|
||||
}
|
||||
}
|
||||
//Kommentare und Varianten anhängen
|
||||
AddCommentsETC(letter, makeVolumes);
|
||||
AddCommentsETC(letter);
|
||||
}
|
||||
|
||||
|
||||
public static void AddCommentsETC(LetterObj letter, bool makeVolumes)
|
||||
public static void AddCommentsETC(LetterObj letter)
|
||||
{
|
||||
if (letter.Tradition != null)
|
||||
{
|
||||
@@ -273,29 +275,18 @@ namespace HamannPrinter
|
||||
CreateColSection(letter.WordDoc, margSingle);
|
||||
}
|
||||
|
||||
if (makeVolumes)
|
||||
{
|
||||
MakeFinalPageBreak(letter);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
MakeSourceSection(letter);
|
||||
}
|
||||
MakeFinalPageBreak(letter);
|
||||
}
|
||||
|
||||
public static void MakeSourceSection(LetterObj letter)
|
||||
{
|
||||
string txt = "Johann Georg Hamann: Kommentierte Briefausgabe (HKB). Hrsg. von Leonard Keidel und Janina Reibold, auf Grundlage der Vorarbeiten Arthur Henkels, unter Mitarbeit von Gregor Babelotzky, Konrad Bucher, Christian Großmann, Carl Friedrich Haak, Luca Klopfer, Johannes Knüchel, Isabel Langkabel und Simon Martens. (Heidelberg 2020ff.) URL: ";
|
||||
//Hyperlink link = new Hyperlink(new Run(new Text("www.hamann-ausgabe.de"))) { Anchor = "Hamann-Ausgabe online", DocLocation = "https://www.hamann-ausgabe.de", Id= "https://www.hamann-ausgabe.de" };
|
||||
var link = new Run(new Text("www.hamann-ausgabe.de"));
|
||||
var head = new Run(new Text("Quelle:"));
|
||||
var src = new Run(new Break(), new Text(txt) { Space = SpaceProcessingModeValues.Preserve });
|
||||
var srcPara = new Paragraph(head, src, link, new Run(new Text(".")));
|
||||
/*SansSerifRun(src);
|
||||
SansSerifRun(head);
|
||||
BoldRun(head);*/
|
||||
ApplyParaStyle(srcPara, "quelle");
|
||||
GetLastPara(letter.WordDoc).Remove();
|
||||
GetLastPara(letter.WordDoc).InsertAfterSelf(srcPara);
|
||||
}
|
||||
|
||||
@@ -731,7 +722,7 @@ namespace HamannPrinter
|
||||
case "page":
|
||||
if (run != null)
|
||||
{
|
||||
string pagenumber = xelem.Attribute("autopsic").Value.ToString();
|
||||
string pagenumber = xelem.Attribute("index").Value.ToString();
|
||||
run.AppendChild<Text>(new Text(" |" + pagenumber + "| ") { Space = SpaceProcessingModeValues.Preserve });
|
||||
|
||||
}
|
||||
@@ -829,11 +820,13 @@ namespace HamannPrinter
|
||||
break;
|
||||
|
||||
case "line":
|
||||
CheckLineTag(xelem, wordDoc);
|
||||
CheckLineTag(xelem, wordDoc, letter);
|
||||
break;
|
||||
|
||||
case "page":
|
||||
CheckPageTag(xelem, wordDoc);
|
||||
if (!letter.stateFirstLine)
|
||||
{
|
||||
CheckPageTag(xelem, wordDoc);
|
||||
}
|
||||
break;
|
||||
|
||||
case "nr":
|
||||
@@ -959,110 +952,73 @@ namespace HamannPrinter
|
||||
|
||||
#region Vorbereitungen für Letterparsen
|
||||
|
||||
/*
|
||||
//veraltete funktion, kann gelöscht werden
|
||||
public void Coordinator(ILibrary lib, string[] vols, bool? letterDocs, bool? letterPdfs, bool? volDocs, bool? volPdf, bool? registerDocs, bool? registerPdf)
|
||||
{
|
||||
// koordiniert das Erstellen der einzelnen Dokumenttypen/-sorten
|
||||
if (letterDocs == true)
|
||||
{
|
||||
Logger.Out("Erstelle docx für einzelbriefe");
|
||||
MakeLetterDocuments(lib, vols);
|
||||
if (letterPdfs == true)
|
||||
{
|
||||
Logger.Out("Erstelle PDF für einzelbriefe");
|
||||
PdfPrinter.Print(LetterPaths);
|
||||
}
|
||||
}
|
||||
if (volDocs == true)
|
||||
{
|
||||
Logger.Out("Erstelle docx für BandDateien");
|
||||
MakeVolumeDocuments(lib, vols);
|
||||
if (volPdf == true)
|
||||
{
|
||||
Logger.Out("Erstelle PDF für BandDateien");
|
||||
PdfPrinter.Print(VolumePaths);
|
||||
}
|
||||
}
|
||||
if (registerDocs == true)
|
||||
{
|
||||
Logger.Out("Erstelle docx für Register");
|
||||
MakeRegisterComms();
|
||||
if (registerPdf == true)
|
||||
{
|
||||
Logger.Out("Erstelle PDF für Register");
|
||||
PdfPrinter.Print(RegisterPaths);
|
||||
}
|
||||
}
|
||||
System.IO.File.WriteAllText(OutputDir + "logfile.txt", Logger.LogString.ToString());
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
public void MakeLetterDocuments(ILibrary lib, (int, int) years)
|
||||
{
|
||||
/*Holt eine Liste von Briefobjekten der zu Parsenden Bände (vols), lässt deren dcox.
|
||||
* Dokumente formatieren und befüllen. Schließt/Speichert die Dokumente.*/
|
||||
|
||||
List<LetterObj> letterList = Lib2List(lib, years);
|
||||
//System.Threading.Tasks.Parallel.ForEach(letterList, MakeLetter);
|
||||
foreach (LetterObj letter in letterList)
|
||||
{
|
||||
letter.WordDoc = CreateLetterDocx(letter.OutPutFile);
|
||||
Logger.Out(letter.OutPutFile);
|
||||
if (letter.WordDoc == null)
|
||||
{
|
||||
Logger.Out(letter.Autopsic + "\n hat kein worddoc!");
|
||||
}
|
||||
StyleLetterDocx(letter);
|
||||
Letter2Docx(letter, false);
|
||||
letter.WordDoc.Save();
|
||||
letter.WordDoc.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeYearDocuments(ILibrary lib, (int, int) years)
|
||||
{
|
||||
/*erzeugt temporäre Briefdateien und verbindet siezu einer Banddatei
|
||||
die dauerhaften Brief.docx dateien können nicht gemergt werden, da sie die
|
||||
für Bände überflüssige source section am ende enthalten und alt chunks nicht
|
||||
verändert werden können*/
|
||||
for (; years.Item1 < years.Item2; years.Item1++)
|
||||
{
|
||||
Logger.Out("Dokument für Jahr " + years.Item1.ToString());
|
||||
string tempfolder = GetTemporaryDirectory();
|
||||
Logger.Out("tempfolder ist " + tempfolder);
|
||||
var outputPaths = new Dictionary<int, string>();
|
||||
var letterList = Lib2List(lib, years.Item1, tempfolder);
|
||||
foreach (var letter in letterList)
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// Parallel.ForEach(Enumerable.Range(years.Item1, years.Item2 - years.Item1 + 1), i => {
|
||||
// Logger.Out("Dokument für Jahr " + i.ToString());
|
||||
// var outputPaths = new List<(int, string)>();
|
||||
// var letterList = Lib2List(lib, i);
|
||||
// if (letterList.Any())
|
||||
// {
|
||||
// foreach (var letter in letterList.OrderBy(x => x.Meta.Sort).ThenBy(x => x.Meta.Order))
|
||||
// {
|
||||
// letter.WordDoc = CreateLetterDocx(letter.OutPutFile);
|
||||
// StyleLetterDocx(letter);
|
||||
// Letter2Docx(letter);
|
||||
// outputPaths.Add((Int32.Parse(letter.Index), letter.OutPutFile));
|
||||
// letter.WordDoc.Dispose();
|
||||
// }
|
||||
// MergeDocx(lib, i.ToString(), outputPaths, MakeVolumeDoc(i.ToString()), Editionsrichtlinien);
|
||||
// }
|
||||
// foreach(var letter in letterList)
|
||||
// {
|
||||
// Logger.Out("Nachbearbeitung Brief " + letter.Autopsic);
|
||||
// letter.WordDoc = WordprocessingDocument.Open(letter.OutPutFile, true);
|
||||
// MakeSourceSection(letter);
|
||||
// letter.WordDoc.Dispose();
|
||||
// }
|
||||
// });
|
||||
// sw.Stop();
|
||||
// TimeSpan ts = sw.Elapsed;
|
||||
// string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
|
||||
// ts.Hours, ts.Minutes, ts.Seconds,
|
||||
// ts.Milliseconds / 10);
|
||||
// Logger.Out(elapsedTime);
|
||||
// sw.Restart();
|
||||
for (; years.Item1 <= years.Item2; years.Item1++)
|
||||
{
|
||||
letter.WordDoc = CreateLetterDocx(letter.OutPutFile);
|
||||
StyleLetterDocx(letter);
|
||||
Letter2Docx(letter, true);
|
||||
letter.WordDoc.Save();
|
||||
outputPaths.Add(Int32.Parse(letter.Index), letter.OutPutFile);
|
||||
letter.WordDoc.Close();
|
||||
}
|
||||
outputPaths.Add(0, MakeVolumeDoc(years.Item1.ToString()));
|
||||
outputPaths.Add(1000000000, Editionsrichtlinien);
|
||||
MergeDocx(years.Item1.ToString(), outputPaths);
|
||||
//temporären briefdateien löschen
|
||||
RemoveTempFolderFiles(outputPaths, tempfolder);
|
||||
}
|
||||
}
|
||||
Logger.Out("Dokument für Jahr " + years.Item1.ToString());
|
||||
var outputPaths = new List<(int, string)>();
|
||||
var letterList = Lib2List(lib, years.Item1);
|
||||
if (letterList.Any())
|
||||
{
|
||||
foreach (var letter in letterList.OrderBy(x => x.Meta.Sort).ThenBy(x => x.Meta.Order))
|
||||
{
|
||||
letter.WordDoc = CreateLetterDocx(letter.OutPutFile);
|
||||
StyleLetterDocx(letter);
|
||||
Letter2Docx(letter);
|
||||
outputPaths.Add((Int32.Parse(letter.Index), letter.OutPutFile));
|
||||
letter.WordDoc.Dispose();
|
||||
}
|
||||
MergeDocx(lib, years.Item1.ToString(), outputPaths, MakeVolumeDoc(years.Item1.ToString()), Editionsrichtlinien);
|
||||
}
|
||||
Parallel.ForEach(letterList, letter => {
|
||||
Logger.Out("Nachbearbeitung Brief " + letter.Autopsic);
|
||||
letter.WordDoc = WordprocessingDocument.Open(letter.OutPutFile, true);
|
||||
MakeSourceSection(letter);
|
||||
letter.WordDoc.Dispose();
|
||||
});
|
||||
|
||||
private static void MakeLetter(LetterObj letter)
|
||||
{
|
||||
letter.WordDoc = CreateLetterDocx(letter.OutPutFile);
|
||||
Logger.Out(letter.OutPutFile);
|
||||
if (letter.WordDoc == null)
|
||||
{
|
||||
Logger.Out(letter.Autopsic + "\n hat kein worddoc!");
|
||||
}
|
||||
StyleLetterDocx(letter);
|
||||
Letter2Docx(letter, false);
|
||||
letter.WordDoc.Save();
|
||||
letter.WordDoc.Close();
|
||||
}
|
||||
sw.Stop();
|
||||
var ts = sw.Elapsed;
|
||||
var elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
|
||||
ts.Hours, ts.Minutes, ts.Seconds,
|
||||
ts.Milliseconds / 10);
|
||||
Logger.Out("ELAPSED: " + elapsedTime);
|
||||
}
|
||||
|
||||
public static void StyleLetterDocx(LetterObj letter)
|
||||
@@ -1117,7 +1073,7 @@ namespace HamannPrinter
|
||||
return letterList;
|
||||
}
|
||||
|
||||
public static List<LetterObj> Lib2List(ILibrary library, int year, string tempDir)
|
||||
public static List<LetterObj> Lib2List(ILibrary library, int year)
|
||||
{
|
||||
/*Da die Erstellung von Volume.docx dateien über das Erstellen und mergen von Einzelbriefdokumenten funtkioniert,
|
||||
* ist diese Überladung von Lib2List nötig.
|
||||
@@ -1126,9 +1082,10 @@ namespace HamannPrinter
|
||||
List<LetterObj> letterList = new List<LetterObj>();
|
||||
foreach (var letter in library.Letters.Where(x => library.Metas[x.Key].ZH != null && library.Metas[x.Key].Sort.Year == year))
|
||||
{
|
||||
var letterObj = CreateLetterObj(letter, library, tempDir);
|
||||
var letterObj = CreateLetterObj(letter, library);
|
||||
letterList.Add(letterObj);
|
||||
}
|
||||
|
||||
return letterList;
|
||||
}
|
||||
|
||||
@@ -1816,7 +1773,7 @@ namespace HamannPrinter
|
||||
props.SectionProperties.AppendChild(new Columns() { ColumnCount = 2, Space = ColumnDistance, EqualWidth = true });
|
||||
}
|
||||
props.SectionProperties.AppendChild<SectionType>(new SectionType() { Val = SectionMarkValues.Continuous });
|
||||
PageMargin pageMargin = new PageMargin() { Top = MarginTop, Right = MarginRight, Bottom = MarginBottom, Left = MarginLeft, Footer = MarginFooter };
|
||||
PageMargin pageMargin = new PageMargin() { Top = MarginTop, Right = MarginRightColumns, Bottom = MarginBottom, Left = MarginLeft, Footer = MarginFooter };
|
||||
props.SectionProperties.PrependChild(pageMargin);
|
||||
}
|
||||
|
||||
@@ -2573,25 +2530,25 @@ namespace HamannPrinter
|
||||
|
||||
XElement xLine = GetLineXisIn(hand);
|
||||
firstPage = GetPageXisOn(xLine, letter);
|
||||
if (!xLine.Attributes("autopsic").Any() || xLine.Attributes("fn").Any())
|
||||
if (!xLine.Attributes("index").Any() || xLine.Attributes("fn").Any())
|
||||
{
|
||||
firstLine = isFN;
|
||||
}
|
||||
else
|
||||
{
|
||||
firstLine = xLine.Attribute("autopsic").Value;
|
||||
firstLine = xLine.Attribute("index").Value;
|
||||
}
|
||||
|
||||
var lastXPage = hand.Descendants().Where(x => !((x as XNode) is XText) && x?.Name?.LocalName == "page").LastOrDefault();
|
||||
if (lastXPage != null)
|
||||
{
|
||||
lastPage = lastXPage.Attribute("autopsic").Value;
|
||||
lastPage = lastXPage.Attribute("index").Value;
|
||||
}
|
||||
|
||||
var lastXLine = hand.Descendants().Where(x => !((x as XNode) is XText) && x?.Name?.LocalName == "line").LastOrDefault();
|
||||
if (lastXLine != null && firstLine != isFN)
|
||||
{
|
||||
lastLine = lastXLine.Attribute("autopsic").Value;
|
||||
lastLine = lastXLine.Attribute("index").Value;
|
||||
}
|
||||
|
||||
if (lastPage != "")
|
||||
|
||||
@@ -8,6 +8,8 @@ using System.Text.RegularExpressions;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using HaDocument.Interfaces;
|
||||
using HaDocument.Models;
|
||||
using static HamannPrinter.Hamann2Word;
|
||||
using static HamannPrinter.Parser;
|
||||
using Comment = HaDocument.Models.Comment;
|
||||
@@ -19,10 +21,10 @@ namespace HamannPrinter
|
||||
|
||||
public static void Warn(string message)
|
||||
{
|
||||
MessageBox.Show(message,
|
||||
"Confirmation",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Exclamation);
|
||||
MessageBox.Show(message,
|
||||
"Confirmation",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Exclamation);
|
||||
}
|
||||
|
||||
public static void Ok(string message)
|
||||
@@ -155,11 +157,13 @@ namespace HamannPrinter
|
||||
return "VII";
|
||||
default:
|
||||
var number = 0;
|
||||
if (!Int32.TryParse(index, out number)) {
|
||||
if (!Int32.TryParse(index, out number))
|
||||
{
|
||||
Logger.Out("Kann BandZahl " + index + "nicht in römische Zahl auflösen.");
|
||||
return "?";
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return ToRoman(number);
|
||||
}
|
||||
}
|
||||
@@ -398,7 +402,7 @@ namespace HamannPrinter
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckLineTag(XElement xelem, WordprocessingDocument wordDoc)
|
||||
public static void CheckLineTag(XElement xelem, WordprocessingDocument wordDoc, LetterObj letter)
|
||||
{
|
||||
|
||||
bool isFootNote = false;
|
||||
@@ -409,7 +413,8 @@ namespace HamannPrinter
|
||||
isFootNote = true;
|
||||
}
|
||||
|
||||
if (xelem.Attribute("index") != null)
|
||||
|
||||
if (xelem.Attribute("index") != null && !letter.stateFirstLine)
|
||||
{
|
||||
//coutable: Zeile ist eine der zu zählenden 5er Zeilen
|
||||
bool isCountable = CheckIndex(xelem);
|
||||
@@ -437,6 +442,19 @@ namespace HamannPrinter
|
||||
newOne = lastParagraph.InsertAfterSelf<Paragraph>(new Paragraph());
|
||||
}
|
||||
}
|
||||
else if (xelem.Attribute("index") != null && letter.stateFirstLine)
|
||||
{
|
||||
Paragraph counterParagraph = new Paragraph();
|
||||
Run run = new Run(new Text("S. " + letter.Meta.ZH.Page + ", " + xelem.Attribute("index").Value));
|
||||
counterParagraph.AppendChild<Run>(run);
|
||||
SmallFont(run);
|
||||
ApplyParaStyle(counterParagraph, "zeilenzählung");
|
||||
Paragraph lastParagraph = GetLastPara(wordDoc);
|
||||
lastParagraph.InsertAfterSelf<Paragraph>(counterParagraph);
|
||||
FrameCounterParagraph(counterParagraph);
|
||||
letter.stateFirstLine = false;
|
||||
newOne = counterParagraph.InsertAfterSelf<Paragraph>(new Paragraph());
|
||||
}
|
||||
else
|
||||
{
|
||||
Paragraph lastParagraph = GetLastPara(wordDoc);
|
||||
@@ -564,9 +582,9 @@ namespace HamannPrinter
|
||||
{
|
||||
//erstellt Textboxen für die Seitenzählung
|
||||
string pagenumber = "";
|
||||
if (xelem.Attributes("autopsic").Any())
|
||||
pagenumber = xelem.Attribute("autopsic").Value.ToString();
|
||||
else if (xelem.Attributes("index").Any())
|
||||
if (xelem.Attributes("index").Any())
|
||||
pagenumber = xelem.Attribute("index").Value.ToString();
|
||||
else if (xelem.Attributes("autopsic").Any())
|
||||
pagenumber = xelem.Attribute("index").Value.ToString();
|
||||
Paragraph counterParagraph = new Paragraph();
|
||||
ApplyParaStyle(counterParagraph, "seitenzählung");
|
||||
@@ -582,7 +600,7 @@ namespace HamannPrinter
|
||||
public static Paragraph IfLine5(WordprocessingDocument wordDoc, XElement xelem, int numbr)
|
||||
{
|
||||
Paragraph counterParagraph = new Paragraph();
|
||||
Run run = new Run(new Text(xelem.Attribute("autopsic").Value));
|
||||
Run run = new Run(new Text(xelem.Attribute("index").Value));
|
||||
counterParagraph.AppendChild<Run>(run);
|
||||
SmallFont(run);
|
||||
ApplyParaStyle(counterParagraph, "zeilenzählung");
|
||||
@@ -758,7 +776,7 @@ namespace HamannPrinter
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Out("Diese URL ist im Eimer: " + url+ "\nObwohl ich sie lösche mag Word das Dokument danach nicht öffnen! Diese URL also bitte im XML korrigieren! \n"+exception.Message);
|
||||
Logger.Out("Diese URL ist im Eimer: " + url + "\nObwohl ich sie lösche mag Word das Dokument danach nicht öffnen! Diese URL also bitte im XML korrigieren! \n" + exception.Message);
|
||||
link.Remove();
|
||||
}
|
||||
}
|
||||
@@ -787,13 +805,13 @@ namespace HamannPrinter
|
||||
return tempFolder;
|
||||
}
|
||||
|
||||
public static void RemoveTempFolderFiles(Dictionary<int, string> outputPaths, string tempfolder)
|
||||
public static void RemoveTempFolderFiles(List<(int, string)> outputPaths, string tempfolder)
|
||||
{
|
||||
foreach (var path in outputPaths.Where(x => x.Key != 0 && x.Key != 1000000000))
|
||||
foreach (var path in outputPaths)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(path.Value);
|
||||
File.Delete(path.Item2);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -811,31 +829,43 @@ namespace HamannPrinter
|
||||
}
|
||||
}
|
||||
|
||||
public static void MergeDocx(string year, Dictionary<int, string> outputPaths)
|
||||
public static void MergeDocx(ILibrary lib, string year, List<(int, string)> outputPaths, string basepath, string additions)
|
||||
{
|
||||
/*verbindet die einzelnen temporären ZH Briefdateien zu einer Banddatei
|
||||
die dauerhaften Brief.docx dateien können nicht gemergt werden, da sie die
|
||||
für Bände überflüssige source section am ende enthalten und alt chunks nicht
|
||||
verändert werden können*/
|
||||
Logger.Out("erstelle Jahr " + year);
|
||||
var OrderedPathKeys = outputPaths.Keys.ToList();
|
||||
OrderedPathKeys.Sort((a, b) => -1 * a.CompareTo(b));
|
||||
foreach (var key in OrderedPathKeys.Where(k => k != 0))
|
||||
using (WordprocessingDocument doc = WordprocessingDocument.Open(basepath, true))
|
||||
{
|
||||
using (WordprocessingDocument doc = WordprocessingDocument.Open(@outputPaths[0], true))
|
||||
MainDocumentPart mainPart = doc.MainDocumentPart;
|
||||
AltChunk altChunk = null;
|
||||
var altChunkId = "AltChunkId" + "1000000000";
|
||||
var chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.WordprocessingML, altChunkId);
|
||||
using (FileStream fileStream = File.Open(additions, FileMode.Open))
|
||||
{
|
||||
MainDocumentPart mainPart = doc.MainDocumentPart;
|
||||
string altChunkId = "AltChunkId" + key;
|
||||
AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.WordprocessingML, altChunkId);
|
||||
using (FileStream fileStream = File.Open(@outputPaths[key], FileMode.Open))
|
||||
chunk.FeedData(fileStream);
|
||||
}
|
||||
altChunk = new AltChunk();
|
||||
altChunk.Id = altChunkId;
|
||||
mainPart.Document.Body.InsertAfter(altChunk, GetLastPara(doc));
|
||||
mainPart.Document.Save();
|
||||
|
||||
|
||||
outputPaths.Reverse();
|
||||
foreach (var (key, value) in outputPaths)
|
||||
{
|
||||
altChunkId = "AltChunkId" + key;
|
||||
chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.WordprocessingML, altChunkId);
|
||||
using (FileStream fileStream = File.Open(value, FileMode.Open))
|
||||
{
|
||||
chunk.FeedData(fileStream);
|
||||
}
|
||||
AltChunk altChunk = new AltChunk();
|
||||
altChunk = new AltChunk();
|
||||
altChunk.Id = altChunkId;
|
||||
mainPart.Document.Body.InsertAfter(altChunk, GetLastPara(doc));
|
||||
mainPart.Document.Save();
|
||||
doc.Close();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,29 +5,27 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:HamannPrinter"
|
||||
mc:Ignorable="d"
|
||||
Title="HamannPrinter" Height="450" Width="800" WindowStartupLocation="CenterOwner" WindowState="Minimized">
|
||||
Title="HamannPrinter" Height="227" Width="684" WindowStartupLocation="CenterOwner" WindowState="Minimized">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="377*"/>
|
||||
<ColumnDefinition Width="423*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.ColumnSpan="2">
|
||||
<CheckBox x:Name="LetterDocs" Content="Brief.docx erzeugen" HorizontalAlignment="Left" Margin="40,34,0,0" VerticalAlignment="Top" Checked="SingleDocChanged" Unchecked="SingleDocChanged" IsChecked="True"/>
|
||||
<CheckBox x:Name="VolumeDocs" Content="Jahr.docx erzeugen" HorizontalAlignment="Left" Margin="40,59,0,0" VerticalAlignment="Top" Checked="VolDocChanged" Unchecked="VolDocChanged" IsChecked="True"/>
|
||||
<CheckBox x:Name="RegisterDocs" Content="Kommentar.docx erzeugen" HorizontalAlignment="Left" Margin="40,84,0,0" VerticalAlignment="Top" Unchecked="CommDocChanged" Checked="CommDocChanged" IsChecked="True"/>
|
||||
<Label Content="Jahre" HorizontalAlignment="Left" Margin="40,133,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Left"/>
|
||||
<Label Content="Verzeichnis mit Hamann-XML-Teildateien:" HorizontalAlignment="Left" Margin="320,133,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="XmlFileBox" HorizontalAlignment="Left" Margin="320,158,0,0" Text="" TextWrapping="NoWrap" VerticalAlignment="Top" Width="342" Grid.ColumnSpan="2"/>
|
||||
<Button x:Name="XmlFileButton" Content="suchen" Grid.Column="1" HorizontalAlignment="Left" Margin="680,158,0,0" VerticalAlignment="Top" Click="XmlFileButton_Click"/>
|
||||
<Label Content="Ausgabeverzeichnis:" HorizontalAlignment="Left" Margin="320,183,0,0" VerticalAlignment="Top" Width="136"/>
|
||||
<TextBox x:Name="OutputDirBox" HorizontalAlignment="Left" Margin="320,208,0,0" Text="" TextWrapping="NoWrap" VerticalAlignment="Top" Width="342"/>
|
||||
<Button x:Name="OutputDirButton" Content="suchen" Grid.Column="1" HorizontalAlignment="Left" Margin="680,208,20,0" VerticalAlignment="Top" Click="OutputDirButton_Click"/>
|
||||
<Button Content="Dokumente erzeugen" HorizontalAlignment="Left" Margin="603,0,0,45" VerticalAlignment="Bottom" Click="Button_Click"/>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="321,304,0,0" Text="Achtung! Auf keinen Fall sollte man während des Erstellens von PDF-Dateien Word öffnen oder geöffnet haben!" TextWrapping="Wrap" VerticalAlignment="Top" Width="364"/>
|
||||
<TextBox x:Name="StartYearTextBox" HorizontalAlignment="Left" Margin="102,158,0,0" Text="1751" TextWrapping="Wrap" VerticalAlignment="Top" Width="56" RenderTransformOrigin="0.474,0.709" TextInput="TextBox_TextInput"/>
|
||||
<TextBox x:Name="EndYearTextBox" HorizontalAlignment="Left" Margin="102,181,0,0" Text="1788" TextWrapping="Wrap" VerticalAlignment="Top" Width="56" RenderTransformOrigin="0.474,0.709" MaxLength="6" TextInput="EndYearTextBox_TextInput"/>
|
||||
<Label Content="und" HorizontalAlignment="Left" Margin="40,177,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Left"/>
|
||||
<Label Content="zwischen" HorizontalAlignment="Left" Margin="40,155,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Left" RenderTransformOrigin="0.418,1.293"/>
|
||||
<CheckBox x:Name="VolumeDocs" Content="Docx für Briefe und Jahre erzeugen" HorizontalAlignment="Left" Margin="40,27,0,0" VerticalAlignment="Top" Checked="VolDocChanged" Unchecked="VolDocChanged" IsChecked="True"/>
|
||||
<CheckBox x:Name="RegisterDocs" Content="Docx für Kommentare erzeugen" HorizontalAlignment="Left" Margin="40,52,0,0" VerticalAlignment="Top" Unchecked="CommDocChanged" Checked="CommDocChanged" IsChecked="True"/>
|
||||
<Label Content="Jahre" HorizontalAlignment="Left" Margin="44,80,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Left"/>
|
||||
<Label Content="Verzeichnis mit Hamann-XML-Teildateien:" HorizontalAlignment="Left" Margin="267,20,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="XmlFileBox" HorizontalAlignment="Left" Margin="267,45,0,0" Text="" TextWrapping="NoWrap" VerticalAlignment="Top" Width="342"/>
|
||||
<Button x:Name="XmlFileButton" Content="suchen" HorizontalAlignment="Left" Margin="627,45,0,0" VerticalAlignment="Top" Click="XmlFileButton_Click"/>
|
||||
<Label Content="Ausgabeverzeichnis:" HorizontalAlignment="Left" Margin="267,70,0,0" VerticalAlignment="Top" Width="136"/>
|
||||
<TextBox x:Name="OutputDirBox" HorizontalAlignment="Left" Margin="267,95,0,0" Text="" TextWrapping="NoWrap" VerticalAlignment="Top" Width="342"/>
|
||||
<Button x:Name="OutputDirButton" Content="suchen" HorizontalAlignment="Left" Margin="627,95,0,0" VerticalAlignment="Top" Click="OutputDirButton_Click"/>
|
||||
<Button Content="Dokumente erzeugen" HorizontalAlignment="Left" Margin="550,0,0,19" VerticalAlignment="Bottom" Click="Button_Click"/>
|
||||
<TextBox x:Name="StartYearTextBox" HorizontalAlignment="Left" Margin="106,105,0,0" Text="1751" TextWrapping="Wrap" VerticalAlignment="Top" Width="56" RenderTransformOrigin="0.474,0.709" TextInput="TextBox_TextInput"/>
|
||||
<TextBox x:Name="EndYearTextBox" HorizontalAlignment="Left" Margin="106,128,0,0" Text="1788" TextWrapping="Wrap" VerticalAlignment="Top" Width="56" RenderTransformOrigin="0.474,0.709" MaxLength="6" TextInput="EndYearTextBox_TextInput"/>
|
||||
<Label Content="und" HorizontalAlignment="Left" Margin="44,124,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Left"/>
|
||||
<Label Content="zwischen" HorizontalAlignment="Left" Margin="44,102,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Left" RenderTransformOrigin="0.418,1.293"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace HamannPrinter
|
||||
RegisterDocs.IsChecked = false;
|
||||
VolumeDocs.IsChecked = true;
|
||||
StartYearTextBox.Text = "1751";
|
||||
EndYearTextBox.Text = "1764";
|
||||
EndYearTextBox.Text = "1788"; // DEV
|
||||
XmlFileBox.Text = @"D:\dev\source\hamann-ausgabe-core\XML\XML"; // DEV
|
||||
OutputDirBox.Text = @"D:\dev\source\hamann-ausgabe-core\XML\Ausg"; // DEV
|
||||
Act(); // DEV
|
||||
@@ -108,7 +108,7 @@ namespace HamannPrinter
|
||||
|
||||
private bool CheckInput()
|
||||
{
|
||||
if (LetterDocs.IsChecked == true || VolumeDocs.IsChecked == true)
|
||||
if (VolumeDocs.IsChecked == true)
|
||||
{
|
||||
if (GetYears().Item1 <= GetYears().Item2)
|
||||
{
|
||||
@@ -179,7 +179,6 @@ namespace HamannPrinter
|
||||
var confix = new Confix()
|
||||
{
|
||||
Editionsrichtlinien = CheckForEditionsRichtlinien(),
|
||||
LettersDocx = LetterDocs.IsChecked,
|
||||
VolumeDocx = VolumeDocs.IsChecked,
|
||||
RegisterDocx = RegisterDocs.IsChecked,
|
||||
HamannXmlPath = GetHAMANNxml(),
|
||||
|
||||
@@ -39,11 +39,12 @@ namespace HamannPrinter
|
||||
public string SmallFontSize { get; set; } = "12";
|
||||
public string BigFontSize { get; set; } = "32";
|
||||
public int MarginTop { get; set; } = 1416;
|
||||
public UInt32 MarginRight { get; set; } = 2600U;
|
||||
public UInt32 MarginRight { get; set; } = 2400U;
|
||||
public int MarginBottom { get; set; } = 2132;
|
||||
public UInt32 MarginLeft { get; set; } = 1984U;
|
||||
public UInt32 MarginFooter { get; set; } = 1417U;
|
||||
public string ColumnDistance { get; set; } = "560";
|
||||
public UInt32 MarginRightColumns { get; set; } = 1900U;
|
||||
public string FooterToText { get; set; } = "420";
|
||||
public string NormalFont { get; set; } = "Linux Libertine G";
|
||||
public string SpecialFont { get; set; } = "Linux Biolinum";
|
||||
@@ -77,7 +78,7 @@ namespace HamannPrinter
|
||||
var hamannDoc = Document.Create(new Options(confix.HamannXmlPath));
|
||||
DocOptions docOpt = new DocOptions(confix.Years, confix.OutputPath, confix.Editionsrichtlinien);
|
||||
CheckXML(confix, docOpt, hamannDoc);
|
||||
Coordinator(docOpt, hamannDoc, hamannDoc, docOpt.Years, confix.LettersDocx, confix.VolumeDocx, confix.RegisterDocx);
|
||||
Coordinator(docOpt, hamannDoc, hamannDoc, docOpt.Years, confix.VolumeDocx, confix.RegisterDocx);
|
||||
// DEV Helper.Ok("Fertig!");
|
||||
Environment.Exit(0);
|
||||
}
|
||||
@@ -306,17 +307,12 @@ namespace HamannPrinter
|
||||
System.IO.File.WriteAllText(docOpt.OutputDir + "errors.txt", errors.ToString());
|
||||
}
|
||||
|
||||
public void Coordinator(DocOptions docOpt, ILibrary hamannDoc, ILibrary lib, (int, int) years, bool? letterDocs, bool? volDocs, bool? registerDocs)
|
||||
public void Coordinator(DocOptions docOpt, ILibrary hamannDoc, ILibrary lib, (int, int) years, bool? volDocs, bool? registerDocs)
|
||||
{
|
||||
/* koordiniert das Erstellen der einzelnen Dokumenttypen/-sorten*/
|
||||
//try
|
||||
//{
|
||||
var h2w = new Hamann2Word(hamannDoc, docOpt);
|
||||
if (letterDocs == true || letterDocs == false) // DEV
|
||||
{
|
||||
Logger.Out("Erstelle docx für einzelbriefe");
|
||||
h2w.MakeLetterDocuments(lib, years);
|
||||
}
|
||||
if (volDocs == true)
|
||||
{
|
||||
Logger.Out("Erstelle docx für BandDateien");
|
||||
|
||||
Reference in New Issue
Block a user