From: Yegor Kozlov Date: Mon, 20 Jun 2011 08:01:23 +0000 (+0000) Subject: junit test for sprm, added missing line from r1137143 X-Git-Tag: REL_3_8_BETA4~376 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=350806a1576c0ac45849ade2be95357c8b2ee74f;p=poi.git junit test for sprm, added missing line from r1137143 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1137538 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java b/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java index b4b322d4ff..9268183702 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java @@ -347,6 +347,7 @@ public final class ParagraphSprmUncompressor break; case 0x41: // sprmPFBiDi + newPAP.setFBiDi((byte) sprm.getOperand()); break; case 0x43: diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/sprm/TestSprms.java b/src/scratchpad/testcases/org/apache/poi/hwpf/sprm/TestSprms.java new file mode 100755 index 0000000000..3bd0309d8d --- /dev/null +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/sprm/TestSprms.java @@ -0,0 +1,61 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.apache.poi.hwpf.sprm; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import junit.framework.TestCase; +import org.apache.poi.POIDataSamples; +import org.apache.poi.hwpf.HWPFDocument; + +public class TestSprms extends TestCase { + /** + * Test correct processing of "sprmPJc" by uncompressor + */ + public void testSprmPJc() throws IOException { + InputStream resourceAsStream = POIDataSamples.getDocumentInstance() + .openResourceAsStream("Bug49820.doc"); + HWPFDocument hwpfDocument = new HWPFDocument(resourceAsStream); + assertEquals(1, hwpfDocument.getStyleSheet().getParagraphStyle(8) + .getJustification()); + resourceAsStream.close(); + } + + /** + * Test correct processing of "sprmPJc" by compressor and uncompressor + */ + public void testSprmPJcResave() throws IOException { + InputStream resourceAsStream = POIDataSamples.getDocumentInstance() + .openResourceAsStream("Bug49820.doc"); + HWPFDocument hwpfDocument = new HWPFDocument(resourceAsStream); + resourceAsStream.close(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + hwpfDocument.write(baos); + hwpfDocument = new HWPFDocument( + new ByteArrayInputStream(baos.toByteArray())); + + assertEquals(1, hwpfDocument.getStyleSheet().getParagraphStyle(8) + .getJustification()); + } +}