You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Duc Phuong Nguyen <Ph...@unibas.ch> on 2006/11/15 11:49:03 UTC
How to get the comment text on a power point slide
Hi all,
I tried to get the comment on a power point slide (Menu-Insert-Comment)
using the Comment2000 class but haven't succeeded so far.
Does anybody tried it before? Thanks in advance for any suggestion.
Phuong
Here is the code: Try with a ppt file with some comments on some slides,
The program will not found any Comment2000 object (getRecordType =1200)
import org.apache.poi.hslf.extractor.PowerPointExtractor;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.model.TextRun;
import org.apache.poi.hslf.record.Comment2000;
import org.apache.poi.hslf.record.Record;
public class PPExtractor{
public static void main(String[] args){
String strFileName = args[0];
try{
HSLFSlideShow objSlide = new HSLFSlideShow(strFileName);
Record[] arrayRecords = objSlide.getRecords();
for(int loop=0;loop< arrayRecords.length;loop++){
//http://jakarta.apache.org/poi/apidocs/org/apache/poi/hslf/record/Comment2000.html#Comment2000()
if(arrayRecords[loop].getRecordType() == 1200){ //type =
Comment2000
Comment2000 aComment = (Comment2000)arrayRecords[loop];
String strComment = aComment.getText();
System.out.println("Comment for slide" + i + "is:" +
strComment);
}//end processing the comment of this slide
else{
System.out.println("record type of item " + loop + "
=" + arrayRecords[loop].getRecordType());
}
}//end loop for each records
}//end loop for each slide
}//end try
catch(Exception e){
System.out.println("Error occur while processing...:");
e.printStackTrace();
}//end catch
}//end main
}//end class PPExtractor
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
Re: How to get the comment text on a power point slide
Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 16 Nov 2006, Duc Phuong Nguyen wrote:
> But now, at least I could read with my code the Notes from an
> OpenOffice-created ppt file.
That's good to know. One interesting thing might be to take the same
(office) generated ppt file, then add the same comment in office and in
openoffice, and see how the resulting files differ.
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
Re: How to get the comment text on a power point slide
Posted by Duc Phuong Nguyen <Ph...@unibas.ch>.
Thank you Nick for your help. It seems to be a compatible issue between
OpenOffice and MS Office.
I read in OpenOffice 1.1.5 Help that "Comments in Office XP is
equivalent to Notes in OOffice".
But when I tried to open an MS ppt with OpenOffice 1.1.5, the comments
disappeared, vice versa when
I created a Notes in OpenOffice, I could not open the ppt file with MS
Office.
But now, at least I could read with my code the Notes from an
OpenOffice-created ppt file.
Phuong
Nick Burch wrote:
> On Wed, 15 Nov 2006, Duc Phuong Nguyen wrote:
>> I tried to get the comment on a power point slide
>> (Menu-Insert-Comment) using the Comment2000 class but haven't
>> succeeded so far.
>
> Looks like your code is only checking for top level records. In a
> normal powerpoint file, the top level records are things like Slide,
> Notes, Document.
>
> The Comment records are stored as (IIRC) children of children of Slide
> records. If I were you, I'd write some code to recursivly search the
> children until you find it.
>
>
> Also, you might want to do
> if(record.getRecordType() == RecordTypes.Comment2000.typeID)
> rather than hard coding 1200 into your code, so it's a bit cleaner.
> Or, do
> if(record instanceof Comment2000)
> since we do have a Comment2000 class
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
Re: How to get the comment text on a power point slide
Posted by Nick Burch <ni...@torchbox.com>.
On Wed, 15 Nov 2006, Duc Phuong Nguyen wrote:
> I tried to get the comment on a power point slide (Menu-Insert-Comment)
> using the Comment2000 class but haven't succeeded so far.
Looks like your code is only checking for top level records. In a normal
powerpoint file, the top level records are things like Slide, Notes,
Document.
The Comment records are stored as (IIRC) children of children of Slide
records. If I were you, I'd write some code to recursivly search the
children until you find it.
Also, you might want to do
if(record.getRecordType() == RecordTypes.Comment2000.typeID)
rather than hard coding 1200 into your code, so it's a bit cleaner. Or, do
if(record instanceof Comment2000)
since we do have a Comment2000 class
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/