⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtfrow.java

📁 iText是一个能够快速产生PDF文件的java类库。iText的java类对于那些要产生包含文本
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**
 * $Id: RtfRow.java 2748 2007-05-12 15:11:48Z blowagie $
 * $Name$
 *
 * Copyright 2001, 2002 by Mark Hall
 *
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (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.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the License.
 *
 * The Original Code is 'iText, a free JAVA-PDF library'.
 *
 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
 * All Rights Reserved.
 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
 *
 * Contributor(s): all the names of the contributors are added in the source code
 * where applicable.
 *
 * Alternatively, the contents of this file may be used under the terms of the
 * LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
 * provisions of LGPL are applicable instead of those above.  If you wish to
 * allow use of your version of this file only under the terms of the LGPL
 * License and not to allow others to use your version of this file under
 * the MPL, indicate your decision by deleting the provisions above and
 * replace them with the notice and other provisions required by the LGPL.
 * If you do not delete the provisions above, a recipient may use your version
 * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the MPL as stated above or under the terms of the GNU
 * Library General Public License as published by the Free Software Foundation;
 * either version 2 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
 * details.
 *
 * If you didn't download this code from the following link, you should check if
 * you aren't using an obsolete version:
 * http://www.lowagie.com/iText/
 */

package com.lowagie.text.rtf;

import java.awt.Color;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;

import com.lowagie.text.Cell;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Rectangle;
import com.lowagie.text.Row;
import com.lowagie.text.Table;

/**
 * A Helper Class for the <CODE>RtfWriter</CODE>.
 * <P>
 * Do not use it directly
 * 
 * ONLY FOR USE WITH THE RtfWriter NOT with the RtfWriter2.
 *
 * Parts of this Class were contributed by Steffen Stundzig. Many thanks for the
 * improvements.
 * Code added by c
 * @deprecated Please move to the RtfWriter2 and associated classes.
 */
public class RtfRow {
    /** Table border solid */
    public static final byte[] tableBorder = "brdrs".getBytes();
    /** Table border width */
    public static final byte[] tableBorderWidth = "brdrw".getBytes();
    /** Table border color */
    public static final byte[] tableBorderColor = "brdrcf".getBytes();

    /** Table row defaults */
    private static final byte[] rowBegin = "trowd".getBytes();
    /** End of table row */
    private static final byte[] rowEnd = "row".getBytes();
    /** Table row autofit */
    private static final byte[] rowAutofit = "trautofit1".getBytes();
    private static final byte[] graphLeft = "trgaph".getBytes();
    /** Row border left */
    private static final byte[] rowBorderLeft = "trbrdrl".getBytes();
    /** Row border right */
    private static final byte[] rowBorderRight = "trbrdrr".getBytes();
    /** Row border top */
    private static final byte[] rowBorderTop = "trbrdrt".getBytes();
    /** Row border bottom */
    private static final byte[] rowBorderBottom = "trbrdrb".getBytes();
    /** Row border horiz inline */
    private static final byte[] rowBorderInlineHorizontal = "trbrdrh".getBytes();
    /** Row border bottom */
    private static final byte[] rowBorderInlineVertical = "trbrdrv".getBytes();
    /** Default cell spacing left */
    private static final byte[] rowSpacingLeft = "trspdl".getBytes();
    /** Default cell spacing right */
    private static final byte[] rowSpacingRight = "trspdr".getBytes();
    /** Default cell spacing top */
    private static final byte[] rowSpacingTop = "trspdt".getBytes();
    /** Default cell spacing bottom */
    private static final byte[] rowSpacingBottom = "trspdb".getBytes();
    /** Default cell spacing format left */
    private static final byte[] rowSpacingLeftStyle = "trspdfl3".getBytes();
    /** Default cell spacing format right */
    private static final byte[] rowSpacingRightStyle = "trspdfr3".getBytes();
    /** Default cell spacing format top */
    private static final byte[] rowSpacingTopStyle = "trspdft3".getBytes();
    /** Default cell spacing format bottom */
    private static final byte[] rowSpacingBottomStyle = "trspdfb3".getBytes();
    /** Default cell padding left */
    private static final byte[] rowPaddingLeft = "trpaddl".getBytes();
    /** Default cell padding right */
    private static final byte[] rowPaddingRight = "trpaddr".getBytes();
    /** Default cell padding format left */
    private static final byte[] rowPaddingLeftStyle = "trpaddfl3".getBytes();
    /** Default cell padding format right */
    private static final byte[] rowPaddingRightStyle = "trpaddfr3".getBytes();
    /** Row width format */
    private static final byte[] rowWidthStyle = "trftsWidth3".getBytes();
    /** Row width */
    private static final byte[] rowWidth = "trwWidth".getBytes();
    /**
     * Table row header. This row should appear at the top of every
     * page the current table appears on.
     */
    private static final byte[] rowHeader = "trhdr".getBytes();
    /**
     * Table row keep together. This row cannot be split by a page break.
     * This property is assumed to be off unless the control word is
     * present.
     */
    private static final byte[] rowKeep = "trkeep".getBytes();
    /** Table alignment left */
    private static final byte[] rowAlignLeft = "trql".getBytes();
    /** Table alignment center */
    private static final byte[] rowAlignCenter = "trqc".getBytes();
    /** Table alignment right */
    private static final byte[] rowAlignRight = "trqr".getBytes();

    /** List of <code>RtfCell</code>s in this <code>RtfRow</code> */
    private ArrayList cells = new ArrayList();
    /** The <code>RtfWriter</code> to which this <code>RtfRow</code> belongs */
    private RtfWriter writer = null;
    /** The <coce>RtfTable</code> to which this <code>RtfRow</code> belongs */
    private RtfTable mainTable = null;

    /** The width of this <code>RtfRow</code> (in percent) */
    private int width = 100;
    /** The default cellpadding of <code>RtfCells</code> in this
     * <code>RtfRow</code> */
    private int cellpadding = 115;
    /** The default cellspacing of <code>RtfCells</code> in this
     * <code>RtfRow</code> */
    private int cellspacing = 14;
    /** The borders of this <code>RtfRow</code> */
    private int borders = 0;
    /** The border color of this <code>RtfRow</code> */
    private java.awt.Color borderColor = null;
    /** The border width of this <code>RtfRow</code> */
    private float borderWidth = 0;

    /** Original Row */
    private Row origRow = null;

    /**
     * Create a new <code>RtfRow</code>.
     *
     * @param writer The <code>RtfWriter</code> that this <code>RtfRow</code> belongs to
     * @param mainTable The <code>RtfTable</code> that created this
     * <code>RtfRow</code>
     */
    public RtfRow(RtfWriter writer, RtfTable mainTable) {
        super();
        this.writer = writer;
        this.mainTable = mainTable;
    }

    /**
     * Pregenerate the <code>RtfCell</code>s in this <code>RtfRow</code>.
     *
     * @param columns The number of <code>RtfCell</code>s to be generated.
     */
    public void pregenerateRows(int columns) {
        for (int i = 0; i < columns; i++) {
            RtfCell rtfCell = new RtfCell(writer, mainTable);
            cells.add(rtfCell);
        }
    }

    /**
     * Import a <code>Row</code>.
     * <P>
     * All the parameters are taken from the <code>RtfTable</code> which contains
     * this <code>RtfRow</code> and they do exactely what they say
     * @param row
     * @param propWidths in percent
     * @param tableWidth in percent
     * @param pageWidth
     * @param cellpadding
     * @param cellspacing
     * @param borders
     * @param borderColor
     * @param borderWidth
     * @param y
     * @return true if importing the row succeeded
     */
    public boolean importRow(Row row, float[] propWidths, int tableWidth, int pageWidth, int cellpadding,
                             int cellspacing, int borders, java.awt.Color borderColor, float borderWidth,
                             int y) {
        // the width of this row is the absolute witdh, calculated from the
        // proportional with of the table and the total width of the page
        this.origRow = row;
        this.width = pageWidth * tableWidth / 100;
        this.cellpadding = cellpadding;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -