Various work...
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@51 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
5311ac0b6b
commit
144b59f561
15 changed files with 368 additions and 126 deletions
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-11-23)
|
||||
* Version 1.2 (2010-03-12)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -179,7 +179,9 @@ public class ParConverter extends StyleConverter {
|
|||
|
||||
// Add newline if *between* paragraphs
|
||||
if (!bLastInBlock) { ba.add("","\n"); }
|
||||
|
||||
|
||||
context.setVerbatim(false);
|
||||
|
||||
if (context.isInSimpleTable()) {
|
||||
if (config.formatting()!=LaTeXConfig.IGNORE_ALL) {
|
||||
// only character formatting!
|
||||
|
@ -191,6 +193,20 @@ public class ParConverter extends StyleConverter {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (config.getParStyleMap().contains(ofr.getParStyles().getDisplayName(sName))) {
|
||||
// We have a style map in the configuration
|
||||
StyleMap sm = config.getParStyleMap();
|
||||
String sDisplayName = ofr.getParStyles().getDisplayName(sName);
|
||||
String sBefore = sm.getBefore(sDisplayName);
|
||||
String sAfter = sm.getAfter(sDisplayName);
|
||||
ba.add(sBefore, sAfter);
|
||||
// Add line breaks inside?
|
||||
if (sm.getLineBreak(sDisplayName)) {
|
||||
if (sBefore.length()>0) { ba.add("\n",""); }
|
||||
if (sAfter.length()>0 && !"}".equals(sAfter)) { ba.add("","\n"); }
|
||||
}
|
||||
if (sm.getVerbatim(sDisplayName)) { context.setVerbatim(true); }
|
||||
}
|
||||
else if (bNoTextPar && (config.formatting()==LaTeXConfig.CONVERT_BASIC || config.formatting()==LaTeXConfig.IGNORE_MOST) ) {
|
||||
// only alignment!
|
||||
StyleWithProperties style = ofr.getParStyle(sName);
|
||||
|
@ -251,7 +267,6 @@ public class ParConverter extends StyleConverter {
|
|||
StyleWithProperties style = ofr.getParStyle(sName);
|
||||
if (style==null) { return; }
|
||||
context.updateFormattingFromStyle(style);
|
||||
context.setVerbatim(styleMap.getVerbatim(sName));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-12-15)
|
||||
* Version 1.2 (2010-03-12)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -40,6 +40,7 @@ import org.w3c.dom.NodeList;
|
|||
import org.w3c.dom.Element;
|
||||
|
||||
import writer2latex.util.Misc;
|
||||
import writer2latex.office.FontDeclaration;
|
||||
import writer2latex.office.XMLString;
|
||||
import writer2latex.office.IndexMark;
|
||||
import writer2latex.office.ListCounter;
|
||||
|
@ -1725,7 +1726,86 @@ public class TextConverter extends ConverterHelper {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// UTILITY METHODS
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Methods to query individual formatting properties (no inheritance)
|
||||
|
||||
// Does this style contain the bold attribute?
|
||||
private boolean isBold(StyleWithProperties style) {
|
||||
String s = style.getProperty(XMLString.FO_FONT_WEIGHT,false);
|
||||
return s!=null && "bold".equals(s);
|
||||
}
|
||||
|
||||
// Does this style contain the italics/oblique attribute?
|
||||
private boolean isItalics(StyleWithProperties style) {
|
||||
String s = style.getProperty(XMLString.FO_FONT_STYLE,false);
|
||||
return s!=null && !"normal".equals(s);
|
||||
}
|
||||
|
||||
// Does this style contain a fixed pitch font?
|
||||
private boolean isFixed(StyleWithProperties style) {
|
||||
String s = style.getProperty(XMLString.STYLE_FONT_NAME,false);
|
||||
String s2 = null;
|
||||
String s3 = null;
|
||||
if (s!=null) {
|
||||
FontDeclaration fd = (FontDeclaration) ofr.getFontDeclarations().getStyle(s);
|
||||
if (fd!=null) {
|
||||
s2 = fd.getFontFamilyGeneric();
|
||||
s3 = fd.getFontPitch();
|
||||
}
|
||||
}
|
||||
else {
|
||||
s = style.getProperty(XMLString.FO_FONT_FAMILY,false);
|
||||
s2 = style.getProperty(XMLString.STYLE_FONT_FAMILY_GENERIC,false);
|
||||
s3 = style.getProperty(XMLString.STYLE_FONT_PITCH,false);
|
||||
}
|
||||
if ("fixed".equals(s3)) { return true; }
|
||||
if ("modern".equals(s2)) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
// Does this style specify superscript?
|
||||
private boolean isSuperscript(StyleWithProperties style) {
|
||||
String sPos = style.getProperty(XMLString.STYLE_TEXT_POSITION,false);
|
||||
if (sPos==null) return false;
|
||||
if (sPos.startsWith("sub")) return false;
|
||||
if (sPos.startsWith("-")) return false;
|
||||
if (sPos.startsWith("0%")) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Does this style specify subscript?
|
||||
private boolean isSubscript(StyleWithProperties style) {
|
||||
String sPos = style.getProperty(XMLString.STYLE_TEXT_POSITION,false);
|
||||
if (sPos==null) return false;
|
||||
if (sPos.startsWith("sub")) return true;
|
||||
if (sPos.startsWith("-")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Does this style specify underline?
|
||||
private boolean isUnderline(StyleWithProperties style) {
|
||||
String s;
|
||||
if (ofr.isOpenDocument()) {
|
||||
s = style.getProperty(XMLString.STYLE_TEXT_UNDERLINE_STYLE,false);
|
||||
}
|
||||
else {
|
||||
s = style.getProperty(XMLString.STYLE_TEXT_UNDERLINE,false);
|
||||
}
|
||||
return s!=null && !"none".equals(s);
|
||||
}
|
||||
|
||||
// Does this style specify overstrike?
|
||||
private boolean isOverstrike(StyleWithProperties style) {
|
||||
String s;
|
||||
if (ofr.isOpenDocument()) {
|
||||
s = style.getProperty(XMLString.STYLE_TEXT_LINE_THROUGH_STYLE,false);
|
||||
}
|
||||
else {
|
||||
s = style.getProperty(XMLString.STYLE_TEXT_CROSSING_OUT,false);
|
||||
}
|
||||
return s!=null && !"none".equals(s);
|
||||
}
|
||||
|
||||
/* apply hard formatting attribute style maps */
|
||||
private Element applyAttributes(Element node, StyleWithProperties style) {
|
||||
// Do nothing if we convert hard formatting
|
||||
|
@ -1733,11 +1813,13 @@ public class TextConverter extends ConverterHelper {
|
|||
// Do nothing if this is not an automatic style
|
||||
if (style==null) { return node; }
|
||||
if (!style.isAutomatic()) { return node; }
|
||||
node = applyAttribute(node,"bold",getTextSc().isBold(style));
|
||||
node = applyAttribute(node,"italics",getTextSc().isItalics(style));
|
||||
node = applyAttribute(node,"fixed",getTextSc().isFixed(style));
|
||||
node = applyAttribute(node,"superscript",getTextSc().isSuperscript(style));
|
||||
node = applyAttribute(node,"subscript",getTextSc().isSubscript(style));
|
||||
node = applyAttribute(node,"bold",isBold(style));
|
||||
node = applyAttribute(node,"italics",isItalics(style));
|
||||
node = applyAttribute(node,"fixed",isFixed(style));
|
||||
node = applyAttribute(node,"superscript",isSuperscript(style));
|
||||
node = applyAttribute(node,"subscript",isSubscript(style));
|
||||
node = applyAttribute(node,"underline",isUnderline(style));
|
||||
node = applyAttribute(node,"overstrike",isOverstrike(style));
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-02-14)
|
||||
* Version 1.2 (2010-03-12)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -198,61 +198,6 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper {
|
|||
cssText(style,props,bInherit);
|
||||
}
|
||||
|
||||
// Methods to query individual formatting properties (no inheritance)
|
||||
|
||||
// Does this style contain the bold attribute?
|
||||
public boolean isBold(StyleWithProperties style) {
|
||||
String s = style.getProperty(XMLString.FO_FONT_WEIGHT,false);
|
||||
return s!=null && "bold".equals(s);
|
||||
}
|
||||
|
||||
// Does this style contain the italics/oblique attribute?
|
||||
public boolean isItalics(StyleWithProperties style) {
|
||||
String s = style.getProperty(XMLString.FO_FONT_STYLE,false);
|
||||
return s!=null && !"normal".equals(s);
|
||||
}
|
||||
|
||||
// Does this style contain a fixed pitch font?
|
||||
public boolean isFixed(StyleWithProperties style) {
|
||||
String s = style.getProperty(XMLString.STYLE_FONT_NAME,false);
|
||||
String s2 = null;
|
||||
String s3 = null;
|
||||
if (s!=null) {
|
||||
FontDeclaration fd = (FontDeclaration) ofr.getFontDeclarations().getStyle(s);
|
||||
if (fd!=null) {
|
||||
s2 = fd.getFontFamilyGeneric();
|
||||
s3 = fd.getFontPitch();
|
||||
}
|
||||
}
|
||||
else {
|
||||
s = style.getProperty(XMLString.FO_FONT_FAMILY,false);
|
||||
s2 = style.getProperty(XMLString.STYLE_FONT_FAMILY_GENERIC,false);
|
||||
s3 = style.getProperty(XMLString.STYLE_FONT_PITCH,false);
|
||||
}
|
||||
if ("fixed".equals(s3)) { return true; }
|
||||
if ("modern".equals(s2)) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
// Does this style specify superscript?
|
||||
public boolean isSuperscript(StyleWithProperties style) {
|
||||
String sPos = style.getProperty(XMLString.STYLE_TEXT_POSITION,false);
|
||||
if (sPos==null) return false;
|
||||
if (sPos.startsWith("sub")) return false;
|
||||
if (sPos.startsWith("-")) return false;
|
||||
if (sPos.startsWith("0%")) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Does this style specify subscript?
|
||||
public boolean isSubscript(StyleWithProperties style) {
|
||||
String sPos = style.getProperty(XMLString.STYLE_TEXT_POSITION,false);
|
||||
if (sPos==null) return false;
|
||||
if (sPos.startsWith("sub")) return true;
|
||||
if (sPos.startsWith("-")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// OpenDocument text properties
|
||||
// Text properties can be applied to text, paragraph, cell, graphic and
|
||||
|
|
|
@ -292,7 +292,7 @@ public class XhtmlDocument extends DOMDocument {
|
|||
|
||||
String[] sTemplateIds = config.templateIds().split(",");
|
||||
int nIdCount = sTemplateIds.length;
|
||||
if (nIdCount>0) sContentId = sTemplateIds[0].trim(); else sContentId = "content";
|
||||
if (nIdCount>0 && sTemplateIds[0].trim().length()>0) sContentId = sTemplateIds[0].trim(); else sContentId = "content";
|
||||
if (nIdCount>1) sHeaderId = sTemplateIds[1].trim(); else sHeaderId = "header";
|
||||
if (nIdCount>2) sFooterId = sTemplateIds[2].trim(); else sFooterId = "footer";
|
||||
if (nIdCount>3) sPanelId = sTemplateIds[3].trim(); else sPanelId = "panel";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue