]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
adds support for fo:character and property character
authorfotis <fotis@unknown>
Fri, 15 Dec 2000 21:35:36 +0000 (21:35 +0000)
committerfotis <fotis@unknown>
Fri, 15 Dec 2000 21:35:36 +0000 (21:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193874 13f79535-47bb-0310-9956-ffa450edef68

STATUS
docs/examples/build.xml
src/codegen/foproperties.xml
src/org/apache/fop/fo/StandardElementMapping.java
src/org/apache/fop/layout/BlockArea.java
src/org/apache/fop/layout/LineArea.java

diff --git a/STATUS b/STATUS
index 597d9995156da0e00e92d1d5659e6debe190074a..1476b2031e2ea3959e6a7c35f7efed5394147404 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -30,29 +30,31 @@ Jon Smirl
 
 Done since 0.15 release
 
-- added vertical alignment for table cell contents [Marcus Crafter]
+- added: fo:character and property 'character' [Fotis Jannidis]
+         (limitation: not included into hyphenation)
+- added vertical alignment for table cell contents [Keiron Liddle]
 - added: Finnish hyphenation patterns [Jarno Elovirta]
 - added: hyphenation package (Carlos Villegas), integration into Fop [Fotis Jannidis]
 - added: interim configuration package [Fotis Jannidis]
 - added: FopImage class that uses JAI [Eric Schaeffer] and JAI compile target [Kelly Campbell]
 - added: support for rule-style [Fotis Jannidis]
 - updated tables to handle headers, footers, keep-with, colspan 
-          is partly done [Marcus Crafter]
+          is partly done [Keiron Liddle]
 - updated: svg stuff for the latest java bindings [Keiron Liddle]
 - fixed: enhanced error messages for page layout (region names, master) [Norm Walsh]
 - fixed: infinite looping bug when TableCell or TableRow is larger than a page [Hani Elabed]
 - fixed: corrected the size of the "-" char [Marcus Crafter]
 - fixed: check for unnecessary whitespace at end of line [Marcus Crafter]
-- fixed: moves table completely to next page if first row doesn't fit into last page [Marcus Crafter]
+- fixed: moves table completely to next page if first row doesn't fit into last page [Keiron Liddle]
 - fixed: problem where id's where being setup twice for
          table row going over the page  [Kelly Campbell]
 - fixed colspanning so that the cell state keeps track of the
-        width so far properly [Marcus Crafter]
+        width so far properly [Keiron Liddle]
 - fix to allow JDK 1.1 users to compile and use FOP [Mikko Honkala] 
 - fix: removing duplicate character mappings [Dharamveer Salecha]
 - fix: NullPointerException in FopImageFactory [Kelly Campbell] 
-- fixed: space after's where not being removed if table row was being removed [Marcus Crafter]
-- fixed problem with keep-with not storing the correct rows [Marcus Crafter]
+- fixed: space after's where not being removed if table row was being removed [Keiron Liddle]
+- fixed problem with keep-with not storing the correct rows [Keiron Liddle]
 
 
 Done since 0.14 release
@@ -146,7 +148,6 @@ first target is basic conformance
 1.One category of tasks will be to implement missing formatting objects. 
 
 basic
-  fo:character 
   fo:declarations
   fo:multi-case 
   fo:table-and-caption 
@@ -194,7 +195,6 @@ extended
    border-before-precedence
    border-end-precedence
    border-start-precedence
-   character                                              
    clip                                                   
    column-number                                          
    content-type                                           
@@ -218,7 +218,6 @@ extended
    reference-orientation         
    relative-align                
    role                          
-   rule-style                    
    source-document               
    space-after (full)
    space-before (full)
index 2186eaed5e66bde21e27408c4e16f57ce2416de2..42bd51d87c26eeeb69fd7bfa056adf767a63af8a 100644 (file)
@@ -57,6 +57,7 @@
     <fop fofile="${foDir}/normalex.fo" pdffile="${testDir}/normalex.pdf"/>
     <fop fofile="${foDir}/simple.fo" pdffile="${testDir}/simple.pdf"/>
     <fop fofile="${foDir}/hyphen.fo" pdffile="${testDir}/hyphen.pdf"/>
+    <fop fofile="${foDir}/character.fo" pdffile="${testDir}/character.pdf"/>
   </target>
 
 
@@ -91,6 +92,9 @@
     <fop fofile="${foDir}/inhprop.fo"   pdffile="${referenceDir}/inhprop.pdf"/> 
     <fop fofile="${foDir}/normalex.fo"   pdffile="${referenceDir}/normalex.pdf"/> 
     <fop fofile="${foDir}/simple.fo"   pdffile="${referenceDir}/simple.pdf"/> 
+    <fop fofile="${foDir}/hyphen.fo" pdffile="${referenceDir}/hyphen.pdf"/>
+    <fop fofile="${foDir}/character.fo" pdffile="${referenceDir}/character.pdf"/>
+
   </target>
 
 
index 5f6af34e88633d57904f38cdaa8d8d769d77d0e1..6e6f4765044f6a1d674d60cebdd500b3430081c8 100644 (file)
     <default>none</default>
   </property>
 
+  <property>
+    <name>character</name>
+    <class-name>Character</class-name>
+    <inherited>false</inherited>
+    <datatype>Character</datatype>
+    <default>none</default>
+  </property>
+
  </generic-property-list>
 </property-list>
 
index b882012b00e1f99adccc7b597b972f75c5bfd6ee..0aade4fff3d02bd066ff6bd69b2a82a8c0ce93ac 100644 (file)
@@ -1,36 +1,36 @@
-/*-- $Id$ -- 
+/*-- $Id$ --
 
  ============================================================================
                    The Apache Software License, Version 1.1
  ============================================================================
+
     Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
  Redistribution and use in source and binary forms, with or without modifica-
  tion, are permitted provided that the following conditions are met:
+
  1. Redistributions of  source code must  retain the above copyright  notice,
     this list of conditions and the following disclaimer.
+
  2. Redistributions in binary form must reproduce the above copyright notice,
     this list of conditions and the following disclaimer in the documentation
     and/or other materials provided with the distribution.
+
  3. The end-user documentation included with the redistribution, if any, must
     include  the following  acknowledgment:  "This product includes  software
     developed  by the  Apache Software Foundation  (http://www.apache.org/)."
     Alternately, this  acknowledgment may  appear in the software itself,  if
     and wherever such third-party acknowledgments normally appear.
+
  4. The names "FOP" and  "Apache Software Foundation"  must not be used to
     endorse  or promote  products derived  from this  software without  prior
     written permission. For written permission, please contact
     apache@apache.org.
+
  5. Products  derived from this software may not  be called "Apache", nor may
     "Apache" appear  in their name,  without prior written permission  of the
     Apache Software Foundation.
+
  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
  This software  consists of voluntary contributions made  by many individuals
  on  behalf of the Apache Software  Foundation and was  originally created by
- James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
  Software Foundation, please see <http://www.apache.org/>.
+
  */
 
 package org.apache.fop.fo;
@@ -60,41 +60,41 @@ public class StandardElementMapping implements ElementMapping {
 
        String uri = "http://www.w3.org/1999/XSL/Format";
 
-       builder.addMapping(uri, "root", Root.maker()); 
+       builder.addMapping(uri, "root", Root.maker());
        builder.addMapping(uri, "layout-master-set",
-                          LayoutMasterSet.maker()); 
+                          LayoutMasterSet.maker());
        builder.addMapping(uri, "simple-page-master",
-                          SimplePageMaster.maker()); 
-       builder.addMapping(uri, "region-body", RegionBody.maker()); 
-       builder.addMapping(uri, "region-before", RegionBefore.maker()); 
-       builder.addMapping(uri, "region-after", RegionAfter.maker()); 
-       builder.addMapping(uri, "page-sequence", PageSequence.maker()); 
+                          SimplePageMaster.maker());
+       builder.addMapping(uri, "region-body", RegionBody.maker());
+       builder.addMapping(uri, "region-before", RegionBefore.maker());
+       builder.addMapping(uri, "region-after", RegionAfter.maker());
+       builder.addMapping(uri, "page-sequence", PageSequence.maker());
        builder.addMapping(uri, "page-sequence-master",
-                          PageSequenceMaster.maker()); 
+                          PageSequenceMaster.maker());
        builder.addMapping(uri, "single-page-master-reference",
-                          SinglePageMasterReference.maker()); 
+                          SinglePageMasterReference.maker());
        builder.addMapping(uri, "repeatable-page-master-reference",
-                          RepeatablePageMasterReference.maker()); 
+                          RepeatablePageMasterReference.maker());
        builder.addMapping(uri, "conditional-page-master-reference",
-                          ConditionalPageMasterReference.maker()); 
+                          ConditionalPageMasterReference.maker());
        builder.addMapping(uri, "repeatable-page-master-alternatives",
-                          RepeatablePageMasterAlternatives.maker()); 
-       builder.addMapping(uri, "flow", Flow.maker()); 
+                          RepeatablePageMasterAlternatives.maker());
+       builder.addMapping(uri, "flow", Flow.maker());
        builder.addMapping(uri, "static-content",
                           StaticContent.maker());
-       builder.addMapping(uri, "block", Block.maker()); 
-       builder.addMapping(uri, "block-container", BlockContainer.maker()); 
+       builder.addMapping(uri, "block", Block.maker());
+       builder.addMapping(uri, "block-container", BlockContainer.maker());
        builder.addMapping(uri, "list-block", ListBlock.maker());
        builder.addMapping(uri, "list-item", ListItem.maker());
        builder.addMapping(uri, "list-item-label",
-                          ListItemLabel.maker()); 
+                          ListItemLabel.maker());
        builder.addMapping(uri, "list-item-body", ListItemBody.maker());
        builder.addMapping(uri, "page-number", PageNumber.maker());
        builder.addMapping(uri, "page-number-citation", PageNumberCitation.maker());
        builder.addMapping(uri, "display-sequence",
-                          DisplaySequence.maker()); 
+                          DisplaySequence.maker());
        builder.addMapping(uri, "inline",
-                          Inline.maker()); 
+                          Inline.maker());
   builder.addMapping(uri, "external-graphic",
                            ExternalGraphic.maker());
        builder.addMapping(uri, "table", Table.maker());
@@ -107,5 +107,6 @@ public class StandardElementMapping implements ElementMapping {
        builder.addMapping(uri, "basic-link", BasicLink.maker());
        builder.addMapping(uri, "instream-foreign-object", InstreamForeignObject.maker());
        builder.addMapping(uri, "leader", Leader.maker());
+       builder.addMapping(uri, "character", org.apache.fop.fo.flow.Character.maker());
     }
 }
index 3a7eb48c012813c6e89e5f6f4c196de2edae27d0..fc31e89f24067e3bc0629f9ec8e6894641761fb9 100644 (file)
@@ -279,6 +279,45 @@ public class BlockArea extends Area {
         return 1;
     }
 
+    public void addCharacter(FontState fontState, float red, float green,
+                       float blue, int wrapOption, LinkSet ls,
+                       int whiteSpaceCollapse, char data, boolean ul) {
+
+        this.currentLineArea.changeFont(fontState);
+        this.currentLineArea.changeColor(red, green, blue);
+        this.currentLineArea.changeWrapOption(wrapOption);
+        this.currentLineArea.changeWhiteSpaceCollapse(whiteSpaceCollapse);
+
+        if (ls != null) {
+            this.currentLinkSet = ls;
+            ls.setYOffset(currentHeight);
+        }
+
+        int marker = this.currentLineArea.addCharacter(data, ls, ul);
+        //if character didn't fit into line, open a new one
+        if (marker == org.apache.fop.fo.flow.Character.DOESNOT_FIT) {
+            this.currentLineArea.align(this.align);
+            this.addLineArea(this.currentLineArea);
+
+            this.currentLineArea =
+              new LineArea(fontState, lineHeight, halfLeading,
+                           allocationWidth, startIndent, endIndent,
+                           currentLineArea);
+            this.currentLineArea.changeFont(fontState);
+            this.currentLineArea.changeColor(red, green, blue);
+            this.currentLineArea.changeWrapOption(wrapOption);
+            this.currentLineArea.changeWhiteSpaceCollapse(
+              whiteSpaceCollapse);
+            if (ls != null) {
+                this.currentLinkSet = ls;
+                ls.setYOffset(currentHeight);
+            }
+
+            this.currentLineArea.addCharacter(data, ls, ul);
+        }
+        this.hasLines = true;
+    }
+
 
     public void end() {
         if (this.hasLines) {
index 63d2ef0d3310b25678dd02d55c640bebf5900a23..9967abb378404fe8a2db9e8599fd6b3e061b7310 100644 (file)
@@ -250,9 +250,7 @@ public class LineArea extends Area {
                 } else if (prev == TEXT) {
 
                     // if current is WHITESPACE and previous TEXT
-
                     // the current word made it, so
-
                     // add the space before the current word (if there
                     // was some)
 
@@ -539,7 +537,7 @@ public class LineArea extends Area {
 
     /**
        * adds pending inline areas to the line area
-       * normally done,if the line area is filled and
+       * normally done, when the line area is filled and
        * added as child to the parent block area
        */
     public void addPending() {
@@ -804,4 +802,34 @@ public class LineArea extends Area {
       }
       return width;
     }
+
+    public int addCharacter (char data, LinkSet ls, boolean ul) {
+        InlineArea ia = null;
+        int remainingWidth =
+          this.getContentWidth() - this.getCurrentXPosition();
+        int width = this.currentFontState.width(data);
+        //if it doesn't fit, return
+        if (width > remainingWidth) {
+          return org.apache.fop.fo.flow.Character.DOESNOT_FIT;
+        } else {
+          //if whitespace-collapse == true, discard character
+          if (Character.isSpaceChar(data) && whiteSpaceCollapse == WhiteSpaceCollapse.TRUE) {
+            return org.apache.fop.fo.flow.Character.OK;
+          }
+          //create new InlineArea
+          ia = new InlineArea(currentFontState,
+                                         this.red, this.green, this.blue,
+                                         new Character(data).toString(),width);
+          ia.setUnderlined(ul);
+          pendingAreas.addElement(ia);
+          if (Character.isSpaceChar(data)) {
+            this.spaceWidth =+ width;
+            prev = LineArea.WHITESPACE;
+          } else {
+            pendingWidth += width;
+            prev = LineArea.TEXT;
+          }
+          return org.apache.fop.fo.flow.Character.OK;
+        }
+    }
 }