svn commit: r406450 [2/2] - in /maven/doxia/trunk/doxia-modules/doxia-module-itext: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/ma

2006-05-14 Thread jvanzyl
Added: 
maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextUtil.java
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextUtil.java?rev=406450&view=auto
==
--- 
maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextUtil.java
 (added)
+++ 
maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextUtil.java
 Sun May 14 15:15:30 2006
@@ -0,0 +1,174 @@
+package org.apache.maven.doxia.module.itext;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Locale;
+
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.PageSize;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.xml.XmlToHtml;
+import com.lowagie.text.xml.XmlToPdf;
+import com.lowagie.text.xml.XmlToRtf;
+
+/**
+ * A set of util methods for the iText framework
+ *
+ * @author mailto:[EMAIL PROTECTED]">Vincent Siveton
+ * @version $Id$
+ */
+public class ITextUtil
+{
+/**
+ * Set the default page size for the document depending the user's country.
+ * TODO Maybe more generic?
+ *
+ * @see com.lowagie.text.PageSize
+ *
+ * @return the page size
+ */
+public static Rectangle getDefaultPageSize()
+{
+String defaultCountry = Locale.getDefault().getCountry();
+if ( defaultCountry != null
+&& ( defaultCountry.equals( Locale.US.getCountry() ) || 
defaultCountry.equals( Locale.CANADA.getCountry() ) ) )
+{
+return PageSize.LETTER;
+}
+
+return PageSize.A4;
+}
+
+/**
+ * Return a page size as String.
+ *
+ * @see com.lowagie.text.PageSize
+ *
+ * @param rect a Rectangle
+ * @return a page size as String
+ */
+public static String getPageSize( Rectangle rect )
+{
+if ( ( rect.width() == PageSize.LETTER.width() ) && ( rect.height() == 
PageSize.LETTER.height() ) )
+{
+return "LETTER";
+}
+
+return "A4";
+}
+
+/**
+ * Return true if the page size is supported by PageSize 
class, false otherwise
+ *
+ * @see com.lowagie.text.PageSize
+ *
+ * @param aPageSize a page size
+ * @return true if the page size is supported, false otherwise
+ */
+public static boolean isPageSizeSupported( String aPageSize )
+{
+Field[] sizes = PageSize.class.getDeclaredFields();
+for ( int i = 0; i < sizes.length; i++ )
+{
+Field currentField = sizes[i];
+if ( ( currentField.getName().equalsIgnoreCase( aPageSize ) )
+&& ( Modifier.isStatic( currentField.getModifiers() ) )
+&& ( currentField.getType().equals( Rectangle.class ) ) )
+{
+return true;
+}
+}
+
+return false;
+}
+
+/**
+ * Parse an iText XML from the specified InputStream, writing 
an Pdf document
+ * specified OutputStream.
+ *
+ * @see com.lowagie.text.xml.XmlToPdf
+ *
+ * @param is the InputStream from which the XML is read.
+ * @param os the OutputStream to which the result as Pdf is 
written.
+ * @throws RuntimeException if any
+ */
+public static void writePdf( InputStream is, OutputStream os )
+throws RuntimeException
+{
+try
+{
+XmlToPdf x = new XmlToPdf();
+x.parse( is, os );
+}
+catch ( DocumentException e )
+{
+throw new RuntimeException( "DocumentException : " + 
e.getMessage() );
+}
+}
+
+/**
+ * Parse an iText XML from the specified InputStream, writing 
an rtf document
+ * specified OutputStream.
+ *
+ * @see com.lowagie.text.xml.XmlToRtf
+ *
+ * @param is the InputStream from which the XML is read.
+ * @param os the OutputStream to which the result as RTF is 
written.
+ * @throws RuntimeException if any
+ */
+public static void writeRtf( InputStream is, OutputStream os )
+throws RuntimeException
+

svn commit: r406451 - in /maven/doxia/trunk/doxia-doc-renderer: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/m

2006-05-14 Thread jvanzyl
Author: jvanzyl
Date: Sun May 14 15:16:12 2006
New Revision: 406451

URL: http://svn.apache.org/viewcvs?rev=406451&view=rev
Log:
o adding vincent's document renderer

Added:
maven/doxia/trunk/doxia-doc-renderer/
maven/doxia/trunk/doxia-doc-renderer/pom.xml   (with props)
maven/doxia/trunk/doxia-doc-renderer/src/
maven/doxia/trunk/doxia-doc-renderer/src/main/
maven/doxia/trunk/doxia-doc-renderer/src/main/java/
maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/
maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/
maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/
maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/

maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/

maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/DocRenderer.java
   (with props)

maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/DocRendererException.java
   (with props)

maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/

maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/AbstractITextRender.java
   (with props)

maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/DefaultPdfRenderer.java
   (with props)

maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/DefaultRtfRenderer.java
   (with props)

maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/PdfRenderer.java
   (with props)

maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/RtfRenderer.java
   (with props)
maven/doxia/trunk/doxia-doc-renderer/src/main/mdo/
maven/doxia/trunk/doxia-doc-renderer/src/main/mdo/document.mdo
maven/doxia/trunk/doxia-doc-renderer/src/main/resources/
maven/doxia/trunk/doxia-doc-renderer/src/main/resources/org/
maven/doxia/trunk/doxia-doc-renderer/src/main/resources/org/apache/
maven/doxia/trunk/doxia-doc-renderer/src/main/resources/org/apache/maven/

maven/doxia/trunk/doxia-doc-renderer/src/main/resources/org/apache/maven/doxia/

maven/doxia/trunk/doxia-doc-renderer/src/main/resources/org/apache/maven/doxia/docrenderer/

maven/doxia/trunk/doxia-doc-renderer/src/main/resources/org/apache/maven/doxia/docrenderer/itext/

maven/doxia/trunk/doxia-doc-renderer/src/main/resources/org/apache/maven/doxia/docrenderer/itext/xslt/

maven/doxia/trunk/doxia-doc-renderer/src/main/resources/org/apache/maven/doxia/docrenderer/itext/xslt/TOC.xslt
   (with props)
maven/doxia/trunk/doxia-doc-renderer/src/test/
maven/doxia/trunk/doxia-doc-renderer/src/test/java/
maven/doxia/trunk/doxia-doc-renderer/src/test/resources/

Added: maven/doxia/trunk/doxia-doc-renderer/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-doc-renderer/pom.xml?rev=406451&view=auto
==
--- maven/doxia/trunk/doxia-doc-renderer/pom.xml (added)
+++ maven/doxia/trunk/doxia-doc-renderer/pom.xml Sun May 14 15:16:12 2006
@@ -0,0 +1,65 @@
+
+http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  
+doxia
+org.apache.maven.doxia
+1.0-alpha-8-SNAPSHOT
+  
+  4.0.0
+  doxia-doc-renderer
+  Doxia Document Renderer Component
+  1.0-SNAPSHOT
+  
+
+  
+org.codehaus.modello
+modello-maven-plugin
+1.0-alpha-8
+
+  
+
+  xpp3-writer
+  java
+  xpp3-reader
+  xsd
+
+  
+
+
+  1.0.0
+  src/main/mdo/document.mdo
+
+  
+
+  
+  
+
+  vsiveton
+  Vincent Siveton
+  [EMAIL PROTECTED]
+  Apache Software Foundation
+  
+Java Developer
+  
+  -5
+
+  
+  
+
+  org.codehaus.plexus
+  plexus-i18n
+  1.0-beta-6
+
+
+  org.apache.maven.doxia
+  doxia-module-itext
+  1.0-SNAPSHOT
+
+
+
+  org.codehaus.plexus
+  plexus-utils
+  1.2-SNAPSHOT
+
+  
+
\ No newline at end of file

Propchange: maven/doxia/trunk/doxia-doc-renderer/pom.xml
--
svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-doc-renderer/pom.xml
--
svn:keywords = "Author Date Id Revision"

Added: 
maven/doxia/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/DocRenderer.java
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-doc-renderer/s