public class ReadOdt extends TranslateOdtCommon
Modifier and Type | Class and Description |
---|---|
static class |
ReadOdt.CmdArgs |
(package private) static class |
ReadOdt.LabelRef |
TranslateOdtCommon.CommonArgs
Modifier and Type | Field and Description |
---|---|
private boolean |
bInCodeBlock |
private boolean |
bInColumns |
(package private) int[] |
chapterNr
If not null, then replace the first ' ' of the next output with this char.
|
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. known by knowledge. |
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<XmlDataNode> |
listNdTitle
Node text:h with the title of the document.
|
private XmlDataNode |
nodeDirectStyles |
private 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
to write it in <#label, text ....> to compare with the other refs. |
private java.lang.String |
sRefChapter
Stores a found text in
|
private StyleOdt |
styleP |
private java.io.Writer |
wr |
private java.io.Writer |
wra |
private java.io.Writer |
wrFrame |
private java.io.Writer |
wrRep |
private XmlCfg |
xmlCfgOdt |
log
Constructor and Description |
---|
ReadOdt(ReadOdt.CmdArgs cmdArgs) |
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 void |
defineIndirectStyles()
This operation defines the indirect styles which should be general known with its specific properties.
|
int |
execute() |
private void |
gatherAllBookmarksInHeader(XmlDataNode ndHead) |
private java.lang.String |
gatherAllHeading(XmlDataNode ndText) |
protected java.lang.String |
gatherContent(XmlDataNode nodeContent,
int deepnessSection) |
private java.lang.String |
gatherDirectStyles(XmlDataNode nodeDirectStyles)
Gather all direct styles in the document.
|
private java.lang.String |
gatherHeader(XmlDataNode node)
Writes a header as
'''
[#label]
==== Chapter title
|
private void |
gathImageInFrame(XmlDataNode ndParagr,
XmlDataNode nodeFrame,
boolean bImgCaption) |
private void |
gathWrCodeInclude(XmlDataNode ndCaption,
java.util.ListIterator<XmlDataNode> iterParentNodes) |
private java.lang.String |
gathWrFrameOrImage(XmlDataNode ndParagr,
XmlDataNode ndFrame,
java.lang.String styleFrameRaw,
boolean bCaption) |
private java.lang.String |
gathWrList(XmlDataNode nodeList) |
private java.lang.String |
gathWrListItem(XmlDataNode ndItem) |
private java.lang.String |
gathWrListItemOrNumbHeader(XmlDataNode nodeItem)
Gather an item in a list, not known what is it.
|
private java.lang.String |
gathWrParagraph(XmlDataNode node,
java.util.ListIterator<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 |
gathWrSpan(java.lang.String textSpan,
StyleOdt style)
span is for any text part with specific formatting.
|
private java.lang.String |
gathWrTable(XmlDataNode ndTable) |
private java.lang.String |
gathWrTableOfContent(XmlDataNode node) |
private java.lang.String |
gathWrText(XmlDataNode nodeP)
This is all inside a paragraph.
|
private java.lang.String |
gathWrXlink(XmlDataNode ndA,
java.util.ListIterator<XmlDataNode> iterNodes) |
private char |
gathWrXRef(XmlDataNode nodeXref)
Gathers a <text:bookmark-ref ...>, writes in Adoc as <<#label>>.
|
private int |
getAttribNumber(XmlDataNode node,
java.lang.String key,
int defaultNr) |
private StyleOdt |
getBaseStyle(java.lang.String styleNameArg)
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(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(XmlDataNode nodep,
java.lang.StringBuilder sbText,
boolean bSubnodes) |
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(XmlDataNode ndRootOdg)
This is the main routine after reading the whole XML file content.xml from odg.
|
private java.lang.String |
readXml(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 java.lang.CharSequence |
replaceToBackslasSubscription(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.
|
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 ". " whereby the space is replaced by the line break.
|
private java.lang.String |
wrClose() |
private void |
writeAsciidocHead() |
private void |
writeLabelRef() |
private java.lang.String |
writeTitle(XmlDataNode nodeContent) |
private void |
writeVmlHead() |
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 VML.
|
private java.lang.String |
wrTextAdoc(java.lang.String textArg)
Writes a given text from XML to Asciidoc, but with detection of pass:[...] parts.
|
searchForReplaceLinkOperationLabel, writeBackupFile
private final ReadOdt.CmdArgs cmdArgs
private 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 XmlDataNode nodeDirectStyles
private XmlDataNode nodeText
private java.util.List<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 bInCodeBlock
private boolean bInColumns
private java.lang.String lastHlinkPathToReplaced
private java.lang.String lastXref
int[] chapterNr
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, java.io.FileNotFoundException, java.io.IOException
java.nio.charset.IllegalCharsetNameException
java.nio.charset.UnsupportedCharsetException
java.io.FileNotFoundException
java.io.IOException
public static int amain(ReadOdt.CmdArgs args) throws java.io.IOException
args
- prepared cmd line argumentsjava.io.IOException
java.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.IOException
java.lang.Exception
- if unexpected.public static void main(java.lang.String[] sArgs)
sArgs
- public int execute() throws java.io.IOException
java.io.IOException
private void defineIndirectStyles()
private java.lang.String readXml(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(XmlDataNode ndRootOdg) throws java.io.IOException
ndRootOdg
- the root node of the content.xmljava.io.IOException
private java.lang.String gatherDirectStyles(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.IOException
private void writeVmlHead() throws java.io.IOException
java.io.IOException
private java.lang.String gatherAllHeading(XmlDataNode ndText)
private void gatherAllBookmarksInHeader(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(XmlDataNode nodeContent) throws java.io.IOException
java.io.IOException
protected java.lang.String gatherContent(XmlDataNode nodeContent, int deepnessSection) throws java.io.IOException
java.io.IOException
private java.lang.String gatherHeader(XmlDataNode node) throws java.io.IOException
''' [#label] ==== Chapter title
node
- text:h or maybe text:p nodejava.io.IOException
private java.lang.String gathWrParagraph(XmlDataNode node, java.util.ListIterator<XmlDataNode> iterParentNodes, int indent, java.lang.String[] stylesExpected) throws java.io.IOException
node
- indent
- stylesExpected
- java.io.IOException
private void gathImageInFrame(XmlDataNode ndParagr, XmlDataNode nodeFrame, boolean bImgCaption) throws java.io.IOException
java.io.IOException
private void gathWrCodeInclude(XmlDataNode ndCaption, java.util.ListIterator<XmlDataNode> iterParentNodes) throws java.io.IOException
java.io.IOException
private java.lang.String gathWrText(XmlDataNode nodeP) throws java.io.IOException
nodeP
- java.io.IOException
private java.lang.String getTextXml(XmlDataNode nodep, boolean bSubnodes)
nodep
- the given nodebSubnodes
- true then get the text also from all sub nodes, usefully for <span...private void getTextXml(XmlDataNode nodep, java.lang.StringBuilder sbText, boolean bSubnodes)
private java.lang.String gathWrSpan(java.lang.String textSpan, StyleOdt style) throws java.io.IOException
node
- style
- java.io.IOException
private java.lang.String gathWrList(XmlDataNode nodeList) throws java.io.IOException
java.io.IOException
private java.lang.String gathWrListItemOrNumbHeader(XmlDataNode nodeItem) throws java.io.IOException
nodeItem
- java.io.IOException
private java.lang.String gathWrListItem(XmlDataNode ndItem) throws java.io.IOException
java.io.IOException
private java.lang.String gathWrTable(XmlDataNode ndTable) throws java.io.IOException
java.io.IOException
private java.lang.String gathWrTableOfContent(XmlDataNode node) throws java.io.IOException
java.io.IOException
private java.lang.String gathWrFrameOrImage(XmlDataNode ndParagr, XmlDataNode ndFrame, java.lang.String styleFrameRaw, boolean bCaption) throws java.io.IOException
java.io.IOException
private java.lang.String gathWrXlink(XmlDataNode ndA, java.util.ListIterator<XmlDataNode> iterNodes) throws java.io.IOException
java.io.IOException
private char gathWrXRef(XmlDataNode nodeXref) throws java.io.IOException
nodeXref
- java.io.IOException
private StyleOdt getBaseStyle(java.lang.String styleNameArg)
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(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.IOException
private java.lang.CharSequence replaceToBackslasSubscription(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.IOException
private void wrReplaceLastSpace(char cNew)
private void wrAdoc(java.lang.CharSequence text) throws java.io.IOException
java.io.IOException
private void wrm(java.lang.CharSequence text) throws java.io.IOException
java.io.IOException
private 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.IOException
private void wrRep(java.lang.CharSequence line) throws java.io.IOException
java.io.IOException
private void writeLabelRef()
private java.lang.String wrClose() throws java.io.IOException
java.io.IOException