From odf-commits-return-170-apmail-incubator-odf-commits-archive=incubator.apache.org@incubator.apache.org Fri Sep 2 09:57:41 2011 Return-Path: X-Original-To: apmail-incubator-odf-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-odf-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 AC6D2761B for ; Fri, 2 Sep 2011 09:57:41 +0000 (UTC) Received: (qmail 83564 invoked by uid 500); 2 Sep 2011 09:57:41 -0000 Delivered-To: apmail-incubator-odf-commits-archive@incubator.apache.org Received: (qmail 83520 invoked by uid 500); 2 Sep 2011 09:57:39 -0000 Mailing-List: contact odf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: odf-dev@incubator.apache.org Delivered-To: mailing list odf-commits@incubator.apache.org Received: (qmail 83493 invoked by uid 99); 2 Sep 2011 09:57:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Sep 2011 09:57:38 +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; Fri, 02 Sep 2011 09:57:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 78ECE238889B; Fri, 2 Sep 2011 09:57:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1164453 - /incubator/odf/site/trunk/content/odftoolkit/simple/demo/demo5.mdtext Date: Fri, 02 Sep 2011 09:57:12 -0000 To: odf-commits@incubator.apache.org From: devinhan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110902095712.78ECE238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: devinhan Date: Fri Sep 2 09:57:12 2011 New Revision: 1164453 URL: http://svn.apache.org/viewvc?rev=1164453&view=rev Log: clear tags Modified: incubator/odf/site/trunk/content/odftoolkit/simple/demo/demo5.mdtext Modified: incubator/odf/site/trunk/content/odftoolkit/simple/demo/demo5.mdtext URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/demo/demo5.mdtext?rev=1164453&r1=1164452&r2=1164453&view=diff ============================================================================== --- incubator/odf/site/trunk/content/odftoolkit/simple/demo/demo5.mdtext (original) +++ incubator/odf/site/trunk/content/odftoolkit/simple/demo/demo5.mdtext Fri Sep 2 09:57:12 2011 @@ -1,231 +1,82 @@ - - - - - - -Demos - SimpleODF - - - - -
-
-
-
-
- -
- - - - - - -
- - -

If you make a lot of presentations in your daily work, you know that you don't always create a presentation from scratch. - Assembling several different presentations together to make a new presentation, e.g. copying several pages from presentation A - and copying another several pages from presentation B, is a common activity for the presentation author. -
This demo provides a Java application that can assemble specific pages of presentations together and make one presentation from the command line. -
Here is an example. I want to make a presentation with the first page from presentation A, - the first page from presentation B and the first page from presentation C. I can call the following command: -
Java PresentationAssembler -in PresentationA.odp(1) -in PresentationB.odp(1) -in PresentationC.odp(1-2) -out newPresentation.odp -

A new presentation will be generated which is showed in the following picture. You can see, the pictures, the styles and master pages are copied also.

      

In the next section, I will show how easy it is to create this assembling application using the Simple API. - - -

- - -
- - -
- - -
- - - Code Introduction - - -
- - -
- -

- assemble is the method that accepts the command line parameters, analyzes them, and assembles presentations - with the Simple Java API for ODF. In this method, a new presentation is created, and then, pages from other presentation - documents are attached while the command line is being analyzed. Simple Java API for ODF provides very simple methods to - copy pages from other presentations: -
-
PresentationDocument.copyForeignSlide(int destIndex, PresentationDocument srcDoc, int srcIndex) -
and -
PresentationDocument.appendPresentation(PresentationDocument srcDoc). -
-
After the slides are attached, the first slide of the new presentation is deleted by invoking method - PresentationDocument.deleteSlideByIndex(int index). - This is because the first slide is an empty slide which was created when the new presentation was created with - method PresentationDocument.newPresentationDocument() - -

-

Below is the source code of method assemble. Most of the code is used to analyze the command line - parameters. Only a few statements are used to attach slides to the new presentation. So you can see how powerful - functions Simple Java API for ODF provides.

- - - - -
-
-
-	public void assemble(String[] args) throws Exception
-	{
-		String outputFileName="default.odp";
-		int pageIndex = 1;
-		PresentationDocument doc = PresentationDocument.newPresentationDocument();
-		int i=0;
-		while (i < args.length)
-		{
-			String param = args[i];
-			if (param.equals("-out")) //get the output file name
-				outputFileName = args[++i];
-			else if (param.equals("-in")) //get the input file name 
-			{
-				String pageDesc = args[++i];
-				String filename = pageDesc, pagelist;
-				int indexStart = pageDesc.indexOf('('); //get the page numbers
-				int[] srcPages = null;
-				if (indexStart > -1)
-				{
-					filename = pageDesc.substring(0, indexStart);
-					pagelist = pageDesc.substring(indexStart+1, pageDesc.length()-1);
-					srcPages = getPageNumbers(pagelist); //analysis the page number description 
-									                     //and return all page numbers that need to be copied
-				}
-				PresentationDocument sourceDoc = PresentationDocument.loadDocument(new File(filename));
-				if (srcPages==null)
-				{
-					doc.appendPresentation(sourceDoc);
-					pageIndex += sourceDoc.getSlideCount();
-				} else for(int j=0;j < srcPages.length;j++)
-				{
-					doc.copyForeignSlide(pageIndex, sourceDoc, srcPages[j]);
-					pageIndex++;
-				}
-			}
-			i++;
-		}
-		doc.deleteSlideByIndex(0);
-		doc.save(outputFileName);
-		doc.close();
-	}
-
-
-    
- - -

- - -

- - -

- - -
- - -
- - -
- - - Download - - -
- - -
- - -

- - - Powered by the Simple Java API for ODF version 0.4.5. - - -

- - -

- - - You can download the code of this demo from here. - - -

- - -
- - -
- -
-
- - - - - - - - - - - - - +**[Demos][1]** > Multiple Presentations Assembler + +**Overview** + +If you make a lot of presentations in your daily work, you know that you don't always create a presentation from scratch. + +Assembling several different presentations together to make a new presentation, e.g. copying several pages from presentation A and copying another several pages from presentation B, is a common activity for the presentation author. +This demo provides a Java application that can assemble specific pages of presentations together and make one presentation from the command line. + +Here is an example. I want to make a presentation with the first page from presentation A, the first page from presentation B and the first page from presentation C. I can call the following command: + +Java PresentationAssembler -in PresentationA.odp(1) -in PresentationB.odp(1) -in PresentationC.odp(1-2) -out newPresentation.odp + +A new presentation will be generated which is showed in the following picture. You can see, the pictures, the styles and master pages are copied too. + +![alt text][2] + +In the next section, I will show how easy it is to create this assembling application using the Simple API. + + +**Code Introduction** + +assemble is the method that accepts the command line parameters, analyzes them, and assembles presentations with the Simple API. In this method, a new presentation is created, and then, pages from other presentation documents are attached while the command line is being analyzed. Simple API provides very simple methods to copy pages from other presentations: +PresentationDocument.copyForeignSlide(int destIndex, PresentationDocument srcDoc, int srcIndex) and +PresentationDocument.appendPresentation(PresentationDocument srcDoc). + +After the slides are attached, the first slide of the new presentation is deleted by invoking method PresentationDocument.deleteSlideByIndex(int index). + +This is because the first slide is an empty slide which was created when the new presentation was created with method PresentationDocument.newPresentationDocument() + +Below is the source code of method assemble. Most of the code is used to analyze the command line parameters. Only a few statements are used to attach slides to the new presentation. So you can see how powerful functions Simple API provides. + + public void assemble(String[] args) throws Exception + { + String outputFileName="default.odp"; + int pageIndex = 1; + PresentationDocument doc = PresentationDocument.newPresentationDocument(); + int i=0; + while (i < args.length) + { + String param = args[i]; + if (param.equals("-out")) //get the output file name + outputFileName = args[++i]; + else if (param.equals("-in")) //get the input file name + { + String pageDesc = args[++i]; + String filename = pageDesc, pagelist; + int indexStart = pageDesc.indexOf('('); //get the page numbers + int[] srcPages = null; + if (indexStart > -1) + { + filename = pageDesc.substring(0, indexStart); + pagelist = pageDesc.substring(indexStart+1, pageDesc.length()-1); + srcPages = getPageNumbers(pagelist); //analysis the page number description + //and return all page numbers that need to be copied + } + PresentationDocument sourceDoc = PresentationDocument.loadDocument(new File(filename)); + if (srcPages==null) + { + doc.appendPresentation(sourceDoc); + pageIndex += sourceDoc.getSlideCount(); + } else for(int j=0;j < srcPages.length;j++) + { + doc.copyForeignSlide(pageIndex, sourceDoc, srcPages[j]); + pageIndex++; + } + } + i++; + } + doc.deleteSlideByIndex(0); + doc.save(outputFileName); + doc.close(); + } + +**Download** + +Powered by the Simple Java API for ODF version 0.4.5. +You can download the code of this demo from here. + + + [1]: index.html + [2]: image/demo5_doc.jpg \ No newline at end of file