1 /*
2 * Copyright (c) 1997, 2008, 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
851 outputStream.write('\\');
852 writeRawString(keyword);
853 writeRawString(String.valueOf(arg)); /* TODO: correct in all cases? */
854 afterKeyword = true;
855 }
856
857 public void writeBegingroup()
858 throws IOException
859 {
860 outputStream.write('{');
861 afterKeyword = false;
862 }
863
864 public void writeEndgroup()
865 throws IOException
866 {
867 outputStream.write('}');
868 afterKeyword = false;
869 }
870
871 public void writeCharacter(char ch)
872 throws IOException
873 {
874 /* Nonbreaking space is in most RTF encodings, but the keyword is
875 preferable; same goes for tabs */
876 if (ch == 0xA0) { /* nonbreaking space */
877 outputStream.write(0x5C); /* backslash */
878 outputStream.write(0x7E); /* tilde */
879 afterKeyword = false; /* non-alpha keywords are self-terminating */
880 return;
881 }
882
883 if (ch == 0x09) { /* horizontal tab */
884 writeControlWord("tab");
885 return;
886 }
887
888 if (ch == 10 || ch == 13) { /* newline / paragraph */
889 /* ignore CRs, we'll write a paragraph element soon enough */
890 return;
|
1 /*
2 * Copyright (c) 1997, 2014, 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
851 outputStream.write('\\');
852 writeRawString(keyword);
853 writeRawString(String.valueOf(arg)); /* TODO: correct in all cases? */
854 afterKeyword = true;
855 }
856
857 public void writeBegingroup()
858 throws IOException
859 {
860 outputStream.write('{');
861 afterKeyword = false;
862 }
863
864 public void writeEndgroup()
865 throws IOException
866 {
867 outputStream.write('}');
868 afterKeyword = false;
869 }
870
871 @SuppressWarnings("fallthrough")
872 public void writeCharacter(char ch)
873 throws IOException
874 {
875 /* Nonbreaking space is in most RTF encodings, but the keyword is
876 preferable; same goes for tabs */
877 if (ch == 0xA0) { /* nonbreaking space */
878 outputStream.write(0x5C); /* backslash */
879 outputStream.write(0x7E); /* tilde */
880 afterKeyword = false; /* non-alpha keywords are self-terminating */
881 return;
882 }
883
884 if (ch == 0x09) { /* horizontal tab */
885 writeControlWord("tab");
886 return;
887 }
888
889 if (ch == 10 || ch == 13) { /* newline / paragraph */
890 /* ignore CRs, we'll write a paragraph element soon enough */
891 return;
|