Return-Path: X-Original-To: apmail-poi-commits-archive@minotaur.apache.org Delivered-To: apmail-poi-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EECF6D5E2 for ; Wed, 7 Nov 2012 16:03:08 +0000 (UTC) Received: (qmail 14203 invoked by uid 500); 7 Nov 2012 16:03:08 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 14085 invoked by uid 500); 7 Nov 2012 16:03:05 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 14051 invoked by uid 99); 7 Nov 2012 16:03:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Nov 2012 16:03:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Nov 2012 16:03:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A7DB1238897F for ; Wed, 7 Nov 2012 16:02:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1406688 - in /poi/trunk: src/documentation/content/xdocs/status.xml src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java test-data/slideshow/54111.ppt Date: Wed, 07 Nov 2012 16:02:42 -0000 To: commits@poi.apache.org From: yegor@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121107160242.A7DB1238897F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: yegor Date: Wed Nov 7 16:02:42 2012 New Revision: 1406688 URL: http://svn.apache.org/viewvc?rev=1406688&view=rev Log: Bugzilla 54111 - Fixed extracting text from table cells in HSLF Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java poi/trunk/test-data/slideshow/54111.ppt (with props) Modified: poi/trunk/src/documentation/content/xdocs/status.xml poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java Modified: poi/trunk/src/documentation/content/xdocs/status.xml URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1406688&r1=1406687&r2=1406688&view=diff ============================================================================== --- poi/trunk/src/documentation/content/xdocs/status.xml (original) +++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Nov 7 16:02:42 2012 @@ -34,6 +34,7 @@ + 54111 - Fixed extracting text from table cells in HSLF 52583 - add support for drop-down lists in doc to html convertion 52863 - add workaround for files with broken CHP SPRMs 53182 - Reading combined character styling and direct formatting of a character run Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java?rev=1406688&r1=1406687&r2=1406688&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java Wed Nov 7 16:02:42 2012 @@ -42,6 +42,7 @@ import org.apache.poi.hslf.record.PPDraw import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.RecordTypes; import org.apache.poi.hslf.record.StyleTextPropAtom; +import org.apache.poi.hslf.record.TextBytesAtom; import org.apache.poi.hslf.record.TextCharsAtom; import org.apache.poi.hslf.record.TextHeaderAtom; import org.apache.poi.hslf.record.TxInteractiveInfoAtom; @@ -484,8 +485,26 @@ public abstract class TextShape extends /** * @return the TextRun object for this text box */ - public TextRun getTextRun(){ - if(_txtrun == null) initTextRun(); + public TextRun getTextRun(){ + if (null == this._txtrun) initTextRun(); + if (null == this._txtrun && null != this._txtbox) { + TextHeaderAtom tha = null; + TextBytesAtom tba = null; + StyleTextPropAtom sta = null; + Record[] childRecords = this._txtbox.getChildRecords(); + for (Record r : childRecords) { + if (r instanceof TextHeaderAtom) { + tha = (TextHeaderAtom) r; + } else if (r instanceof TextBytesAtom) { + tba = (TextBytesAtom) r; + } else if (r instanceof StyleTextPropAtom) { + sta = (StyleTextPropAtom) r; + } + } + if (null != tba) { + this._txtrun = new TextRun(tha, tba, sta); + } + } return _txtrun; } Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java?rev=1406688&view=auto ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java (added) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java Wed Nov 7 16:02:42 2012 @@ -0,0 +1,75 @@ +/* + * ==================================================================== + * 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.hslf.usermodel; + +import junit.framework.TestCase; + +import org.apache.poi.hslf.model.Shape; +import org.apache.poi.hslf.model.Slide; +import org.apache.poi.hslf.model.Table; +import org.apache.poi.hslf.model.TextRun; +import org.apache.poi.POIDataSamples; + + +/** + * Test that checks numbered list functionality. + * + * @author Alex Nikiforov [mailto:anikif@gmail.com] + */ +public final class TestTable extends TestCase { + private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); + + protected void setUp() throws Exception { + } + + public void testTable() throws Exception { + SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("54111.ppt")); + assertTrue("No Exceptions while reading file", true); + + final Slide[] slides = ppt.getSlides(); + assertEquals(1, slides.length); + checkSlide(slides[0]); + } + private void checkSlide(final Slide s) { + TextRun[] textRuns = s.getTextRuns(); + assertEquals(2, textRuns.length); + + RichTextRun textRun = textRuns[0].getRichTextRuns()[0]; + assertEquals("Table sample", textRun.getRawText().trim()); + assertEquals(1, textRuns[0].getRichTextRuns().length); + assertFalse(textRun.isBullet()); + + assertEquals("Dummy text", textRuns[1].getRawText()); + + final Shape[] shapes = s.getShapes(); + assertNotNull(shapes); + assertEquals(3, shapes.length); + assertTrue(shapes[2] instanceof Table); + final Table table = (Table) shapes[2]; + assertEquals(4, table.getNumberOfColumns()); + assertEquals(6, table.getNumberOfRows()); + for (int x = 0; x < 4; x ++) { + assertEquals("TH Cell " + (x + 1), table.getCell(0, x).getTextRun().getRawText()); + for (int y = 1; y < 6; y++) { + assertEquals("Row " + y + ", Cell " + (x + 1), table.getCell(y, x).getText()); + } + } + } +} Added: poi/trunk/test-data/slideshow/54111.ppt URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/54111.ppt?rev=1406688&view=auto ============================================================================== Binary file - no diff available. Propchange: poi/trunk/test-data/slideshow/54111.ppt ------------------------------------------------------------------------------ svn:mime-type = application/msword --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org