< prev index next >

src/java.desktop/share/classes/javax/swing/text/rtf/RTFGenerator.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  25 package javax.swing.text.rtf;
  26 
  27 import java.lang.*;
  28 import java.util.*;
  29 import java.awt.Color;
  30 import java.awt.Font;
  31 import java.io.OutputStream;
  32 import java.io.IOException;
  33 
  34 import javax.swing.text.*;
  35 
  36 /**
  37  * Generates an RTF output stream (java.io.OutputStream) from rich text
  38  * (handed off through a series of LTTextAcceptor calls).  Can be used to
  39  * generate RTF from any object which knows how to write to a text acceptor
  40  * (e.g., LTAttributedText and LTRTFFilter).
  41  *
  42  * <p>Note that this is a lossy conversion since RTF's model of
  43  * text does not exactly correspond with LightText's.
  44  *
  45  * @see LTAttributedText
  46  * @see LTRTFFilter
  47  * @see LTTextAcceptor
  48  * @see java.io.OutputStream
  49  */
  50 
  51 class RTFGenerator extends Object
  52 {
  53     /* These dictionaries map Colors, font names, or Style objects
  54        to Integers */
  55     Dictionary<Object, Integer> colorTable;
  56     int colorCount;
  57     Dictionary<String, Integer> fontTable;
  58     int fontCount;
  59     Dictionary<AttributeSet, Integer> styleTable;
  60     int styleCount;
  61 
  62     /* where all the text is going */
  63     OutputStream outputStream;
  64 
  65     boolean afterKeyword;
  66 
  67     MutableAttributeSet outputAttributes;
  68 
  69     /* the value of the last \\ucN keyword emitted */
  70     int unicodeCount;


   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  25 package javax.swing.text.rtf;
  26 
  27 import java.lang.*;
  28 import java.util.*;
  29 import java.awt.Color;
  30 import java.awt.Font;
  31 import java.io.OutputStream;
  32 import java.io.IOException;
  33 
  34 import javax.swing.text.*;
  35 
  36 /**
  37  * Generates an RTF output stream (java.io.OutputStream) from rich text
  38  * (handed off through a series of LTTextAcceptor calls).  Can be used to
  39  * generate RTF from any object which knows how to write to a text acceptor
  40  * (e.g., LTAttributedText and LTRTFFilter).
  41  *
  42  * <p>Note that this is a lossy conversion since RTF's model of
  43  * text does not exactly correspond with LightText's.
  44  *



  45  * @see java.io.OutputStream
  46  */

  47 class RTFGenerator extends Object
  48 {
  49     /* These dictionaries map Colors, font names, or Style objects
  50        to Integers */
  51     Dictionary<Object, Integer> colorTable;
  52     int colorCount;
  53     Dictionary<String, Integer> fontTable;
  54     int fontCount;
  55     Dictionary<AttributeSet, Integer> styleTable;
  56     int styleCount;
  57 
  58     /* where all the text is going */
  59     OutputStream outputStream;
  60 
  61     boolean afterKeyword;
  62 
  63     MutableAttributeSet outputAttributes;
  64 
  65     /* the value of the last \\ucN keyword emitted */
  66     int unicodeCount;


< prev index next >