public class WriteOdt extends TranslateOdtCommon
| Modifier and Type | Class and Description |
|---|---|
private static class |
WriteOdt.Cfg |
static class |
WriteOdt.CmdArgs |
static class |
WriteOdt.DirPrepareJavadoc |
TranslateOdtCommon.CommonArgs| Modifier and Type | Field and Description |
|---|---|
(package private) WriteOdt.CmdArgs |
args |
(package private) boolean |
bColumnBreakBefore
True then a "'''" was seen before.
|
(package private) boolean |
bInsideCode |
(package private) boolean |
bInsideColumn2 |
(package private) boolean |
bInsideListItem
true then a <text:list-item...
|
(package private) boolean |
bPage2Start |
(package private) boolean |
bPageBreakBefore
True then a "'''" was seen before.
|
(package private) boolean |
bParagrFirstline
true only immediately after set <text:p ...>
|
(package private) boolean |
bSetNrChapter
Set
nrChapter from ZmL should only done one time,
then this flag should be set to false. |
(package private) WriteOdt.Cfg |
cfg |
(package private) java.util.Map<java.lang.String,ReadOdt.LabelRef> |
idxChnrExternRef
Same content as
idxLabelExternRef but sorted to document and chapter number
to write out writeExternReferences(). |
(package private) java.util.Map<java.lang.String,ReadOdt.LabelRef> |
idxLabelExternRef
Index of all book marks of related docu suite (adequate option -labels:*.Labels.text)
filled from this files.
|
(package private) java.util.Map<java.lang.String,java.lang.String> |
idxLabelIntern |
private java.lang.String |
lastAnchorReplaced
The last anchor which is replaced for operation arguments.
|
(package private) int |
nList
>=1 then the deepness of nesting list nodes.
|
(package private) int[] |
nrChapter |
(package private) int |
nrFrameImgName |
(package private) int |
nrSectionName |
(package private) int |
nrTableName |
(package private) int |
nSection
>=1 then the deepness of nesting section nodes.
|
(package private) java.io.BufferedReader |
rZmL |
(package private) java.lang.StringBuilder |
sbo |
(package private) static java.lang.String[] |
sCheckTextReplZmL
Builds the search Strings for replacing from ZmL to character in
sTextReplace [0]. |
(package private) java.lang.String |
sCodeStyle
If set (not null) then the next lines till "----" should be written as <text:p...
|
(package private) java.lang.String |
sInclude
If !=null then this is the label after '__PART_...' to include another file.
|
(package private) java.lang.String |
sLineNext
Last read line from aDoc.
|
private static java.lang.String[] |
specificLineStarts |
(package private) java.lang.String |
sRefBookmark
It is set if a ref to bookmark was created.
|
(package private) java.lang.String |
sStyleParagr
If not null then a
[.style] was read. |
(package private) java.util.Stack<java.io.BufferedReader> |
stack_rAdoc |
(package private) static java.lang.String[][] |
sTextCtrlCommon |
(package private) static java.lang.String[] |
sTextCtrlCommonSearchAsciidoc
Contains the Strings to search in Markup source to replace with function or style..
|
(package private) static java.lang.String[] |
sTextCtrlCommonSearchMu
Contains the Strings to search in Markup source to replace with function or style..
|
(package private) static java.lang.String[][] |
sTextReplace
Replacement of special characters.
|
(package private) static java.lang.String[][] |
sTextReplaceAsciidoc
This Strings are replaced from Asciidoc to LibreOffice.
|
(package private) static java.lang.String |
sTextReplaceChars
Single characters to replace with
sTextReplace proper for StringFunctions# |
(package private) static java.lang.String[] |
sWwwLink |
(package private) java.lang.String |
sXXXLabel
Stores a [#label] for the next header or paragraph.
|
static java.lang.String |
version
Version, history and license.
|
private java.io.Writer |
wrRep |
(package private) org.vishia.xmlReader.XmlCfg |
xmlCfgOdt |
(package private) org.vishia.xmlSimple.XmlSequWriter |
xmlWr |
javadocLabel, log| Modifier | Constructor and Description |
|---|---|
protected |
WriteOdt(WriteOdt.CmdArgs args)
Note: close of LogMessageStream as in
amain(CmdArgs) where this instance is constructed. |
| Modifier and Type | Method and Description |
|---|---|
static int |
amain(WriteOdt.CmdArgs args)
main for this class, with given prepared arguments
Does not catch unexpected exceptions and does not System.exit(...), use it to execute in a Java environment.
|
private java.io.File |
checkAndChangeFileImage(java.lang.String[] sLinkUse,
java.io.File dirOdt,
java.lang.String sLink,
java.lang.String sTitle) |
private static boolean |
checkIndentation(int nrIndent,
int nrofSpacesIndent,
int posTag,
java.lang.String sLine)
Checks whether the line has the requested indentation, in cohesion with searching a tag.
|
private java.lang.String |
checkParseCommentLine(java.lang.String line) |
private java.lang.String |
checkReplaceLinkOperationLabel(java.lang.String sRef) |
void |
execute() |
private void |
finitList(int nList) |
private void |
finitSection(int toLevel) |
private void |
includeSrcCode(java.lang.String sLineInclArg,
java.lang.String sCodeStyle)
Includes lines from a source file.
|
private boolean |
isEmptyLine(java.lang.String line,
int fromPos) |
static void |
main(java.lang.String[] sArgs)
main for WriteOdt, invoked from cmd line.
|
protected java.lang.String |
parseAdocLine(java.lang.String line)
Parse a new line for paragraph etc, not the continued lines from a paragraph.
|
private java.lang.String |
parseAdocM(java.lang.String line)
Parse a new line for paragraph etc, not the continued lines from a paragraph.
|
private java.lang.String |
parseImage(java.lang.String args,
boolean bOnlyImage)
Writes an image with given arguments from the text <:image:....>
|
private java.lang.String |
parseList(java.lang.String line) |
private java.lang.String |
parseTableRow(java.lang.String line) |
private java.lang.String |
parseWriteCodeBlock(java.lang.String sStartLine)
Writes a block as code, write each line as extra <text:p....
|
private java.lang.String |
parseWriteParagr(java.lang.String line,
java.lang.String sLabel) |
private java.lang.String |
parseWriteParagrStyleLabel(java.lang.String line) |
private java.lang.String |
parseWriteSection(java.lang.String line) |
private java.lang.String |
parseWriteTable(java.lang.String line) |
private java.lang.String |
parseWriteText(java.lang.CharSequence clineArg,
boolean bIndentSpaces)
Analyzes the given line where interpretation are necessrary, and writes it with <:text:span...
|
void |
parseZmlWriteOdt() |
private java.lang.StringBuilder |
readAllTextLinesOfParagraph(java.lang.String sLineStart)
Reads all text lines till empty line or till specific such as "* " for a list.
|
private int |
readHeaderNr(java.lang.String line,
int zLine,
int pos0,
int nHeader)
Reads the number before the chapter title (header).
|
private void |
readLabelFile(java.io.File fLabel,
java.lang.String nameRefFile) |
private void |
readOwnLabels() |
private java.lang.CharSequence |
replaceBackslasSubscription(java.lang.CharSequence txtArg,
java.lang.StringBuilder sbTextArg,
boolean bReplaceToAscii,
boolean bRemoveSpace)
Replace the ZmL specific backslash subscription by the specific UTF16 character to save in odg.
|
void |
searchFirstHeaderLine()
This is called one time on start of the main file.
|
private void |
showArguments() |
static int |
smain(java.lang.String[] sArgs,
java.lang.Appendable logHelp,
java.lang.Appendable logError)
main gets the arguments as String,
but does not catch unexpected exceptions and does not System.exit(...), use it to execute in a Java environment.
|
private boolean |
switchToInclude(java.lang.String sFileArg)
Switches to the file to include due to Label '__PART_Name' or __PART_RD_Name'
|
private void |
writeChapterRef(java.lang.String refArg)
Writes a link to a chapter due to <@ref:Label:....>.
|
private void |
writeChapterRefExtern(java.lang.String sRefZmL,
ReadOdt.LabelRef labelRef)
Writes links to pdf and html www and local in the following form:
'>>docu.pdf[] >>1.2 Chapter page 23' Whereas: The first '>>' contains the pdf link to www, if given, else '>>' is not written. |
private void |
writeExternReferences()
Writes a list of external references with the labels.
|
private java.lang.String |
writeHeaderLine(java.lang.String lineArg) |
private void |
writeInternalRefPage(java.lang.String sRefArg)
Writes a page reference due to given <:@page:sRef.>
|
private boolean |
writeJavadocLink(java.lang.CharSequence textw,
java.lang.String styleChars)
Writes a link to a Javadoc/...html entry.
|
private void |
writeLink(java.lang.String sLink) |
private java.lang.String |
writeSectionEnd(java.lang.String line) |
private int |
writeSpaceSupplement(java.lang.CharSequence spaces) |
private void |
writeStyleSections() |
private java.lang.String |
writeTableOfContents(java.lang.String line) |
private java.lang.String |
writeText(java.lang.CharSequence txtArg,
boolean bNewline)
Writes the pure text to XML, whereby spaces are replaced by <text:s...>
and also \n and \t are replaced by elements <text:line-break/> and <text:tab/>
as necessary in LibreOffice
See also
#parseWriteText(String) |
private void |
wrRep(java.lang.CharSequence line) |
getLinkFileFromURL, getLinkNameFromURL, searchForReplacingLinkOperationLabel, writeBackupFilepublic static final java.lang.String version
searchFirstHeaderLine() now new, called only on the main file to detect the first line
which starts with "=" in ZmL. This should not done if parseZmlWriteOdt() is started again after an included file.
The cause was, that this has skipped the '<::pageBreak.>' line in the main file because continued with the next chapter content.
final WriteOdt.CmdArgs args
final WriteOdt.Cfg cfg
final org.vishia.xmlReader.XmlCfg xmlCfgOdt
java.io.BufferedReader rZmL
java.util.Stack<java.io.BufferedReader> stack_rAdoc
java.lang.String sLineNext
java.lang.String sStyleParagr
[.style] was read.
Valid for the next paragraph.boolean bParagrFirstline
int nSection
int nList
boolean bInsideListItem
boolean bPageBreakBefore
boolean bColumnBreakBefore
boolean bInsideColumn2
boolean bPage2Start
int nrSectionName
int nrTableName
int nrFrameImgName
boolean bSetNrChapter
nrChapter from ZmL should only done one time,
then this flag should be set to false.int[] nrChapter
java.util.Map<java.lang.String,java.lang.String> idxLabelIntern
java.util.Map<java.lang.String,ReadOdt.LabelRef> idxLabelExternRef
readLabelFile(File, String).
This index is used for writeChapterRef(String) and writeInternalRefPage(String)
to write the external link.java.util.Map<java.lang.String,ReadOdt.LabelRef> idxChnrExternRef
idxLabelExternRef but sorted to document and chapter number
to write out writeExternReferences().java.lang.String sCodeStyle
boolean bInsideCode
java.lang.String sRefBookmark
java.lang.String sXXXLabel
java.lang.String sInclude
final java.lang.StringBuilder sbo
private java.io.Writer wrRep
private java.lang.String lastAnchorReplaced
final org.vishia.xmlSimple.XmlSequWriter xmlWr
private static java.lang.String[] specificLineStarts
static java.lang.String[][] sTextReplace
static java.lang.String sTextReplaceChars
sTextReplace proper for StringFunctions#static java.lang.String[][] sTextReplaceAsciidoc
static java.lang.String[] sCheckTextReplZmL
sTextReplace [0].static java.lang.String[][] sTextCtrlCommon
static java.lang.String[] sTextCtrlCommonSearchMu
sTextCtrlCommon[...][0]static java.lang.String[] sTextCtrlCommonSearchAsciidoc
static java.lang.String[] sWwwLink
protected WriteOdt(WriteOdt.CmdArgs args)
amain(CmdArgs) where this instance is constructed.
This closes also a given TranslateOdtCommon.CommonArgs.fLog because of
call LogMessageStream(java.io.OutputStream, java.io.OutputStream, Appendable, Appendable, boolean, Charset)
with trut for argument closeOnClose.args - public static int amain(WriteOdt.CmdArgs args) throws java.io.IOException
args - prepared cmd line argumentsjava.io.IOExceptionjava.lang.Exception - if unexpected.public static int smain(java.lang.String[] sArgs,
java.lang.Appendable logHelp,
java.lang.Appendable logError)
throws java.io.IOException
sArgs - java.io.IOExceptionjava.lang.Exception - if unexpected.public static void main(java.lang.String[] sArgs)
sArgs - private void wrRep(java.lang.CharSequence line)
throws java.io.IOException
java.io.IOExceptionpublic void execute()
throws java.io.IOException
java.io.IOExceptionprivate void showArguments()
private boolean switchToInclude(java.lang.String sFileArg)
throws java.io.IOException
sFileArg - the line after the label '__PART_' or '__PART_RD_', start of file namejava.io.IOExceptionprivate void readOwnLabels()
throws java.io.IOException
java.io.IOExceptionprivate void readLabelFile(java.io.File fLabel,
java.lang.String nameRefFile)
private void writeStyleSections()
throws java.io.IOException
java.io.IOExceptionpublic void searchFirstHeaderLine()
throws java.io.IOException
java.io.IOExceptionpublic void parseZmlWriteOdt()
throws java.io.IOException
java.io.IOExceptionprotected java.lang.String parseAdocLine(java.lang.String line)
throws java.io.IOException
line - found linejava.io.IOExceptionprivate java.lang.String parseAdocM(java.lang.String line)
throws java.io.IOException
line - found linejava.io.IOExceptionprivate boolean isEmptyLine(java.lang.String line,
int fromPos)
private java.lang.String writeHeaderLine(java.lang.String lineArg)
throws java.io.IOException
java.io.IOExceptionprivate int readHeaderNr(java.lang.String line,
int zLine,
int pos0,
int nHeader)
bSetNrChapter is true, then the read number is written to nrChapter,
but with -1 subtracted because it will be incremented.
This is the numbering of the first chapter in this odt.
After detection the first chapter in first ZmL, bSetNrChapter is set to false.
Then, all other chapters are incremented and set back to 0 if a parent chapter is offered.line - the header line with '=== 2.3.4 Title' from ZmLzLine - line lengthpos0 - Position after '===' as startnHeader - The number of '===', nHeader ==0 for one '=', for the title.private java.lang.String checkParseCommentLine(java.lang.String line)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String parseWriteSection(java.lang.String line)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String writeSectionEnd(java.lang.String line)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String parseWriteParagrStyleLabel(java.lang.String line)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String parseWriteParagr(java.lang.String line,
java.lang.String sLabel)
throws java.io.IOException
line - This is only the start (first) line. All other lines will be read here
calling readAllTextLinesOfParagraph(String)sLabel - null or a label (bookmark) for this paragraph TODO not implemented yet.java.io.IOExceptionprivate java.lang.String parseList(java.lang.String line)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.StringBuilder readAllTextLinesOfParagraph(java.lang.String sLineStart)
throws java.io.IOException
sLineStart - The first line.sLineNext for using for the next paragraph, especially a list.java.io.IOExceptionprivate java.lang.String parseWriteText(java.lang.CharSequence clineArg,
boolean bIndentSpaces)
throws java.io.IOException
#writeText(String, boolean) outside interpreations stuff.
Which is regarded: see sTextCtrlCommon, #sTextCtrlItalicBold, #sTextCtrlStyleForItalicBold.
The WriteOdt.Cfg.useItalicBold decides whether __textInItalic__ etc. is outputted as indirect style italic
or as direct style "Quotation". Both is possible.line - java.io.IOExceptionprivate boolean writeJavadocLink(java.lang.CharSequence textw,
java.lang.String styleChars)
throws java.io.IOException
textw - the "Class" or "Class#element" itselfstyleChars - "cJ" as style definitionjava.io.IOExceptionprivate int writeSpaceSupplement(java.lang.CharSequence spaces)
throws java.io.IOException
java.io.IOExceptionprivate void writeChapterRef(java.lang.String refArg)
throws java.io.IOException
idxLabelExternRef idxChnrExternRefrefArg - java.io.IOExceptionprivate void writeChapterRefExtern(java.lang.String sRefZmL,
ReadOdt.LabelRef labelRef)
throws java.io.IOException
sRefZmL - reference as given in ZmL after '@ref:#' without leading '#'labelRef - java.io.IOExceptionprivate void writeInternalRefPage(java.lang.String sRefArg)
throws java.io.IOException
sRef - can be empty or only consist of a max 3-digit number,
then it is ignored, instead the reference use on last called writeChapterRef(String) is used here also.
This is sensible if the <:@page:.> follows after the <:@ref:sRef:Title.>.
If sRef is given, it can be used only for a page reference without reference text.java.io.IOExceptionprivate void writeLink(java.lang.String sLink)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String checkReplaceLinkOperationLabel(java.lang.String sRef)
private java.lang.String writeText(java.lang.CharSequence txtArg,
boolean bNewline)
throws java.io.IOException
#parseWriteText(String)txtArg - bNewline - java.io.IOExceptionprivate java.lang.CharSequence replaceBackslasSubscription(java.lang.CharSequence txtArg,
java.lang.StringBuilder sbTextArg,
boolean bReplaceToAscii,
boolean bRemoveSpace)
txtArg - If given use it. If it is a StringBuilder, use it already for return.sbTextArg - If given use it.private java.lang.String parseWriteCodeBlock(java.lang.String sStartLine)
throws java.io.IOException
#parseWriteText(String).
It means, also here character mark up (span) and character replacements
(#replaceBackslasSubscription(CharSequence, StringBuilder) are also done here.
#includeSrcCode(String).sStartLine - first line of code block, containing the <:Code....java.io.IOExceptionprivate void includeSrcCode(java.lang.String sLineInclArg,
java.lang.String sCodeStyle)
throws java.io.IOException
<::include:../path/to/src::TAG::44::4:marker,6:-,8:+,10:-.>Syntax in ZBNF:
includeCode::=\<::include:<*|::?PATH>::<*|::?TAG>
[::<#?LineWidth>][::-<*|::?removeComment>]
[{[+<?nextLine>]<#?LINE>[,<#?COLUMN>][:<*:\.?MARKER>?::}]:;.
It means:
../../path/to/source.c
Examples:
<::include:../path/to/source.c::startTAG::80.>
includes the lines from <::startTag> to <.startTag> with a line width of max 80 character.
<::include:../path/to/source.c::'code text'::80::16:-.>
includes from the line which contains "code text", 16 lines.
<::include:../path/to/source.c::startTAG::80.>
includes the lines from <::startTag> to <.startTag> with a line width of max 80 character.
<::include:../path/to/source.c::'code text'::80::16:-.>
includes from the line which contains "code text", 16 lines.
<::include:../path/to/source.c::'code text'::80::4:MARKER::16:-.>
as above, writes on end of line 4 "MARKER"
<::include:../path/to/source.c::'code text'::80::4:MARKER::7,25:M2::16:-.>
as above, writes in line 7 column 25 "M2"
sLineIncl - java.io.IOExceptionprivate static boolean checkIndentation(int nrIndent,
int nrofSpacesIndent,
int posTag,
java.lang.String sLine)
nrIndent - number of indentation levels requirednrofSpacesIndent - number of spaces presents one indentation levelposTag - sLine - private java.lang.String writeTableOfContents(java.lang.String line)
throws java.io.IOException
java.io.IOExceptionprivate void writeExternReferences()
throws java.io.IOException
java.io.IOExceptionprivate void finitList(int nList)
throws java.io.IOException
java.io.IOExceptionprivate void finitSection(int toLevel)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String parseWriteTable(java.lang.String line)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String parseTableRow(java.lang.String line)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String parseImage(java.lang.String args,
boolean bOnlyImage)
throws java.io.IOException
args - starts with the path to the image, contains all after "<:image:"bOnlyImage - true then the paragraph contains only the image.
Note in LibreOffice an image is always embedded in a paragraph.java.io.IOExceptionprivate java.io.File checkAndChangeFileImage(java.lang.String[] sLinkUse,
java.io.File dirOdt,
java.lang.String sLink,
java.lang.String sTitle)