writer2latex.latex
Class FieldConverter

java.lang.Object
  extended by writer2latex.latex.ConverterHelper
      extended by writer2latex.latex.FieldConverter

public class FieldConverter
extends ConverterHelper

This class handles text fields and links in the document.

Packages: lastpage, hyperref, titleref, oooref (all optional)

TODO: Need proper treatment of "caption" and "text" for sequence references not to figures and tables (should be fairly rare, though)


Field Summary
private  ExportNameCollection bookmarknames
           
private  boolean bUseHyperref
           
private  boolean bUsesOooref
           
private  boolean bUsesPageCount
           
private  boolean bUsesTitleref
           
private  java.util.Vector postponedBookmarks
           
private  java.util.Vector postponedReferenceMarks
           
private  ExportNameCollection refnames
           
private  java.util.Hashtable seqDecl
           
private  java.util.Hashtable seqFirst
           
private  ExportNameCollection seqnames
           
private  ExportNameCollection seqrefnames
           
private  ExportNameCollection targets
           
 
Fields inherited from class writer2latex.latex.ConverterHelper
config, ofr, palette
 
Constructor Summary
FieldConverter(OfficeReader ofr, Config config, ConverterPalette palette)
           
 
Method Summary
 void addTarget(org.w3c.dom.Element node, java.lang.String sSuffix, LaTeXDocumentPortion ldp)
          Add a \\hypertarget
 void addTarget(java.lang.String sName, java.lang.String sSuffix, LaTeXDocumentPortion ldp)
          Add a \\hypertarget
 void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl)
          Append declarations needed by the FieldConverter to the preamble.
private  java.lang.String createPdfMeta(java.lang.String sName, java.lang.String sValue)
           
private  java.lang.String escapeHref(java.lang.String s)
           
 void flushReferenceMarks(LaTeXDocumentPortion ldp, Context oc)
          Process pending reference marks and bookmarks (which may have been postponed within sections, captions or verbatim text.
 void handleAnchor(org.w3c.dom.Element node, LaTeXDocumentPortion ldp, Context oc)
          Process a hyperlink (text:a tag)
 void handleBookmark(org.w3c.dom.Element node, LaTeXDocumentPortion ldp, Context oc)
          Process a bookmark (text:bookmark tag) A bookmark may be the target for either a hyperlink or a reference, so this will generate a \\hyperref and/or a \\label
 void handleBookmarkRef(org.w3c.dom.Element node, LaTeXDocumentPortion ldp, Context oc)
          Process a bookmark reference (text:bookmark-ref tag).
 void handlePageCount(org.w3c.dom.Element node, LaTeXDocumentPortion ldp, Context oc)
          Process a page count field (text:page-count tag)
 void handlePageNumber(org.w3c.dom.Element node, LaTeXDocumentPortion ldp, Context oc)
          Process a page number field (text:page-number tag)
 void handleReferenceMark(org.w3c.dom.Element node, LaTeXDocumentPortion ldp, Context oc)
          Process a reference mark (text:reference-mark tag)
 void handleReferenceRef(org.w3c.dom.Element node, LaTeXDocumentPortion ldp, Context oc)
          Process a reference (text:reference-ref tag)
 void handleSequence(org.w3c.dom.Element node, LaTeXDocumentPortion ldp, Context oc)
          Process a sequence field (text:sequence tag)
 void handleSequenceDecls(org.w3c.dom.Element node)
          Process sequence declarations
 void handleSequenceRef(org.w3c.dom.Element node, LaTeXDocumentPortion ldp, Context oc)
          Process a sequence reference (text:sequence-ref tag)
private  java.lang.String urlDecode(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targets

private ExportNameCollection targets

refnames

private ExportNameCollection refnames

bookmarknames

private ExportNameCollection bookmarknames

seqnames

private ExportNameCollection seqnames

seqrefnames

private ExportNameCollection seqrefnames

seqDecl

private java.util.Hashtable seqDecl

seqFirst

private java.util.Hashtable seqFirst

postponedReferenceMarks

private java.util.Vector postponedReferenceMarks

postponedBookmarks

private java.util.Vector postponedBookmarks

bUseHyperref

private boolean bUseHyperref

bUsesPageCount

private boolean bUsesPageCount

bUsesTitleref

private boolean bUsesTitleref

bUsesOooref

private boolean bUsesOooref
Constructor Detail

FieldConverter

public FieldConverter(OfficeReader ofr,
                      Config config,
                      ConverterPalette palette)
Method Detail

appendDeclarations

public void appendDeclarations(LaTeXDocumentPortion pack,
                               LaTeXDocumentPortion decl)

Append declarations needed by the FieldConverter to the preamble.

Overrides:
appendDeclarations in class ConverterHelper
Parameters:
pack - the LaTeXDocumentPortion to which declarations of packages should be added (\\usepackage).
decl - the LaTeXDocumentPortion to which other declarations should be added.

handleSequenceDecls

public void handleSequenceDecls(org.w3c.dom.Element node)

Process sequence declarations

Parameters:
node - the text:sequence-decls node

handleSequence

public void handleSequence(org.w3c.dom.Element node,
                           LaTeXDocumentPortion ldp,
                           Context oc)

Process a sequence field (text:sequence tag)

Parameters:
node - The element containing the sequence field
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

handleSequenceRef

public void handleSequenceRef(org.w3c.dom.Element node,
                              LaTeXDocumentPortion ldp,
                              Context oc)

Process a sequence reference (text:sequence-ref tag)

Parameters:
node - The element containing the sequence reference
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

handleReferenceMark

public void handleReferenceMark(org.w3c.dom.Element node,
                                LaTeXDocumentPortion ldp,
                                Context oc)

Process a reference mark (text:reference-mark tag)

Parameters:
node - The element containing the reference mark
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

handleReferenceRef

public void handleReferenceRef(org.w3c.dom.Element node,
                               LaTeXDocumentPortion ldp,
                               Context oc)

Process a reference (text:reference-ref tag)

Parameters:
node - The element containing the reference
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

handleBookmark

public void handleBookmark(org.w3c.dom.Element node,
                           LaTeXDocumentPortion ldp,
                           Context oc)

Process a bookmark (text:bookmark tag)

A bookmark may be the target for either a hyperlink or a reference, so this will generate a \\hyperref and/or a \\label

Parameters:
node - The element containing the bookmark
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

handleBookmarkRef

public void handleBookmarkRef(org.w3c.dom.Element node,
                              LaTeXDocumentPortion ldp,
                              Context oc)

Process a bookmark reference (text:bookmark-ref tag).

Parameters:
node - The element containing the bookmark reference
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

flushReferenceMarks

public void flushReferenceMarks(LaTeXDocumentPortion ldp,
                                Context oc)

Process pending reference marks and bookmarks (which may have been postponed within sections, captions or verbatim text.

Parameters:
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

handleAnchor

public void handleAnchor(org.w3c.dom.Element node,
                         LaTeXDocumentPortion ldp,
                         Context oc)

Process a hyperlink (text:a tag)

Parameters:
node - The element containing the hyperlink
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

addTarget

public void addTarget(org.w3c.dom.Element node,
                      java.lang.String sSuffix,
                      LaTeXDocumentPortion ldp)

Add a \\hypertarget

Parameters:
node - The element containing the name of the target
sSuffix - A suffix to be added to the target, e.g. "|table" for a reference to a table.
ldp - the LaTeXDocumentPortion to which LaTeX code should be added

addTarget

public void addTarget(java.lang.String sName,
                      java.lang.String sSuffix,
                      LaTeXDocumentPortion ldp)

Add a \\hypertarget

Parameters:
sName - The name of the target
sSuffix - A suffix to be added to the target, e.g. "|table" for a reference to a table.
ldp - the LaTeXDocumentPortion to which LaTeX code should be added

handlePageNumber

public void handlePageNumber(org.w3c.dom.Element node,
                             LaTeXDocumentPortion ldp,
                             Context oc)

Process a page number field (text:page-number tag)

Parameters:
node - The element containing the page number field
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

handlePageCount

public void handlePageCount(org.w3c.dom.Element node,
                            LaTeXDocumentPortion ldp,
                            Context oc)

Process a page count field (text:page-count tag)

Parameters:
node - The element containing the page count field
ldp - the LaTeXDocumentPortion to which LaTeX code should be added
oc - the current context

createPdfMeta

private java.lang.String createPdfMeta(java.lang.String sName,
                                       java.lang.String sValue)

urlDecode

private java.lang.String urlDecode(java.lang.String s)

escapeHref

private java.lang.String escapeHref(java.lang.String s)