incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r1181600 - in /incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple: common/field/DateField.java common/field/TimeField.java common/navigation/TextSelection.java table/Table.java text/Footer.java text/Header.java text/Paragraph.java
Date Tue, 11 Oct 2011 02:24:31 GMT
Author: devinhan
Date: Tue Oct 11 02:24:30 2011
New Revision: 1181600

URL: http://svn.apache.org/viewvc?rev=1181600&view=rev
Log:
#ODFTOOLKIT-291# Adapt Simple API to the newest ODFDOM trunk.[Developer:Devin]

Modified:
    incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/DateField.java
    incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/TimeField.java
    incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/navigation/TextSelection.java
    incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/table/Table.java
    incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Footer.java
    incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Header.java
    incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Paragraph.java

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/DateField.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/DateField.java?rev=1181600&r1=1181599&r2=1181600&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/DateField.java
(original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/DateField.java
Tue Oct 11 02:24:30 2011
@@ -26,6 +26,8 @@ import java.util.Date;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.odftoolkit.odfdom.dom.OdfContentDom;
+import org.odftoolkit.odfdom.dom.OdfStylesDom;
 import org.odftoolkit.odfdom.dom.element.text.TextDateElement;
 import org.odftoolkit.odfdom.dom.element.text.TextSpanElement;
 import org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle;
@@ -90,7 +92,12 @@ public class DateField extends Field {
 			SimpleDateFormat newFormat = new SimpleDateFormat(formatString);
 			dateElement.setTextContent(newFormat.format(simpleDate));
 			OdfFileDom dom = (OdfFileDom) dateElement.getOwnerDocument();
-			OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+			OdfOfficeAutomaticStyles styles = null;
+			if (dom instanceof OdfContentDom) {
+				styles = ((OdfContentDom) dom).getAutomaticStyles();
+			} else if (dom instanceof OdfStylesDom) {
+				styles = ((OdfStylesDom) dom).getAutomaticStyles();
+			}
 			OdfNumberDateStyle dataStyle = styles.getDateStyle(dateElement.getStyleDataStyleNameAttribute());
 			dataStyle.buildFromFormat(formatString);
 		} catch (ParseException e) {
@@ -122,7 +129,12 @@ public class DateField extends Field {
 	// Create an <code>OdfNumberDateStyle</code> element
 	private OdfNumberDateStyle newDateStyle() {
 		OdfFileDom dom = (OdfFileDom) dateElement.getOwnerDocument();
-		OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+		OdfOfficeAutomaticStyles styles = null;
+		if (dom instanceof OdfContentDom) {
+			styles = ((OdfContentDom) dom).getAutomaticStyles();
+		} else if (dom instanceof OdfStylesDom) {
+			styles = ((OdfStylesDom) dom).getAutomaticStyles();
+		}
 		OdfNumberDateStyle newStyle = dom.newOdfElement(OdfNumberDateStyle.class);
 		newStyle.setStyleNameAttribute(newUniqueStyleName(styles));
 		styles.appendChild(newStyle);

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/TimeField.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/TimeField.java?rev=1181600&r1=1181599&r2=1181600&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/TimeField.java
(original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/field/TimeField.java
Tue Oct 11 02:24:30 2011
@@ -26,6 +26,8 @@ import java.util.Date;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.odftoolkit.odfdom.dom.OdfContentDom;
+import org.odftoolkit.odfdom.dom.OdfStylesDom;
 import org.odftoolkit.odfdom.dom.element.text.TextSpanElement;
 import org.odftoolkit.odfdom.dom.element.text.TextTimeElement;
 import org.odftoolkit.odfdom.incubator.doc.number.OdfNumberTimeStyle;
@@ -90,7 +92,12 @@ public class TimeField extends Field {
 			SimpleDateFormat newFormat = new SimpleDateFormat(formatString);
 			timeElement.setTextContent(newFormat.format(simpleDate));
 			OdfFileDom dom = (OdfFileDom) timeElement.getOwnerDocument();
-			OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+			OdfOfficeAutomaticStyles styles = null;
+			if (dom instanceof OdfContentDom) {
+				styles = ((OdfContentDom) dom).getAutomaticStyles();
+			} else if (dom instanceof OdfStylesDom) {
+				styles = ((OdfStylesDom) dom).getAutomaticStyles();
+			}
 			OdfNumberTimeStyle dataStyle = styles.getTimeStyle(timeElement.getStyleDataStyleNameAttribute());
 			dataStyle.buildFromFormat(formatString);
 		} catch (ParseException e) {
@@ -122,7 +129,12 @@ public class TimeField extends Field {
 	// Create an <code>OdfNumberTimeStyle</code> element
 	private OdfNumberTimeStyle newTimeStyle() {
 		OdfFileDom dom = (OdfFileDom) timeElement.getOwnerDocument();
-		OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+		OdfOfficeAutomaticStyles styles = null;
+		if (dom instanceof OdfContentDom) {
+			styles = ((OdfContentDom) dom).getAutomaticStyles();
+		} else if (dom instanceof OdfStylesDom) {
+			styles = ((OdfStylesDom) dom).getAutomaticStyles();
+		}
 		OdfNumberTimeStyle newStyle = dom.newOdfElement(OdfNumberTimeStyle.class);
 		newStyle.setStyleNameAttribute(newUniqueStyleName(styles));
 		styles.appendChild(newStyle);

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/navigation/TextSelection.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/navigation/TextSelection.java?rev=1181600&r1=1181599&r2=1181600&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/navigation/TextSelection.java
(original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/navigation/TextSelection.java
Tue Oct 11 02:24:30 2011
@@ -25,7 +25,9 @@ import java.util.Date;
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.odftoolkit.odfdom.dom.OdfContentDom;
 import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
+import org.odftoolkit.odfdom.dom.OdfStylesDom;
 import org.odftoolkit.odfdom.dom.element.OdfStylableElement;
 import org.odftoolkit.odfdom.dom.element.OdfStyleBase;
 import org.odftoolkit.odfdom.dom.element.dc.DcCreatorElement;
@@ -355,7 +357,12 @@ public class TextSelection extends Selec
 		TextPElement notePElement = annotationElement.newTextPElement();
 		TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
 		// set comment style
-		OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+		OdfOfficeAutomaticStyles styles = null;
+		if (dom instanceof OdfContentDom) {
+			styles = ((OdfContentDom) dom).getAutomaticStyles();
+		} else if (dom instanceof OdfStylesDom) {
+			styles = ((OdfStylesDom) dom).getAutomaticStyles();
+		}
 		OdfStyle textStyle = styles.newStyle(OdfStyleFamily.Text);
 		StyleTextPropertiesElement styleTextPropertiesElement = textStyle.newStyleTextPropertiesElement(null);
 		styleTextPropertiesElement.setStyleFontNameAttribute("Tahoma");

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/table/Table.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/table/Table.java?rev=1181600&r1=1181599&r2=1181600&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/table/Table.java (original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/table/Table.java Tue Oct
11 02:24:30 2011
@@ -31,7 +31,9 @@ import java.util.Vector;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.odftoolkit.odfdom.dom.OdfContentDom;
 import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
+import org.odftoolkit.odfdom.dom.OdfStylesDom;
 import org.odftoolkit.odfdom.dom.attribute.table.TableAlignAttribute;
 import org.odftoolkit.odfdom.dom.element.OdfStyleBase;
 import org.odftoolkit.odfdom.dom.element.office.OfficeAnnotationElement;
@@ -875,7 +877,12 @@ public class Table extends Component {
 					+ ", Columns " + numCols + ", HeaderRows " + headerRowNumber + ", HeaderColumns "
 					+ headerColumnNumber);
 		}
-		OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+		OdfOfficeAutomaticStyles styles = null;
+		if (dom instanceof OdfContentDom) {
+			styles = ((OdfContentDom) dom).getAutomaticStyles();
+		} else if (dom instanceof OdfStylesDom) {
+			styles = ((OdfStylesDom) dom).getAutomaticStyles();
+		}
 		// 1. create table element
 		TableTableElement newTEle = (TableTableElement) OdfXMLFactory.newOdfElement(dom, OdfName.newName(
 				OdfDocumentNamespace.TABLE, "table"));

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Footer.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Footer.java?rev=1181600&r1=1181599&r2=1181600&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Footer.java (original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Footer.java Tue Oct
11 02:24:30 2011
@@ -22,7 +22,9 @@ package org.odftoolkit.simple.text;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.odftoolkit.odfdom.dom.OdfContentDom;
 import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
+import org.odftoolkit.odfdom.dom.OdfStylesDom;
 import org.odftoolkit.odfdom.dom.element.style.StyleFooterElement;
 import org.odftoolkit.odfdom.dom.element.style.StyleTableCellPropertiesElement;
 import org.odftoolkit.odfdom.dom.element.style.StyleTablePropertiesElement;
@@ -108,7 +110,12 @@ public class Footer extends Component im
 			TextPElement textEle = (TextPElement) nodeList.item(i);
 			String stylename = textEle.getStyleName();
 			OdfFileDom dom = (OdfFileDom) footerEle.getOwnerDocument();
-			OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+			OdfOfficeAutomaticStyles styles = null;
+			if (dom instanceof OdfContentDom) {
+				styles = ((OdfContentDom) dom).getAutomaticStyles();
+			} else if (dom instanceof OdfStylesDom) {
+				styles = ((OdfStylesDom) dom).getAutomaticStyles();
+			}
 			
 			OdfStyle newStyle = styles.newStyle(OdfStyleFamily.Paragraph);
 			OdfStyle style = styles.getStyle(stylename, OdfStyleFamily.Paragraph);
@@ -188,7 +195,12 @@ public class Footer extends Component im
 		OdfFileDom dom = (OdfFileDom) getTableContainerElement().getOwnerDocument();
 		TableTableElement tableEle = table.getOdfElement();
 		String stylename = tableEle.getStyleName();
-		OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+		OdfOfficeAutomaticStyles styles = null;
+		if (dom instanceof OdfContentDom) {
+			styles = ((OdfContentDom) dom).getAutomaticStyles();
+		} else if (dom instanceof OdfStylesDom) {
+			styles = ((OdfStylesDom) dom).getAutomaticStyles();
+		}
 		OdfStyle tableStyle = styles.getStyle(stylename, OdfStyleFamily.Table);
 		tableStyle.setProperty(StyleTablePropertiesElement.Shadow, "none");
 		NodeList cells = tableEle.getElementsByTagNameNS(OdfDocumentNamespace.TABLE.getUri(), "table-cell");

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Header.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Header.java?rev=1181600&r1=1181599&r2=1181600&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Header.java (original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Header.java Tue Oct
11 02:24:30 2011
@@ -22,7 +22,9 @@ package org.odftoolkit.simple.text;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.odftoolkit.odfdom.dom.OdfContentDom;
 import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
+import org.odftoolkit.odfdom.dom.OdfStylesDom;
 import org.odftoolkit.odfdom.dom.element.style.StyleHeaderElement;
 import org.odftoolkit.odfdom.dom.element.style.StyleTableCellPropertiesElement;
 import org.odftoolkit.odfdom.dom.element.style.StyleTablePropertiesElement;
@@ -109,7 +111,12 @@ public class Header extends Component im
 			TextPElement textEle = (TextPElement) nodeList.item(i);
 			String stylename = textEle.getStyleName();
 			OdfFileDom dom = (OdfFileDom) headerEle.getOwnerDocument();
-			OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+			OdfOfficeAutomaticStyles styles = null;
+			if (dom instanceof OdfContentDom) {
+				styles = ((OdfContentDom) dom).getAutomaticStyles();
+			} else if (dom instanceof OdfStylesDom) {
+				styles = ((OdfStylesDom) dom).getAutomaticStyles();
+			}
 
 			OdfStyle newStyle = styles.newStyle(OdfStyleFamily.Paragraph);
 			OdfStyle style = styles.getStyle(stylename, OdfStyleFamily.Paragraph);
@@ -189,7 +196,12 @@ public class Header extends Component im
 		OdfFileDom dom = (OdfFileDom) getTableContainerElement().getOwnerDocument();
 		TableTableElement tableEle = table.getOdfElement();
 		String stylename = tableEle.getStyleName();
-		OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+		OdfOfficeAutomaticStyles styles = null;
+		if (dom instanceof OdfContentDom) {
+			styles = ((OdfContentDom) dom).getAutomaticStyles();
+		} else if (dom instanceof OdfStylesDom) {
+			styles = ((OdfStylesDom) dom).getAutomaticStyles();
+		}
 		OdfStyle tableStyle = styles.getStyle(stylename, OdfStyleFamily.Table);
 		tableStyle.setProperty(StyleTablePropertiesElement.Shadow, "none");
 		NodeList cells = tableEle.getElementsByTagNameNS(OdfDocumentNamespace.TABLE.getUri(), "table-cell");

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Paragraph.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Paragraph.java?rev=1181600&r1=1181599&r2=1181600&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Paragraph.java (original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/Paragraph.java Tue
Oct 11 02:24:30 2011
@@ -25,7 +25,9 @@ import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 
+import org.odftoolkit.odfdom.dom.OdfContentDom;
 import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
+import org.odftoolkit.odfdom.dom.OdfStylesDom;
 import org.odftoolkit.odfdom.dom.element.OdfStyleBase;
 import org.odftoolkit.odfdom.dom.element.dc.DcCreatorElement;
 import org.odftoolkit.odfdom.dom.element.dc.DcDateElement;
@@ -452,7 +454,12 @@ public class Paragraph extends Component
 		TextPElement notePElement = annotationElement.newTextPElement();
 		TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
 		// set comment style
-		OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
+		OdfOfficeAutomaticStyles styles = null;
+		if (dom instanceof OdfContentDom) {
+			styles = ((OdfContentDom) dom).getAutomaticStyles();
+		} else if (dom instanceof OdfStylesDom) {
+			styles = ((OdfStylesDom) dom).getAutomaticStyles();
+		}
 		OdfStyle textStyle = styles.newStyle(OdfStyleFamily.Text);
 		StyleTextPropertiesElement styleTextPropertiesElement = textStyle.newStyleTextPropertiesElement(null);
 		styleTextPropertiesElement.setStyleFontNameAttribute("Tahoma");



Mime
View raw message