public class ReadOdt extends TranslateOdtCommon
| Modifier and Type | Class and Description |
|---|---|
static class |
ReadOdt.CmdArgs |
private static class |
ReadOdt.GathWrText
Data for
gathWrText(XmlDataNode, char)
and its inner operation. |
(package private) static class |
ReadOdt.LabelRef |
TranslateOdtCommon.CommonArgs| Modifier and Type | Field and Description |
|---|---|
private boolean |
bInCodeBlock |
private boolean |
bInColumns |
private boolean |
bIsInclude
Flag that a included file is read.
|
private boolean |
bTitleFound
Set to true if the title is found in odt.
|
private ReadOdt.CmdArgs |
cmdArgs |
private int |
ctLabel
Counter for non found, automatic numbered labels.
|
(package private) java.lang.IllegalArgumentException |
excTOCnotUpdated
The output channel for markup and asciidoc
|
private java.util.Map<java.lang.String,java.lang.String> |
idxDirectOnlyStyle |
private java.util.Map<java.lang.String,StyleOdt> |
idxDirectToStyle |
private java.util.Map<java.lang.String,StyleImg> |
idxImgDirectToStyle |
private java.util.Map<java.lang.String,StyleOdt> |
idxIndirectStyle
This index is filled initially with a few styles which are expected,
especially TextPg and TextCol, because of
StyleOdt.pgBreakBefore etc. |
private java.util.Map<java.lang.String,ReadOdt.LabelRef> |
idxLabelRef
All found label references in Table of contents
with internal reference for header, VML-Label, title text and page.
|
private java.util.Map<java.lang.String,java.lang.String> |
idxShortToStyle |
private java.util.Map<java.lang.String,java.lang.String> |
idxStyleToShort |
private java.util.Map<java.lang.String,java.lang.String> |
idxUsedStyles |
private java.lang.String |
lastHlinkPathToReplaced
The last anchor which is replaced for operation arguments.
|
private java.lang.String |
lastXref |
private java.util.List<ReadOdt.LabelRef> |
listLabelRef |
private java.util.List<org.vishia.xmlReader.XmlDataNode> |
listNdTitle
Node text:h with the title of the document.
|
private org.vishia.xmlReader.XmlDataNode |
nodeDirectStyles |
private org.vishia.xmlReader.XmlDataNode |
nodeText |
private java.lang.StringBuilder |
sb
Buffer able to see in debug for buffered writer for markup and asciidoc.
|
private java.lang.StringBuilder |
sba
Buffer able to see in debug for buffered writer for markup and asciidoc.
|
(package private) static java.lang.String[][] |
sCheckReplace |
(package private) static java.lang.String |
sIndent |
(package private) static java.lang.String[] |
sNewlineCheck |
(package private) static java.lang.String[] |
sNewlineCheckBack
Used for search a separator position if
sNewlineCheck is not found. |
private java.lang.String |
sRefBookmark
Stores a found BOOKMARK in
|
private java.lang.String |
sRefChapter
Stores a found text in
to write it in <#label, text ....> |
private StyleOdt |
styleP |
static java.lang.String |
version
Version, history and license.
|
private java.io.Writer |
wr |
private java.io.Writer |
wra |
private java.io.Writer |
wrFrame |
private java.io.Writer |
wrRep |
private org.vishia.xmlReader.XmlCfg |
xmlCfgOdt |
javadocLabel, log| Constructor and Description |
|---|
ReadOdt(ReadOdt.CmdArgs cmdArgs)
Note: close of LogMessageStream is in
amain(CmdArgs) where this instance is constructed. |
| Modifier and Type | Method and Description |
|---|---|
static int |
amain(ReadOdt.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 boolean |
checkWrCrossRefPdf(ReadOdt.GathWrText thizi,
org.vishia.xmlReader.XmlDataNode node1,
java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterNodes)
This operation is called if a a:href with ">>>" as text is found.
|
private void |
defineIndirectStyles()
This operation defines the indirect styles which should be general known with its specific properties.
|
int |
execute() |
private void |
executeViewDiff()
Invokes the process in OS to show the Diff Tool adequate the option '-difftool:executable'
|
private void |
gatherAllBookmarksInHeader(org.vishia.xmlReader.XmlDataNode ndHead) |
private java.lang.String |
gatherAllHeading(org.vishia.xmlReader.XmlDataNode ndText) |
protected java.lang.String |
gatherContent(org.vishia.xmlReader.XmlDataNode nodeContent,
int deepnessSection) |
private java.lang.String |
gatherDirectStyles(org.vishia.xmlReader.XmlDataNode nodeDirectStyles)
Gather all direct styles in the document.
|
private void |
gathImageInFrame(org.vishia.xmlReader.XmlDataNode ndParagr,
org.vishia.xmlReader.XmlDataNode nodeFrame,
boolean bImgCaption) |
private void |
gathWrCodeInclude(org.vishia.xmlReader.XmlDataNode ndCaption,
java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterParentNodes) |
private java.lang.String |
gathWrFrameOrImage(org.vishia.xmlReader.XmlDataNode ndParagr,
org.vishia.xmlReader.XmlDataNode ndFrame,
java.lang.String styleFrameRaw,
boolean bCaption) |
private java.lang.String |
gathWrHeader(org.vishia.xmlReader.XmlDataNode ndHeader,
boolean bInInclude)
Writes a header as
|
private java.lang.String |
gathWrList(org.vishia.xmlReader.XmlDataNode nodeList) |
private java.lang.String |
gathWrListItem(org.vishia.xmlReader.XmlDataNode ndItem) |
private java.lang.String |
gathWrListItemOrNumbHeader(org.vishia.xmlReader.XmlDataNode nodeItem)
Gather an item in a list, not known what is it.
|
private java.lang.String |
gathWrParagraph(org.vishia.xmlReader.XmlDataNode node,
java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterParentNodes,
int indent,
java.lang.String[] stylesExpected)
Writes an paragraph from XML to VMU
It does not write a newline after the paragraph text because TODO
|
private java.lang.String |
gathWrTable(org.vishia.xmlReader.XmlDataNode ndTable) |
private java.lang.String |
gathWrTableOfContent(org.vishia.xmlReader.XmlDataNode node) |
private java.lang.String |
gathWrText(org.vishia.xmlReader.XmlDataNode nodeP,
char cSpanParagr)
This is all inside a paragraph.
|
private java.lang.String |
gathWrTextNode(ReadOdt.GathWrText thizi,
org.vishia.xmlReader.XmlDataNode node,
java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterNodes,
char cSpanParagr)
Inner operation for one text node.
|
private java.lang.String |
gathWrTextNodeLink(ReadOdt.GathWrText thizi,
org.vishia.xmlReader.XmlDataNode node1,
java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterNodes,
char cSpanParagr)
This is called for a <text:a>...
|
private java.lang.String |
gathWrXlink(org.vishia.xmlReader.XmlDataNode ndA,
java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterNodes,
boolean bwrm)
writes the appropriate ZmL for a <text:a> which is a hyperlink in odg.
|
private char |
gathWrXRef(org.vishia.xmlReader.XmlDataNode nodeXref)
Gathers a <text:bookmark-ref ...>, writes in Adoc as <<#label>>.
|
private int |
getAttribNumber(org.vishia.xmlReader.XmlDataNode node,
java.lang.String key,
int defaultNr) |
private StyleOdt |
getBaseStyle(java.lang.String styleNameArg,
char[] cStyleSpan)
With the given direct style name the based indirect style is gotten.
|
private int |
getNumber(java.lang.String sNr,
int defaultNr) |
private java.lang.String |
getTextXml(org.vishia.xmlReader.XmlDataNode nodep,
boolean bSubnodes)
Gets the text inside a node, also regarding <text:s...> and <text:t for spaces and tabs
And also searching in sub nodes.
|
private void |
getTextXml(org.vishia.xmlReader.XmlDataNode nodep,
java.lang.StringBuilder sbText,
boolean bSubnodes)
Inner operation for Get text from a text XML node from odt: content.xml with special handling
called from
getTextXml(XmlDataNode, boolean) and recursively from itself. |
static void |
main(java.lang.String[] sArgs)
main for UFBglConv, invoked from cmd line.
|
private void |
newLabelRef(java.util.List<java.lang.String> listBookmark,
java.lang.String sBookmarkTOC,
java.lang.String sBookmarkRef) |
java.lang.String |
readOdgxmlWriteZmL(org.vishia.xmlReader.XmlDataNode ndRootOdg)
This is the main routine after reading the whole XML file content.xml from odg.
|
private java.lang.String |
readXml(org.vishia.xmlReader.XmlDataNode data,
java.io.File fInOdt)
Reads completely the content.xml from the given odt file <::readXml.>
and stores the data in the data instance.
|
private static java.lang.CharSequence |
replaceToBackslashSubscription(java.lang.CharSequence textArg) |
private int |
searchLineBreak(boolean[] bInsideRef,
java.lang.StringBuilder sb1,
int posStart,
int posEndFocus,
int posEndTextSentence,
int posEndTextline)
Searches a possible text line break for a beautification shortened text write style.
|
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 void |
wrAdoc(java.lang.CharSequence text) |
private void |
wrBufferToFile(java.lang.StringBuilder sb1,
java.io.Writer wr1,
java.lang.String[] s2,
boolean bEnd)
Writes the buffer content to the file and supplements necessary line breaks for Asciidoc:
A line break is set always after a ".
|
private java.lang.String |
wrClose() |
private void |
writeAsciidocHead() |
private void |
writeLabelRef() |
private java.lang.String |
writeSpan(java.util.List<org.vishia.xmlReader.XmlDataNode> ndsSpan,
StyleOdt style)
span is for any text part with specific formatting.
|
private java.lang.String |
writeTitle()
The title should always be written as first.
|
private void |
writeZmlHead() |
private void |
wrm(java.lang.CharSequence text) |
private void |
wrRep(java.lang.CharSequence line) |
private void |
wrReplaceLastSpace(char cNew) |
private java.lang.String |
wrText(java.lang.String textArg)
Writes a given text from XML to ZmL.
|
private java.lang.String |
wrTextAdoc(java.lang.String textArg)
Writes a given text from XML to Asciidoc, but with detection of pass:[...] parts.
|
getLinkFileFromURL, getLinkNameFromURL, searchForReplacingLinkOperationLabel, writeBackupFilepublic static final java.lang.String version
gathWrHeader(XmlDataNode, boolean) now also writes the Linux shell script lines in included files.
private final ReadOdt.CmdArgs cmdArgs
private org.vishia.xmlReader.XmlCfg xmlCfgOdt
private java.util.Map<java.lang.String,StyleOdt> idxDirectToStyle
private java.util.Map<java.lang.String,StyleImg> idxImgDirectToStyle
private java.util.Map<java.lang.String,StyleOdt> idxIndirectStyle
StyleOdt.pgBreakBefore etc. known by knowledge.
The index is supplemented by found style names without direct style, which are just indirect styles.
The properties of the indirect styles are not known here, because the styles.xml is not evaluated.private java.util.Map<java.lang.String,java.lang.String> idxDirectOnlyStyle
private java.util.Map<java.lang.String,java.lang.String> idxUsedStyles
private java.util.Map<java.lang.String,java.lang.String> idxStyleToShort
private java.util.Map<java.lang.String,java.lang.String> idxShortToStyle
private java.util.Map<java.lang.String,ReadOdt.LabelRef> idxLabelRef
private java.util.List<ReadOdt.LabelRef> listLabelRef
private int ctLabel
private org.vishia.xmlReader.XmlDataNode nodeDirectStyles
private org.vishia.xmlReader.XmlDataNode nodeText
private java.util.List<org.vishia.xmlReader.XmlDataNode> listNdTitle
gatherAllHeading(XmlDataNode).private StyleOdt styleP
private java.lang.String sRefBookmark
to write it in <#label, text ....> to compare with the other refs.private java.lang.String sRefChapter
text
to write it in <#label, text ....>private boolean bIsInclude
writeLabelRef(), not for included files..private boolean bTitleFound
private boolean bInCodeBlock
private boolean bInColumns
private java.lang.String lastHlinkPathToReplaced
private java.lang.String lastXref
private java.lang.StringBuilder sb
private java.lang.StringBuilder sba
java.lang.IllegalArgumentException excTOCnotUpdated
private java.io.Writer wrFrame
private java.io.Writer wr
private java.io.Writer wra
private java.io.Writer wrRep
static java.lang.String sIndent
static final java.lang.String[] sNewlineCheck
static final java.lang.String[] sNewlineCheckBack
sNewlineCheck is not found.
Also used to search forward the next possible separator position after "<:@xxx.> further text.static java.lang.String[][] sCheckReplace
public ReadOdt(ReadOdt.CmdArgs cmdArgs) throws java.nio.charset.IllegalCharsetNameException, java.nio.charset.UnsupportedCharsetException
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. * @param cmdArgsjava.nio.charset.IllegalCharsetNameExceptionjava.nio.charset.UnsupportedCharsetExceptionpublic static int amain(ReadOdt.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 - public int execute()
throws java.io.IOException
java.io.IOExceptionprivate void showArguments()
private void executeViewDiff()
private void defineIndirectStyles()
private java.lang.String readXml(org.vishia.xmlReader.XmlDataNode data,
java.io.File fInOdt)
throws java.io.IOException
data - The root node for all XML datafInOdt - the odt file is a zip filejava.io.IOException - for file operationpublic java.lang.String readOdgxmlWriteZmL(org.vishia.xmlReader.XmlDataNode ndRootOdg)
throws java.io.IOException
ndRootOdg - the root node of the content.xmljava.io.IOExceptionprivate java.lang.String gatherDirectStyles(org.vishia.xmlReader.XmlDataNode nodeDirectStyles)
idxDirectOnlyStyle.
The transfer from a direct style to the (indirect) parent style is stored in idxDirectToStyle for non images
and idxImgDirectToStyle for images.nodeDirectStyles - The direct style node.private void writeAsciidocHead()
throws java.io.IOException
java.io.IOExceptionprivate void writeZmlHead()
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String gatherAllHeading(org.vishia.xmlReader.XmlDataNode ndText)
private void gatherAllBookmarksInHeader(org.vishia.xmlReader.XmlDataNode ndHead)
private void newLabelRef(java.util.List<java.lang.String> listBookmark,
java.lang.String sBookmarkTOC,
java.lang.String sBookmarkRef)
private java.lang.String writeTitle()
throws java.io.IOException
nodeContent - java.io.IOExceptionprotected java.lang.String gatherContent(org.vishia.xmlReader.XmlDataNode nodeContent,
int deepnessSection)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String gathWrHeader(org.vishia.xmlReader.XmlDataNode ndHeader,
boolean bInInclude)
throws java.io.IOException
''' [#label] ==== Chapter title
ndHeader - text:h or maybe text:p nodebInInclude - false for the main file, true if write a file.ZmL to include after '__PART_' label ??? if read first time, true if read recursively to write the same header without the '__PART_' label in the include file.java.io.IOExceptionprivate java.lang.String gathWrParagraph(org.vishia.xmlReader.XmlDataNode node,
java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterParentNodes,
int indent,
java.lang.String[] stylesExpected)
throws java.io.IOException
node - indent - stylesExpected - java.io.IOExceptionprivate void gathImageInFrame(org.vishia.xmlReader.XmlDataNode ndParagr,
org.vishia.xmlReader.XmlDataNode nodeFrame,
boolean bImgCaption)
throws java.io.IOException
java.io.IOExceptionprivate void gathWrCodeInclude(org.vishia.xmlReader.XmlDataNode ndCaption,
java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterParentNodes)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String gathWrText(org.vishia.xmlReader.XmlDataNode nodeP,
char cSpanParagr)
throws java.io.IOException
nodeP - cSpanParagr - If not 0 then the whole paragraph is marked with italic or bold, cStyleSpan is Q, E, S
Then it writes non span parts as such span.java.io.IOExceptionprivate java.lang.String gathWrTextNode(ReadOdt.GathWrText thizi, org.vishia.xmlReader.XmlDataNode node, java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterNodes, char cSpanParagr) throws java.io.IOException
ReadOdt.GathWrText.nodeLast it it is set in specific conditions.
That's why it is extracted to handle one node.
thizi - the data class. Note: If this operation is part of the data class,
then the access to ReadOdt instance data are more complex.
It is more simple and understandable to use this 'thizi' for specific data.node - The current node.cSpanParagr - java.io.IOExceptionprivate boolean checkWrCrossRefPdf(ReadOdt.GathWrText thizi, org.vishia.xmlReader.XmlDataNode node1, java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterNodes) throws java.io.IOException
thizi - node1 - iterNodes - java.io.IOExceptionprivate java.lang.String gathWrTextNodeLink(ReadOdt.GathWrText thizi, org.vishia.xmlReader.XmlDataNode node1, java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterNodes, char cSpanParagr) throws java.io.IOException
gathWrXlink(XmlDataNode, ListIterator, boolean).
WriteOdt#writeChapterRefExtern(String, LabelRef)thizi - node1 - cSpanParagr - java.io.IOExceptionprivate java.lang.String getTextXml(org.vishia.xmlReader.XmlDataNode nodep,
boolean bSubnodes)
getTextXml(XmlDataNode, StringBuilder, boolean) which does the work.
But if the node contains immediately text, this is returned.nodep - the given nodebSubnodes - true then get the text also from all sub nodes, usefully for <span...private void getTextXml(org.vishia.xmlReader.XmlDataNode nodep,
java.lang.StringBuilder sbText,
boolean bSubnodes)
getTextXml(XmlDataNode, boolean) and recursively from itself.nodep - The text containing XmlDataNode nodesbText - Here the text is added to, a StringBuilderbSubnodes - only on true read the text from sub nodes and insert it immediately.private java.lang.String writeSpan(java.util.List<org.vishia.xmlReader.XmlDataNode> ndsSpan,
StyleOdt style)
throws java.io.IOException
ndsSpan - all nodes for this span entrystyle - The common style of maybe more as one span regions one after another, only the base style.java.io.IOExceptionprivate java.lang.String gathWrList(org.vishia.xmlReader.XmlDataNode nodeList)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String gathWrListItemOrNumbHeader(org.vishia.xmlReader.XmlDataNode nodeItem)
throws java.io.IOException
nodeItem - java.io.IOExceptionprivate java.lang.String gathWrListItem(org.vishia.xmlReader.XmlDataNode ndItem)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String gathWrTable(org.vishia.xmlReader.XmlDataNode ndTable)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String gathWrTableOfContent(org.vishia.xmlReader.XmlDataNode node)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String gathWrFrameOrImage(org.vishia.xmlReader.XmlDataNode ndParagr,
org.vishia.xmlReader.XmlDataNode ndFrame,
java.lang.String styleFrameRaw,
boolean bCaption)
throws java.io.IOException
java.io.IOExceptionprivate java.lang.String gathWrXlink(org.vishia.xmlReader.XmlDataNode ndA,
java.util.ListIterator<org.vishia.xmlReader.XmlDataNode> iterNodes,
boolean bwrm)
throws java.io.IOException
ndA - iterNodes - java.io.IOExceptionprivate char gathWrXRef(org.vishia.xmlReader.XmlDataNode nodeXref)
throws java.io.IOException
nodeXref - java.io.IOExceptionprivate StyleOdt getBaseStyle(java.lang.String styleNameArg, char[] cStyleSpan)
idxIndirectStyle has the same properties for page break, column break ...
then only the indirect style is returned. Properties of the direct style are ignored.
But if the direct style as definitively properties which are important, then the direct style is returned.
The name of the direct style is completed with the specific properties,
and the returned direct style is stored in idxIndirectStyle as quasi indirect style.
It helps to save space if the same properties are given for another direct style (from view of LibreOffice internally)
but based on the same indirect style.styleNameArg - private int getNumber(java.lang.String sNr,
int defaultNr)
private int getAttribNumber(org.vishia.xmlReader.XmlDataNode node,
java.lang.String key,
int defaultNr)
private java.lang.String wrText(java.lang.String textArg)
throws java.io.IOException
WriteOdt.sTextReplace such as non-breaking spaces or the backslash
then the adequate transcription is used. This is in the same kind also in the WriteOdg direction.text - The text from XMLjava.io.IOExceptionprivate static java.lang.CharSequence replaceToBackslashSubscription(java.lang.CharSequence textArg)
private java.lang.String wrTextAdoc(java.lang.String textArg)
throws java.io.IOException
WriteOdt.sTextCtrlCommon
then either +text+ or pass:[text] is translated to Asciidoc
with the adequate text parts. This can/should be given in the same kind in the WriteOdg direction.text - The text from XMLjava.io.IOExceptionprivate void wrReplaceLastSpace(char cNew)
private void wrAdoc(java.lang.CharSequence text)
throws java.io.IOException
java.io.IOExceptionprivate void wrm(java.lang.CharSequence text)
throws java.io.IOException
java.io.IOExceptionprivate int searchLineBreak(boolean[] bInsideRef,
java.lang.StringBuilder sb1,
int posStart,
int posEndFocus,
int posEndTextSentence,
int posEndTextline)
sb1 - The whole bufferposStart - focus from here.posEndFocus - spread span from start of the focus to detect also <:@....> as long span.posEndTextline - spread or span from start ot length of a normal sentence till ". " or alternativel till ", " etc.private void wrBufferToFile(java.lang.StringBuilder sb1,
java.io.Writer wr1,
java.lang.String[] s2,
boolean bEnd)
throws java.io.IOException
bEnd - true then writes all, false then prevent the last content without dot on end.
if false, further output comes which is regarded later.java.io.IOExceptionprivate void wrRep(java.lang.CharSequence line)
throws java.io.IOException
java.io.IOExceptionprivate void writeLabelRef()
private java.lang.String wrClose()
throws java.io.IOException
java.io.IOException