incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fh...@apache.org
Subject svn commit: r1417749 - in /incubator/odf/trunk/simple/src: main/java/org/odftoolkit/simple/common/TextExtractor.java test/java/org/odftoolkit/simple/common/GetTextTest.java
Date Thu, 06 Dec 2012 07:11:34 GMT
Author: fhopf
Date: Thu Dec  6 07:11:33 2012
New Revision: 1417749

URL: http://svn.apache.org/viewvc?rev=1417749&view=rev
Log:
test and fix for ODFTOOLKIT-324 Exception on alien element without namespace

Modified:
    incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/TextExtractor.java
    incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/common/GetTextTest.java

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/TextExtractor.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/TextExtractor.java?rev=1417749&r1=1417748&r2=1417749&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/TextExtractor.java
(original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/common/TextExtractor.java
Thu Dec  6 07:11:33 2012
@@ -27,6 +27,7 @@ import org.odftoolkit.odfdom.dom.element
 import org.odftoolkit.odfdom.dom.element.text.TextSElement;
 import org.odftoolkit.odfdom.dom.element.text.TextTabElement;
 import org.odftoolkit.odfdom.pkg.OdfElement;
+import org.odftoolkit.odfdom.pkg.OdfNamespace;
 import org.w3c.dom.Node;
 
 /**
@@ -176,8 +177,8 @@ public class TextExtractor extends Defau
 	@Override
 	public void visit(OdfElement element) {
 		appendElementText(element);
-		if (element.getNamespaceURI().equals(OdfDocumentNamespace.META.getUri())
-				|| element.getNamespaceURI().equals(OdfDocumentNamespace.DC.getUri())) {
+		if (OdfDocumentNamespace.META.getUri().equals(element.getNamespaceURI())
+				|| OdfDocumentNamespace.DC.getUri().equals(element.getNamespaceURI())) {
 			mTextBuilder.appendLine();
 		}
 	}

Modified: incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/common/GetTextTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/common/GetTextTest.java?rev=1417749&r1=1417748&r2=1417749&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/common/GetTextTest.java
(original)
+++ incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/common/GetTextTest.java
Thu Dec  6 07:11:33 2012
@@ -25,6 +25,8 @@ import java.util.logging.Logger;
 import org.junit.Assert;
 import org.junit.Test;
 import org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph;
+import org.odftoolkit.odfdom.pkg.OdfAlienElement;
+import org.odftoolkit.odfdom.pkg.OdfName;
 import org.odftoolkit.simple.Document;
 import org.odftoolkit.simple.TextDocument;
 import org.odftoolkit.simple.utils.ResourceUtilities;
@@ -92,4 +94,14 @@ public class GetTextTest {
 			Assert.fail(e.getMessage());
 		}
 	}
+        
+        @Test
+        public void testExtractFromDocumentWithAlienElement() throws Exception {
+            TextDocument document = TextDocument.newTextDocument();
+            document.getContentRoot().appendChild(new OdfAlienElement(document.getContentDom(),
OdfName.newName("instance")));
+            document.addParagraph("Some text");
+            TextExtractor extractor = TextExtractor.newOdfTextExtractor(document.getContentRoot());
+            String text = extractor.getText();
+            Assert.assertEquals("\nSome text", text);
+        }
 }



Mime
View raw message