List of usage examples for org.w3c.dom Element hasAttribute
public boolean hasAttribute(String name);
true
when an attribute with a given name is specified on this element or has a default value, false
otherwise. From source file:writer2latex.latex.FieldConverter.java
/** <p>Append declarations needed by the <code>FieldConverter</code> to * the preamble.</p>//from w w w. j ava 2 s . c o m * @param pack the <code>LaTeXDocumentPortion</code> to which * declarations of packages should be added (<code>\\usepackage</code>). * @param decl the <code>LaTeXDocumentPortion</code> to which * other declarations should be added. */ public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) { // Use natbib if (config.useBibtex() && config.useNatbib()) { pack.append("\\usepackage"); if (config.getNatbibOptions().length() > 0) { pack.append("[").append(config.getNatbibOptions()).append("]"); } pack.append("{natbib}").nl(); } // use lastpage.sty if (bUsesPageCount) { pack.append("\\usepackage{lastpage}").nl(); } // use titleref.sty if (bUsesTitleref) { pack.append("\\usepackage{titleref}").nl(); } // use hyperref.sty if (bUseHyperref) { pack.append("\\usepackage{hyperref}").nl(); pack.append("\\hypersetup{"); if (config.getBackend() == LaTeXConfig.PDFTEX) pack.append("pdftex, "); else if (config.getBackend() == LaTeXConfig.DVIPS) pack.append("dvips, "); //else pack.append("hypertex"); pack.append("colorlinks=true, linkcolor=blue, citecolor=blue, filecolor=blue, urlcolor=blue"); if (config.getBackend() == LaTeXConfig.PDFTEX) { pack.append(createPdfMeta("pdftitle", palette.getMetaData().getTitle())); if (config.metadata()) { pack.append(createPdfMeta("pdfauthor", palette.getMetaData().getCreator())) .append(createPdfMeta("pdfsubject", palette.getMetaData().getSubject())) .append(createPdfMeta("pdfkeywords", palette.getMetaData().getKeywords())); } } pack.append("}").nl(); } // Export sequence declarations // The number format is fetched from the first occurence of the // sequence in the text, while the outline level and the separation // character are fetched from the declaration Enumeration<String> names = seqFirst.keys(); while (names.hasMoreElements()) { // Get first text:sequence element String sName = names.nextElement(); Element first = seqFirst.get(sName); // Collect data String sNumFormat = Misc.getAttribute(first, XMLString.STYLE_NUM_FORMAT); if (sNumFormat == null) { sNumFormat = "1"; } int nLevel = 0; String sSepChar = "."; if (seqDecl.containsKey(sName)) { Element sdecl = (Element) seqDecl.get(sName); nLevel = Misc.getPosInteger(sdecl.getAttribute(XMLString.TEXT_DISPLAY_OUTLINE_LEVEL), 0); if (sdecl.hasAttribute(XMLString.TEXT_SEPARATION_CHARACTER)) { sSepChar = palette.getI18n().convert(sdecl.getAttribute(XMLString.TEXT_SEPARATION_CHARACTER), false, palette.getMainContext().getLang()); } } // Create counter decl.append("\\newcounter{").append(seqnames.getExportName(sName)).append("}"); String sPrefix = ""; if (nLevel > 0) { HeadingMap hm = config.getHeadingMap(); int nUsedLevel = nLevel <= hm.getMaxLevel() ? nLevel : hm.getMaxLevel(); if (nUsedLevel > 0) { decl.append("[").append(hm.getName(nUsedLevel)).append("]"); sPrefix = "\\the" + hm.getName(nUsedLevel) + sSepChar; } } decl.nl().append("\\renewcommand\\the").append(seqnames.getExportName(sName)).append("{") .append(sPrefix).append(ListConverter.numFormat(sNumFormat)).append("{") .append(seqnames.getExportName(sName)).append("}}").nl(); } }