Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/jfor/jfor/rtflib/rtfdoc/RtfParagraphKeepTogether.java


1   package org.jfor.jfor.rtflib.rtfdoc;
2   
3   
4   import java.io.Writer;
5   import java.io.*;
6   import java.util.*;
7   import java.io.IOException;
8   
9   /*-----------------------------------------------------------------------------
10   * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
11   *
12   * ====================================================================
13   * jfor Apache-Style Software License.
14   * Copyright (c) 2002 by the jfor project. All rights reserved.
15   *
16   * Redistribution and use in source and binary forms, with or without
17   * modification, are permitted provided that the following conditions
18   * are met:
19   *
20   * 1. Redistributions of source code must retain the above copyright
21   * notice, this list of conditions and the following disclaimer.
22   *
23   * 2. Redistributions in binary form must reproduce the above copyright
24   * notice, this list of conditions and the following disclaimer in
25   * the documentation and/or other materials provided with the
26   * distribution.
27   *
28   * 3. The end-user documentation included with the redistribution,
29   * if any, must include the following acknowledgment:
30   * "This product includes software developed
31   * by the jfor project (http://www.jfor.org)."
32   * Alternately, this acknowledgment may appear in the software itself,
33   * if and wherever such third-party acknowledgments normally appear.
34   *
35   * 4. The name "jfor" must not be used to endorse
36   * or promote products derived from this software without prior written
37   * permission.  For written permission, please contact info@jfor.org.
38   *
39   * 5. Products derived from this software may not be called "jfor",
40   * nor may "jfor" appear in their name, without prior written
41   * permission of info@jfor.org.
42   *
43   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
44   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
46   * DISCLAIMED.  IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
47   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
48   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
49   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
50   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
52   * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54   * ====================================================================
55   * Contributor(s):
56  -----------------------------------------------------------------------------*/
57  
58  public class RtfParagraphKeepTogether extends RtfContainer{
59    
60    public static final int STATUS_NULL=0;
61    public static final int STATUS_OPEN_PARAGRAPH=1;
62    public static final int STATUS_CLOSE_PARAGRAPH=2;
63    private int m_status =STATUS_NULL;
64    
65  
66    /**  RtfParagraphKeepTogether*/ 
67    RtfParagraphKeepTogether(IRtfParagraphContainer parent, Writer w) throws IOException {
68      super((RtfContainer)parent,w);
69    }
70  
71  
72    protected void writeRtfContent() throws IOException {
73  
74      //First reet paragraph properties
75      // create a new one with keepn
76      if (m_status==STATUS_OPEN_PARAGRAPH) {
77        writeControlWord("pard");
78        writeControlWord("par");
79        writeControlWord("keepn");
80        writeGroupMark(true);      
81        m_status = STATUS_NULL;
82      }
83  
84  
85      if (m_status == STATUS_CLOSE_PARAGRAPH) {
86        writeGroupMark(false);
87        m_status = STATUS_NULL;      
88      }
89  
90    }
91    
92    
93  
94    public void setStatus(int status) {
95      m_status = status;  
96    }  
97  
98     /** true if this element would generate no "useful" RTF content */
99      public boolean isEmpty()
100     {
101         return false;
102     }
103   
104 }