diff --git a/src/main/java/writer2latex/xhtml/Converter.java b/src/main/java/writer2latex/xhtml/Converter.java index 5c1efd1..a08089e 100644 --- a/src/main/java/writer2latex/xhtml/Converter.java +++ b/src/main/java/writer2latex/xhtml/Converter.java @@ -101,7 +101,7 @@ public class Converter extends BasicConverter { public int nType = XhtmlDocument.XHTML10; // the doctype private boolean bOPS = false; // Do we need to be OPS conforming? Vector outFiles; - private int nOutFileIndex; + private int outFileIndex; private XhtmlDocument htmlDoc; // current outfile private Document htmlDOM; // current DOM, usually within htmlDoc private boolean bNeedHeaderFooter = false; @@ -203,7 +203,7 @@ public class Converter extends BasicConverter { public boolean isHTML5() { return nType==XhtmlDocument.HTML5; } - public int getOutFileIndex() { return nOutFileIndex; } + public int getOutFileIndex() { return outFileIndex; } public void addContentEntry(String sTitle, int nLevel, String sTarget) { converterResult.addContentEntry(new ContentEntryImpl(sTitle,nLevel,htmlDoc,sTarget)); @@ -251,7 +251,7 @@ public class Converter extends BasicConverter { sTargetFileName = Misc.trimDocumentName(sTargetFileName,XhtmlDocument.getExtension(nType)); outFiles = new Vector(); - nOutFileIndex = -1; + outFileIndex = -1; bNeedHeaderFooter = !bOPS && (ofr.isSpreadsheet() || ofr.isPresentation() || config.getXhtmlSplitLevel()>0 || config.pageBreakSplit()>XhtmlConfig.NONE || config.getXhtmlUplink().length()>0); @@ -348,10 +348,10 @@ public class Converter extends BasicConverter { // Export styles (XHTML) if (!isOPS() && !config.separateStylesheet()) { - for (int i=0; i<=nOutFileIndex; i++) { + for (int i=0; i<=outFileIndex; i++) { Element head = outFiles.get(i).getHeadNode(); if (head!=null) { - Node styles = styleCv.exportStyles(outFiles.get(i).getContentDOM()); + Node styles = styleCv.getStyleSelectors(outFiles.get(i).getContentDOM()); if (styles!=null) { head.appendChild(styles); } @@ -362,7 +362,7 @@ public class Converter extends BasicConverter { // Load MathJax // TODO: Should we support different configurations of MathJax? if ((nType==XhtmlDocument.HTML5 || nType==XhtmlDocument.XHTML_MATHML) && config.useMathJax()) { - for (int i=0; i<=nOutFileIndex; i++) { + for (int i=0; i<=outFileIndex; i++) { if (outFiles.get(i).hasMath()) { XhtmlDocument doc = outFiles.get(i); Element head = doc.getHeadNode(); @@ -378,7 +378,7 @@ public class Converter extends BasicConverter { // Create headers & footers (if nodes are available) if (ofr.isSpreadsheet()) { - for (int i=0; i<=nOutFileIndex; i++) { + for (int i=0; i<=outFileIndex; i++) { XhtmlDocument doc = outFiles.get(i); Document dom = doc.getContentDOM(); @@ -418,8 +418,8 @@ public class Converter extends BasicConverter { if (footer!=null) { footer.appendChild(footerPar); } } } - else if (nOutFileIndex>0) { - for (int i=0; i<=nOutFileIndex; i++) { + else if (outFileIndex>0) { + for (int i=0; i<=outFileIndex; i++) { XhtmlDocument doc = outFiles.get(i); Document dom = doc.getContentDOM(); //Element content = doc.getContentNode(); @@ -441,7 +441,7 @@ public class Converter extends BasicConverter { addNavigationLink(dom,header,l10n.get(L10n.FIRST),0); addNavigationLink(dom,header,l10n.get(L10n.PREVIOUS),i-1); addNavigationLink(dom,header,l10n.get(L10n.NEXT),i+1); - addNavigationLink(dom,header,l10n.get(L10n.LAST),nOutFileIndex); + addNavigationLink(dom,header,l10n.get(L10n.LAST),outFileIndex); if (textCv.getTocIndex()>=0) { addNavigationLink(dom,header,l10n.get(L10n.CONTENTS),textCv.getTocIndex()); } @@ -464,7 +464,7 @@ public class Converter extends BasicConverter { addNavigationLink(dom,footer,l10n.get(L10n.FIRST),0); addNavigationLink(dom,footer,l10n.get(L10n.PREVIOUS),i-1); addNavigationLink(dom,footer,l10n.get(L10n.NEXT),i+1); - addNavigationLink(dom,footer,l10n.get(L10n.LAST),nOutFileIndex); + addNavigationLink(dom,footer,l10n.get(L10n.LAST),outFileIndex); if (textCv.getTocIndex()>=0) { addNavigationLink(dom,footer,l10n.get(L10n.CONTENTS),textCv.getTocIndex()); } @@ -475,7 +475,7 @@ public class Converter extends BasicConverter { } } else if (config.getXhtmlUplink().length()>0) { - for (int i=0; i<=nOutFileIndex; i++) { + for (int i=0; i<=outFileIndex; i++) { XhtmlDocument doc = outFiles.get(i); Document dom = doc.getContentDOM(); //Element content = doc.getContentNode(); @@ -504,12 +504,12 @@ public class Converter extends BasicConverter { if (config.xhtmlFormatting()>XhtmlConfig.IGNORE_STYLES) { if (isOPS()) { // EPUB CssDocument cssDoc = new CssDocument(EPUB_STYLESHEET); - cssDoc.read(styleCv.exportStyles(false)); + cssDoc.read(styleCv.allStyleSelectors(false)); converterResult.addDocument(cssDoc); } else if (config.separateStylesheet()) { // XHTML CssDocument cssDoc = new CssDocument(sTargetFileName+"-styles.css"); - cssDoc.read(styleCv.exportStyles(false)); + cssDoc.read(styleCv.allStyleSelectors(false)); converterResult.addDocument(cssDoc); } } @@ -517,7 +517,7 @@ public class Converter extends BasicConverter { } private void addNavigationLink(Document dom, Node node, String s, int nIndex) { - if (nIndex>=0 && nIndex<=nOutFileIndex) { + if (nIndex>=0 && nIndex<=outFileIndex) { Element a = dom.createElement("a"); a.setAttribute("href",Misc.makeHref(getOutFileName(nIndex,true))); a.appendChild(dom.createTextNode(s)); @@ -631,7 +631,7 @@ public class Converter extends BasicConverter { // Use another document. TODO: This is very ugly; clean it up!!! public void changeOutFile(int nIndex) { - nOutFileIndex = nIndex; + outFileIndex = nIndex; htmlDoc = outFiles.get(nIndex); htmlDOM = htmlDoc.getContentDOM(); } @@ -650,11 +650,11 @@ public class Converter extends BasicConverter { } // Prepare next output file public Element nextOutFile() { - htmlDoc = new XhtmlDocument(getOutFileName(++nOutFileIndex,false),nType); + htmlDoc = new XhtmlDocument(getOutFileName(++outFileIndex,false),nType); htmlDoc.setConfig(config); if (template!=null) { htmlDoc.readFromTemplate(template); } /*else if (bNeedHeaderFooter) { htmlDoc.createHeaderFooter(); }*/ - outFiles.add(nOutFileIndex,htmlDoc); + outFiles.add(outFileIndex,htmlDoc); converterResult.addDocument(htmlDoc); // Create head + body @@ -814,21 +814,21 @@ public class Converter extends BasicConverter { public Element createTarget(String sId) { Element a = htmlDOM.createElement("a"); a.setAttribute("id",targetNames.addToExport(sId)); - targets.put(sId, new Integer(nOutFileIndex)); + targets.put(sId, new Integer(outFileIndex)); return a; } // put a target id on an existing element public void addTarget(Element node,String sId) { node.setAttribute("id",targetNames.addToExport(sId)); - targets.put(sId, new Integer(nOutFileIndex)); + targets.put(sId, new Integer(outFileIndex)); } // create an internal link public Element createLink(String sId) { Element a = htmlDOM.createElement("a"); LinkDescriptor ld = new LinkDescriptor(); - ld.element = a; ld.sId = sId; ld.nIndex = nOutFileIndex; + ld.element = a; ld.sId = sId; ld.nIndex = outFileIndex; links.add(ld); return a; } diff --git a/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java b/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java index 58f1688..1d26c43 100644 --- a/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java @@ -61,10 +61,10 @@ public class FrameStyleParser extends StyleWithPropertiesParser { /** Convert style information for used styles * @param sIndent a String of spaces to add before each line */ - public String getStyleDeclarations(String sIndent) { + public String getStyleSelectors(String sIndent) { if (bConvertStyles) { StringBuilder buf = new StringBuilder(); - buf.append(super.getStyleDeclarations(sIndent)); + buf.append(super.getStyleSelectors(sIndent)); Enumeration names = styleNames.keys(); while (names.hasMoreElements()) { String sDisplayName = names.nextElement(); diff --git a/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java b/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java index 84d212e..2c171da 100644 --- a/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java @@ -56,7 +56,7 @@ public class HeadingStyleParser extends StyleFamilyParser { } @Override - public String getStyleDeclarations(String sIndent) { + public String getStyleSelectors(String sIndent) { if (bConvertStyles) { StringBuilder buf = new StringBuilder(); for (int i = 1; i <= 6; i++) { diff --git a/src/main/java/writer2latex/xhtml/style/ListStyleFamilyParser.java b/src/main/java/writer2latex/xhtml/style/ListStyleFamilyParser.java index 5da8ae3..a867455 100644 --- a/src/main/java/writer2latex/xhtml/style/ListStyleFamilyParser.java +++ b/src/main/java/writer2latex/xhtml/style/ListStyleFamilyParser.java @@ -90,7 +90,7 @@ public class ListStyleFamilyParser extends StyleFamilyParser { /**

Convert style information for used styles

* @param sIndent a String of spaces to add before each line */ - public String getStyleDeclarations(String sIndent) { + public String getStyleSelectors(String sIndent) { if (bConvertStyles) { StringBuilder buf = new StringBuilder(); Enumeration names = styleNames.keys(); diff --git a/src/main/java/writer2latex/xhtml/style/PageStyleParser.java b/src/main/java/writer2latex/xhtml/style/PageStyleParser.java index ab0a896..0e17e0a 100644 --- a/src/main/java/writer2latex/xhtml/style/PageStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/PageStyleParser.java @@ -131,7 +131,7 @@ public class PageStyleParser extends StyleFamilyParser { /** Convert style information for used styles * @param sIndent a String of spaces to add before each line */ - public String getStyleDeclarations(String sIndent) { + public String getStyleSelectors(String sIndent) { StringBuilder buf = new StringBuilder(); // This will be master pages for presentations only diff --git a/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java b/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java index f3d1824..20afa6b 100644 --- a/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java @@ -86,10 +86,10 @@ public class PresentationStyleParser extends FrameStyleParser { /**

Convert style information for used styles

* @param sIndent a String of spaces to add before each line */ - public String getStyleDeclarations(String sIndent) { + public String getStyleSelectors(String sIndent) { if (bConvertStyles) { StringBuilder buf = new StringBuilder(); - buf.append(super.getStyleDeclarations(sIndent)); + buf.append(super.getStyleSelectors(sIndent)); Enumeration names = outlineStyleNames.keys(); while (names.hasMoreElements()) { String sDisplayName = names.nextElement(); diff --git a/src/main/java/writer2latex/xhtml/style/StyleFamilyParser.java b/src/main/java/writer2latex/xhtml/style/StyleFamilyParser.java index 4c131ba..b1e6ff7 100644 --- a/src/main/java/writer2latex/xhtml/style/StyleFamilyParser.java +++ b/src/main/java/writer2latex/xhtml/style/StyleFamilyParser.java @@ -120,6 +120,6 @@ public abstract class StyleFamilyParser extends Parser { /**

Convert style information for used styles

* @param sIndent a String of spaces to add before each line */ - public abstract String getStyleDeclarations(String sIndent); + public abstract String getStyleSelectors(String sIndent); } diff --git a/src/main/java/writer2latex/xhtml/style/StyleParser.java b/src/main/java/writer2latex/xhtml/style/StyleParser.java index e1160b9..c50fea6 100644 --- a/src/main/java/writer2latex/xhtml/style/StyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/StyleParser.java @@ -128,7 +128,7 @@ public class StyleParser extends Parser { * @param bIndent true if the CSS code should be indented * @return the CSS code */ - public String exportStyles(boolean bIndent) { + public String allStyleSelectors(boolean bIndent) { String sIndent = bIndent ? " " : ""; StringBuilder buf = new StringBuilder(); @@ -139,17 +139,17 @@ public class StyleParser extends Parser { // Text documents: text, par, list, frame // Spreadsheet documents: cell // Presentation documents: frame, presentation, page - buf.append(getTextSc().getStyleDeclarations(sIndent)); - buf.append(getParSc().getStyleDeclarations(sIndent)); - buf.append(getHeadingSc().getStyleDeclarations(sIndent)); - buf.append(getListSc().getStyleDeclarations(sIndent)); - buf.append(getSectionSc().getStyleDeclarations(sIndent)); - buf.append(getCellSc().getStyleDeclarations(sIndent)); - buf.append(getTableSc().getStyleDeclarations(sIndent)); - buf.append(getRowSc().getStyleDeclarations(sIndent)); - buf.append(getFrameSc().getStyleDeclarations(sIndent)); - buf.append(getPresentationSc().getStyleDeclarations(sIndent)); - buf.append(getPageSc().getStyleDeclarations(sIndent)); + buf.append(textSc.getStyleSelectors(sIndent)); + buf.append(parSc.getStyleSelectors(sIndent)); + buf.append(headingSc.getStyleSelectors(sIndent)); + buf.append(listSc.getStyleSelectors(sIndent)); + buf.append(sectionSc.getStyleSelectors(sIndent)); + buf.append(cellSc.getStyleSelectors(sIndent)); + buf.append(tableSc.getStyleSelectors(sIndent)); + buf.append(rowSc.getStyleSelectors(sIndent)); + buf.append(frameSc.getStyleSelectors(sIndent)); + buf.append(presentationSc.getStyleSelectors(sIndent)); + buf.append(pageSc.getStyleSelectors(sIndent)); return buf.toString(); } @@ -158,18 +158,18 @@ public class StyleParser extends Parser { * @param htmlDOM the XHTML DOM to which the generated element belongs * @return the style element */ - public Node exportStyles(Document htmlDOM) { - String sStyles = exportStyles(config.prettyPrint()); + public Node getStyleSelectors(Document htmlDOM) { + String styleSelectors = allStyleSelectors(config.prettyPrint()); // Create node - if (sStyles.length()>0) { - Element htmlStyle = htmlDOM.createElement("style"); - htmlStyle.setAttribute("media","all"); - htmlStyle.setAttribute("type","text/css"); - htmlStyle.appendChild(htmlDOM.createTextNode(config.prettyPrint() ? "\n" : " ")); - htmlStyle.appendChild(htmlDOM.createTextNode(sStyles)); - if (config.prettyPrint()) { htmlStyle.appendChild(htmlDOM.createTextNode(" ")); } - return htmlStyle; + if (styleSelectors.length()>0) { + Element styleElement = htmlDOM.createElement("style"); + styleElement.setAttribute("media","all"); + styleElement.setAttribute("type","text/css"); + styleElement.appendChild(htmlDOM.createTextNode(config.prettyPrint() ? "\n" : " ")); + styleElement.appendChild(htmlDOM.createTextNode(styleSelectors)); + if (config.prettyPrint()) { styleElement.appendChild(htmlDOM.createTextNode(" ")); } + return styleElement; } else { return null; diff --git a/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java b/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java index ee7f289..8b96fc0 100644 --- a/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java +++ b/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java @@ -95,7 +95,7 @@ public abstract class StyleWithPropertiesParser /** Convert style information for used styles * @param sIndent a String of spaces to add before each line */ - public String getStyleDeclarations(String sIndent) { + public String getStyleSelectors(String sIndent) { if (bConvertStyles) { StringBuilder buf = new StringBuilder(); Enumeration names = styleNames.keys(); diff --git a/src/main/java/writer2latex/xhtml/style/TextStyleParser.java b/src/main/java/writer2latex/xhtml/style/TextStyleParser.java index 7ebd9aa..f004805 100644 --- a/src/main/java/writer2latex/xhtml/style/TextStyleParser.java +++ b/src/main/java/writer2latex/xhtml/style/TextStyleParser.java @@ -153,8 +153,8 @@ public class TextStyleParser extends StyleWithPropertiesParser { * @param sIndent a String of spaces to add before each line */ StringBuilder buf = new StringBuilder(); - public String getStyleDeclarations(String sIndent) { - buf.append(super.getStyleDeclarations(sIndent)); + public String getStyleSelectors(String sIndent) { + buf.append(super.getStyleSelectors(sIndent)); if (bConvertStyles) { // Export anchor styles // Default is always the styles "Internet link" and "Visited Internet Link"(?)