Return-Path: X-Original-To: apmail-poi-user-archive@www.apache.org Delivered-To: apmail-poi-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8FFBF10145 for ; Thu, 30 Jan 2014 22:46:52 +0000 (UTC) Received: (qmail 58334 invoked by uid 500); 30 Jan 2014 22:46:52 -0000 Delivered-To: apmail-poi-user-archive@poi.apache.org Received: (qmail 58278 invoked by uid 500); 30 Jan 2014 22:46:51 -0000 Mailing-List: contact user-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Users List" Delivered-To: mailing list user@poi.apache.org Received: (qmail 58270 invoked by uid 99); 30 Jan 2014 22:46:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jan 2014 22:46:51 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [81.169.146.217] (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.217) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jan 2014 22:46:47 +0000 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1391121985; l=5984; s=domk; d=apconsult.de; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References: Subject:To:MIME-Version:From:Date:X-RZG-CLASS-ID:X-RZG-AUTH; bh=t/spXDyEnFpsiSTKferOI2ZB9BM=; b=yRM0mOzACQqEgjC1FmVl8cWKv8eAzyfVTrLDGWDAtxlxttRGnHQxSH7EHpoFAqxRl+6 zjuJUzUq3eK6qn9EByOG0oaGIrS7rKD7Dk2X4NC8yEsjZDjmIxNIXd9m4RmSmfXlM7jc6 awoT4Xrzxs2AfWZhDa/1eLJ9ippL5EApemA= X-RZG-AUTH: :KG0SfETmd/55bSarYSJgwI+Iuho+dmriAESeqkyNCY6u2StSfNt+8Kuz4Sjl/Xe+CxfCbg== X-RZG-CLASS-ID: mo00 Received: from [192.168.179.52] (pD9E03D8D.dip0.t-ipconnect.de [217.224.61.141]) by smtp.strato.de (RZmta 32.22 DYNA|AUTH) with ESMTPSA id Z02159q0UMkOjml (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate); Thu, 30 Jan 2014 23:46:24 +0100 (CET) Message-ID: <52EAD64A.50309@apconsult.de> Date: Thu, 30 Jan 2014 23:46:34 +0100 From: David Law User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: POI Users List Subject: Re: Retrieving content of hyperlinked slides in powerpoint files(.PPTX) through apache POI References: <1390976512134-5714766.post@n5.nabble.com> <52E96F0A.1000005@gmx.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Simanchal, may I ask a couple of stupid questions? I've removed some dead code & what's left in the heart of all those nested if's & for's is this: CTRegularTextRun[] ctRegularTextRun = xslfParagraph.getXmlObject().getRArray(); for (int index = ctRegularTextRun.length - 1; index > 0; index--) { xslfParagraph.getXmlObject().removeR(index); } if (ctRegularTextRun.length > 0) { ctRegularTextRun[0].setT(""); } First you get an Array of all CTRegularTextRuns contained in the XmlObject. Then you remove them all from the XmlObject. (they now only exist in the Array you just got) Finally you set the T Element of (only!) the 1st CTRegularTextRun (if present) to "". Q1) Now I wonder why you need to iterate backwards through the Array? Q2) Setting the T Element will have no effect (because you have just deleted all R's from the XmlObject?! All the best, DaveLaw On 30.01.2014 04:44, simanchal maharana wrote: > Hi Andreas, > > PFA PPTX file for your review. > > Thanks, > Simanchal > > On Thu, Jan 30, 2014 at 2:44 AM, Andreas Beeker [via Apache POI] > wrote: >> Hi, >> >> is there a chance to get your .pptx-files? >> >> - link it to your stackoverflow post [1] >> - or open a bugzilla entry [2] >> - or send it to my email address (least preferred ...) >> >> Andi. >> >> >> [1] >> http://stackoverflow.com/questions/21386211/retrieving-content-of-hyperlinked-slides-in-powerpoint-files-pptx-through-apac >> [2] http://issues.apache.org/bugzilla/buglist.cgi?product=POI >> >> On 29.01.2014 07:21, simanchal maharana wrote: >> >>> I am trying to get the text content of powerpoint files and replace with >>> some >>> other text. I have a powerpoint file of 20 slides. where 13,14,15,16 >>> slides >>> have hyperlink to 17,18,19 and 20th slide. I am using XMLSlideshow to >>> traverse through the slides, But it gives only 16 slides. It does not give >>> last 4 hyperlinked slides. >>> >>> Any idea really appreciable in advance how can I get content of all >>> hyper-linked slides and Replace by some other text. >>> >>> here is my code. >>> >>> import java.io.FileInputStream; >>> import java.io.FileOutputStream; >>> import org.apache.poi.xslf.usermodel.XMLSlideShow; >>> import org.apache.poi.xslf.usermodel.XSLFShape; >>> import org.apache.poi.xslf.usermodel.XSLFSlide; >>> import org.apache.poi.xslf.usermodel.XSLFTextParagraph; >>> import org.apache.poi.xslf.usermodel.XSLFTextShape; >>> import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun; >>> public class Testing { >>> static String inputFile = >>> "C:\\Users\\SM78882\\Desktop\\Testing\\IE_Basics_English.pptx"; >>> static String outputFile = >>> "C:\\Users\\SM78882\\Desktop\\Testing\\result.pptx"; >>> >>> public static String replaceUnwantedChar(String originalString) { >>> if (null != originalString) >>> return "" + originalString.replaceAll("(\n+)|(\t+)|(\\s{2,})", " ") >>> .trim(); >>> else >>> return ""; >>> } >>> public static void main(String[] args) { >>> FileInputStream fis = null; >>> FileOutputStream fos = null; >>> XMLSlideShow ppt = null; >>> try { >>> fis = new FileInputStream(inputFile); >>> fos = new FileOutputStream(outputFile); >>> ppt = new XMLSlideShow(fis); >>> System.out.println("No of slides:" + ppt.getSlides().length); // gives 16 >>> slides. >>> for (XSLFSlide slide : ppt.getSlides()) { >>> for (XSLFShape shape : slide) { >>> if (shape instanceof XSLFTextShape) { >>> XSLFTextShape txShape = (XSLFTextShape) shape; >>> for (XSLFTextParagraph xslfParagraph : txShape .getTextParagraphs()) { >>> String originalText = replaceUnwantedChar(xslfParagraph .getText()); >>> if (!originalText.isEmpty()) { >>> String translation = ""; >>> if (translation != null) { >>> CTRegularTextRun[] ctRegularTextRun = xslfParagraph >>> .getXmlObject().getRArray(); >>> for (int index = ctRegularTextRun.length - 1; index > 0; index--) { >>> xslfParagraph.getXmlObject().removeR( index); >>> } >>> if (ctRegularTextRun.length > 0) >>> ctRegularTextRun[0].setT(translation); >>> } >>> } >>> } >>> } >>> } >>> } >>> ppt.write(fos); >>> fos.close(); >>> fis.close(); >>> } catch (Exception ex) { >>> ex.printStackTrace(); >>> } >>> } >>> } >>> >>> >>> >>> >>> >>> >>> -- >>> View this message in context: >>> http://apache-poi.1045710.n5.nabble.com/Retrieving-content-of-hyperlinked-slides-in-powerpoint-files-PPTX-through-apache-POI-tp5714766.html >>> Sent from the POI - User mailing list archive at Nabble.com. >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [hidden email] >>> For additional commands, e-mail: [hidden email] >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> >> >> >> ________________________________ >> If you reply to this email, your message will be added to the discussion >> below: >> http://apache-poi.1045710.n5.nabble.com/Retrieving-content-of-hyperlinked-slides-in-powerpoint-files-PPTX-through-apache-POI-tp5714766p5714769.html >> To unsubscribe from Retrieving content of hyperlinked slides in powerpoint >> files(.PPTX) through apache POI, click here. >> NAML > > Final_2.7z (16M) > IE_Basics_English.pptx (4M) > PPTXParser_Code.java (4K) > > > > > -- > View this message in context: http://apache-poi.1045710.n5.nabble.com/Retrieving-content-of-hyperlinked-slides-in-powerpoint-files-PPTX-through-apache-POI-tp5714766p5714773.html > Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional commands, e-mail: user-help@poi.apache.org