You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ph...@apache.org on 2006/06/05 13:32:59 UTC

svn commit: r411750 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf: TextAttributesConverter.java rtflib/rtfdoc/RtfTableCell.java rtflib/rtfdoc/RtfTextrun.java

Author: pherweg
Date: Mon Jun  5 04:32:59 2006
New Revision: 411750

URL: http://svn.apache.org/viewvc?rev=411750&view=rev
Log:
Blocklevel attributes did not work for last fo:block element under fo:table-cell. Fixed.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java?rev=411750&r1=411749&r2=411750&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Mon Jun  5 04:32:59 2006
@@ -178,6 +178,8 @@
     private static void attrTextDecoration(CommonTextDecoration textDecoration, 
                 RtfAttributes rtfAttr) {
         if (textDecoration == null) {
+            rtfAttr.set(RtfText.ATTR_UNDERLINE, 0);
+            rtfAttr.set(RtfText.ATTR_STRIKETHROUGH, 0);
             return;
         }
                 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java?rev=411750&r1=411749&r2=411750&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java Mon Jun  5 04:32:59 2006
@@ -327,7 +327,20 @@
             } else if (setRight) {
                 writeControlWord("qr");
             } else {
-                writeControlWord("ql");
+                RtfElement lastChild = null;
+                
+                if (getChildren().size() > 0) {
+                    lastChild = (RtfElement) getChildren().get(getChildren().size() - 1);
+                }
+                    
+                
+                if (lastChild != null
+                        && lastChild instanceof RtfTextrun) {
+                    //Don't write \ql in order to allow for example a right aligned paragraph 
+                    //in a not right aligned table-cell to write its \qr.
+                } else {
+                    writeControlWord("ql");
+                }                
             }
 
             if (!containsText()) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java?rev=411750&r1=411749&r2=411750&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java Mon Jun  5 04:32:59 2006
@@ -16,13 +16,6 @@
 
 /* $Id$ */
 
-
-
-/*
- * This file is part of the RTF library of the FOP project.
- */
-
-
 package org.apache.fop.render.rtf.rtflib.rtfdoc;
 
 // Java
@@ -132,7 +125,7 @@
      * @param attrs  attributes to add
      * @throws IOException for I/O problems
      */
-    public void addOpenGroupMark(RtfAttributes attrs) throws IOException {
+    private void addOpenGroupMark(RtfAttributes attrs) throws IOException {
         RtfOpenGroupMark r = new RtfOpenGroupMark(this, writer, attrs);
     }
 
@@ -141,7 +134,7 @@
      * 
      * @throws IOException for I/O problems
      */
-    public void addCloseGroupMark() throws IOException {
+    private void addCloseGroupMark() throws IOException {
         RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer);
     }
     
@@ -209,6 +202,12 @@
         rtfSpaceManager.popRtfSpaceSplitter();
     }
     
+    /**
+     * Inserts a footnote.
+     * 
+     * @return inserted footnote
+     * @throws IOException for I/O problems
+     */
     public RtfFootnote addFootnote() throws IOException {
         return new RtfFootnote(this, writer);
     }
@@ -242,21 +241,42 @@
         }
     }
     
+    /**
+     * Inserts a page number.
+     * @param attr Attributes for the page number to insert.
+     * @throws IOException for I/O problems
+     */
     public void addPageNumber(RtfAttributes attr) throws IOException {
         RtfPageNumber r = new RtfPageNumber(this, writer, attr);
     }
     
+    /**
+     * Inserts a hyperlink.
+     * @param attr Attributes for the hyperlink to insert.
+     * @return inserted hyperlink
+     * @throws IOException for I/O problems
+     */
     public RtfHyperLink addHyperlink(RtfAttributes attr) throws IOException {
         return new RtfHyperLink(this, writer, attr);
     }
     
+    /**
+     * Inserts a bookmark.
+     * @param id Id for the inserted bookmark
+     * @throws IOException for I/O problems
+     */
     public void addBookmark(String id) throws IOException {
        if (id != "") {
             // if id is not empty, add boormark
            new RtfBookmark(this, writer, id);
        }
     }
-    
+
+    /**
+     * Inserts an image.
+     * @return inserted image
+     * @throws IOException for I/O problems
+     */
     public RtfExternalGraphic newImage() throws IOException {
         return new RtfExternalGraphic(this, writer);
     }
@@ -266,11 +286,12 @@
      * @param container RtfContainer, which is the parent of the returned RtfTextrun
      * @param writer Writer of the given RtfContainer
      * @param attrs RtfAttributes which are to write at the beginning of the RtfTextrun
+     * @return new or existing RtfTextrun object.
      * @throws IOException for I/O problems
      */
     public static RtfTextrun getTextrun(RtfContainer container, Writer writer, RtfAttributes attrs)
             throws IOException {
-        Object obj;
+
         List list = container.getChildren();
                 
         if (list.size() == 0) {
@@ -279,9 +300,13 @@
             list.add(textrun);
 
             return textrun;
-        } else if ((obj = list.get(list.size() - 1)) instanceof RtfTextrun ) {
+        }
+        
+        Object obj = list.get(list.size() - 1);
+
+        if (obj instanceof RtfTextrun) {
             //if the last child is a RtfTextrun, return it
-            return (RtfTextrun)obj;
+            return (RtfTextrun) obj;
         }
 
         //add a new RtfTextrun as the last child
@@ -310,6 +335,10 @@
          * 2. To write the children
          * Maybe this can be done more efficient.
          */
+        
+        boolean bHasTableCellParent =
+            this.getParentOfClass(RtfTableCell.class) != null;
+        RtfAttributes attrBlockLevel = new RtfAttributes();
 
         //determine, if this RtfTextrun is the last child of its parent
         boolean bLast = false;
@@ -351,6 +380,11 @@
             final RtfElement e = (RtfElement)it.next();
             final boolean bRtfParagraphBreak = (e instanceof RtfParagraphBreak);
 
+            if (bHasTableCellParent) {
+                attrBlockLevel.set(e.getRtfAttributes());
+            }
+            
+            
             /**
              * -Write RtfParagraphBreak only, if the previous visible child
              * was't also a RtfParagraphBreak.
@@ -386,13 +420,29 @@
                 bPrevPar = bPrevPar && e.isEmpty();
                 bFirst = bFirst && e.isEmpty();
             }
+        } //for (Iterator it = ...)
+        
+        //
+        if (bHasTableCellParent) {
+            writeAttributes(attrBlockLevel, null);
         }
+        
     }
     
+    /**
+     * Set the parent list-item of the textrun.
+     * 
+     * @param listItem parent list-item of the textrun
+     */
     public void setRtfListItem(RtfListItem listItem) {
         rtfListItem = listItem;
     }
     
+    /**
+     * Gets the parent list-item of the textrun. 
+     * 
+     * @return parent list-item of the textrun
+     */
     public RtfListItem getRtfListItem() {
         return rtfListItem;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org