Initial import
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@5 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
75e32b1e8f
commit
b0b66fcae9
252 changed files with 49000 additions and 0 deletions
75
source/java/writer2latex/latex/util/BeforeAfter.java
Normal file
75
source/java/writer2latex/latex/util/BeforeAfter.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* BeforeAfter.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-12-02)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.util;
|
||||
|
||||
/** Utility class to hold LaTeX code to put before/after other LaTeX code
|
||||
*/
|
||||
public class BeforeAfter {
|
||||
private String sBefore="";
|
||||
private String sAfter="";
|
||||
|
||||
/** Constructor to initialize the object with a pair of strings
|
||||
* @param sBefore1 LaTeX code to put before
|
||||
* @param sAfter1 LaTeX code to put after
|
||||
*/
|
||||
public BeforeAfter(String sBefore1, String sAfter1) {
|
||||
sBefore=sBefore1; sAfter=sAfter1;
|
||||
}
|
||||
|
||||
/** Default constructor: Create with empty strings
|
||||
*/
|
||||
public BeforeAfter() { }
|
||||
|
||||
/** <p>Add data to the <code>BeforeAfter</code></p>
|
||||
* <p>The new data will be be added "inside", thus for example</p>
|
||||
* <ul><li><code>add("\textsf{","}");</code>
|
||||
* <li><code>add("\textit{","}");</code></ul>
|
||||
* <p>will create the pair <code>\textsf{\textit{</code>, <code>}}</code></p>
|
||||
*
|
||||
* @param sBefore1 LaTeX code to put before
|
||||
* @param sAfter1 LaTeX code to put after
|
||||
*/
|
||||
public void add(String sBefore1, String sAfter1) {
|
||||
sBefore+=sBefore1; sAfter=sAfter1+sAfter;
|
||||
}
|
||||
|
||||
/** Get LaTeX code to put before
|
||||
* @return then LaTeX code
|
||||
*/
|
||||
public String getBefore() { return sBefore; }
|
||||
|
||||
/** Get LaTeX code to put after
|
||||
* @return then LaTeX code
|
||||
*/
|
||||
public String getAfter() { return sAfter; }
|
||||
|
||||
/** Check if this <code>BeforeAfter</code> contains any data
|
||||
* @return true if there is data in at least one part
|
||||
*/
|
||||
public boolean isEmpty() { return sBefore.length()==0 && sAfter.length()==0; }
|
||||
|
||||
}
|
310
source/java/writer2latex/latex/util/Context.java
Normal file
310
source/java/writer2latex/latex/util/Context.java
Normal file
|
@ -0,0 +1,310 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* Context.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2007 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2007-11-23)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.util;
|
||||
|
||||
import writer2latex.office.XMLString;
|
||||
import writer2latex.office.StyleWithProperties;
|
||||
|
||||
/** <p>LaTeX code is in general very context dependent. This class tracks the
|
||||
* current context, which is the used by the converter to create valid and
|
||||
* optimal LaTeX code.</p>
|
||||
*/
|
||||
public class Context {
|
||||
|
||||
// *** Formatting Info (current values in the source OOo document) ***
|
||||
|
||||
// Current list style
|
||||
private String sListStyleName = null;
|
||||
|
||||
// Current background color
|
||||
private String sBgColor = null;
|
||||
|
||||
// Current character formatting attributes
|
||||
private String sFontName = null;
|
||||
private String sFontStyle = null;
|
||||
private String sFontVariant = null;
|
||||
private String sFontWeight = null;
|
||||
private String sFontSize = null;
|
||||
private String sFontColor = null;
|
||||
private String sLang = null;
|
||||
private String sCountry = null;
|
||||
|
||||
// *** Structural Info (identifies contructions in the LaTeX document) ***
|
||||
|
||||
// within the header or footer of a pagestyle
|
||||
private boolean bInHeaderFooter = false;
|
||||
|
||||
// within a table cell
|
||||
private boolean bInTable = false; // any column
|
||||
private boolean bInLastTableColumn = false; // last column
|
||||
private boolean bInSimpleTable = false; // l, c or r-column
|
||||
|
||||
// within a multicols environment
|
||||
private boolean bInMulticols = false;
|
||||
|
||||
// within a list of this level
|
||||
private int nListLevel = 0;
|
||||
|
||||
// within a section command
|
||||
private boolean bInSection = false;
|
||||
|
||||
// within a caption
|
||||
private boolean bInCaption = false;
|
||||
|
||||
// within a floating figure (figure environment)
|
||||
private boolean bInFigureFloat = false;
|
||||
|
||||
// within a floating table (table envrionment)
|
||||
private boolean bInTableFloat = false;
|
||||
|
||||
// within a minipage environment
|
||||
private boolean bInFrame = false;
|
||||
|
||||
// within a \footnote or \endnote
|
||||
private boolean bInFootnote = false;
|
||||
|
||||
// in verbatim mode
|
||||
private boolean bVerbatim = false;
|
||||
|
||||
// in math mode
|
||||
private boolean bMathMode = false;
|
||||
|
||||
// *** Special Info ***
|
||||
|
||||
// Inside (inline) verbatim text, where line breaks are disallowed
|
||||
private boolean bNoLineBreaks = false;
|
||||
|
||||
// Inside a construction, where footnotes are disallowed
|
||||
private boolean bNoFootnotes = false;
|
||||
|
||||
// Inside an area, where lists are ignored
|
||||
private boolean bIgnoreLists = false;
|
||||
|
||||
// *** Accessor Methods ***
|
||||
|
||||
public void setBgColor(String sBgColor) { this.sBgColor = sBgColor; }
|
||||
|
||||
public String getBgColor() { return sBgColor; }
|
||||
|
||||
public void setListStyleName(String sListStyleName) { this.sListStyleName = sListStyleName; }
|
||||
|
||||
public String getListStyleName() { return sListStyleName; }
|
||||
|
||||
public void setFontName(String sFontName) { this.sFontName = sFontName; }
|
||||
|
||||
public String getFontName() { return sFontName; }
|
||||
|
||||
public void setFontStyle(String sFontStyle) { this.sFontStyle = sFontStyle; }
|
||||
|
||||
public String getFontStyle() { return sFontStyle; }
|
||||
|
||||
public void setFontVariant(String sFontVariant) { this.sFontVariant = sFontVariant; }
|
||||
|
||||
public String getFontVariant() { return sFontVariant; }
|
||||
|
||||
public void setFontWeight(String sFontWeight) { this.sFontWeight = sFontWeight; }
|
||||
|
||||
public String getFontWeight() { return sFontWeight; }
|
||||
|
||||
public void setFontSize(String sFontSize) { this.sFontSize = sFontSize; }
|
||||
|
||||
public String getFontSize() { return sFontSize; }
|
||||
|
||||
public void setFontColor(String sFontColor) { this.sFontColor = sFontColor; }
|
||||
|
||||
public String getFontColor() { return sFontColor; }
|
||||
|
||||
public void setLang(String sLang) { this.sLang = sLang; }
|
||||
|
||||
public String getLang() { return sLang; }
|
||||
|
||||
public void setCountry(String sCountry) { this.sCountry = sCountry; }
|
||||
|
||||
public String getCountry() { return sCountry; }
|
||||
|
||||
public void setInHeaderFooter(boolean bInHeaderFooter) {
|
||||
this.bInHeaderFooter = bInHeaderFooter;
|
||||
}
|
||||
|
||||
public boolean isInHeaderFooter() { return bInHeaderFooter; }
|
||||
|
||||
public void setInTable(boolean bInTable) { this.bInTable = bInTable; }
|
||||
|
||||
public boolean isInTable() { return bInTable; }
|
||||
|
||||
public void setInLastTableColumn(boolean bInLastTableColumn) { this.bInLastTableColumn = bInLastTableColumn; }
|
||||
|
||||
public boolean isInLastTableColumn() { return bInLastTableColumn; }
|
||||
|
||||
public void setInSimpleTable(boolean bInSimpleTable) { this.bInSimpleTable = bInSimpleTable; }
|
||||
|
||||
public boolean isInSimpleTable() { return bInSimpleTable; }
|
||||
|
||||
public void setInMulticols(boolean bInMulticols) {
|
||||
this.bInMulticols = bInMulticols;
|
||||
}
|
||||
|
||||
public boolean isInMulticols() { return bInMulticols; }
|
||||
|
||||
public void setListLevel(int nListLevel) { this.nListLevel = nListLevel; }
|
||||
|
||||
public void incListLevel() { nListLevel++; }
|
||||
|
||||
public int getListLevel() { return nListLevel; }
|
||||
|
||||
public void setInSection(boolean bInSection) { this.bInSection = bInSection; }
|
||||
|
||||
public boolean isInSection() { return bInSection; }
|
||||
|
||||
public void setInCaption(boolean bInCaption) { this.bInCaption = bInCaption; }
|
||||
|
||||
public boolean isInCaption() { return bInCaption; }
|
||||
|
||||
public void setInFigureFloat(boolean bInFigureFloat) { this.bInFigureFloat = bInFigureFloat; }
|
||||
|
||||
public boolean isInFigureFloat() { return bInFigureFloat; }
|
||||
|
||||
public void setInTableFloat(boolean bInTableFloat) { this.bInTableFloat = bInTableFloat; }
|
||||
|
||||
public boolean isInTableFloat() { return bInTableFloat; }
|
||||
|
||||
public void setInFrame(boolean bInFrame) { this.bInFrame = bInFrame; }
|
||||
|
||||
public boolean isInFrame() { return bInFrame; }
|
||||
|
||||
public void setInFootnote(boolean bInFootnote) {
|
||||
this.bInFootnote = bInFootnote;
|
||||
}
|
||||
|
||||
public boolean isInFootnote() { return bInFootnote; }
|
||||
|
||||
public void setNoFootnotes(boolean bNoFootnotes) {
|
||||
this.bNoFootnotes = bNoFootnotes;
|
||||
}
|
||||
|
||||
public boolean isNoFootnotes() { return bNoFootnotes; }
|
||||
|
||||
public void setIgnoreLists(boolean bIgnoreLists) {
|
||||
this.bIgnoreLists = bIgnoreLists;
|
||||
}
|
||||
|
||||
public boolean isIgnoreLists() { return bIgnoreLists; }
|
||||
|
||||
public void setNoLineBreaks(boolean bNoLineBreaks) {
|
||||
this.bNoLineBreaks = bNoLineBreaks;
|
||||
}
|
||||
public boolean isNoLineBreaks() { return bNoLineBreaks; }
|
||||
|
||||
public boolean isVerbatim() { return bVerbatim; }
|
||||
|
||||
public void setVerbatim(boolean bVerbatim) { this.bVerbatim = bVerbatim; }
|
||||
|
||||
public boolean isMathMode() { return bMathMode; }
|
||||
|
||||
public void setMathMode(boolean bMathMode) { this.bMathMode = bMathMode; }
|
||||
|
||||
// update context
|
||||
|
||||
public void updateFormattingFromStyle(StyleWithProperties style) {
|
||||
String s;
|
||||
|
||||
if (style==null) { return; }
|
||||
|
||||
s = style.getProperty(XMLString.STYLE_FONT_NAME);
|
||||
if (s!=null) { setFontName(s); }
|
||||
|
||||
s = style.getProperty(XMLString.FO_FONT_STYLE);
|
||||
if (s!=null) { setFontStyle(s); }
|
||||
|
||||
s = style.getProperty(XMLString.FO_FONT_VARIANT);
|
||||
if (s!=null) { setFontVariant(s); }
|
||||
|
||||
s = style.getProperty(XMLString.FO_FONT_WEIGHT);
|
||||
if (s!=null) { setFontWeight(s); }
|
||||
|
||||
s = style.getProperty(XMLString.FO_FONT_SIZE);
|
||||
if (s!=null) { setFontSize(s); }
|
||||
|
||||
s = style.getProperty(XMLString.FO_COLOR);
|
||||
if (s!=null) { setFontColor(s); }
|
||||
|
||||
s = style.getProperty(XMLString.FO_LANGUAGE);
|
||||
if (s!=null) { setLang(s); }
|
||||
|
||||
s = style.getProperty(XMLString.FO_COUNTRY);
|
||||
if (s!=null) { setCountry(s); }
|
||||
}
|
||||
|
||||
public void resetFormattingFromStyle(StyleWithProperties style) {
|
||||
setFontName(null);
|
||||
setFontStyle(null);
|
||||
setFontVariant(null);
|
||||
setFontWeight(null);
|
||||
setFontSize(null);
|
||||
setFontColor(null);
|
||||
setLang(null);
|
||||
setCountry(null);
|
||||
updateFormattingFromStyle(style);
|
||||
}
|
||||
|
||||
|
||||
// clone this Context
|
||||
public Object clone() {
|
||||
Context newContext = new Context();
|
||||
|
||||
newContext.setListStyleName(sListStyleName);
|
||||
newContext.setBgColor(sBgColor);
|
||||
newContext.setFontName(sFontName);
|
||||
newContext.setFontStyle(sFontStyle);
|
||||
newContext.setFontVariant(sFontVariant);
|
||||
newContext.setFontWeight(sFontWeight);
|
||||
newContext.setFontSize(sFontSize);
|
||||
newContext.setFontColor(sFontColor);
|
||||
newContext.setLang(sLang);
|
||||
newContext.setCountry(sCountry);
|
||||
newContext.setInHeaderFooter(bInHeaderFooter);
|
||||
newContext.setInTable(bInTable);
|
||||
newContext.setInLastTableColumn(bInLastTableColumn);
|
||||
newContext.setInSimpleTable(bInSimpleTable);
|
||||
newContext.setInMulticols(bInMulticols);
|
||||
newContext.setListLevel(nListLevel);
|
||||
newContext.setInSection(bInSection);
|
||||
newContext.setInCaption(bInCaption);
|
||||
newContext.setInFigureFloat(bInFigureFloat);
|
||||
newContext.setInTableFloat(bInTableFloat);
|
||||
newContext.setInFrame(bInFrame);
|
||||
newContext.setInFootnote(bInFootnote);
|
||||
newContext.setVerbatim(bVerbatim);
|
||||
newContext.setMathMode(bMathMode);
|
||||
newContext.setNoFootnotes(bNoFootnotes);
|
||||
newContext.setIgnoreLists(bIgnoreLists);
|
||||
newContext.setNoLineBreaks(bNoLineBreaks);
|
||||
|
||||
return newContext;
|
||||
}
|
||||
|
||||
}
|
69
source/java/writer2latex/latex/util/HeadingMap.java
Normal file
69
source/java/writer2latex/latex/util/HeadingMap.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* HeadingMap.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2006 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 0.5 (2006-11-02)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.util;
|
||||
|
||||
/** This class contains data for the mapping of OOo headings to LaTeX headings.
|
||||
A LaTeX heading is characterized by a name and a level.
|
||||
The heading is inserted with \name{...} or \name[...]{...}
|
||||
The headings are supposed to be "normal" LaTeX headings,
|
||||
ie. the names are also counter names, and the headings
|
||||
can be reformatted using \@startsection etc.
|
||||
Otherwise max-level should be zero.
|
||||
*/
|
||||
public class HeadingMap {
|
||||
private int nMaxLevel;
|
||||
private String[] sName;
|
||||
private int[] nLevel;
|
||||
|
||||
/** Constructor: Create a new HeadingMap
|
||||
@param nMaxLevel the maximal level of headings that are mapped */
|
||||
public HeadingMap(int nMaxLevel) {
|
||||
reset(nMaxLevel);
|
||||
}
|
||||
|
||||
/** Clear all data associated with this HeadingMap (in order to reuse it) */
|
||||
public void reset(int nMaxLevel) {
|
||||
this.nMaxLevel = nMaxLevel;
|
||||
sName = new String[nMaxLevel+1];
|
||||
nLevel = new int[nMaxLevel+1];
|
||||
}
|
||||
|
||||
/** Set data associated with a specific heading level */
|
||||
public void setLevelData(int nWriterLevel, String sName, int nLevel) {
|
||||
this.sName[nWriterLevel] = sName;
|
||||
this.nLevel[nWriterLevel] = nLevel;
|
||||
}
|
||||
|
||||
/** Returns the maximal Writer level associated with this HeadingMap */
|
||||
public int getMaxLevel() { return nMaxLevel; }
|
||||
|
||||
/** Return the name (for counter and \@startsection) for this level */
|
||||
public String getName(int nWriterLevel) { return sName[nWriterLevel]; }
|
||||
|
||||
/** Return the LaTeX level for this Writer level (for \@startsection) */
|
||||
public int getLevel(int nWriterLevel) { return nLevel[nWriterLevel]; }
|
||||
}
|
76
source/java/writer2latex/latex/util/Info.java
Normal file
76
source/java/writer2latex/latex/util/Info.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* Info.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-09-08)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.util;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import writer2latex.latex.LaTeXConfig;
|
||||
import writer2latex.util.Misc;
|
||||
import writer2latex.office.OfficeReader;
|
||||
import writer2latex.office.StyleWithProperties;
|
||||
import writer2latex.office.XMLString;
|
||||
import writer2latex.latex.LaTeXDocumentPortion;
|
||||
import writer2latex.latex.ConverterHelper;
|
||||
import writer2latex.latex.ConverterPalette;
|
||||
|
||||
|
||||
/**
|
||||
* <p>This class creates various information to the user about the conversion.</p>
|
||||
*/
|
||||
public class Info extends ConverterHelper {
|
||||
|
||||
public Info(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
|
||||
super(ofr,config,palette);
|
||||
}
|
||||
|
||||
public void addDebugInfo(Element node, LaTeXDocumentPortion ldp) {
|
||||
if (config.debug()) {
|
||||
ldp.append("% ").append(node.getNodeName());
|
||||
addDebugInfo(node,ldp,XMLString.TEXT_ID);
|
||||
addDebugInfo(node,ldp,XMLString.TEXT_NAME);
|
||||
addDebugInfo(node,ldp,XMLString.TABLE_NAME);
|
||||
addDebugInfo(node,ldp,XMLString.TEXT_STYLE_NAME);
|
||||
if (node.getNodeName().equals(XMLString.TEXT_P) || node.getNodeName().equals(XMLString.TEXT_H)) {
|
||||
StyleWithProperties style = ofr.getParStyle(node.getAttribute(XMLString.TEXT_STYLE_NAME));
|
||||
if (style!=null && style.isAutomatic()) {
|
||||
ldp.append(" ("+style.getParentName()+")");
|
||||
}
|
||||
ldp.append(" ("+ofr.getParStyles().getDisplayName(node.getAttribute(XMLString.TEXT_STYLE_NAME))+")");
|
||||
}
|
||||
ldp.nl();
|
||||
}
|
||||
}
|
||||
|
||||
private void addDebugInfo(Element node, LaTeXDocumentPortion ldp, String sAttribute) {
|
||||
String sValue = Misc.getAttribute(node,sAttribute);
|
||||
if (sValue!=null) {
|
||||
ldp.append(" ").append(sAttribute).append("=\"").append(sValue).append("\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
11
source/java/writer2latex/latex/util/Package.html
Normal file
11
source/java/writer2latex/latex/util/Package.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>The package writer2latex.xhtml.util</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Some general utility classes for LaTeX export.</p>
|
||||
</body>
|
||||
</html>
|
99
source/java/writer2latex/latex/util/StyleMap.java
Normal file
99
source/java/writer2latex/latex/util/StyleMap.java
Normal file
|
@ -0,0 +1,99 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* StyleMap.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2007 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2007-07-30)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.util;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class StyleMap {
|
||||
private Hashtable items = new Hashtable();
|
||||
|
||||
public void put(String sName, String sBefore, String sAfter, boolean bLineBreak, boolean bVerbatim) {
|
||||
StyleMapItem item = new StyleMapItem();
|
||||
item.sBefore = sBefore;
|
||||
item.sAfter = sAfter;
|
||||
item.sNext = ";;";
|
||||
item.bLineBreak = bLineBreak;
|
||||
item.bVerbatim = bVerbatim;
|
||||
items.put(sName,item);
|
||||
}
|
||||
|
||||
public void put(String sName, String sBefore, String sAfter, String sNext, boolean bVerbatim) {
|
||||
StyleMapItem item = new StyleMapItem();
|
||||
item.sBefore = sBefore;
|
||||
item.sAfter = sAfter;
|
||||
item.sNext = ";"+sNext+";";
|
||||
item.bLineBreak = true;
|
||||
item.bVerbatim = bVerbatim;
|
||||
items.put(sName,item);
|
||||
}
|
||||
|
||||
public void put(String sName, String sBefore, String sAfter) {
|
||||
StyleMapItem item = new StyleMapItem();
|
||||
item.sBefore = sBefore;
|
||||
item.sAfter = sAfter;
|
||||
item.sNext = ";;";
|
||||
item.bLineBreak = true;
|
||||
item.bVerbatim = false;
|
||||
items.put(sName,item);
|
||||
}
|
||||
|
||||
public boolean contains(String sName) {
|
||||
return sName!=null && items.containsKey(sName);
|
||||
}
|
||||
|
||||
public String getBefore(String sName) {
|
||||
return ((StyleMapItem) items.get(sName)).sBefore;
|
||||
}
|
||||
|
||||
public String getAfter(String sName) {
|
||||
return ((StyleMapItem) items.get(sName)).sAfter;
|
||||
}
|
||||
|
||||
public String getNext(String sName) {
|
||||
String sNext = ((StyleMapItem) items.get(sName)).sNext;
|
||||
return sNext.substring(1,sNext.length()-1);
|
||||
}
|
||||
|
||||
public boolean isNext(String sName, String sNext) {
|
||||
String sNext1 = ((StyleMapItem) items.get(sName)).sNext;
|
||||
return sNext1.indexOf(";"+sNext+";")>-1;
|
||||
}
|
||||
|
||||
public boolean getLineBreak(String sName) {
|
||||
return contains(sName) && ((StyleMapItem) items.get(sName)).bLineBreak;
|
||||
}
|
||||
|
||||
public boolean getVerbatim(String sName) {
|
||||
return contains(sName) && ((StyleMapItem) items.get(sName)).bVerbatim;
|
||||
}
|
||||
|
||||
public Enumeration getNames() {
|
||||
return items.keys();
|
||||
}
|
||||
|
||||
}
|
36
source/java/writer2latex/latex/util/StyleMapItem.java
Normal file
36
source/java/writer2latex/latex/util/StyleMapItem.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* StyleMapItem.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2007 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2007-07-30)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.util;
|
||||
|
||||
// A struct to hold data about a style map
|
||||
class StyleMapItem {
|
||||
String sBefore;
|
||||
String sAfter;
|
||||
String sNext;
|
||||
boolean bLineBreak;
|
||||
boolean bVerbatim;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue