Removed spreedshet and presentation code
This commit is contained in:
parent
8f56208024
commit
7348278676
8 changed files with 104 additions and 194 deletions
|
@ -281,7 +281,7 @@ public class Converter extends BasicConverter {
|
|||
mathParser = new MathParser(ofr,config,this,nType!=XhtmlDocument.XHTML10 && nType!=XhtmlDocument.XHTML11);
|
||||
|
||||
// Set locale to document language
|
||||
StyleWithProperties style = ofr.isSpreadsheet() ? ofr.getDefaultCellStyle() : ofr.getDefaultParStyle();
|
||||
StyleWithProperties style = ofr.getDefaultParStyle();
|
||||
if (style!=null) {
|
||||
// The only CTL language recognized currently is farsi
|
||||
if ("fa".equals(style.getProperty(XMLString.STYLE_LANGUAGE_COMPLEX))) {
|
||||
|
@ -297,9 +297,8 @@ public class Converter extends BasicConverter {
|
|||
|
||||
// Traverse the body
|
||||
Element body = ofr.getContent();
|
||||
if (ofr.isSpreadsheet()) { tableParser.convertTableContent(body); }
|
||||
else if (ofr.isPresentation()) { drawParser.convertDrawContent(body); }
|
||||
else { textParser.convertDocumentContent(body); }
|
||||
|
||||
textParser.convertDocumentContent(body);
|
||||
|
||||
// Set the title page and text page entries
|
||||
if (converterResult.getContent().isEmpty()) {
|
||||
|
@ -376,145 +375,98 @@ public class Converter extends BasicConverter {
|
|||
}
|
||||
}
|
||||
|
||||
// Create headers & footers (if nodes are available)
|
||||
if (ofr.isSpreadsheet()) {
|
||||
for (int i=0; i<=outFileIndex; i++) {
|
||||
// Create headers & footers (if nodes are available)
|
||||
if (outFileIndex > 0) {
|
||||
for (int i = 0; i <= outFileIndex; i++) {
|
||||
XhtmlDocument doc = outFiles.get(i);
|
||||
Document dom = doc.getContentDOM();
|
||||
// Element content = doc.getContentNode();
|
||||
|
||||
XhtmlDocument doc = outFiles.get(i);
|
||||
Document dom = doc.getContentDOM();
|
||||
Element header = doc.getHeaderNode();
|
||||
Element footer = doc.getFooterNode();
|
||||
Element headerPar = dom.createElement("p");
|
||||
Element footerPar = dom.createElement("p");
|
||||
footerPar.setAttribute("style","clear:both"); // no floats may pass!
|
||||
// Header links
|
||||
Element header = doc.getHeaderNode();
|
||||
if (header != null) {
|
||||
if (config.getXhtmlUplink().length() > 0) {
|
||||
Element a = dom.createElement("a");
|
||||
a.setAttribute("href", config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
header.appendChild(a);
|
||||
header.appendChild(dom.createTextNode(" "));
|
||||
}
|
||||
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), outFileIndex);
|
||||
if (textParser.getTocIndex() >= 0) {
|
||||
addNavigationLink(dom, header, l10n.get(L10n.CONTENTS), textParser.getTocIndex());
|
||||
}
|
||||
if (textParser.getAlphabeticalIndex() >= 0) {
|
||||
addNavigationLink(dom, header, l10n.get(L10n.INDEX), textParser.getAlphabeticalIndex());
|
||||
}
|
||||
}
|
||||
|
||||
// Add uplink
|
||||
if (config.getXhtmlUplink().length()>0) {
|
||||
Element a = dom.createElement("a");
|
||||
a.setAttribute("href",config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
headerPar.appendChild(a);
|
||||
headerPar.appendChild(dom.createTextNode(" "));
|
||||
a = dom.createElement("a");
|
||||
a.setAttribute("href",config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
footerPar.appendChild(a);
|
||||
footerPar.appendChild(dom.createTextNode(" "));
|
||||
}
|
||||
// Add links to all sheets:
|
||||
int nSheets = tableParser.sheetNames.size();
|
||||
for (int j=0; j<nSheets; j++) {
|
||||
if (config.xhtmlCalcSplit()) {
|
||||
addNavigationLink(dom,headerPar,tableParser.sheetNames.get(j),j);
|
||||
addNavigationLink(dom,footerPar,tableParser.sheetNames.get(j),j);
|
||||
}
|
||||
else {
|
||||
addInternalNavigationLink(dom,headerPar,tableParser.sheetNames.get(j),"tableheading"+j);
|
||||
addInternalNavigationLink(dom,footerPar,tableParser.sheetNames.get(j),"tableheading"+j);
|
||||
}
|
||||
}
|
||||
// Footer links
|
||||
Element footer = doc.getFooterNode();
|
||||
if (footer != null) {
|
||||
// No footer in presentations
|
||||
if (config.getXhtmlUplink().length() > 0) {
|
||||
Element a = dom.createElement("a");
|
||||
a.setAttribute("href", config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
footer.appendChild(a);
|
||||
footer.appendChild(dom.createTextNode(" "));
|
||||
}
|
||||
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), outFileIndex);
|
||||
if (textParser.getTocIndex() >= 0) {
|
||||
addNavigationLink(dom, footer, l10n.get(L10n.CONTENTS), textParser.getTocIndex());
|
||||
}
|
||||
if (textParser.getAlphabeticalIndex() >= 0) {
|
||||
addNavigationLink(dom, footer, l10n.get(L10n.INDEX), textParser.getAlphabeticalIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (config.getXhtmlUplink().length() > 0) {
|
||||
for (int i = 0; i <= outFileIndex; i++) {
|
||||
XhtmlDocument doc = outFiles.get(i);
|
||||
Document dom = doc.getContentDOM();
|
||||
// Element content = doc.getContentNode();
|
||||
|
||||
if (header!=null) { header.appendChild(headerPar); }
|
||||
if (footer!=null) { footer.appendChild(footerPar); }
|
||||
}
|
||||
}
|
||||
else if (outFileIndex>0) {
|
||||
for (int i=0; i<=outFileIndex; i++) {
|
||||
XhtmlDocument doc = outFiles.get(i);
|
||||
Document dom = doc.getContentDOM();
|
||||
//Element content = doc.getContentNode();
|
||||
Element header = doc.getHeaderNode();
|
||||
if (header != null) {
|
||||
Element a = dom.createElement("a");
|
||||
a.setAttribute("href", config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
header.appendChild(a);
|
||||
header.appendChild(dom.createTextNode(" "));
|
||||
}
|
||||
|
||||
// Header links
|
||||
Element header = doc.getHeaderNode();
|
||||
if (header!=null) {
|
||||
if (ofr.isPresentation()) {
|
||||
// Absolute placement in presentations (quick and dirty solution)
|
||||
header.setAttribute("style","position:absolute;top:0;left:0");
|
||||
}
|
||||
if (config.getXhtmlUplink().length()>0) {
|
||||
Element a = dom.createElement("a");
|
||||
a.setAttribute("href",config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
header.appendChild(a);
|
||||
header.appendChild(dom.createTextNode(" "));
|
||||
}
|
||||
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),outFileIndex);
|
||||
if (textParser.getTocIndex()>=0) {
|
||||
addNavigationLink(dom,header,l10n.get(L10n.CONTENTS),textParser.getTocIndex());
|
||||
}
|
||||
if (textParser.getAlphabeticalIndex()>=0) {
|
||||
addNavigationLink(dom,header,l10n.get(L10n.INDEX),textParser.getAlphabeticalIndex());
|
||||
}
|
||||
}
|
||||
Element footer = doc.getFooterNode();
|
||||
if (footer != null) {
|
||||
Element a = dom.createElement("a");
|
||||
a.setAttribute("href", config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
footer.appendChild(a);
|
||||
footer.appendChild(dom.createTextNode(" "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Footer links
|
||||
Element footer = doc.getFooterNode();
|
||||
if (footer!=null && !ofr.isPresentation()) {
|
||||
// No footer in presentations
|
||||
if (config.getXhtmlUplink().length()>0) {
|
||||
Element a = dom.createElement("a");
|
||||
a.setAttribute("href",config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
footer.appendChild(a);
|
||||
footer.appendChild(dom.createTextNode(" "));
|
||||
}
|
||||
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),outFileIndex);
|
||||
if (textParser.getTocIndex()>=0) {
|
||||
addNavigationLink(dom,footer,l10n.get(L10n.CONTENTS),textParser.getTocIndex());
|
||||
}
|
||||
if (textParser.getAlphabeticalIndex()>=0) {
|
||||
addNavigationLink(dom,footer,l10n.get(L10n.INDEX),textParser.getAlphabeticalIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (config.getXhtmlUplink().length()>0) {
|
||||
for (int i=0; i<=outFileIndex; i++) {
|
||||
XhtmlDocument doc = outFiles.get(i);
|
||||
Document dom = doc.getContentDOM();
|
||||
//Element content = doc.getContentNode();
|
||||
// Export styles
|
||||
if (config.xhtmlFormatting() > XhtmlConfig.IGNORE_STYLES) {
|
||||
if (isOPS()) { // EPUB
|
||||
CssDocument cssDoc = new CssDocument(EPUB_STYLESHEET);
|
||||
cssDoc.read(styles.allStyleSelectors(false));
|
||||
converterResult.addDocument(cssDoc);
|
||||
} else if (config.separateStylesheet()) { // XHTML
|
||||
CssDocument cssDoc = new CssDocument(sTargetFileName + "-styles.css");
|
||||
cssDoc.read(styles.allStyleSelectors(false));
|
||||
converterResult.addDocument(cssDoc);
|
||||
}
|
||||
}
|
||||
|
||||
Element header = doc.getHeaderNode();
|
||||
if (header!=null) {
|
||||
Element a = dom.createElement("a");
|
||||
a.setAttribute("href",config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
header.appendChild(a);
|
||||
header.appendChild(dom.createTextNode(" "));
|
||||
}
|
||||
|
||||
Element footer = doc.getFooterNode();
|
||||
if (footer!=null) {
|
||||
Element a = dom.createElement("a");
|
||||
a.setAttribute("href",config.getXhtmlUplink());
|
||||
a.appendChild(dom.createTextNode(l10n.get(L10n.UP)));
|
||||
footer.appendChild(a);
|
||||
footer.appendChild(dom.createTextNode(" "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Export styles
|
||||
if (config.xhtmlFormatting()>XhtmlConfig.IGNORE_STYLES) {
|
||||
if (isOPS()) { // EPUB
|
||||
CssDocument cssDoc = new CssDocument(EPUB_STYLESHEET);
|
||||
cssDoc.read(styles.allStyleSelectors(false));
|
||||
converterResult.addDocument(cssDoc);
|
||||
}
|
||||
else if (config.separateStylesheet()) { // XHTML
|
||||
CssDocument cssDoc = new CssDocument(sTargetFileName+"-styles.css");
|
||||
cssDoc.read(styles.allStyleSelectors(false));
|
||||
converterResult.addDocument(cssDoc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void addNavigationLink(Document dom, Node node, String s, int nIndex) {
|
||||
if (nIndex>=0 && nIndex<=outFileIndex) {
|
||||
|
@ -681,13 +633,12 @@ public class Converter extends BasicConverter {
|
|||
return rootElement;
|
||||
}
|
||||
|
||||
private void applyWritingDirection() {
|
||||
if (!ofr.isPresentation()) {
|
||||
StyleInfo pageInfo = new StyleInfo();
|
||||
styles.getPageSc().applyDefaultWritingDirection(pageInfo);
|
||||
styles.getPageSc().writeStyle(pageInfo,htmlDoc.getContentNode());
|
||||
}
|
||||
}
|
||||
private void applyWritingDirection() {
|
||||
StyleInfo pageInfo = new StyleInfo();
|
||||
styles.getPageSc().applyDefaultWritingDirection(pageInfo);
|
||||
styles.getPageSc().writeStyle(pageInfo, htmlDoc.getContentNode());
|
||||
|
||||
}
|
||||
|
||||
private void addHeadData() {
|
||||
Element head = htmlDoc.getHeadNode();
|
||||
|
|
|
@ -116,8 +116,6 @@ public class DrawParser extends Parser {
|
|||
|
||||
// Frames in spreadsheet documents are collected here
|
||||
private Vector<Element> frames = new Vector<Element>();
|
||||
// This flag determines whether to collect frames or insert them immediately
|
||||
private boolean bCollectFrames = false;
|
||||
|
||||
// Large images (for full screen) in EPUB export are collected here
|
||||
private Vector<Element> fullscreenFrames = new Vector<Element>();
|
||||
|
@ -132,7 +130,6 @@ public class DrawParser extends Parser {
|
|||
if (formsIterator.hasNext() && config.getXhtmlSplitLevel()==0) {
|
||||
form = formsIterator.next();
|
||||
}
|
||||
bCollectFrames = ofr.isSpreadsheet();
|
||||
bCollectFullscreenFrames = true;
|
||||
sScale = config.getXhtmlScaling();
|
||||
bConvertToPx = config.xhtmlConvertToPx();
|
||||
|
@ -291,13 +288,11 @@ public class DrawParser extends Parser {
|
|||
}
|
||||
|
||||
public void flushFrames(Element hnode) {
|
||||
bCollectFrames = false;
|
||||
int nCount = frames.size();
|
||||
for (int i=0; i<nCount; i++) {
|
||||
handleDrawElement(frames.get(i),hnode,null,CENTERED);
|
||||
}
|
||||
frames.clear();
|
||||
bCollectFrames = true;
|
||||
}
|
||||
|
||||
/** <p>Convert a draw element to xhtml. The presentation depends on the
|
||||
|
@ -320,10 +315,6 @@ public class DrawParser extends Parser {
|
|||
* @param nMode identifies how the element should be presented
|
||||
*/
|
||||
public void handleDrawElement(Element onode, Element hnodeBlock, Element hnodeInline, int nMode) {
|
||||
if (bCollectFrames) {
|
||||
frames.add(onode);
|
||||
return;
|
||||
}
|
||||
String sName = onode.getNodeName();
|
||||
if (sName.equals(XMLString.DRAW_OBJECT)) {
|
||||
handleDrawObject(onode,hnodeBlock,hnodeInline,nMode);
|
||||
|
|
|
@ -168,11 +168,6 @@ public class TableParser extends Parser {
|
|||
|
||||
// Create view (full table)
|
||||
TableRange range = new TableRange(tblr);
|
||||
if (ofr.isSpreadsheet()) {
|
||||
// skip trailing empty rows and columns
|
||||
range.setLastRow(tblr.getMaxRowCount()-1);
|
||||
range.setLastCol(tblr.getMaxColCount()-1);
|
||||
}
|
||||
range.setIncludeHidden(config.displayHiddenRowsCols());
|
||||
range.setIncludeFiltered(config.displayFilteredRowsCols());
|
||||
traverseTable(range.createTableView(),table);
|
||||
|
@ -377,8 +372,6 @@ public class TableParser extends Parser {
|
|||
|
||||
//info.props.addValue("empty-cells","show"); use instead...
|
||||
|
||||
if (ofr.isSpreadsheet()) { info.props.addProperty("white-space","nowrap"); }
|
||||
|
||||
if (bIsSubTable) {
|
||||
// Should try to fill the cell; hence:
|
||||
info.props.addProperty("width","100%");
|
||||
|
@ -448,13 +441,6 @@ public class TableParser extends Parser {
|
|||
info.props.addProperty("width",Calc.sub(getTableSc().colScale(sTotalWidth),sEdge));
|
||||
}
|
||||
}
|
||||
|
||||
// Automatic horizontal alignment (calc only)
|
||||
if (ofr.isSpreadsheet() && !"fix".equals(style.getProperty(XMLString.STYLE_TEXT_ALIGN_SOURCE))) {
|
||||
// Strings go left, other types (float, time, date, percentage, currency, boolean) go right
|
||||
// The default is string
|
||||
info.props.addProperty("text-align", sValueType==null || "string".equals(sValueType) ? "left" : "right");
|
||||
}
|
||||
}
|
||||
|
||||
if (!cell.hasChildNodes()) { // hack to handle empty cells even in msie
|
||||
|
|
|
@ -652,17 +652,13 @@ public class TextParser extends Parser {
|
|||
if (!displayHiddenText && style!=null && "none".equals(style.getProperty(TEXT_DISPLAY))) { return; }
|
||||
|
||||
Element par;
|
||||
if (ofr.isSpreadsheet()) { // attach inline text directly to parent (always a table cell)
|
||||
par = (Element) hnode;
|
||||
}
|
||||
else {
|
||||
// Hack because createParagraph doesn't work the way we need here :-(
|
||||
Element temp = converter.createElement("temp");
|
||||
par = createParagraph(temp, styleName);
|
||||
prependAsapNode(par);
|
||||
traverseFloats(onode,hnode,par);
|
||||
hnode.appendChild(temp.getFirstChild());
|
||||
}
|
||||
|
||||
// Hack because createParagraph doesn't work the way we need here :-(
|
||||
Element temp = converter.createElement("temp");
|
||||
par = createParagraph(temp, styleName);
|
||||
prependAsapNode(par);
|
||||
traverseFloats(onode, hnode, par);
|
||||
hnode.appendChild(temp.getFirstChild());
|
||||
|
||||
// Maybe add to toc
|
||||
tocParser.handleParagraph((Element)onode, par, sCurrentListLabel);
|
||||
|
|
|
@ -100,7 +100,7 @@ public class CellStyleParser extends StyleWithPropertiesParser {
|
|||
// No value or "automatic" means, according to the spec,
|
||||
//"The application decide how to align the text."
|
||||
// We treat this case like OOo does:
|
||||
props.addProperty("vertical-align", ofr.isSpreadsheet() ? "bottom" : "top");
|
||||
props.addProperty("vertical-align", "top");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,11 +127,6 @@ public class PageStyleParser extends StyleParser {
|
|||
MasterPage masterPage = ofr.getMasterPage(sStyleName);
|
||||
if (masterPage!=null) {
|
||||
String sDisplayName = masterPage.getDisplayName();
|
||||
if (ofr.isPresentation()) {
|
||||
// Always generates class name
|
||||
styleNames.addName(sDisplayName);
|
||||
info.sClass="masterpage"+styleNames.getName(sDisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,13 +159,6 @@ public class ParStyleParser extends StyleWithPropertiesParser {
|
|||
else if (s.equals("end")) { s="right"; }
|
||||
props.addProperty("text-align",s);
|
||||
}
|
||||
|
||||
// Wrap (only in table cells, only in spreadsheets):
|
||||
if (ofr.isSpreadsheet()) {
|
||||
s = style.getProperty(XMLString.FO_WRAP_OPTION,bInherit);
|
||||
if ("no-wrap".equals(s)) props.addProperty("white-space","nowrap");
|
||||
else if ("wrap".equals(s)) props.addProperty("white-space","normal");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -219,9 +219,7 @@ public class Styles extends Parser {
|
|||
}
|
||||
|
||||
private StyleWithProperties getDefaultStyle() {
|
||||
if (ofr.isSpreadsheet()) return ofr.getDefaultCellStyle();
|
||||
else if (ofr.isPresentation()) return ofr.getDefaultFrameStyle();
|
||||
else return ofr.getDefaultParStyle();
|
||||
return ofr.getDefaultParStyle();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue