/************************************************************************ * * ConverterHelper.java * * Copyright: 2002-2015 by Henrik Just * * This file is part of Writer2LaTeX. * * Writer2LaTeX is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Writer2LaTeX is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Writer2LaTeX. If not, see . * * Version 1.6 (2015-06-15) * */ package writer2latex.xhtml; import org.w3c.dom.Element; import writer2latex.office.OfficeReader; /** A ConverterHelper is responsible for conversion of some specific content into XHTML. */ class Parser { // Member variables providing our content (set in constructor) OfficeReader ofr; XhtmlConfig config; Converter converter; /** Construct a new converter helper based on a * * @param ofr the office reader used to access the source document * @param config the configuration to use * @param converter the main converter to which the helper belongs */ Parser(OfficeReader ofr, XhtmlConfig config, Converter converter) { this.ofr = ofr; this.config = config; this.converter = converter; } // Convenience accessor methods to other converter helpers (only needed to save some typing) StyleParser getStyleCv() { return converter.getStyleCv(); } TextStyleParser getTextSc() { return converter.getStyleCv().getTextSc(); } ParStyleParser getParSc() { return converter.getStyleCv().getParSc(); } HeadingStyleParser getHeadingSc() { return converter.getStyleCv().getHeadingSc(); } ListStyleFamilyParser getListSc() { return converter.getStyleCv().getListSc(); } SectionStyleParser getSectionSc() { return converter.getStyleCv().getSectionSc(); } TableStyleParser getTableSc() { return converter.getStyleCv().getTableSc(); } RowStyleParser getRowSc() { return converter.getStyleCv().getRowSc(); } CellStyleParser getCellSc() { return converter.getStyleCv().getCellSc(); } FrameStyleParser getFrameSc() { return converter.getStyleCv().getFrameSc(); } PresentationStyleParser getPresentationSc() { return converter.getStyleCv().getPresentationSc(); } PageStyleParser getPageSc() { return converter.getStyleCv().getPageSc(); } TextParser getTextCv() { return converter.getTextCv(); } TableParser getTableCv() { return converter.getTableCv(); } DrawParser getDrawCv() { return converter.getDrawCv(); } MathParser getMathCv() { return converter.getMathCv(); } /** Apply style information to an XHTML node * * @param info the style to apply * @param hnode the XHTML node */ void applyStyle(StyleInfo info, Element hnode) { if (info.sClass!=null) { hnode.setAttribute("class",info.sClass); } if (!info.props.isEmpty()) { hnode.setAttribute("style",info.props.toString()); } if (info.sLang!=null) { hnode.setAttribute("xml:lang",info.sLang); if (converter.getType()==XhtmlDocument.XHTML10 || converter.getType()==XhtmlDocument.HTML5) { hnode.setAttribute("lang",info.sLang); // HTML4 compatibility/polyglot HTML5S } } if (info.sDir!=null) { hnode.setAttribute("dir",info.sDir); } } }