diff options
Diffstat (limited to 'source/ShiftUI/RTF')
25 files changed, 6170 insertions, 0 deletions
diff --git a/source/ShiftUI/RTF/Charcode.cs b/source/ShiftUI/RTF/Charcode.cs new file mode 100644 index 0000000..02480b5 --- /dev/null +++ b/source/ShiftUI/RTF/Charcode.cs @@ -0,0 +1,413 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +using System.Collections; + +namespace ShiftUI.RTF { + internal class Charcode { + #region Local Variables + private StandardCharCode[] codes; + private Hashtable reverse; + private int size; + #endregion // Local Variables + + #region Cached Values + static Charcode ansi_generic; + #endregion + + #region Public Constructors + public Charcode() : this(256) { + } + + private Charcode(int size) { + this.size = size; + this.codes = new StandardCharCode[size]; + this.reverse = new Hashtable(size); + + // No need to reinitialize array to its default value + //for (int i = 0; i < size; i++) { + // codes[i] = StandardCharCode.nothing; + //} + } + #endregion // Public Constructors + + #region Public Instance Properties + public int this[StandardCharCode c] { + get { + object obj; + + obj = reverse[c]; + if (obj != null) { + return (int)obj; + } + for (int i = 0; i < size; i++) { + if (codes[i] == c) { + return i; + } + } + + return -1; + } + } + + public StandardCharCode this[int c] { + get { + if (c < 0 || c >= size) { + return StandardCharCode.nothing; + } + + return codes[c]; + } + + private set { + if (c < 0 || c >= size) { + return; + } + + codes[c] = value; + reverse[value] = c; + } + } + #endregion // Public Instance Properties + + #region Public Instance Methods + #endregion // Public Instance Methods + + #region Public Static Methods + public static Charcode AnsiGeneric { + get { + if (ansi_generic != null) + return ansi_generic; + + ansi_generic = new Charcode(256); + + ansi_generic[0x06] = StandardCharCode.formula; + ansi_generic[0x1e] = StandardCharCode.nobrkhyphen; + ansi_generic[0x1f] = StandardCharCode.opthyphen; + ansi_generic[' '] = StandardCharCode.space; + ansi_generic['!'] = StandardCharCode.exclam; + ansi_generic['"'] = StandardCharCode.quotedbl; + ansi_generic['#'] = StandardCharCode.numbersign; + ansi_generic['$'] = StandardCharCode.dollar; + ansi_generic['%'] = StandardCharCode.percent; + ansi_generic['&'] = StandardCharCode.ampersand; + ansi_generic['\\'] = StandardCharCode.quoteright; + ansi_generic['('] = StandardCharCode.parenleft; + ansi_generic[')'] = StandardCharCode.parenright; + ansi_generic['*'] = StandardCharCode.asterisk; + ansi_generic['+'] = StandardCharCode.plus; + ansi_generic[','] = StandardCharCode.comma; + ansi_generic['-'] = StandardCharCode.hyphen; + ansi_generic['.'] = StandardCharCode.period; + ansi_generic['/'] = StandardCharCode.slash; + ansi_generic['0'] = StandardCharCode.zero; + ansi_generic['1'] = StandardCharCode.one; + ansi_generic['2'] = StandardCharCode.two; + ansi_generic['3'] = StandardCharCode.three; + ansi_generic['4'] = StandardCharCode.four; + ansi_generic['5'] = StandardCharCode.five; + ansi_generic['6'] = StandardCharCode.six; + ansi_generic['7'] = StandardCharCode.seven; + ansi_generic['8'] = StandardCharCode.eight; + ansi_generic['9'] = StandardCharCode.nine; + ansi_generic[':'] = StandardCharCode.colon; + ansi_generic[';'] = StandardCharCode.semicolon; + ansi_generic['<'] = StandardCharCode.less; + ansi_generic['='] = StandardCharCode.equal; + ansi_generic['>'] = StandardCharCode.greater; + ansi_generic['?'] = StandardCharCode.question; + ansi_generic['@'] = StandardCharCode.at; + ansi_generic['A'] = StandardCharCode.A; + ansi_generic['B'] = StandardCharCode.B; + ansi_generic['C'] = StandardCharCode.C; + ansi_generic['D'] = StandardCharCode.D; + ansi_generic['E'] = StandardCharCode.E; + ansi_generic['F'] = StandardCharCode.F; + ansi_generic['G'] = StandardCharCode.G; + ansi_generic['H'] = StandardCharCode.H; + ansi_generic['I'] = StandardCharCode.I; + ansi_generic['J'] = StandardCharCode.J; + ansi_generic['K'] = StandardCharCode.K; + ansi_generic['L'] = StandardCharCode.L; + ansi_generic['M'] = StandardCharCode.M; + ansi_generic['N'] = StandardCharCode.N; + ansi_generic['O'] = StandardCharCode.O; + ansi_generic['P'] = StandardCharCode.P; + ansi_generic['Q'] = StandardCharCode.Q; + ansi_generic['R'] = StandardCharCode.R; + ansi_generic['S'] = StandardCharCode.S; + ansi_generic['T'] = StandardCharCode.T; + ansi_generic['U'] = StandardCharCode.U; + ansi_generic['V'] = StandardCharCode.V; + ansi_generic['W'] = StandardCharCode.W; + ansi_generic['X'] = StandardCharCode.X; + ansi_generic['Y'] = StandardCharCode.Y; + ansi_generic['Z'] = StandardCharCode.Z; + ansi_generic['['] = StandardCharCode.bracketleft; + ansi_generic['\\'] = StandardCharCode.backslash; + ansi_generic[']'] = StandardCharCode.bracketright; + ansi_generic['^'] = StandardCharCode.asciicircum; + ansi_generic['_'] = StandardCharCode.underscore; + ansi_generic['`'] = StandardCharCode.quoteleft; + ansi_generic['a'] = StandardCharCode.a; + ansi_generic['b'] = StandardCharCode.b; + ansi_generic['c'] = StandardCharCode.c; + ansi_generic['d'] = StandardCharCode.d; + ansi_generic['e'] = StandardCharCode.e; + ansi_generic['f'] = StandardCharCode.f; + ansi_generic['g'] = StandardCharCode.g; + ansi_generic['h'] = StandardCharCode.h; + ansi_generic['i'] = StandardCharCode.i; + ansi_generic['j'] = StandardCharCode.j; + ansi_generic['k'] = StandardCharCode.k; + ansi_generic['l'] = StandardCharCode.l; + ansi_generic['m'] = StandardCharCode.m; + ansi_generic['n'] = StandardCharCode.n; + ansi_generic['o'] = StandardCharCode.o; + ansi_generic['p'] = StandardCharCode.p; + ansi_generic['q'] = StandardCharCode.q; + ansi_generic['r'] = StandardCharCode.r; + ansi_generic['s'] = StandardCharCode.s; + ansi_generic['t'] = StandardCharCode.t; + ansi_generic['u'] = StandardCharCode.u; + ansi_generic['v'] = StandardCharCode.v; + ansi_generic['w'] = StandardCharCode.w; + ansi_generic['x'] = StandardCharCode.x; + ansi_generic['y'] = StandardCharCode.y; + ansi_generic['z'] = StandardCharCode.z; + ansi_generic['{'] = StandardCharCode.braceleft; + ansi_generic['|'] = StandardCharCode.bar; + ansi_generic['}'] = StandardCharCode.braceright; + ansi_generic['~'] = StandardCharCode.asciitilde; + ansi_generic[0xa0] = StandardCharCode.nobrkspace; + ansi_generic[0xa1] = StandardCharCode.exclamdown; + ansi_generic[0xa2] = StandardCharCode.cent; + ansi_generic[0xa3] = StandardCharCode.sterling; + ansi_generic[0xa4] = StandardCharCode.currency; + ansi_generic[0xa5] = StandardCharCode.yen; + ansi_generic[0xa6] = StandardCharCode.brokenbar; + ansi_generic[0xa7] = StandardCharCode.section; + ansi_generic[0xa8] = StandardCharCode.dieresis; + ansi_generic[0xa9] = StandardCharCode.copyright; + ansi_generic[0xaa] = StandardCharCode.ordfeminine; + ansi_generic[0xab] = StandardCharCode.guillemotleft; + ansi_generic[0xac] = StandardCharCode.logicalnot; + ansi_generic[0xad] = StandardCharCode.opthyphen; + ansi_generic[0xae] = StandardCharCode.registered; + ansi_generic[0xaf] = StandardCharCode.macron; + ansi_generic[0xb0] = StandardCharCode.degree; + ansi_generic[0xb1] = StandardCharCode.plusminus; + ansi_generic[0xb2] = StandardCharCode.twosuperior; + ansi_generic[0xb3] = StandardCharCode.threesuperior; + ansi_generic[0xb4] = StandardCharCode.acute; + ansi_generic[0xb5] = StandardCharCode.mu; + ansi_generic[0xb6] = StandardCharCode.paragraph; + ansi_generic[0xb7] = StandardCharCode.periodcentered; + ansi_generic[0xb8] = StandardCharCode.cedilla; + ansi_generic[0xb9] = StandardCharCode.onesuperior; + ansi_generic[0xba] = StandardCharCode.ordmasculine; + ansi_generic[0xbb] = StandardCharCode.guillemotright; + ansi_generic[0xbc] = StandardCharCode.onequarter; + ansi_generic[0xbd] = StandardCharCode.onehalf; + ansi_generic[0xbe] = StandardCharCode.threequarters; + ansi_generic[0xbf] = StandardCharCode.questiondown; + ansi_generic[0xc0] = StandardCharCode.Agrave; + ansi_generic[0xc1] = StandardCharCode.Aacute; + ansi_generic[0xc2] = StandardCharCode.Acircumflex; + ansi_generic[0xc3] = StandardCharCode.Atilde; + ansi_generic[0xc4] = StandardCharCode.Adieresis; + ansi_generic[0xc5] = StandardCharCode.Aring; + ansi_generic[0xc6] = StandardCharCode.AE; + ansi_generic[0xc7] = StandardCharCode.Ccedilla; + ansi_generic[0xc8] = StandardCharCode.Egrave; + ansi_generic[0xc9] = StandardCharCode.Eacute; + ansi_generic[0xca] = StandardCharCode.Ecircumflex; + ansi_generic[0xcb] = StandardCharCode.Edieresis; + ansi_generic[0xcc] = StandardCharCode.Igrave; + ansi_generic[0xcd] = StandardCharCode.Iacute; + ansi_generic[0xce] = StandardCharCode.Icircumflex; + ansi_generic[0xcf] = StandardCharCode.Idieresis; + ansi_generic[0xd0] = StandardCharCode.Eth; + ansi_generic[0xd1] = StandardCharCode.Ntilde; + ansi_generic[0xd2] = StandardCharCode.Ograve; + ansi_generic[0xd3] = StandardCharCode.Oacute; + ansi_generic[0xd4] = StandardCharCode.Ocircumflex; + ansi_generic[0xd5] = StandardCharCode.Otilde; + ansi_generic[0xd6] = StandardCharCode.Odieresis; + ansi_generic[0xd7] = StandardCharCode.multiply; + ansi_generic[0xd8] = StandardCharCode.Oslash; + ansi_generic[0xd9] = StandardCharCode.Ugrave; + ansi_generic[0xda] = StandardCharCode.Uacute; + ansi_generic[0xdb] = StandardCharCode.Ucircumflex; + ansi_generic[0xdc] = StandardCharCode.Udieresis; + ansi_generic[0xdd] = StandardCharCode.Yacute; + ansi_generic[0xde] = StandardCharCode.Thorn; + ansi_generic[0xdf] = StandardCharCode.germandbls; + ansi_generic[0xe0] = StandardCharCode.agrave; + ansi_generic[0xe1] = StandardCharCode.aacute; + ansi_generic[0xe2] = StandardCharCode.acircumflex; + ansi_generic[0xe3] = StandardCharCode.atilde; + ansi_generic[0xe4] = StandardCharCode.adieresis; + ansi_generic[0xe5] = StandardCharCode.aring; + ansi_generic[0xe6] = StandardCharCode.ae; + ansi_generic[0xe7] = StandardCharCode.ccedilla; + ansi_generic[0xe8] = StandardCharCode.egrave; + ansi_generic[0xe9] = StandardCharCode.eacute; + ansi_generic[0xea] = StandardCharCode.ecircumflex; + ansi_generic[0xeb] = StandardCharCode.edieresis; + ansi_generic[0xec] = StandardCharCode.igrave; + ansi_generic[0xed] = StandardCharCode.iacute; + ansi_generic[0xee] = StandardCharCode.icircumflex; + ansi_generic[0xef] = StandardCharCode.idieresis; + ansi_generic[0xf0] = StandardCharCode.eth; + ansi_generic[0xf1] = StandardCharCode.ntilde; + ansi_generic[0xf2] = StandardCharCode.ograve; + ansi_generic[0xf3] = StandardCharCode.oacute; + ansi_generic[0xf4] = StandardCharCode.ocircumflex; + ansi_generic[0xf5] = StandardCharCode.otilde; + ansi_generic[0xf6] = StandardCharCode.odieresis; + ansi_generic[0xf7] = StandardCharCode.divide; + ansi_generic[0xf8] = StandardCharCode.oslash; + ansi_generic[0xf9] = StandardCharCode.ugrave; + ansi_generic[0xfa] = StandardCharCode.uacute; + ansi_generic[0xfb] = StandardCharCode.ucircumflex; + ansi_generic[0xfc] = StandardCharCode.udieresis; + ansi_generic[0xfd] = StandardCharCode.yacute; + ansi_generic[0xfe] = StandardCharCode.thorn; + ansi_generic[0xff] = StandardCharCode.ydieresis; + + return ansi_generic; + } + } + + public static Charcode AnsiSymbol { + get { + Charcode code = new Charcode(256); + + code[0x06] = StandardCharCode.formula; + code[0x1e] = StandardCharCode.nobrkhyphen; + code[0x1f] = StandardCharCode.opthyphen; + code[' '] = StandardCharCode.space; + code['!'] = StandardCharCode.exclam; + code['"'] = StandardCharCode.universal; + code['#'] = StandardCharCode.mathnumbersign; + code['$'] = StandardCharCode.existential; + code['%'] = StandardCharCode.percent; + code['&'] = StandardCharCode.ampersand; + code['\\'] = StandardCharCode.suchthat; + code['('] = StandardCharCode.parenleft; + code[')'] = StandardCharCode.parenright; + code['*'] = StandardCharCode.mathasterisk; + code['+'] = StandardCharCode.mathplus; + code[','] = StandardCharCode.comma; + code['-'] = StandardCharCode.mathminus; + code['.'] = StandardCharCode.period; + code['/'] = StandardCharCode.slash; + code['0'] = StandardCharCode.zero; + code['1'] = StandardCharCode.one; + code['2'] = StandardCharCode.two; + code['3'] = StandardCharCode.three; + code['4'] = StandardCharCode.four; + code['5'] = StandardCharCode.five; + code['6'] = StandardCharCode.six; + code['7'] = StandardCharCode.seven; + code['8'] = StandardCharCode.eight; + code['9'] = StandardCharCode.nine; + code[':'] = StandardCharCode.colon; + code[';'] = StandardCharCode.semicolon; + code['<'] = StandardCharCode.less; + code['='] = StandardCharCode.mathequal; + code['>'] = StandardCharCode.greater; + code['?'] = StandardCharCode.question; + code['@'] = StandardCharCode.congruent; + code['A'] = StandardCharCode.Alpha; + code['B'] = StandardCharCode.Beta; + code['C'] = StandardCharCode.Chi; + code['D'] = StandardCharCode.Delta; + code['E'] = StandardCharCode.Epsilon; + code['F'] = StandardCharCode.Phi; + code['G'] = StandardCharCode.Gamma; + code['H'] = StandardCharCode.Eta; + code['I'] = StandardCharCode.Iota; + code['K'] = StandardCharCode.Kappa; + code['L'] = StandardCharCode.Lambda; + code['M'] = StandardCharCode.Mu; + code['N'] = StandardCharCode.Nu; + code['O'] = StandardCharCode.Omicron; + code['P'] = StandardCharCode.Pi; + code['Q'] = StandardCharCode.Theta; + code['R'] = StandardCharCode.Rho; + code['S'] = StandardCharCode.Sigma; + code['T'] = StandardCharCode.Tau; + code['U'] = StandardCharCode.Upsilon; + code['V'] = StandardCharCode.varsigma; + code['W'] = StandardCharCode.Omega; + code['X'] = StandardCharCode.Xi; + code['Y'] = StandardCharCode.Psi; + code['Z'] = StandardCharCode.Zeta; + code['['] = StandardCharCode.bracketleft; + code['\\'] = StandardCharCode.backslash; + code[']'] = StandardCharCode.bracketright; + code['^'] = StandardCharCode.asciicircum; + code['_'] = StandardCharCode.underscore; + code['`'] = StandardCharCode.quoteleft; + code['a'] = StandardCharCode.alpha; + code['b'] = StandardCharCode.beta; + code['c'] = StandardCharCode.chi; + code['d'] = StandardCharCode.delta; + code['e'] = StandardCharCode.epsilon; + code['f'] = StandardCharCode.phi; + code['g'] = StandardCharCode.gamma; + code['h'] = StandardCharCode.eta; + code['i'] = StandardCharCode.iota; + code['k'] = StandardCharCode.kappa; + code['l'] = StandardCharCode.lambda; + code['m'] = StandardCharCode.mu; + code['n'] = StandardCharCode.nu; + code['o'] = StandardCharCode.omicron; + code['p'] = StandardCharCode.pi; + code['q'] = StandardCharCode.theta; + code['r'] = StandardCharCode.rho; + code['s'] = StandardCharCode.sigma; + code['t'] = StandardCharCode.tau; + code['u'] = StandardCharCode.upsilon; + code['w'] = StandardCharCode.omega; + code['x'] = StandardCharCode.xi; + code['y'] = StandardCharCode.psi; + code['z'] = StandardCharCode.zeta; + code['{'] = StandardCharCode.braceleft; + code['|'] = StandardCharCode.bar; + code['}'] = StandardCharCode.braceright; + code['~'] = StandardCharCode.mathtilde; + + return code; + } + } + #endregion // Public Static Methods + } +} diff --git a/source/ShiftUI/RTF/Charset.cs b/source/ShiftUI/RTF/Charset.cs new file mode 100644 index 0000000..37dc4db --- /dev/null +++ b/source/ShiftUI/RTF/Charset.cs @@ -0,0 +1,157 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +using System; + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + class Charset { + #region Local Variables + private CharsetType id; + private CharsetFlags flags; + private Charcode code; + private string file; + #endregion // Local Variables + + #region Public Constructors + public Charset() { + flags = CharsetFlags.Read | CharsetFlags.Switch; + id = CharsetType.General; + file = string.Empty; + this.ReadMap(); + } + #endregion // Public Constructors + + #region Public Instance Properties + public Charcode Code { + get { + return code; + } + + set { + code = value; + } + } + + public CharsetFlags Flags { + get { + return flags; + } + + set { + flags = value; + } + } + + public CharsetType ID { + get { + return id; + } + + set { + switch(value) { + case CharsetType.Symbol: { + id = CharsetType.Symbol; + return; + } + + default: + case CharsetType.General: { + id = CharsetType.General; + return; + } + } + } + } + + public string File { + get { + return file; + } + + set { + if (file != value) { + file = value; + } + } + } + + public StandardCharCode this[int c] { + get { + return code[c]; + } + } + + #endregion // Public Instance Properties + + #region Public Instance Methods + public bool ReadMap() { + switch (id) { + case CharsetType.General: { + if (file == string.Empty) { + code = Charcode.AnsiGeneric; + return true; + } + // FIXME - implement reading charmap from file... + return true; + } + + case CharsetType.Symbol: { + if (file == string.Empty) { + code = Charcode.AnsiSymbol; + return true; + } + + // FIXME - implement reading charmap from file... + return true; + } + + default: { + return false; + } + } + } + + public char StdCharCode(string name) { + // FIXME - finish this + return ' '; + + } + + public string StdCharName(char code) { + // FIXME - finish this + return String.Empty; + } + #endregion // Public Instance Methods + } +} diff --git a/source/ShiftUI/RTF/CharsetFlags.cs b/source/ShiftUI/RTF/CharsetFlags.cs new file mode 100644 index 0000000..bf6dd90 --- /dev/null +++ b/source/ShiftUI/RTF/CharsetFlags.cs @@ -0,0 +1,42 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE +using System; + +namespace ShiftUI.RTF { + [Flags] +#if RTF_LIB + public +#else + internal +#endif + enum CharsetFlags { + None = 0x00, + Read = 0x01, + Switch = 0x02 + } +} diff --git a/source/ShiftUI/RTF/CharsetType.cs b/source/ShiftUI/RTF/CharsetType.cs new file mode 100644 index 0000000..8ffd8ab --- /dev/null +++ b/source/ShiftUI/RTF/CharsetType.cs @@ -0,0 +1,40 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + enum CharsetType { + General = 0, + Symbol = 1, + } +} diff --git a/source/ShiftUI/RTF/ClassDelegate.cs b/source/ShiftUI/RTF/ClassDelegate.cs new file mode 100644 index 0000000..fc3eebc --- /dev/null +++ b/source/ShiftUI/RTF/ClassDelegate.cs @@ -0,0 +1,61 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE +using System; + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + delegate void ClassDelegate(RTF sender); + +#if RTF_LIB + public +#else + internal +#endif + class ClassCallback { + ClassDelegate[] callbacks; + + public ClassCallback() { + callbacks = new ClassDelegate[Enum.GetValues(typeof(Major)).Length]; + } + + public ClassDelegate this[TokenClass c] { + get { + return callbacks[(int)c]; + } + + set { + callbacks[(int)c] = value; + } + } + } +} diff --git a/source/ShiftUI/RTF/Color.cs b/source/ShiftUI/RTF/Color.cs new file mode 100644 index 0000000..943b960 --- /dev/null +++ b/source/ShiftUI/RTF/Color.cs @@ -0,0 +1,133 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + class Color { + #region Local Variables + private int red; + private int green; + private int blue; + private int num; + private Color next; + #endregion // Local Variables + + #region Constructors + public Color(RTF rtf) { + red = -1; + green = -1; + blue = -1; + num = -1; + + lock (rtf) { + if (rtf.Colors == null) { + rtf.Colors = this; + } else { + Color c = rtf.Colors; + while (c.next != null) + c = c.next; + c.next = this; + } + } + } + #endregion // Constructors + + #region Properties + public int Red { + get { + return red; + } + + set { + red = value; + } + } + + public int Green { + get { + return green; + } + + set { + green = value; + } + } + + public int Blue { + get { + return blue; + } + + set { + blue = value; + } + } + + public int Num { + get { + return num; + } + + set { + num = value; + } + } + #endregion // Properties + + #region Methods + static public Color GetColor(RTF rtf, int color_number) { + Color c; + + lock (rtf) { + c = GetColor(rtf.Colors, color_number); + } + return c; + } + + static private Color GetColor(Color start, int color_number) { + Color c; + + if (color_number == -1) { + return start; + } + + c = start; + + while ((c != null) && (c.num != color_number)) { + c = c.next; + } + return c; + } + #endregion // Methods + } +} diff --git a/source/ShiftUI/RTF/DestinationDelegate.cs b/source/ShiftUI/RTF/DestinationDelegate.cs new file mode 100644 index 0000000..80fa0b3 --- /dev/null +++ b/source/ShiftUI/RTF/DestinationDelegate.cs @@ -0,0 +1,61 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE +using System; + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + delegate void DestinationDelegate(RTF Sender); + +#if RTF_LIB + public +#else + internal +#endif + class DestinationCallback { + DestinationDelegate[] callbacks; + + public DestinationCallback() { + callbacks = new DestinationDelegate[Enum.GetValues(typeof(Minor)).Length]; + } + + public DestinationDelegate this[Minor c] { + get { + return callbacks[(int)c]; + } + + set { + callbacks[(int)c] = value; + } + } + } +} diff --git a/source/ShiftUI/RTF/Font.cs b/source/ShiftUI/RTF/Font.cs new file mode 100644 index 0000000..52b29e5 --- /dev/null +++ b/source/ShiftUI/RTF/Font.cs @@ -0,0 +1,209 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE +using System; + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + class Font { + #region Local Variables + private string name; + private string alt_name; + private int num; + private int family; + private CharsetType charset; + private int pitch; + private int type; + private int codepage; + private Font next; + private RTF rtf; + #endregion // Local Variables + + #region Constructors + public Font(RTF rtf) { + this.rtf = rtf; + num = -1; + name = String.Empty; + + lock (rtf) { + if (rtf.Fonts == null) + rtf.Fonts = this; + else { + Font f = rtf.Fonts; + while (f.next != null) + f = f.next; + f.next = this; + } + } + } + #endregion // Constructors + + #region Properties + public string Name { + get { + return name; + } + + set { + name = value; + } + } + + public string AltName { + get { + return alt_name; + } + + set { + alt_name = value; + } + } + + public int Num { + get { + return num; + } + + set { + // Whack any previous font with the same number + DeleteFont(rtf, value); + num = value; + } + } + + public int Family { + get { + return family; + } + + set { + family = value; + } + } + + public CharsetType Charset { + get { + return charset; + } + + set { + charset = value; + } + } + + + public int Pitch { + get { + return pitch; + } + + set { + pitch = value; + } + } + + public int Type { + get { + return type; + } + + set { + type = value; + } + } + + public int Codepage { + get { + return codepage; + } + + set { + codepage = value; + } + } + #endregion // Properties + + #region Methods + static public bool DeleteFont(RTF rtf, int font_number) { + Font f; + Font prev; + + lock (rtf) { + f = rtf.Fonts; + prev = null; + while ((f != null) && (f.num != font_number)) { + prev = f; + f = f.next; + } + + if (f != null) { + if (f == rtf.Fonts) { + rtf.Fonts = f.next; + } else { + if (prev != null) { + prev.next = f.next; + } else { + rtf.Fonts = f.next; + } + } + return true; + } + } + return false; + } + + static public Font GetFont(RTF rtf, int font_number) { + Font f; + + lock (rtf) { + f = GetFont(rtf.Fonts, font_number); + } + return f; + } + + static public Font GetFont(Font start, int font_number) { + Font f; + + if (font_number == -1) { + return start; + } + + f = start; + + while ((f != null) && (f.num != font_number)) { + f = f.next; + } + return f; + } + #endregion // Methods + } +} diff --git a/source/ShiftUI/RTF/KeyStruct.cs b/source/ShiftUI/RTF/KeyStruct.cs new file mode 100644 index 0000000..6c4120c --- /dev/null +++ b/source/ShiftUI/RTF/KeyStruct.cs @@ -0,0 +1,46 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + struct KeyStruct { + public KeyStruct(Major major, Minor minor, string symbol) { + Major = major; + Minor = minor; + Symbol = symbol; + } + public Major Major; + public Minor Minor; + public string Symbol; + } +} diff --git a/source/ShiftUI/RTF/KeysInit.cs b/source/ShiftUI/RTF/KeysInit.cs new file mode 100644 index 0000000..49daf1e --- /dev/null +++ b/source/ShiftUI/RTF/KeysInit.cs @@ -0,0 +1,720 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + internal class KeysInit { + public static KeyStruct[] Init() { + return new KeyStruct[] { + new KeyStruct(Major.SpecialChar, Minor.IIntVersion, "vern"), + new KeyStruct(Major.SpecialChar, Minor.ICreateTime, "creatim"), + new KeyStruct(Major.SpecialChar, Minor.IRevisionTime, "revtim"), + new KeyStruct(Major.SpecialChar, Minor.IPrintTime, "printim"), + new KeyStruct(Major.SpecialChar, Minor.IBackupTime, "buptim"), + new KeyStruct(Major.SpecialChar, Minor.IEditTime, "edmins"), + new KeyStruct(Major.SpecialChar, Minor.IYear, "yr"), + new KeyStruct(Major.SpecialChar, Minor.IMonth, "mo"), + new KeyStruct(Major.SpecialChar, Minor.IDay, "dy"), + new KeyStruct(Major.SpecialChar, Minor.IHour, "hr"), + new KeyStruct(Major.SpecialChar, Minor.IMinute, "min"), + new KeyStruct(Major.SpecialChar, Minor.ISecond, "sec"), + new KeyStruct(Major.SpecialChar, Minor.INPages, "nofpages"), + new KeyStruct(Major.SpecialChar, Minor.INWords, "nofwords"), + new KeyStruct(Major.SpecialChar, Minor.INChars, "nofchars"), + new KeyStruct(Major.SpecialChar, Minor.IIntID, "id"), + new KeyStruct(Major.SpecialChar, Minor.CurHeadDate, "chdate"), + new KeyStruct(Major.SpecialChar, Minor.CurHeadDateLong, "chdpl"), + new KeyStruct(Major.SpecialChar, Minor.CurHeadDateAbbrev, "chdpa"), + new KeyStruct(Major.SpecialChar, Minor.CurHeadTime, "chtime"), + new KeyStruct(Major.SpecialChar, Minor.CurHeadPage, "chpgn"), + new KeyStruct(Major.SpecialChar, Minor.SectNum, "sectnum"), + new KeyStruct(Major.SpecialChar, Minor.CurFNote, "chftn"), + new KeyStruct(Major.SpecialChar, Minor.CurAnnotRef, "chatn"), + new KeyStruct(Major.SpecialChar, Minor.FNoteSep, "chftnsep"), + new KeyStruct(Major.SpecialChar, Minor.FNoteCont, "chftnsepc"), + new KeyStruct(Major.SpecialChar, Minor.Cell, "cell"), + new KeyStruct(Major.SpecialChar, Minor.Row, "row"), + new KeyStruct(Major.SpecialChar, Minor.Par, "par"), + new KeyStruct(Major.SpecialChar, Minor.Par, "\n"), + new KeyStruct(Major.SpecialChar, Minor.Par, "\r"), + new KeyStruct(Major.SpecialChar, Minor.Sect, "sect"), + new KeyStruct(Major.SpecialChar, Minor.Page, "page"), + new KeyStruct(Major.SpecialChar, Minor.Column, "column"), + new KeyStruct(Major.SpecialChar, Minor.Line, "line"), + new KeyStruct(Major.SpecialChar, Minor.SoftPage, "softpage"), + new KeyStruct(Major.SpecialChar, Minor.SoftColumn, "softcol"), + new KeyStruct(Major.SpecialChar, Minor.SoftLine, "softline"), + new KeyStruct(Major.SpecialChar, Minor.SoftLineHt, "softlheight"), + new KeyStruct(Major.SpecialChar, Minor.Tab, "tab"), + new KeyStruct(Major.SpecialChar, Minor.EmDash, "emdash"), + new KeyStruct(Major.SpecialChar, Minor.EnDash, "endash"), + new KeyStruct(Major.SpecialChar, Minor.EmSpace, "emspace"), + new KeyStruct(Major.SpecialChar, Minor.EnSpace, "enspace"), + new KeyStruct(Major.SpecialChar, Minor.Bullet, "bullet"), + new KeyStruct(Major.SpecialChar, Minor.LQuote, "lquote"), + new KeyStruct(Major.SpecialChar, Minor.RQuote, "rquote"), + new KeyStruct(Major.SpecialChar, Minor.LDblQuote, "ldblquote"), + new KeyStruct(Major.SpecialChar, Minor.RDblQuote, "rdblquote"), + new KeyStruct(Major.SpecialChar, Minor.Formula, "|"), + new KeyStruct(Major.SpecialChar, Minor.NoBrkSpace, "~"), + new KeyStruct(Major.SpecialChar, Minor.NoReqHyphen, "-"), + new KeyStruct(Major.SpecialChar, Minor.NoBrkHyphen, "_"), + new KeyStruct(Major.SpecialChar, Minor.LTRMark, "ltrmark"), + new KeyStruct(Major.SpecialChar, Minor.RTLMark, "rtlmark"), + new KeyStruct(Major.SpecialChar, Minor.NoWidthJoiner, "zwj"), + new KeyStruct(Major.SpecialChar, Minor.NoWidthNonJoiner, "zwnj"), + new KeyStruct(Major.SpecialChar, Minor.CurHeadPict, "chpict"), + new KeyStruct(Major.CharAttr, Minor.Plain, "plain"), + new KeyStruct(Major.CharAttr, Minor.Bold, "b"), + new KeyStruct(Major.CharAttr, Minor.AllCaps, "caps"), + new KeyStruct(Major.CharAttr, Minor.Deleted, "deleted"), + new KeyStruct(Major.CharAttr, Minor.SubScript, "dn"), + new KeyStruct(Major.CharAttr, Minor.SubScrShrink, "sub"), + new KeyStruct(Major.CharAttr, Minor.NoSuperSub, "nosupersub"), + new KeyStruct(Major.CharAttr, Minor.Expand, "expnd"), + new KeyStruct(Major.CharAttr, Minor.ExpandTwips, "expndtw"), + new KeyStruct(Major.CharAttr, Minor.Kerning, "kerning"), + new KeyStruct(Major.CharAttr, Minor.FontNum, "f"), + new KeyStruct(Major.CharAttr, Minor.FontSize, "fs"), + new KeyStruct(Major.CharAttr, Minor.Italic, "i"), + new KeyStruct(Major.CharAttr, Minor.Outline, "outl"), + new KeyStruct(Major.CharAttr, Minor.Revised, "revised"), + new KeyStruct(Major.CharAttr, Minor.RevAuthor, "revauth"), + new KeyStruct(Major.CharAttr, Minor.RevDTTM, "revdttm"), + new KeyStruct(Major.CharAttr, Minor.SmallCaps, "scaps"), + new KeyStruct(Major.CharAttr, Minor.Shadow, "shad"), + new KeyStruct(Major.CharAttr, Minor.StrikeThru, "strike"), + new KeyStruct(Major.CharAttr, Minor.Underline, "ul"), + new KeyStruct(Major.CharAttr, Minor.DotUnderline, "uld"), + new KeyStruct(Major.CharAttr, Minor.DbUnderline, "uldb"), + new KeyStruct(Major.CharAttr, Minor.NoUnderline, "ulnone"), + new KeyStruct(Major.CharAttr, Minor.WordUnderline, "ulw"), + new KeyStruct(Major.CharAttr, Minor.SuperScript, "up"), + new KeyStruct(Major.CharAttr, Minor.SuperScrShrink, "super"), + new KeyStruct(Major.CharAttr, Minor.Invisible, "v"), + new KeyStruct(Major.CharAttr, Minor.ForeColor, "cf"), + new KeyStruct(Major.CharAttr, Minor.BackColor, "cb"), + new KeyStruct(Major.CharAttr, Minor.RTLChar, "rtlch"), + new KeyStruct(Major.CharAttr, Minor.LTRChar, "ltrch"), + new KeyStruct(Major.CharAttr, Minor.CharStyleNum, "cs"), + new KeyStruct(Major.CharAttr, Minor.CharCharSet, "cchs"), + new KeyStruct(Major.CharAttr, Minor.Language, "lang"), + new KeyStruct(Major.CharAttr, Minor.Gray, "gray"), + new KeyStruct(Major.ParAttr, Minor.ParDef, "pard"), + new KeyStruct(Major.ParAttr, Minor.StyleNum, "s"), + new KeyStruct(Major.ParAttr, Minor.Hyphenate, "hyphpar"), + new KeyStruct(Major.ParAttr, Minor.InTable, "intbl"), + new KeyStruct(Major.ParAttr, Minor.Keep, "keep"), + new KeyStruct(Major.ParAttr, Minor.NoWidowControl, "nowidctlpar"), + new KeyStruct(Major.ParAttr, Minor.KeepNext, "keepn"), + new KeyStruct(Major.ParAttr, Minor.OutlineLevel, "level"), + new KeyStruct(Major.ParAttr, Minor.NoLineNum, "noline"), + new KeyStruct(Major.ParAttr, Minor.PBBefore, "pagebb"), + new KeyStruct(Major.ParAttr, Minor.SideBySide, "sbys"), + new KeyStruct(Major.ParAttr, Minor.QuadLeft, "ql"), + new KeyStruct(Major.ParAttr, Minor.QuadRight, "qr"), + new KeyStruct(Major.ParAttr, Minor.QuadJust, "qj"), + new KeyStruct(Major.ParAttr, Minor.QuadCenter, "qc"), + new KeyStruct(Major.ParAttr, Minor.FirstIndent, "fi"), + new KeyStruct(Major.ParAttr, Minor.LeftIndent, "li"), + new KeyStruct(Major.ParAttr, Minor.RightIndent, "ri"), + new KeyStruct(Major.ParAttr, Minor.SpaceBefore, "sb"), + new KeyStruct(Major.ParAttr, Minor.SpaceAfter, "sa"), + new KeyStruct(Major.ParAttr, Minor.SpaceBetween, "sl"), + new KeyStruct(Major.ParAttr, Minor.SpaceMultiply, "slmult"), + new KeyStruct(Major.ParAttr, Minor.SubDocument, "subdocument"), + new KeyStruct(Major.ParAttr, Minor.RTLPar, "rtlpar"), + new KeyStruct(Major.ParAttr, Minor.LTRPar, "ltrpar"), + new KeyStruct(Major.ParAttr, Minor.TabPos, "tx"), + new KeyStruct(Major.ParAttr, Minor.TabLeft, "tql"), + new KeyStruct(Major.ParAttr, Minor.TabRight, "tqr"), + new KeyStruct(Major.ParAttr, Minor.TabCenter, "tqc"), + new KeyStruct(Major.ParAttr, Minor.TabDecimal, "tqdec"), + new KeyStruct(Major.ParAttr, Minor.TabBar, "tb"), + new KeyStruct(Major.ParAttr, Minor.LeaderDot, "tldot"), + new KeyStruct(Major.ParAttr, Minor.LeaderHyphen, "tlhyph"), + new KeyStruct(Major.ParAttr, Minor.LeaderUnder, "tlul"), + new KeyStruct(Major.ParAttr, Minor.LeaderThick, "tlth"), + new KeyStruct(Major.ParAttr, Minor.LeaderEqual, "tleq"), + new KeyStruct(Major.ParAttr, Minor.ParLevel, "pnlvl"), + new KeyStruct(Major.ParAttr, Minor.ParBullet, "pnlvlblt"), + new KeyStruct(Major.ParAttr, Minor.ParSimple, "pnlvlbody"), + new KeyStruct(Major.ParAttr, Minor.ParNumCont, "pnlvlcont"), + new KeyStruct(Major.ParAttr, Minor.ParNumOnce, "pnnumonce"), + new KeyStruct(Major.ParAttr, Minor.ParNumAcross, "pnacross"), + new KeyStruct(Major.ParAttr, Minor.ParHangIndent, "pnhang"), + new KeyStruct(Major.ParAttr, Minor.ParNumRestart, "pnrestart"), + new KeyStruct(Major.ParAttr, Minor.ParNumCardinal, "pncard"), + new KeyStruct(Major.ParAttr, Minor.ParNumDecimal, "pndec"), + new KeyStruct(Major.ParAttr, Minor.ParNumULetter, "pnucltr"), + new KeyStruct(Major.ParAttr, Minor.ParNumURoman, "pnucrm"), + new KeyStruct(Major.ParAttr, Minor.ParNumLLetter, "pnlcltr"), + new KeyStruct(Major.ParAttr, Minor.ParNumLRoman, "pnlcrm"), + new KeyStruct(Major.ParAttr, Minor.ParNumOrdinal, "pnord"), + new KeyStruct(Major.ParAttr, Minor.ParNumOrdinalText, "pnordt"), + new KeyStruct(Major.ParAttr, Minor.ParNumBold, "pnb"), + new KeyStruct(Major.ParAttr, Minor.ParNumItalic, "pni"), + new KeyStruct(Major.ParAttr, Minor.ParNumAllCaps, "pncaps"), + new KeyStruct(Major.ParAttr, Minor.ParNumSmallCaps, "pnscaps"), + new KeyStruct(Major.ParAttr, Minor.ParNumUnder, "pnul"), + new KeyStruct(Major.ParAttr, Minor.ParNumDotUnder, "pnuld"), + new KeyStruct(Major.ParAttr, Minor.ParNumDbUnder, "pnuldb"), + new KeyStruct(Major.ParAttr, Minor.ParNumNoUnder, "pnulnone"), + new KeyStruct(Major.ParAttr, Minor.ParNumWordUnder, "pnulw"), + new KeyStruct(Major.ParAttr, Minor.ParNumStrikethru, "pnstrike"), + new KeyStruct(Major.ParAttr, Minor.ParNumForeColor, "pncf"), + new KeyStruct(Major.ParAttr, Minor.ParNumFont, "pnf"), + new KeyStruct(Major.ParAttr, Minor.ParNumFontSize, "pnfs"), + new KeyStruct(Major.ParAttr, Minor.ParNumIndent, "pnindent"), + new KeyStruct(Major.ParAttr, Minor.ParNumSpacing, "pnsp"), + new KeyStruct(Major.ParAttr, Minor.ParNumInclPrev, "pnprev"), + new KeyStruct(Major.ParAttr, Minor.ParNumCenter, "pnqc"), + new KeyStruct(Major.ParAttr, Minor.ParNumLeft, "pnql"), + new KeyStruct(Major.ParAttr, Minor.ParNumRight, "pnqr"), + new KeyStruct(Major.ParAttr, Minor.ParNumStartAt, "pnstart"), + new KeyStruct(Major.ParAttr, Minor.BorderTop, "brdrt"), + new KeyStruct(Major.ParAttr, Minor.BorderBottom, "brdrb"), + new KeyStruct(Major.ParAttr, Minor.BorderLeft, "brdrl"), + new KeyStruct(Major.ParAttr, Minor.BorderRight, "brdrr"), + new KeyStruct(Major.ParAttr, Minor.BorderBetween, "brdrbtw"), + new KeyStruct(Major.ParAttr, Minor.BorderBar, "brdrbar"), + new KeyStruct(Major.ParAttr, Minor.BorderBox, "box"), + new KeyStruct(Major.ParAttr, Minor.BorderSingle, "brdrs"), + new KeyStruct(Major.ParAttr, Minor.BorderThick, "brdrth"), + new KeyStruct(Major.ParAttr, Minor.BorderShadow, "brdrsh"), + new KeyStruct(Major.ParAttr, Minor.BorderDouble, "brdrdb"), + new KeyStruct(Major.ParAttr, Minor.BorderDot, "brdrdot"), + new KeyStruct(Major.ParAttr, Minor.BorderDot, "brdrdash"), + new KeyStruct(Major.ParAttr, Minor.BorderHair, "brdrhair"), + new KeyStruct(Major.ParAttr, Minor.BorderWidth, "brdrw"), + new KeyStruct(Major.ParAttr, Minor.BorderColor, "brdrcf"), + new KeyStruct(Major.ParAttr, Minor.BorderSpace, "brsp"), + new KeyStruct(Major.ParAttr, Minor.Shading, "shading"), + new KeyStruct(Major.ParAttr, Minor.BgPatH, "bghoriz"), + new KeyStruct(Major.ParAttr, Minor.BgPatV, "bgvert"), + new KeyStruct(Major.ParAttr, Minor.FwdDiagBgPat, "bgfdiag"), + new KeyStruct(Major.ParAttr, Minor.BwdDiagBgPat, "bgbdiag"), + new KeyStruct(Major.ParAttr, Minor.HatchBgPat, "bgcross"), + new KeyStruct(Major.ParAttr, Minor.DiagHatchBgPat, "bgdcross"), + new KeyStruct(Major.ParAttr, Minor.DarkBgPatH, "bgdkhoriz"), + new KeyStruct(Major.ParAttr, Minor.DarkBgPatV, "bgdkvert"), + new KeyStruct(Major.ParAttr, Minor.FwdDarkBgPat, "bgdkfdiag"), + new KeyStruct(Major.ParAttr, Minor.BwdDarkBgPat, "bgdkbdiag"), + new KeyStruct(Major.ParAttr, Minor.DarkHatchBgPat, "bgdkcross"), + new KeyStruct(Major.ParAttr, Minor.DarkDiagHatchBgPat, "bgdkdcross"), + new KeyStruct(Major.ParAttr, Minor.BgPatLineColor, "cfpat"), + new KeyStruct(Major.ParAttr, Minor.BgPatColor, "cbpat"), + new KeyStruct(Major.SectAttr, Minor.SectDef, "sectd"), + new KeyStruct(Major.SectAttr, Minor.ENoteHere, "endnhere"), + new KeyStruct(Major.SectAttr, Minor.PrtBinFirst, "binfsxn"), + new KeyStruct(Major.SectAttr, Minor.PrtBin, "binsxn"), + new KeyStruct(Major.SectAttr, Minor.SectStyleNum, "ds"), + new KeyStruct(Major.SectAttr, Minor.NoBreak, "sbknone"), + new KeyStruct(Major.SectAttr, Minor.ColBreak, "sbkcol"), + new KeyStruct(Major.SectAttr, Minor.PageBreak, "sbkpage"), + new KeyStruct(Major.SectAttr, Minor.EvenBreak, "sbkeven"), + new KeyStruct(Major.SectAttr, Minor.OddBreak, "sbkodd"), + new KeyStruct(Major.SectAttr, Minor.Columns, "cols"), + new KeyStruct(Major.SectAttr, Minor.ColumnSpace, "colsx"), + new KeyStruct(Major.SectAttr, Minor.ColumnNumber, "colno"), + new KeyStruct(Major.SectAttr, Minor.ColumnSpRight, "colsr"), + new KeyStruct(Major.SectAttr, Minor.ColumnWidth, "colw"), + new KeyStruct(Major.SectAttr, Minor.ColumnLine, "linebetcol"), + new KeyStruct(Major.SectAttr, Minor.LineModulus, "linemod"), + new KeyStruct(Major.SectAttr, Minor.LineDist, "linex"), + new KeyStruct(Major.SectAttr, Minor.LineStarts, "linestarts"), + new KeyStruct(Major.SectAttr, Minor.LineRestart, "linerestart"), + new KeyStruct(Major.SectAttr, Minor.LineRestartPg, "lineppage"), + new KeyStruct(Major.SectAttr, Minor.LineCont, "linecont"), + new KeyStruct(Major.SectAttr, Minor.SectPageWid, "pgwsxn"), + new KeyStruct(Major.SectAttr, Minor.SectPageHt, "pghsxn"), + new KeyStruct(Major.SectAttr, Minor.SectMarginLeft, "marglsxn"), + new KeyStruct(Major.SectAttr, Minor.SectMarginRight, "margrsxn"), + new KeyStruct(Major.SectAttr, Minor.SectMarginTop, "margtsxn"), + new KeyStruct(Major.SectAttr, Minor.SectMarginBottom, "margbsxn"), + new KeyStruct(Major.SectAttr, Minor.SectMarginGutter, "guttersxn"), + new KeyStruct(Major.SectAttr, Minor.SectLandscape, "lndscpsxn"), + new KeyStruct(Major.SectAttr, Minor.TitleSpecial, "titlepg"), + new KeyStruct(Major.SectAttr, Minor.HeaderY, "headery"), + new KeyStruct(Major.SectAttr, Minor.FooterY, "footery"), + new KeyStruct(Major.SectAttr, Minor.PageStarts, "pgnstarts"), + new KeyStruct(Major.SectAttr, Minor.PageCont, "pgncont"), + new KeyStruct(Major.SectAttr, Minor.PageRestart, "pgnrestart"), + new KeyStruct(Major.SectAttr, Minor.PageNumRight, "pgnx"), + new KeyStruct(Major.SectAttr, Minor.PageNumTop, "pgny"), + new KeyStruct(Major.SectAttr, Minor.PageDecimal, "pgndec"), + new KeyStruct(Major.SectAttr, Minor.PageURoman, "pgnucrm"), + new KeyStruct(Major.SectAttr, Minor.PageLRoman, "pgnlcrm"), + new KeyStruct(Major.SectAttr, Minor.PageULetter, "pgnucltr"), + new KeyStruct(Major.SectAttr, Minor.PageLLetter, "pgnlcltr"), + new KeyStruct(Major.SectAttr, Minor.PageNumHyphSep, "pgnhnsh"), + new KeyStruct(Major.SectAttr, Minor.PageNumSpaceSep, "pgnhnsp"), + new KeyStruct(Major.SectAttr, Minor.PageNumColonSep, "pgnhnsc"), + new KeyStruct(Major.SectAttr, Minor.PageNumEmdashSep, "pgnhnsm"), + new KeyStruct(Major.SectAttr, Minor.PageNumEndashSep, "pgnhnsn"), + new KeyStruct(Major.SectAttr, Minor.TopVAlign, "vertalt"), + new KeyStruct(Major.SectAttr, Minor.BottomVAlign, "vertalb"), + new KeyStruct(Major.SectAttr, Minor.CenterVAlign, "vertalc"), + new KeyStruct(Major.SectAttr, Minor.JustVAlign, "vertalj"), + new KeyStruct(Major.SectAttr, Minor.RTLSect, "rtlsect"), + new KeyStruct(Major.SectAttr, Minor.LTRSect, "ltrsect"), + new KeyStruct(Major.DocAttr, Minor.DefTab, "deftab"), + new KeyStruct(Major.DocAttr, Minor.HyphHotZone, "hyphhotz"), + new KeyStruct(Major.DocAttr, Minor.HyphConsecLines, "hyphconsec"), + new KeyStruct(Major.DocAttr, Minor.HyphCaps, "hyphcaps"), + new KeyStruct(Major.DocAttr, Minor.HyphAuto, "hyphauto"), + new KeyStruct(Major.DocAttr, Minor.LineStart, "linestart"), + new KeyStruct(Major.DocAttr, Minor.FracWidth, "fracwidth"), + new KeyStruct(Major.DocAttr, Minor.MakeBackup, "makeback"), + new KeyStruct(Major.DocAttr, Minor.MakeBackup, "makebackup"), + new KeyStruct(Major.DocAttr, Minor.RTFDefault, "defformat"), + new KeyStruct(Major.DocAttr, Minor.PSOverlay, "psover"), + new KeyStruct(Major.DocAttr, Minor.DocTemplate, "doctemp"), + new KeyStruct(Major.DocAttr, Minor.DefLanguage, "deflang"), + new KeyStruct(Major.DocAttr, Minor.FENoteType, "fet"), + new KeyStruct(Major.DocAttr, Minor.FNoteEndSect, "endnotes"), + new KeyStruct(Major.DocAttr, Minor.FNoteEndDoc, "enddoc"), + new KeyStruct(Major.DocAttr, Minor.FNoteText, "ftntj"), + new KeyStruct(Major.DocAttr, Minor.FNoteBottom, "ftnbj"), + new KeyStruct(Major.DocAttr, Minor.ENoteEndSect, "aendnotes"), + new KeyStruct(Major.DocAttr, Minor.ENoteEndDoc, "aenddoc"), + new KeyStruct(Major.DocAttr, Minor.ENoteText, "aftntj"), + new KeyStruct(Major.DocAttr, Minor.ENoteBottom, "aftnbj"), + new KeyStruct(Major.DocAttr, Minor.FNoteStart, "ftnstart"), + new KeyStruct(Major.DocAttr, Minor.ENoteStart, "aftnstart"), + new KeyStruct(Major.DocAttr, Minor.FNoteRestartPage, "ftnrstpg"), + new KeyStruct(Major.DocAttr, Minor.FNoteRestart, "ftnrestart"), + new KeyStruct(Major.DocAttr, Minor.FNoteRestartCont, "ftnrstcont"), + new KeyStruct(Major.DocAttr, Minor.ENoteRestart, "aftnrestart"), + new KeyStruct(Major.DocAttr, Minor.ENoteRestartCont, "aftnrstcont"), + new KeyStruct(Major.DocAttr, Minor.FNoteNumArabic, "ftnnar"), + new KeyStruct(Major.DocAttr, Minor.FNoteNumLLetter, "ftnnalc"), + new KeyStruct(Major.DocAttr, Minor.FNoteNumULetter, "ftnnauc"), + new KeyStruct(Major.DocAttr, Minor.FNoteNumLRoman, "ftnnrlc"), + new KeyStruct(Major.DocAttr, Minor.FNoteNumURoman, "ftnnruc"), + new KeyStruct(Major.DocAttr, Minor.FNoteNumChicago, "ftnnchi"), + new KeyStruct(Major.DocAttr, Minor.ENoteNumArabic, "aftnnar"), + new KeyStruct(Major.DocAttr, Minor.ENoteNumLLetter, "aftnnalc"), + new KeyStruct(Major.DocAttr, Minor.ENoteNumULetter, "aftnnauc"), + new KeyStruct(Major.DocAttr, Minor.ENoteNumLRoman, "aftnnrlc"), + new KeyStruct(Major.DocAttr, Minor.ENoteNumURoman, "aftnnruc"), + new KeyStruct(Major.DocAttr, Minor.ENoteNumChicago, "aftnnchi"), + new KeyStruct(Major.DocAttr, Minor.PaperWidth, "paperw"), + new KeyStruct(Major.DocAttr, Minor.PaperHeight, "paperh"), + new KeyStruct(Major.DocAttr, Minor.PaperSize, "psz"), + new KeyStruct(Major.DocAttr, Minor.LeftMargin, "margl"), + new KeyStruct(Major.DocAttr, Minor.RightMargin, "margr"), + new KeyStruct(Major.DocAttr, Minor.TopMargin, "margt"), + new KeyStruct(Major.DocAttr, Minor.BottomMargin, "margb"), + new KeyStruct(Major.DocAttr, Minor.FacingPage, "facingp"), + new KeyStruct(Major.DocAttr, Minor.GutterWid, "gutter"), + new KeyStruct(Major.DocAttr, Minor.MirrorMargin, "margmirror"), + new KeyStruct(Major.DocAttr, Minor.Landscape, "landscape"), + new KeyStruct(Major.DocAttr, Minor.PageStart, "pgnstart"), + new KeyStruct(Major.DocAttr, Minor.WidowCtrl, "widowctrl"), + new KeyStruct(Major.DocAttr, Minor.LinkStyles, "linkstyles"), + new KeyStruct(Major.DocAttr, Minor.NoAutoTabIndent, "notabind"), + new KeyStruct(Major.DocAttr, Minor.WrapSpaces, "wraptrsp"), + new KeyStruct(Major.DocAttr, Minor.PrintColorsBlack, "prcolbl"), + new KeyStruct(Major.DocAttr, Minor.NoExtraSpaceRL, "noextrasprl"), + new KeyStruct(Major.DocAttr, Minor.NoColumnBalance, "nocolbal"), + new KeyStruct(Major.DocAttr, Minor.CvtMailMergeQuote, "cvmme"), + new KeyStruct(Major.DocAttr, Minor.SuppressTopSpace, "sprstsp"), + new KeyStruct(Major.DocAttr, Minor.SuppressPreParSpace, "sprsspbf"), + new KeyStruct(Major.DocAttr, Minor.CombineTblBorders, "otblrul"), + new KeyStruct(Major.DocAttr, Minor.TranspMetafiles, "transmf"), + new KeyStruct(Major.DocAttr, Minor.SwapBorders, "swpbdr"), + new KeyStruct(Major.DocAttr, Minor.ShowHardBreaks, "brkfrm"), + new KeyStruct(Major.DocAttr, Minor.FormProtected, "formprot"), + new KeyStruct(Major.DocAttr, Minor.AllProtected, "allprot"), + new KeyStruct(Major.DocAttr, Minor.FormShading, "formshade"), + new KeyStruct(Major.DocAttr, Minor.FormDisplay, "formdisp"), + new KeyStruct(Major.DocAttr, Minor.PrintData, "printdata"), + new KeyStruct(Major.DocAttr, Minor.RevProtected, "revprot"), + new KeyStruct(Major.DocAttr, Minor.Revisions, "revisions"), + new KeyStruct(Major.DocAttr, Minor.RevDisplay, "revprop"), + new KeyStruct(Major.DocAttr, Minor.RevBar, "revbar"), + new KeyStruct(Major.DocAttr, Minor.AnnotProtected, "annotprot"), + new KeyStruct(Major.DocAttr, Minor.RTLDoc, "rtldoc"), + new KeyStruct(Major.DocAttr, Minor.LTRDoc, "ltrdoc"), + new KeyStruct(Major.StyleAttr, Minor.Additive, "additive"), + new KeyStruct(Major.StyleAttr, Minor.BasedOn, "sbasedon"), + new KeyStruct(Major.StyleAttr, Minor.Next, "snext"), + new KeyStruct(Major.PictAttr, Minor.MacQD, "macpict"), + new KeyStruct(Major.PictAttr, Minor.PMMetafile, "pmmetafile"), + new KeyStruct(Major.PictAttr, Minor.WinMetafile, "wmetafile"), + new KeyStruct(Major.PictAttr, Minor.DevIndBitmap, "dibitmap"), + new KeyStruct(Major.PictAttr, Minor.WinBitmap, "wbitmap"), + new KeyStruct(Major.PictAttr, Minor.PngBlip, "pngblip"), + new KeyStruct(Major.PictAttr, Minor.PixelBits, "wbmbitspixel"), + new KeyStruct(Major.PictAttr, Minor.BitmapPlanes, "wbmplanes"), + new KeyStruct(Major.PictAttr, Minor.BitmapWid, "wbmwidthbytes"), + new KeyStruct(Major.PictAttr, Minor.PicWid, "picw"), + new KeyStruct(Major.PictAttr, Minor.PicHt, "pich"), + new KeyStruct(Major.PictAttr, Minor.PicGoalWid, "picwgoal"), + new KeyStruct(Major.PictAttr, Minor.PicGoalHt, "pichgoal"), + new KeyStruct(Major.PictAttr, Minor.PicGoalWid, "picwGoal"), + new KeyStruct(Major.PictAttr, Minor.PicGoalHt, "pichGoal"), + new KeyStruct(Major.PictAttr, Minor.PicScaleX, "picscalex"), + new KeyStruct(Major.PictAttr, Minor.PicScaleY, "picscaley"), + new KeyStruct(Major.PictAttr, Minor.PicScaled, "picscaled"), + new KeyStruct(Major.PictAttr, Minor.PicCropTop, "piccropt"), + new KeyStruct(Major.PictAttr, Minor.PicCropBottom, "piccropb"), + new KeyStruct(Major.PictAttr, Minor.PicCropLeft, "piccropl"), + new KeyStruct(Major.PictAttr, Minor.PicCropRight, "piccropr"), + new KeyStruct(Major.PictAttr, Minor.PicMFHasBitmap, "picbmp"), + new KeyStruct(Major.PictAttr, Minor.PicMFBitsPerPixel, "picbpp"), + new KeyStruct(Major.PictAttr, Minor.PicBinary, "bin"), + new KeyStruct(Major.NeXTGrAttr, Minor.NeXTGWidth, "width"), + new KeyStruct(Major.NeXTGrAttr, Minor.NeXTGHeight, "height"), + new KeyStruct(Major.Destination, Minor.OptDest, "*"), + new KeyStruct(Major.Destination, Minor.FontTbl, "fonttbl"), + new KeyStruct(Major.Destination, Minor.FontAltName, "falt"), + new KeyStruct(Major.Destination, Minor.EmbeddedFont, "fonteb"), + new KeyStruct(Major.Destination, Minor.FontFile, "fontfile"), + new KeyStruct(Major.Destination, Minor.FileTbl, "filetbl"), + new KeyStruct(Major.Destination, Minor.FileInfo, "file"), + new KeyStruct(Major.Destination, Minor.ColorTbl, "colortbl"), + new KeyStruct(Major.Destination, Minor.StyleSheet, "stylesheet"), + new KeyStruct(Major.Destination, Minor.KeyCode, "keycode"), + new KeyStruct(Major.Destination, Minor.RevisionTbl, "revtbl"), + new KeyStruct(Major.Destination, Minor.Info, "info"), + new KeyStruct(Major.Destination, Minor.ITitle, "title"), + new KeyStruct(Major.Destination, Minor.ISubject, "subject"), + new KeyStruct(Major.Destination, Minor.IAuthor, "author"), + new KeyStruct(Major.Destination, Minor.IOperator, "operator"), + new KeyStruct(Major.Destination, Minor.IKeywords, "keywords"), + new KeyStruct(Major.Destination, Minor.IComment, "comment"), + new KeyStruct(Major.Destination, Minor.IVersion, "version"), + new KeyStruct(Major.Destination, Minor.IDoccomm, "doccomm"), + new KeyStruct(Major.Destination, Minor.IVerscomm, "verscomm"), + new KeyStruct(Major.Destination, Minor.NextFile, "nextfile"), + new KeyStruct(Major.Destination, Minor.Template, "template"), + new KeyStruct(Major.Destination, Minor.FNSep, "ftnsep"), + new KeyStruct(Major.Destination, Minor.FNContSep, "ftnsepc"), + new KeyStruct(Major.Destination, Minor.FNContNotice, "ftncn"), + new KeyStruct(Major.Destination, Minor.ENSep, "aftnsep"), + new KeyStruct(Major.Destination, Minor.ENContSep, "aftnsepc"), + new KeyStruct(Major.Destination, Minor.ENContNotice, "aftncn"), + new KeyStruct(Major.Destination, Minor.PageNumLevel, "pgnhn"), + new KeyStruct(Major.Destination, Minor.ParNumLevelStyle, "pnseclvl"), + new KeyStruct(Major.Destination, Minor.Header, "header"), + new KeyStruct(Major.Destination, Minor.Footer, "footer"), + new KeyStruct(Major.Destination, Minor.HeaderLeft, "headerl"), + new KeyStruct(Major.Destination, Minor.HeaderRight, "headerr"), + new KeyStruct(Major.Destination, Minor.HeaderFirst, "headerf"), + new KeyStruct(Major.Destination, Minor.FooterLeft, "footerl"), + new KeyStruct(Major.Destination, Minor.FooterRight, "footerr"), + new KeyStruct(Major.Destination, Minor.FooterFirst, "footerf"), + new KeyStruct(Major.Destination, Minor.ParNumText, "pntext"), + new KeyStruct(Major.Destination, Minor.ParNumbering, "pn"), + new KeyStruct(Major.Destination, Minor.ParNumTextAfter, "pntexta"), + new KeyStruct(Major.Destination, Minor.ParNumTextBefore, "pntextb"), + new KeyStruct(Major.Destination, Minor.BookmarkStart, "bkmkstart"), + new KeyStruct(Major.Destination, Minor.BookmarkEnd, "bkmkend"), + new KeyStruct(Major.Destination, Minor.Pict, "pict"), + new KeyStruct(Major.Destination, Minor.Object, "object"), + new KeyStruct(Major.Destination, Minor.ObjClass, "objclass"), + new KeyStruct(Major.Destination, Minor.ObjName, "objname"), + new KeyStruct(Major.ObjAttr, Minor.ObjTime, "objtime"), + new KeyStruct(Major.Destination, Minor.ObjData, "objdata"), + new KeyStruct(Major.Destination, Minor.ObjAlias, "objalias"), + new KeyStruct(Major.Destination, Minor.ObjSection, "objsect"), + new KeyStruct(Major.Destination, Minor.ObjItem, "objitem"), + new KeyStruct(Major.Destination, Minor.ObjTopic, "objtopic"), + new KeyStruct(Major.Destination, Minor.ObjResult, "result"), + new KeyStruct(Major.Destination, Minor.DrawObject, "do"), + new KeyStruct(Major.Destination, Minor.Footnote, "footnote"), + new KeyStruct(Major.Destination, Minor.AnnotRefStart, "atrfstart"), + new KeyStruct(Major.Destination, Minor.AnnotRefEnd, "atrfend"), + new KeyStruct(Major.Destination, Minor.AnnotID, "atnid"), + new KeyStruct(Major.Destination, Minor.AnnotAuthor, "atnauthor"), + new KeyStruct(Major.Destination, Minor.Annotation, "annotation"), + new KeyStruct(Major.Destination, Minor.AnnotRef, "atnref"), + new KeyStruct(Major.Destination, Minor.AnnotTime, "atntime"), + new KeyStruct(Major.Destination, Minor.AnnotIcon, "atnicn"), + new KeyStruct(Major.Destination, Minor.Field, "field"), + new KeyStruct(Major.Destination, Minor.FieldInst, "fldinst"), + new KeyStruct(Major.Destination, Minor.FieldResult, "fldrslt"), + new KeyStruct(Major.Destination, Minor.DataField, "datafield"), + new KeyStruct(Major.Destination, Minor.Index, "xe"), + new KeyStruct(Major.Destination, Minor.IndexText, "txe"), + new KeyStruct(Major.Destination, Minor.IndexRange, "rxe"), + new KeyStruct(Major.Destination, Minor.TOC, "tc"), + new KeyStruct(Major.Destination, Minor.NeXTGraphic, "NeXTGraphic"), + new KeyStruct(Major.FontFamily, Minor.FFNil, "fnil"), + new KeyStruct(Major.FontFamily, Minor.FFRoman, "froman"), + new KeyStruct(Major.FontFamily, Minor.FFSwiss, "fswiss"), + new KeyStruct(Major.FontFamily, Minor.FFModern, "fmodern"), + new KeyStruct(Major.FontFamily, Minor.FFScript, "fscript"), + new KeyStruct(Major.FontFamily, Minor.FFDecor, "fdecor"), + new KeyStruct(Major.FontFamily, Minor.FFTech, "ftech"), + new KeyStruct(Major.FontFamily, Minor.FFBidirectional, "fbidi"), + new KeyStruct(Major.FontAttr, Minor.FontCharSet, "fcharset"), + new KeyStruct(Major.FontAttr, Minor.FontPitch, "fprq"), + new KeyStruct(Major.FontAttr, Minor.FontCodePage, "cpg"), + new KeyStruct(Major.FontAttr, Minor.FTypeNil, "ftnil"), + new KeyStruct(Major.FontAttr, Minor.FTypeTrueType, "fttruetype"), + new KeyStruct(Major.FileAttr, Minor.FileNum, "fid"), + new KeyStruct(Major.FileAttr, Minor.FileRelPath, "frelative"), + new KeyStruct(Major.FileAttr, Minor.FileOSNum, "fosnum"), + new KeyStruct(Major.FileSource, Minor.SrcMacintosh, "fvalidmac"), + new KeyStruct(Major.FileSource, Minor.SrcDOS, "fvaliddos"), + new KeyStruct(Major.FileSource, Minor.SrcNTFS, "fvalidntfs"), + new KeyStruct(Major.FileSource, Minor.SrcHPFS, "fvalidhpfs"), + new KeyStruct(Major.FileSource, Minor.SrcNetwork, "fnetwork"), + new KeyStruct(Major.ColorName, Minor.Red, "red"), + new KeyStruct(Major.ColorName, Minor.Green, "green"), + new KeyStruct(Major.ColorName, Minor.Blue, "blue"), + new KeyStruct(Major.CharSet, Minor.MacCharSet, "mac"), + new KeyStruct(Major.CharSet, Minor.AnsiCharSet, "ansi"), + new KeyStruct(Major.CharSet, Minor.PcCharSet, "pc"), + new KeyStruct(Major.CharSet, Minor.PcaCharSet, "pca"), + new KeyStruct(Major.TblAttr, Minor.RowDef, "trowd"), + new KeyStruct(Major.TblAttr, Minor.RowGapH, "trgaph"), + new KeyStruct(Major.TblAttr, Minor.CellPos, "cellx"), + new KeyStruct(Major.TblAttr, Minor.MergeRngFirst, "clmgf"), + new KeyStruct(Major.TblAttr, Minor.MergePrevious, "clmrg"), + new KeyStruct(Major.TblAttr, Minor.RowLeft, "trql"), + new KeyStruct(Major.TblAttr, Minor.RowRight, "trqr"), + new KeyStruct(Major.TblAttr, Minor.RowCenter, "trqc"), + new KeyStruct(Major.TblAttr, Minor.RowLeftEdge, "trleft"), + new KeyStruct(Major.TblAttr, Minor.RowHt, "trrh"), + new KeyStruct(Major.TblAttr, Minor.RowHeader, "trhdr"), + new KeyStruct(Major.TblAttr, Minor.RowKeep, "trkeep"), + new KeyStruct(Major.TblAttr, Minor.RTLRow, "rtlrow"), + new KeyStruct(Major.TblAttr, Minor.LTRRow, "ltrrow"), + new KeyStruct(Major.TblAttr, Minor.RowBordTop, "trbrdrt"), + new KeyStruct(Major.TblAttr, Minor.RowBordLeft, "trbrdrl"), + new KeyStruct(Major.TblAttr, Minor.RowBordBottom, "trbrdrb"), + new KeyStruct(Major.TblAttr, Minor.RowBordRight, "trbrdrr"), + new KeyStruct(Major.TblAttr, Minor.RowBordHoriz, "trbrdrh"), + new KeyStruct(Major.TblAttr, Minor.RowBordVert, "trbrdrv"), + new KeyStruct(Major.TblAttr, Minor.CellBordBottom, "clbrdrb"), + new KeyStruct(Major.TblAttr, Minor.CellBordTop, "clbrdrt"), + new KeyStruct(Major.TblAttr, Minor.CellBordLeft, "clbrdrl"), + new KeyStruct(Major.TblAttr, Minor.CellBordRight, "clbrdrr"), + new KeyStruct(Major.TblAttr, Minor.CellShading, "clshdng"), + new KeyStruct(Major.TblAttr, Minor.CellBgPatH, "clbghoriz"), + new KeyStruct(Major.TblAttr, Minor.CellBgPatV, "clbgvert"), + new KeyStruct(Major.TblAttr, Minor.CellFwdDiagBgPat, "clbgfdiag"), + new KeyStruct(Major.TblAttr, Minor.CellBwdDiagBgPat, "clbgbdiag"), + new KeyStruct(Major.TblAttr, Minor.CellHatchBgPat, "clbgcross"), + new KeyStruct(Major.TblAttr, Minor.CellDiagHatchBgPat, "clbgdcross"), + new KeyStruct(Major.TblAttr, Minor.CellDarkBgPatH, "clbgdkhoriz"), + new KeyStruct(Major.TblAttr, Minor.CellDarkBgPatH, "clbgdkhor"), + new KeyStruct(Major.TblAttr, Minor.CellDarkBgPatV, "clbgdkvert"), + new KeyStruct(Major.TblAttr, Minor.CellFwdDarkBgPat, "clbgdkfdiag"), + new KeyStruct(Major.TblAttr, Minor.CellBwdDarkBgPat, "clbgdkbdiag"), + new KeyStruct(Major.TblAttr, Minor.CellDarkHatchBgPat, "clbgdkcross"), + new KeyStruct(Major.TblAttr, Minor.CellDarkDiagHatchBgPat, "clbgdkdcross"), + new KeyStruct(Major.TblAttr, Minor.CellBgPatLineColor, "clcfpat"), + new KeyStruct(Major.TblAttr, Minor.CellBgPatColor, "clcbpat"), + new KeyStruct(Major.FieldAttr, Minor.FieldDirty, "flddirty"), + new KeyStruct(Major.FieldAttr, Minor.FieldEdited, "fldedit"), + new KeyStruct(Major.FieldAttr, Minor.FieldLocked, "fldlock"), + new KeyStruct(Major.FieldAttr, Minor.FieldPrivate, "fldpriv"), + new KeyStruct(Major.FieldAttr, Minor.FieldAlt, "fldalt"), + new KeyStruct(Major.PosAttr, Minor.AbsWid, "absw"), + new KeyStruct(Major.PosAttr, Minor.AbsHt, "absh"), + new KeyStruct(Major.PosAttr, Minor.RPosMargH, "phmrg"), + new KeyStruct(Major.PosAttr, Minor.RPosPageH, "phpg"), + new KeyStruct(Major.PosAttr, Minor.RPosColH, "phcol"), + new KeyStruct(Major.PosAttr, Minor.PosX, "posx"), + new KeyStruct(Major.PosAttr, Minor.PosNegX, "posnegx"), + new KeyStruct(Major.PosAttr, Minor.PosXCenter, "posxc"), + new KeyStruct(Major.PosAttr, Minor.PosXInside, "posxi"), + new KeyStruct(Major.PosAttr, Minor.PosXOutSide, "posxo"), + new KeyStruct(Major.PosAttr, Minor.PosXRight, "posxr"), + new KeyStruct(Major.PosAttr, Minor.PosXLeft, "posxl"), + new KeyStruct(Major.PosAttr, Minor.RPosMargV, "pvmrg"), + new KeyStruct(Major.PosAttr, Minor.RPosPageV, "pvpg"), + new KeyStruct(Major.PosAttr, Minor.RPosParaV, "pvpara"), + new KeyStruct(Major.PosAttr, Minor.PosY, "posy"), + new KeyStruct(Major.PosAttr, Minor.PosNegY, "posnegy"), + new KeyStruct(Major.PosAttr, Minor.PosYInline, "posyil"), + new KeyStruct(Major.PosAttr, Minor.PosYTop, "posyt"), + new KeyStruct(Major.PosAttr, Minor.PosYCenter, "posyc"), + new KeyStruct(Major.PosAttr, Minor.PosYBottom, "posyb"), + new KeyStruct(Major.PosAttr, Minor.NoWrap, "nowrap"), + new KeyStruct(Major.PosAttr, Minor.DistFromTextAll, "dxfrtext"), + new KeyStruct(Major.PosAttr, Minor.DistFromTextX, "dfrmtxtx"), + new KeyStruct(Major.PosAttr, Minor.DistFromTextY, "dfrmtxty"), + new KeyStruct(Major.PosAttr, Minor.TextDistY, "dyfrtext"), + new KeyStruct(Major.PosAttr, Minor.DropCapLines, "dropcapli"), + new KeyStruct(Major.PosAttr, Minor.DropCapType, "dropcapt"), + new KeyStruct(Major.ObjAttr, Minor.ObjEmb, "objemb"), + new KeyStruct(Major.ObjAttr, Minor.ObjLink, "objlink"), + new KeyStruct(Major.ObjAttr, Minor.ObjAutoLink, "objautlink"), + new KeyStruct(Major.ObjAttr, Minor.ObjSubscriber, "objsub"), + new KeyStruct(Major.ObjAttr, Minor.ObjPublisher, "objpub"), + new KeyStruct(Major.ObjAttr, Minor.ObjICEmb, "objicemb"), + new KeyStruct(Major.ObjAttr, Minor.ObjLinkSelf, "linkself"), + new KeyStruct(Major.ObjAttr, Minor.ObjLock, "objupdate"), + new KeyStruct(Major.ObjAttr, Minor.ObjUpdate, "objlock"), + new KeyStruct(Major.ObjAttr, Minor.ObjHt, "objh"), + new KeyStruct(Major.ObjAttr, Minor.ObjWid, "objw"), + new KeyStruct(Major.ObjAttr, Minor.ObjSetSize, "objsetsize"), + new KeyStruct(Major.ObjAttr, Minor.ObjAlign, "objalign"), + new KeyStruct(Major.ObjAttr, Minor.ObjTransposeY, "objtransy"), + new KeyStruct(Major.ObjAttr, Minor.ObjCropTop, "objcropt"), + new KeyStruct(Major.ObjAttr, Minor.ObjCropBottom, "objcropb"), + new KeyStruct(Major.ObjAttr, Minor.ObjCropLeft, "objcropl"), + new KeyStruct(Major.ObjAttr, Minor.ObjCropRight, "objcropr"), + new KeyStruct(Major.ObjAttr, Minor.ObjScaleX, "objscalex"), + new KeyStruct(Major.ObjAttr, Minor.ObjScaleY, "objscaley"), + new KeyStruct(Major.ObjAttr, Minor.ObjResRTF, "rsltrtf"), + new KeyStruct(Major.ObjAttr, Minor.ObjResPict, "rsltpict"), + new KeyStruct(Major.ObjAttr, Minor.ObjResBitmap, "rsltbmp"), + new KeyStruct(Major.ObjAttr, Minor.ObjResText, "rslttxt"), + new KeyStruct(Major.ObjAttr, Minor.ObjResMerge, "rsltmerge"), + new KeyStruct(Major.ObjAttr, Minor.ObjBookmarkPubObj, "bkmkpub"), + new KeyStruct(Major.ObjAttr, Minor.ObjPubAutoUpdate, "pubauto"), + new KeyStruct(Major.ACharAttr, Minor.ACBold, "ab"), + new KeyStruct(Major.ACharAttr, Minor.ACAllCaps, "caps"), + new KeyStruct(Major.ACharAttr, Minor.ACForeColor, "acf"), + new KeyStruct(Major.ACharAttr, Minor.ACSubScript, "adn"), + new KeyStruct(Major.ACharAttr, Minor.ACExpand, "aexpnd"), + new KeyStruct(Major.ACharAttr, Minor.ACFontNum, "af"), + new KeyStruct(Major.ACharAttr, Minor.ACFontSize, "afs"), + new KeyStruct(Major.ACharAttr, Minor.ACItalic, "ai"), + new KeyStruct(Major.ACharAttr, Minor.ACLanguage, "alang"), + new KeyStruct(Major.ACharAttr, Minor.ACOutline, "aoutl"), + new KeyStruct(Major.ACharAttr, Minor.ACSmallCaps, "ascaps"), + new KeyStruct(Major.ACharAttr, Minor.ACShadow, "ashad"), + new KeyStruct(Major.ACharAttr, Minor.ACStrikeThru, "astrike"), + new KeyStruct(Major.ACharAttr, Minor.ACUnderline, "aul"), + new KeyStruct(Major.ACharAttr, Minor.ACDotUnderline, "auld"), + new KeyStruct(Major.ACharAttr, Minor.ACDbUnderline, "auldb"), + new KeyStruct(Major.ACharAttr, Minor.ACNoUnderline, "aulnone"), + new KeyStruct(Major.ACharAttr, Minor.ACWordUnderline, "aulw"), + new KeyStruct(Major.ACharAttr, Minor.ACSuperScript, "aup"), + new KeyStruct(Major.FNoteAttr, Minor.FNAlt, "ftnalt"), + new KeyStruct(Major.KeyCodeAttr, Minor.AltKey, "alt"), + new KeyStruct(Major.KeyCodeAttr, Minor.ShiftKey, "shift"), + new KeyStruct(Major.KeyCodeAttr, Minor.ControlKey, "ctrl"), + new KeyStruct(Major.KeyCodeAttr, Minor.FunctionKey, "fn"), + new KeyStruct(Major.BookmarkAttr, Minor.BookmarkFirstCol, "bkmkcolf"), + new KeyStruct(Major.BookmarkAttr, Minor.BookmarkLastCol, "bkmkcoll"), + new KeyStruct(Major.IndexAttr, Minor.IndexNumber, "xef"), + new KeyStruct(Major.IndexAttr, Minor.IndexBold, "bxe"), + new KeyStruct(Major.IndexAttr, Minor.IndexItalic, "ixe"), + new KeyStruct(Major.TOCAttr, Minor.TOCType, "tcf"), + new KeyStruct(Major.TOCAttr, Minor.TOCLevel, "tcl"), + new KeyStruct(Major.DrawAttr, Minor.DrawLock, "dolock"), + new KeyStruct(Major.DrawAttr, Minor.DrawPageRelX, "doxpage"), + new KeyStruct(Major.DrawAttr, Minor.DrawColumnRelX, "dobxcolumn"), + new KeyStruct(Major.DrawAttr, Minor.DrawMarginRelX, "dobxmargin"), + new KeyStruct(Major.DrawAttr, Minor.DrawPageRelY, "dobypage"), + new KeyStruct(Major.DrawAttr, Minor.DrawColumnRelY, "dobycolumn"), + new KeyStruct(Major.DrawAttr, Minor.DrawMarginRelY, "dobymargin"), + new KeyStruct(Major.DrawAttr, Minor.DrawHeight, "dobhgt"), + new KeyStruct(Major.DrawAttr, Minor.DrawBeginGroup, "dpgroup"), + new KeyStruct(Major.DrawAttr, Minor.DrawGroupCount, "dpcount"), + new KeyStruct(Major.DrawAttr, Minor.DrawEndGroup, "dpendgroup"), + new KeyStruct(Major.DrawAttr, Minor.DrawArc, "dparc"), + new KeyStruct(Major.DrawAttr, Minor.DrawCallout, "dpcallout"), + new KeyStruct(Major.DrawAttr, Minor.DrawEllipse, "dpellipse"), + new KeyStruct(Major.DrawAttr, Minor.DrawLine, "dpline"), + new KeyStruct(Major.DrawAttr, Minor.DrawPolygon, "dppolygon"), + new KeyStruct(Major.DrawAttr, Minor.DrawPolyLine, "dppolyline"), + new KeyStruct(Major.DrawAttr, Minor.DrawRect, "dprect"), + new KeyStruct(Major.DrawAttr, Minor.DrawTextBox, "dptxbx"), + new KeyStruct(Major.DrawAttr, Minor.DrawOffsetX, "dpx"), + new KeyStruct(Major.DrawAttr, Minor.DrawSizeX, "dpxsize"), + new KeyStruct(Major.DrawAttr, Minor.DrawOffsetY, "dpy"), + new KeyStruct(Major.DrawAttr, Minor.DrawSizeY, "dpysize"), + new KeyStruct(Major.DrawAttr, Minor.COAngle, "dpcoa"), + new KeyStruct(Major.DrawAttr, Minor.COAccentBar, "dpcoaccent"), + new KeyStruct(Major.DrawAttr, Minor.COBestFit, "dpcobestfit"), + new KeyStruct(Major.DrawAttr, Minor.COBorder, "dpcoborder"), + new KeyStruct(Major.DrawAttr, Minor.COAttachAbsDist, "dpcodabs"), + new KeyStruct(Major.DrawAttr, Minor.COAttachBottom, "dpcodbottom"), + new KeyStruct(Major.DrawAttr, Minor.COAttachCenter, "dpcodcenter"), + new KeyStruct(Major.DrawAttr, Minor.COAttachTop, "dpcodtop"), + new KeyStruct(Major.DrawAttr, Minor.COLength, "dpcolength"), + new KeyStruct(Major.DrawAttr, Minor.CONegXQuadrant, "dpcominusx"), + new KeyStruct(Major.DrawAttr, Minor.CONegYQuadrant, "dpcominusy"), + new KeyStruct(Major.DrawAttr, Minor.COOffset, "dpcooffset"), + new KeyStruct(Major.DrawAttr, Minor.COAttachSmart, "dpcosmarta"), + new KeyStruct(Major.DrawAttr, Minor.CODoubleLine, "dpcotdouble"), + new KeyStruct(Major.DrawAttr, Minor.CORightAngle, "dpcotright"), + new KeyStruct(Major.DrawAttr, Minor.COSingleLine, "dpcotsingle"), + new KeyStruct(Major.DrawAttr, Minor.COTripleLine, "dpcottriple"), + new KeyStruct(Major.DrawAttr, Minor.DrawTextBoxMargin, "dptxbxmar"), + new KeyStruct(Major.DrawAttr, Minor.DrawTextBoxText, "dptxbxtext"), + new KeyStruct(Major.DrawAttr, Minor.DrawRoundRect, "dproundr"), + new KeyStruct(Major.DrawAttr, Minor.DrawPointX, "dpptx"), + new KeyStruct(Major.DrawAttr, Minor.DrawPointY, "dppty"), + new KeyStruct(Major.DrawAttr, Minor.DrawPolyCount, "dppolycount"), + new KeyStruct(Major.DrawAttr, Minor.DrawArcFlipX, "dparcflipx"), + new KeyStruct(Major.DrawAttr, Minor.DrawArcFlipY, "dparcflipy"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineBlue, "dplinecob"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineGreen, "dplinecog"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineRed, "dplinecor"), + new KeyStruct(Major.DrawAttr, Minor.DrawLinePalette, "dplinepal"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineDashDot, "dplinedado"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineDashDotDot, "dplinedadodo"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineDash, "dplinedash"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineDot, "dplinedot"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineGray, "dplinegray"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineHollow, "dplinehollow"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineSolid, "dplinesolid"), + new KeyStruct(Major.DrawAttr, Minor.DrawLineWidth, "dplinew"), + new KeyStruct(Major.DrawAttr, Minor.DrawHollowEndArrow, "dpaendhol"), + new KeyStruct(Major.DrawAttr, Minor.DrawEndArrowLength, "dpaendl"), + new KeyStruct(Major.DrawAttr, Minor.DrawSolidEndArrow, "dpaendsol"), + new KeyStruct(Major.DrawAttr, Minor.DrawEndArrowWidth, "dpaendw"), + new KeyStruct(Major.DrawAttr, Minor.DrawHollowStartArrow,"dpastarthol"), + new KeyStruct(Major.DrawAttr, Minor.DrawStartArrowLength,"dpastartl"), + new KeyStruct(Major.DrawAttr, Minor.DrawSolidStartArrow, "dpastartsol"), + new KeyStruct(Major.DrawAttr, Minor.DrawStartArrowWidth, "dpastartw"), + new KeyStruct(Major.DrawAttr, Minor.DrawBgFillBlue, "dpfillbgcb"), + new KeyStruct(Major.DrawAttr, Minor.DrawBgFillGreen, "dpfillbgcg"), + new KeyStruct(Major.DrawAttr, Minor.DrawBgFillRed, "dpfillbgcr"), + new KeyStruct(Major.DrawAttr, Minor.DrawBgFillPalette, "dpfillbgpal"), + new KeyStruct(Major.DrawAttr, Minor.DrawBgFillGray, "dpfillbggray"), + new KeyStruct(Major.DrawAttr, Minor.DrawFgFillBlue, "dpfillfgcb"), + new KeyStruct(Major.DrawAttr, Minor.DrawFgFillGreen, "dpfillfgcg"), + new KeyStruct(Major.DrawAttr, Minor.DrawFgFillRed, "dpfillfgcr"), + new KeyStruct(Major.DrawAttr, Minor.DrawFgFillPalette, "dpfillfgpal"), + new KeyStruct(Major.DrawAttr, Minor.DrawFgFillGray, "dpfillfggray"), + new KeyStruct(Major.DrawAttr, Minor.DrawFillPatIndex, "dpfillpat"), + new KeyStruct(Major.DrawAttr, Minor.DrawShadow, "dpshadow"), + new KeyStruct(Major.DrawAttr, Minor.DrawShadowXOffset, "dpshadx"), + new KeyStruct(Major.DrawAttr, Minor.DrawShadowYOffset, "dpshady"), + new KeyStruct(Major.Version, Minor.Undefined, "rtf"), + new KeyStruct(Major.DefFont, Minor.Undefined, "deff"), + new KeyStruct(Major.Unicode, Minor.UnicodeCharBytes, "uc"), + new KeyStruct(Major.Unicode, Minor.UnicodeChar, "u"), + new KeyStruct(Major.Unicode, Minor.UnicodeDestination, "ud"), + new KeyStruct(Major.Unicode, Minor.UnicodeDualDestination, "upr"), + new KeyStruct(Major.Unicode, Minor.UnicodeAnsiCodepage, "ansicpg"), + }; + } + } +} diff --git a/source/ShiftUI/RTF/Major.cs b/source/ShiftUI/RTF/Major.cs new file mode 100644 index 0000000..bbd11b5 --- /dev/null +++ b/source/ShiftUI/RTF/Major.cs @@ -0,0 +1,73 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + enum Major { + // Group class + BeginGroup, + EndGroup, + + // Widget + Version, + DefFont, + CharSet, + + Destination, + FontFamily, + ColorName, + SpecialChar, + StyleAttr, + DocAttr, + SectAttr, + TblAttr, + ParAttr, + CharAttr, + PictAttr, + BookmarkAttr, + NeXTGrAttr, + FieldAttr, + TOCAttr, + PosAttr, + ObjAttr, + FNoteAttr, + KeyCodeAttr, + ACharAttr, + FontAttr, + FileAttr, + FileSource, + DrawAttr, + IndexAttr, + Unicode + } +} diff --git a/source/ShiftUI/RTF/Minor.cs b/source/ShiftUI/RTF/Minor.cs new file mode 100644 index 0000000..75f5047 --- /dev/null +++ b/source/ShiftUI/RTF/Minor.cs @@ -0,0 +1,769 @@ +// Permission is hereby , free of , to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without , including +// without limitation the rights to , , , , , +// , , and/or sell copies of the , and to +// permit persons to whom the Software is furnished to do , subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY , +// EXPRESS OR , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// , FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY , DAMAGES OR OTHER , WHETHER IN AN ACTION +// OF , TORT OR , ARISING , OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 , Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + + internal enum Minor { + Undefined, + + Skip, + + // Major.CharSet + AnsiCharSet, + MacCharSet, + PcCharSet, + PcaCharSet, + + // Major.Destinan + FontTbl, + FontAltName, + EmbeddedFont, + FontFile, + FileTbl, + FileInfo, + ColorTbl, + StyleSheet, + KeyCode, + RevisionTbl, + Info, + ITitle, + ISubject, + IAuthor, + IOperator, + IKeywords, + IComment, + IVersion, + IDoccomm, + IVerscomm, + NextFile, + Template, + FNSep, + FNContSep, + FNContNotice, + ENSep, + ENContSep, + ENContNotice, + PageNumLevel, + ParNumLevelStyle, + Header, + Footer, + HeaderLeft, + HeaderRight, + HeaderFirst, + FooterLeft, + FooterRight, + FooterFirst, + ParNumText, + ParNumbering, + ParNumTextAfter, + ParNumTextBefore, + BookmarkStart, + BookmarkEnd, + Pict, + Object, + ObjClass, + ObjName, + ObjTime, + ObjData, + ObjAlias, + ObjSection, + ObjResult, + ObjItem, + ObjTopic, + DrawObject, + Footnote, + AnnotRefStart, + AnnotRefEnd, + AnnotID, + AnnotAuthor, + Annotation, + AnnotRef, + AnnotTime, + AnnotIcon, + Field, + FieldInst, + FieldResult, + DataField, + Index, + IndexText, + IndexRange, + TOC, + NeXTGraphic, + MaxDestination, + + // Major.FontFamily + FFNil, + FFRoman, + FFSwiss, + FFModern, + FFScript, + FFDecor, + FFTech, + FFBidirectional, + + // Major.ColorName + Red, + Green, + Blue, + + // Major.SpecialChar + IIntVersion, + ICreateTime, + IRevisionTime, + IPrintTime, + IBackupTime, + IEditTime, + IYear, + IMonth, + IDay, + IHour, + IMinute, + ISecond, + INPages, + INWords, + INChars, + IIntID, + CurHeadDate, + CurHeadDateLong, + CurHeadDateAbbrev, + CurHeadTime, + CurHeadPage, + SectNum, + CurFNote, + CurAnnotRef, + FNoteSep, + FNoteCont, + Cell, + Row, + Par, + Sect, + Page, + Column, + Line, + SoftPage, + SoftColumn, + SoftLine, + SoftLineHt, + Tab, + EmDash, + EnDash, + EmSpace, + EnSpace, + Bullet, + LQuote, + RQuote, + LDblQuote, + RDblQuote, + Formula, + NoBrkSpace, + NoReqHyphen, + NoBrkHyphen, + OptDest, + LTRMark, + RTLMark, + NoWidthJoiner, + NoWidthNonJoiner, + CurHeadPict, + + // Major.StyleAttr + Additive, + BasedOn, + Next, + + // Major.DocAttr + DefTab, + HyphHotZone, + HyphConsecLines, + HyphCaps, + HyphAuto, + LineStart, + FracWidth, + MakeBackup, + RTFDefault, + PSOverlay, + DocTemplate, + DefLanguage, + FENoteType, + FNoteEndSect, + FNoteEndDoc, + FNoteText, + FNoteBottom, + ENoteEndSect, + ENoteEndDoc, + ENoteText, + ENoteBottom, + FNoteStart, + ENoteStart, + FNoteRestartPage, + FNoteRestart, + FNoteRestartCont, + ENoteRestart, + ENoteRestartCont, + FNoteNumArabic, + FNoteNumLLetter, + FNoteNumULetter, + FNoteNumLRoman, + FNoteNumURoman, + FNoteNumChicago, + ENoteNumArabic, + ENoteNumLLetter, + ENoteNumULetter, + ENoteNumLRoman, + ENoteNumURoman, + ENoteNumChicago, + PaperWidth, + PaperHeight, + PaperSize, + LeftMargin, + RightMargin, + TopMargin, + BottomMargin, + FacingPage, + GutterWid, + MirrorMargin, + Landscape, + PageStart, + WidowCtrl, + LinkStyles, + NoAutoTabIndent, + WrapSpaces, + PrintColorsBlack, + NoExtraSpaceRL, + NoColumnBalance, + CvtMailMergeQuote, + SuppressTopSpace, + SuppressPreParSpace, + CombineTblBorders, + TranspMetafiles, + SwapBorders, + ShowHardBreaks, + FormProtected, + AllProtected, + FormShading, + FormDisplay, + PrintData, + RevProtected, + Revisions, + RevDisplay, + RevBar, + AnnotProtected, + RTLDoc, + LTRDoc, + + // Major.SectAttr + + SectDef, + ENoteHere, + PrtBinFirst, + PrtBin, + SectStyleNum, + NoBreak, + ColBreak, + PageBreak, + EvenBreak, + OddBreak, + Columns, + ColumnSpace, + ColumnNumber, + ColumnSpRight, + ColumnWidth, + ColumnLine, + LineModulus, + LineDist, + LineStarts, + LineRestart, + LineRestartPg, + LineCont, + SectPageWid, + SectPageHt, + SectMarginLeft, + SectMarginRight, + SectMarginTop, + SectMarginBottom, + SectMarginGutter, + SectLandscape, + TitleSpecial, + HeaderY, + FooterY, + PageStarts, + PageCont, + PageRestart, + PageNumRight, + PageNumTop, + PageDecimal, + PageURoman, + PageLRoman, + PageULetter, + PageLLetter, + PageNumHyphSep, + PageNumSpaceSep, + PageNumColonSep, + PageNumEmdashSep, + PageNumEndashSep, + TopVAlign, + BottomVAlign, + CenterVAlign, + JustVAlign, + RTLSect, + LTRSect, + + // Major.TblAttr + RowDef, + RowGapH, + CellPos, + MergeRngFirst, + MergePrevious, + RowLeft, + RowRight, + RowCenter, + RowLeftEdge, + RowHt, + RowHeader, + RowKeep, + RTLRow, + LTRRow, + RowBordTop, + RowBordLeft, + RowBordBottom, + RowBordRight, + RowBordHoriz, + RowBordVert, + CellBordBottom, + CellBordTop, + CellBordLeft, + CellBordRight, + CellShading, + CellBgPatH, + CellBgPatV, + CellFwdDiagBgPat, + CellBwdDiagBgPat, + CellHatchBgPat, + CellDiagHatchBgPat, + CellDarkBgPatH, + CellDarkBgPatV, + CellFwdDarkBgPat, + CellBwdDarkBgPat, + CellDarkHatchBgPat, + CellDarkDiagHatchBgPat, + CellBgPatLineColor, + CellBgPatColor, + + // Major.ParAttr + ParDef, + StyleNum, + Hyphenate, + InTable, + Keep, + NoWidowControl, + KeepNext, + OutlineLevel, + NoLineNum, + PBBefore, + SideBySide, + QuadLeft, + QuadRight, + QuadJust, + QuadCenter, + FirstIndent, + LeftIndent, + RightIndent, + SpaceBefore, + SpaceAfter, + SpaceBetween, + SpaceMultiply, + SubDocument, + RTLPar, + LTRPar, + TabPos, + TabLeft, + TabRight, + TabCenter, + TabDecimal, + TabBar, + LeaderDot, + LeaderHyphen, + LeaderUnder, + LeaderThick, + LeaderEqual, + ParLevel, + ParBullet, + ParSimple, + ParNumCont, + ParNumOnce, + ParNumAcross, + ParHangIndent, + ParNumRestart, + ParNumCardinal, + ParNumDecimal, + ParNumULetter, + ParNumURoman, + ParNumLLetter, + ParNumLRoman, + ParNumOrdinal, + ParNumOrdinalText, + ParNumBold, + ParNumItalic, + ParNumAllCaps, + ParNumSmallCaps, + ParNumUnder, + ParNumDotUnder, + ParNumDbUnder, + ParNumNoUnder, + ParNumWordUnder, + ParNumStrikethru, + ParNumForeColor, + ParNumFont, + ParNumFontSize, + ParNumIndent, + ParNumSpacing, + ParNumInclPrev, + ParNumCenter, + ParNumLeft, + ParNumRight, + ParNumStartAt, + BorderTop, + BorderBottom, + BorderLeft, + BorderRight, + BorderBetween, + BorderBar, + BorderBox, + BorderSingle, + BorderThick, + BorderShadow, + BorderDouble, + BorderDot, + BorderDash, + BorderHair, + BorderWidth, + BorderColor, + BorderSpace, + Shading, + BgPatH, + BgPatV, + FwdDiagBgPat, + BwdDiagBgPat, + HatchBgPat, + DiagHatchBgPat, + DarkBgPatH, + DarkBgPatV, + FwdDarkBgPat, + BwdDarkBgPat, + DarkHatchBgPat, + DarkDiagHatchBgPat, + BgPatLineColor, + BgPatColor, + + // Major.CharAttr + Plain, + Bold, + AllCaps, + Deleted, + SubScript, + SubScrShrink, + NoSuperSub, + Expand, + ExpandTwips, + Kerning, + FontNum, + FontSize, + Italic, + Outline, + Revised, + RevAuthor, + RevDTTM, + SmallCaps, + Shadow, + StrikeThru, + Underline, + DotUnderline, + DbUnderline, + NoUnderline, + WordUnderline, + SuperScript, + SuperScrShrink, + Invisible, + ForeColor, + BackColor, + RTLChar, + LTRChar, + CharStyleNum, + CharCharSet, + Language, + Gray, + + // Major.PictAttr + MacQD, + PMMetafile, + WinMetafile, + DevIndBitmap, + WinBitmap, + PngBlip, + PixelBits, + BitmapPlanes, + BitmapWid, + PicWid, + PicHt, + PicGoalWid, + PicGoalHt, + PicScaleX, + PicScaleY, + PicScaled, + PicCropTop, + PicCropBottom, + PicCropLeft, + PicCropRight, + PicMFHasBitmap, + PicMFBitsPerPixel, + PicBinary, + + // Major.BookmarkAttr + BookmarkFirstCol, + BookmarkLastCol , + + // Major.NeXTGrAttr + NeXTGWidth, + NeXTGHeight, + + // Major.FieldAttr + FieldDirty, + FieldEdited, + FieldLocked, + FieldPrivate, + FieldAlt, + + // Major.TOCAttr + TOCType, + TOCLevel, + + // Major.PosAttr + AbsWid, + AbsHt, + RPosMargH, + RPosPageH, + RPosColH, + PosX, + PosNegX, + PosXCenter, + PosXInside, + PosXOutSide, + PosXRight, + PosXLeft, + RPosMargV, + RPosPageV, + RPosParaV, + PosY, + PosNegY, + PosYInline, + PosYTop, + PosYCenter, + PosYBottom, + NoWrap, + DistFromTextAll, + DistFromTextX, + DistFromTextY, + TextDistY, + DropCapLines, + DropCapType, + + // Major.ObjAttr + ObjEmb, + ObjLink, + ObjAutoLink, + ObjSubscriber, + ObjPublisher, + ObjICEmb, + ObjLinkSelf, + ObjLock, + ObjUpdate, + ObjHt, + ObjWid, + ObjSetSize, + ObjAlign, + ObjTransposeY, + ObjCropTop, + ObjCropBottom, + ObjCropLeft, + ObjCropRight, + ObjScaleX, + ObjScaleY, + ObjResRTF, + ObjResPict, + ObjResBitmap, + ObjResText, + ObjResMerge, + ObjBookmarkPubObj, + ObjPubAutoUpdate, + + // Major.FNoteAttr + FNAlt, + + // Major.KeyCodeAttr + AltKey, + ShiftKey, + ControlKey, + FunctionKey, + + // Major.ACharAttr + ACBold, + ACAllCaps, + ACForeColor, + ACSubScript, + ACExpand, + ACFontNum, + ACFontSize, + ACItalic, + ACLanguage, + ACOutline, + ACSmallCaps, + ACShadow, + ACStrikeThru, + ACUnderline, + ACDotUnderline, + ACDbUnderline, + ACNoUnderline, + ACWordUnderline, + ACSuperScript, + + // Major.FontAttr + FontCharSet, + FontPitch, + FontCodePage, + FTypeNil, + FTypeTrueType, + + // Major.FileAttr + FileNum, + FileRelPath, + FileOSNum, + + // Major.FileSource + SrcMacintosh, + SrcDOS, + SrcNTFS, + SrcHPFS, + SrcNetwork, + + // Major.DrawAttr + DrawLock, + DrawPageRelX, + DrawColumnRelX, + DrawMarginRelX, + DrawPageRelY, + DrawColumnRelY, + DrawMarginRelY, + DrawHeight, + DrawBeginGroup, + DrawGroupCount, + DrawEndGroup, + DrawArc, + DrawCallout, + DrawEllipse, + DrawLine, + DrawPolygon, + DrawPolyLine, + DrawRect, + DrawTextBox, + DrawOffsetX, + DrawSizeX, + DrawOffsetY, + DrawSizeY, + COAngle, + COAccentBar, + COBestFit, + COBorder, + COAttachAbsDist, + COAttachBottom, + COAttachCenter, + COAttachTop, + COLength, + CONegXQuadrant, + CONegYQuadrant, + COOffset, + COAttachSmart, + CODoubleLine, + CORightAngle, + COSingleLine, + COTripleLine, + DrawTextBoxMargin, + DrawTextBoxText, + DrawRoundRect, + DrawPointX, + DrawPointY, + DrawPolyCount, + DrawArcFlipX, + DrawArcFlipY, + DrawLineBlue, + DrawLineGreen, + DrawLineRed, + DrawLinePalette, + DrawLineDashDot, + DrawLineDashDotDot, + DrawLineDash, + DrawLineDot, + DrawLineGray, + DrawLineHollow, + DrawLineSolid, + DrawLineWidth, + DrawHollowEndArrow, + DrawEndArrowLength, + DrawSolidEndArrow, + DrawEndArrowWidth, + DrawHollowStartArrow, + DrawStartArrowLength, + DrawSolidStartArrow, + DrawStartArrowWidth, + DrawBgFillBlue, + DrawBgFillGreen, + DrawBgFillRed, + DrawBgFillPalette, + DrawBgFillGray, + DrawFgFillBlue, + DrawFgFillGreen, + DrawFgFillRed, + DrawFgFillPalette, + DrawFgFillGray, + DrawFillPatIndex, + DrawShadow, + DrawShadowXOffset, + DrawShadowYOffset, + + // Major.IndexAttr + IndexNumber, + IndexBold, + IndexItalic, + + // Major.Unicode + UnicodeCharBytes, + UnicodeChar, + UnicodeDestination, + UnicodeDualDestination, + UnicodeAnsiCodepage + + } +} diff --git a/source/ShiftUI/RTF/Picture.cs b/source/ShiftUI/RTF/Picture.cs new file mode 100644 index 0000000..55d1cc6 --- /dev/null +++ b/source/ShiftUI/RTF/Picture.cs @@ -0,0 +1,149 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2007 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Jackson Harper ([email protected]) +// + + +using System; +using System.IO; +using System.Drawing; + +namespace ShiftUI.RTF { + + internal class Picture { + + private Minor image_type; + private Image image; + private MemoryStream data; + private float width = -1; + private float height = -1; + + private readonly static float dpix; + + static Picture () + { + dpix = TextRenderer.GetDpi ().Width; + } + + public Picture () + { + + } + + public Minor ImageType { + get { return image_type; } + set { image_type = value; } + } + + public MemoryStream Data { + get { + if (data == null) + data = new MemoryStream (); + return data; + } + } + + public float Width { + get { + float w = width; + if (w == -1) { + if (image == null) + image = ToImage (); + w = image.Width; + } + return w; + + } + } + + public float Height { + get { + float h = height; + if (h == -1) { + if (image == null) + image = ToImage (); + h = image.Height; + } + return h; + } + } + + public SizeF Size { + get { + return new SizeF (Width, Height); + } + } + + public void SetWidthFromTwips (int twips) + { + width = (int) (((float) twips / 1440.0F) * dpix + 0.5F); + } + + public void SetHeightFromTwips (int twips) + { + height = (int) (((float) twips / 1440.0F) * dpix + 0.5F); + } + + // + // Makes sure that we got enough information to actually use the image + // + public bool IsValid () + { + if (data == null) + return false; + switch (image_type) { + case Minor.PngBlip: + case Minor.WinMetafile: + break; + default: + return false; + } + + return true; + } + + public void DrawImage (Graphics dc, float x, float y, bool selected) + { + if (image == null) + image = ToImage (); + + float height = this.height; + float width = this.width; + + if (height == -1) + height = image.Height; + if (width == -1) + width = image.Width; + dc.DrawImage (image, x, y, width, height); + } + + public Image ToImage () + { + // Reset the data stream position to the beginning + data.Position = 0; + return Image.FromStream (data); + } + } + +} + diff --git a/source/ShiftUI/RTF/README b/source/ShiftUI/RTF/README new file mode 100644 index 0000000..ccfb3fa --- /dev/null +++ b/source/ShiftUI/RTF/README @@ -0,0 +1,7 @@ +This RTF parser was originally based on a C-based RTF parser written +by Paul DuBois ([email protected]). It came with the following license: + + * This software may be redistributed without restriction and used for + * any purpose whatsoever. + +and was part of the code found in the 'rewind' project. diff --git a/source/ShiftUI/RTF/RTF.cs b/source/ShiftUI/RTF/RTF.cs new file mode 100644 index 0000000..dd67fe6 --- /dev/null +++ b/source/ShiftUI/RTF/RTF.cs @@ -0,0 +1,1056 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// + +// COMPLETE + +#undef RTF_DEBUG + +using System; +using System.Collections; +using System.IO; +using System.Text; + +namespace ShiftUI.RTF { + internal class RTF { + #region Local Variables + internal const char EOF = unchecked((char)-1); + internal const int NoParam = -1000000; + internal const int DefaultEncodingCodePage = 1252; + + private TokenClass rtf_class; + private Major major; + private Minor minor; + private int param; + private string encoded_text; + private Encoding encoding; + private int encoding_code_page = DefaultEncodingCodePage; + private StringBuilder text_buffer; + private Picture picture; + private int line_num; + private int line_pos; + + private char pushed_char; + //private StringBuilder pushed_text_buffer; + private TokenClass pushed_class; + private Major pushed_major; + private Minor pushed_minor; + private int pushed_param; + + private char prev_char; + private bool bump_line; + + private Font font_list; + + private Charset cur_charset; + private Stack charset_stack; + + private Style styles; + private Color colors; + private Font fonts; + + private StreamReader source; + + private static Hashtable key_table; + private static KeyStruct[] Keys = KeysInit.Init(); + + private DestinationCallback destination_callbacks; + private ClassCallback class_callbacks; + #endregion // Local Variables + + #region Constructors + static RTF() { + key_table = new Hashtable(Keys.Length); + for (int i = 0; i < Keys.Length; i++) { + key_table[Keys[i].Symbol] = Keys[i]; + } + } + + public RTF(Stream stream) { + source = new StreamReader(stream); + + text_buffer = new StringBuilder(1024); + //pushed_text_buffer = new StringBuilder(1024); + + rtf_class = TokenClass.None; + pushed_class = TokenClass.None; + pushed_char = unchecked((char)-1); + + line_num = 0; + line_pos = 0; + prev_char = unchecked((char)-1); + bump_line = false; + font_list = null; + charset_stack = null; + + cur_charset = new Charset(); + + destination_callbacks = new DestinationCallback(); + class_callbacks = new ClassCallback(); + + destination_callbacks [Minor.OptDest] = new DestinationDelegate (HandleOptDest); + destination_callbacks[Minor.FontTbl] = new DestinationDelegate(ReadFontTbl); + destination_callbacks[Minor.ColorTbl] = new DestinationDelegate(ReadColorTbl); + destination_callbacks[Minor.StyleSheet] = new DestinationDelegate(ReadStyleSheet); + destination_callbacks[Minor.Info] = new DestinationDelegate(ReadInfoGroup); + destination_callbacks[Minor.Pict] = new DestinationDelegate(ReadPictGroup); + destination_callbacks[Minor.Object] = new DestinationDelegate(ReadObjGroup); + } + #endregion // Constructors + + #region Properties + public TokenClass TokenClass { + get { + return this.rtf_class; + } + + set { + this.rtf_class = value; + } + } + + public Major Major { + get { + return this.major; + } + + set { + this.major = value; + } + } + + public Minor Minor { + get { + return this.minor; + } + + set { + this.minor = value; + } + } + + public int Param { + get { + return this.param; + } + + set { + this.param = value; + } + } + + public string Text { + get { + return this.text_buffer.ToString(); + } + + set { + if (value == null) { + this.text_buffer.Length = 0; + } else { + this.text_buffer = new StringBuilder(value); + } + } + } + + public string EncodedText { + get { return encoded_text; } + } + + public Picture Picture { + get { return picture; } + set { picture = value; } + } + + public Color Colors { + get { + return colors; + } + + set { + colors = value; + } + } + + public Style Styles { + get { + return styles; + } + + set { + styles = value; + } + } + + public Font Fonts { + get { + return fonts; + } + + set { + fonts = value; + } + } + + public ClassCallback ClassCallback { + get { + return class_callbacks; + } + + set { + class_callbacks = value; + } + } + + public DestinationCallback DestinationCallback { + get { + return destination_callbacks; + } + + set { + destination_callbacks = value; + } + } + + public int LineNumber { + get { + return line_num; + } + } + + public int LinePos { + get { + return line_pos; + } + } + #endregion // Properties + + #region Methods + /// <summary>Set the default font for documents without font table</summary> + public void DefaultFont(string name) { + Font font; + + font = new Font(this); + font.Num = 0; + font.Name = name; + } + + /// <summary>Read the next character from the input - skip any crlf</summary> + private char GetChar () + { + return GetChar (true); + } + + /// <summary>Read the next character from the input</summary> + private char GetChar(bool skipCrLf) + { + int c; + bool old_bump_line; + +SkipCRLF: + if ((c = source.Read()) != -1) { + this.text_buffer.Append((char) c); + } + + if (this.prev_char == EOF) { + this.bump_line = true; + } + + old_bump_line = bump_line; + bump_line = false; + + if (skipCrLf) { + if (c == '\r') { + bump_line = true; + text_buffer.Length--; + goto SkipCRLF; + } else if (c == '\n') { + bump_line = true; + if (this.prev_char == '\r') { + old_bump_line = false; + } + + text_buffer.Length--; + goto SkipCRLF; + } + } + + this.line_pos ++; + if (old_bump_line) { + this.line_num++; + this.line_pos = 1; + } + + this.prev_char = (char) c; + return (char) c; + } + + /// <summary>Parse the RTF stream</summary> + public void Read() { + while (GetToken() != TokenClass.EOF) { + RouteToken(); + } + } + + /// <summary>Route a token</summary> + public void RouteToken() { + + if (CheckCM(TokenClass.Widget, Major.Destination)) { + DestinationDelegate d; + + d = destination_callbacks[minor]; + if (d != null) { + d(this); + } + } + + // Invoke class callback if there is one + ClassDelegate c; + + c = class_callbacks[rtf_class]; + if (c != null) { + c(this); + } + + } + + /// <summary>Skip to the end of the next group to start or current group we are in</summary> + public void SkipGroup() { + int level; + + level = 1; + + while (GetToken() != TokenClass.EOF) { + if (rtf_class == TokenClass.Group) { + if (this.major == Major.BeginGroup) { + level++; + } else if (this.major == Major.EndGroup) { + level--; + if (level < 1) { + break; + } + } + } + } + } + + /// <summary>Return the next token in the stream</summary> + public TokenClass GetToken() { + if (pushed_class != TokenClass.None) { + this.rtf_class = this.pushed_class; + this.major = this.pushed_major; + this.minor = this.pushed_minor; + this.param = this.pushed_param; + this.pushed_class = TokenClass.None; + return this.rtf_class; + } + + GetToken2(); + + if (this.rtf_class == TokenClass.Text) { + this.minor = (Minor)this.cur_charset[(int)this.major]; + if (encoding == null) { + encoding = Encoding.GetEncoding (encoding_code_page); + } + encoded_text = new String (encoding.GetChars (new byte [] { (byte) this.major })); + } + + if (this.cur_charset.Flags == CharsetFlags.None) { + return this.rtf_class; + } + + if (CheckCMM (TokenClass.Widget, Major.Unicode, Minor.UnicodeAnsiCodepage)) { + encoding_code_page = param; + + // fallback to the default one in case we have an invalid value + if (encoding_code_page < 0 || encoding_code_page > 65535) + encoding_code_page = DefaultEncodingCodePage; + } + + if (((this.cur_charset.Flags & CharsetFlags.Read) != 0) && CheckCM(TokenClass.Widget, Major.CharSet)) { + this.cur_charset.ReadMap(); + } else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && CheckCMM(TokenClass.Widget, Major.CharAttr, Minor.FontNum)) { + Font fp; + + fp = Font.GetFont(this.font_list, this.param); + + if (fp != null) { + if (fp.Name.StartsWith("Symbol")) { + this.cur_charset.ID = CharsetType.Symbol; + } else { + this.cur_charset.ID = CharsetType.General; + } + } else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && (this.rtf_class == TokenClass.Group)) { + switch(this.major) { + case Major.BeginGroup: { + this.charset_stack.Push(this.cur_charset); + break; + } + + case Major.EndGroup: { + this.cur_charset = (Charset)this.charset_stack.Pop(); + break; + } + } + } + } + + return this.rtf_class; + } + + private void GetToken2() { + char c; + int sign; + + this.rtf_class = TokenClass.Unknown; + this.param = NoParam; + + this.text_buffer.Length = 0; + + if (this.pushed_char != EOF) { + c = this.pushed_char; + this.text_buffer.Append(c); + this.pushed_char = EOF; + } else if ((c = GetChar()) == EOF) { + this.rtf_class = TokenClass.EOF; + return; + } + + if (c == '{') { + this.rtf_class = TokenClass.Group; + this.major = Major.BeginGroup; + return; + } + + if (c == '}') { + this.rtf_class = TokenClass.Group; + this.major = Major.EndGroup; + return; + } + + if (c != '\\') { + if (c != '\t') { + this.rtf_class = TokenClass.Text; + this.major = (Major)c; // FIXME - typing? + return; + } else { + this.rtf_class = TokenClass.Widget; + this.major = Major.SpecialChar; + this.minor = Minor.Tab; + return; + } + } + + if ((c = GetChar()) == EOF) { + // Not so good + return; + } + + if (!Char.IsLetter(c)) { + if (c == '\'') { + char c2; + + if ((c = GetChar()) == EOF) { + return; + } + + if ((c2 = GetChar()) == EOF) { + return; + } + + this.rtf_class = TokenClass.Text; + this.major = (Major)((Char)((Convert.ToByte(c.ToString(), 16) * 16 + Convert.ToByte(c2.ToString(), 16)))); + return; + } + + // Escaped char + if (c == ':' || c == '{' || c == '}' || c == '\\') { + this.rtf_class = TokenClass.Text; + this.major = (Major)c; + return; + } + + Lookup(this.text_buffer.ToString()); + return; + } + + while (Char.IsLetter(c)) { + if ((c = GetChar(false)) == EOF) { + break; + } + } + + if (c != EOF) { + this.text_buffer.Length--; + } + + Lookup(this.text_buffer.ToString()); + + if (c != EOF) { + this.text_buffer.Append(c); + } + + sign = 1; + if (c == '-') { + sign = -1; + c = GetChar(); + } + + if (c != EOF && Char.IsDigit(c) && minor != Minor.PngBlip) { + this.param = 0; + while (Char.IsDigit(c)) { + this.param = this.param * 10 + Convert.ToByte(c) - 48; + if ((c = GetChar()) == EOF) { + break; + } + } + this.param *= sign; + } + + if (c != EOF) { + if (c != ' ' && c != '\r' && c != '\n') { + this.pushed_char = c; + } + this.text_buffer.Length--; + } + } + + public void SetToken(TokenClass cl, Major maj, Minor min, int par, string text) { + this.rtf_class = cl; + this.major = maj; + this.minor = min; + this.param = par; + if (par == NoParam) { + this.text_buffer = new StringBuilder(text); + } else { + this.text_buffer = new StringBuilder(text + par.ToString()); + } + } + + public void UngetToken() { + if (this.pushed_class != TokenClass.None) { + throw new RTFException(this, "Cannot unget more than one token"); + } + + if (this.rtf_class == TokenClass.None) { + throw new RTFException(this, "No token to unget"); + } + + this.pushed_class = this.rtf_class; + this.pushed_major = this.major; + this.pushed_minor = this.minor; + this.pushed_param = this.param; + //this.pushed_text_buffer = new StringBuilder(this.text_buffer.ToString()); + } + + public TokenClass PeekToken() { + GetToken(); + UngetToken(); + return rtf_class; + } + + public void Lookup(string token) { + Object obj; + KeyStruct key; + + obj = key_table[token.Substring(1)]; + if (obj == null) { + rtf_class = TokenClass.Unknown; + major = (Major) -1; + minor = (Minor) -1; + return; + } + + key = (KeyStruct)obj; + this.rtf_class = TokenClass.Widget; + this.major = key.Major; + this.minor = key.Minor; + } + + public bool CheckCM(TokenClass rtf_class, Major major) { + if ((this.rtf_class == rtf_class) && (this.major == major)) { + return true; + } + + return false; + } + + public bool CheckCMM(TokenClass rtf_class, Major major, Minor minor) { + if ((this.rtf_class == rtf_class) && (this.major == major) && (this.minor == minor)) { + return true; + } + + return false; + } + + public bool CheckMM(Major major, Minor minor) { + if ((this.major == major) && (this.minor == minor)) { + return true; + } + + return false; + } + #endregion // Methods + + #region Default Delegates + + private void HandleOptDest (RTF rtf) + { + int group_levels = 1; + + while (true) { + GetToken (); + + // Here is where we should handle recognised optional + // destinations. + // + // Handle a picture group + // + if (rtf.CheckCMM (TokenClass.Widget, Major.Destination, Minor.Pict)) { + ReadPictGroup (rtf); + return; + } + + if (rtf.CheckCM (TokenClass.Group, Major.EndGroup)) { + if ((--group_levels) == 0) { + break; + } + } + + if (rtf.CheckCM (TokenClass.Group, Major.BeginGroup)) { + group_levels++; + } + } + } + + private void ReadFontTbl(RTF rtf) { + int old; + Font font; + + old = -1; + font = null; + + while (true) { + rtf.GetToken(); + + if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) { + break; + } + + if (old < 0) { + if (rtf.CheckCMM(TokenClass.Widget, Major.CharAttr, Minor.FontNum)) { + old = 1; + } else if (rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) { + old = 0; + } else { + throw new RTFException(rtf, "Cannot determine format"); + } + } + + if (old == 0) { + if (!rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) { + throw new RTFException(rtf, "missing \"{\""); + } + rtf.GetToken(); + } + + font = new Font(rtf); + + while ((rtf.rtf_class != TokenClass.EOF) && (!rtf.CheckCM(TokenClass.Text, (Major)';')) && (!rtf.CheckCM(TokenClass.Group, Major.EndGroup))) { + if (rtf.rtf_class == TokenClass.Widget) { + switch(rtf.major) { + case Major.FontFamily: { + font.Family = (int)rtf.minor; + break; + } + + case Major.CharAttr: { + switch(rtf.minor) { + case Minor.FontNum: { + font.Num = rtf.param; + break; + } + + default: { + #if RTF_DEBUG + Console.WriteLine("Got unhandled Widget.CharAttr.Minor: " + rtf.minor); + #endif + break; + } + } + break; + } + + case Major.FontAttr: { + switch (rtf.minor) { + case Minor.FontCharSet: { + font.Charset = (CharsetType)rtf.param; + break; + } + + case Minor.FontPitch: { + font.Pitch = rtf.param; + break; + } + + case Minor.FontCodePage: { + font.Codepage = rtf.param; + break; + } + + case Minor.FTypeNil: + case Minor.FTypeTrueType: { + font.Type = rtf.param; + break; + } + default: { + #if RTF_DEBUG + Console.WriteLine("Got unhandled Widget.FontAttr.Minor: " + rtf.minor); + #endif + break; + } + } + break; + } + + default: { + #if RTF_DEBUG + Console.WriteLine("ReadFontTbl: Unknown Widget token " + rtf.major); + #endif + break; + } + } + } else if (rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) { + rtf.SkipGroup(); + } else if (rtf.rtf_class == TokenClass.Text) { + StringBuilder sb; + + sb = new StringBuilder(); + + while ((rtf.rtf_class != TokenClass.EOF) && (!rtf.CheckCM(TokenClass.Text, (Major)';')) && (!rtf.CheckCM(TokenClass.Group, Major.EndGroup)) && (!rtf.CheckCM(TokenClass.Group, Major.BeginGroup))) { + sb.Append((char)rtf.major); + rtf.GetToken(); + } + + if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) { + rtf.UngetToken(); + } + + font.Name = sb.ToString(); + continue; +#if RTF_DEBUG + } else { + Console.WriteLine("ReadFontTbl: Unknown token " + rtf.text_buffer); +#endif + } + + rtf.GetToken(); + } + + if (old == 0) { + rtf.GetToken(); + + if (!rtf.CheckCM(TokenClass.Group, Major.EndGroup)) { + throw new RTFException(rtf, "Missing \"}\""); + } + } + } + + if (font == null) { + throw new RTFException(rtf, "No font created"); + } + + if (font.Num == -1) { + throw new RTFException(rtf, "Missing font number"); + } + + rtf.RouteToken(); + } + + private void ReadColorTbl(RTF rtf) { + Color color; + int num; + + num = 0; + + while (true) { + rtf.GetToken(); + + if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) { + break; + } + + color = new Color(rtf); + color.Num = num++; + + while (rtf.CheckCM(TokenClass.Widget, Major.ColorName)) { + switch (rtf.minor) { + case Minor.Red: { + color.Red = rtf.param; + break; + } + + case Minor.Green: { + color.Green = rtf.param; + break; + } + + case Minor.Blue: { + color.Blue = rtf.param; + break; + } + } + + rtf.GetToken(); + } + if (!rtf.CheckCM(TokenClass.Text, (Major)';')) { + throw new RTFException(rtf, "Malformed color entry"); + } + } + rtf.RouteToken(); + } + + private void ReadStyleSheet(RTF rtf) { + Style style; + StringBuilder sb; + + sb = new StringBuilder(); + + while (true) { + rtf.GetToken(); + + if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) { + break; + } + + style = new Style(rtf); + + if (!rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) { + throw new RTFException(rtf, "Missing \"{\""); + } + + while (true) { + rtf.GetToken(); + + if ((rtf.rtf_class == TokenClass.EOF) || rtf.CheckCM(TokenClass.Text, (Major)';')) { + break; + } + + if (rtf.rtf_class == TokenClass.Widget) { + if (rtf.CheckMM(Major.ParAttr, Minor.StyleNum)) { + style.Num = rtf.param; + style.Type = StyleType.Paragraph; + continue; + } + if (rtf.CheckMM(Major.CharAttr, Minor.CharStyleNum)) { + style.Num = rtf.param; + style.Type = StyleType.Character; + continue; + } + if (rtf.CheckMM(Major.StyleAttr, Minor.SectStyleNum)) { + style.Num = rtf.param; + style.Type = StyleType.Section; + continue; + } + if (rtf.CheckMM(Major.StyleAttr, Minor.BasedOn)) { + style.BasedOn = rtf.param; + continue; + } + if (rtf.CheckMM(Major.StyleAttr, Minor.Additive)) { + style.Additive = true; + continue; + } + if (rtf.CheckMM(Major.StyleAttr, Minor.Next)) { + style.NextPar = rtf.param; + continue; + } + + new StyleElement(style, rtf.rtf_class, rtf.major, rtf.minor, rtf.param, rtf.text_buffer.ToString()); + } else if (rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) { + // This passes over "{\*\keycode ... }, among other things + rtf.SkipGroup(); + } else if (rtf.rtf_class == TokenClass.Text) { + while (rtf.rtf_class == TokenClass.Text) { + if (rtf.major == (Major)';') { + rtf.UngetToken(); + break; + } + + sb.Append((char)rtf.major); + rtf.GetToken(); + } + + style.Name = sb.ToString(); +#if RTF_DEBUG + } else { + Console.WriteLine("ReadStyleSheet: Ignored token " + rtf.text_buffer); +#endif + } + } + rtf.GetToken(); + + if (!rtf.CheckCM(TokenClass.Group, Major.EndGroup)) { + throw new RTFException(rtf, "Missing EndGroup (\"}\""); + } + + // Sanity checks + if (style.Name == null) { + throw new RTFException(rtf, "Style must have name"); + } + + if (style.Num < 0) { + if (!sb.ToString().StartsWith("Normal") && !sb.ToString().StartsWith("Standard")) { + throw new RTFException(rtf, "Missing style number"); + } + + style.Num = Style.NormalStyleNum; + } + + if (style.NextPar == -1) { + style.NextPar = style.Num; + } + } + + rtf.RouteToken(); + } + + private void ReadInfoGroup(RTF rtf) { + rtf.SkipGroup(); + rtf.RouteToken(); + } + + private void ReadPictGroup(RTF rtf) + { + bool read_image_data = false; + + Picture picture = new Picture (); + while (true) { + rtf.GetToken (); + + if (rtf.CheckCM (TokenClass.Group, Major.EndGroup)) + break; + + switch (minor) { + case Minor.PngBlip: + picture.ImageType = minor; + read_image_data = true; + break; + case Minor.WinMetafile: + picture.ImageType = minor; + read_image_data = true; + continue; + case Minor.PicWid: + continue; + case Minor.PicHt: + continue; + case Minor.PicGoalWid: + picture.SetWidthFromTwips (param); + continue; + case Minor.PicGoalHt: + picture.SetHeightFromTwips (param); + continue; + } + + if (read_image_data && rtf.rtf_class == TokenClass.Text) { + + picture.Data.Seek (0, SeekOrigin.Begin); + + //char c = (char) rtf.major; + + uint digitValue1; + uint digitValue2; + char hexDigit1 = (char) rtf.major; + char hexDigit2; + + while (true) { + + while (hexDigit1 == '\n' || hexDigit1 == '\r') { + hexDigit1 = (char) source.Peek (); + if (hexDigit1 == '}') + break; + hexDigit1 = (char) source.Read (); + } + + hexDigit2 = (char) source.Peek (); + if (hexDigit2 == '}') + break; + hexDigit2 = (char) source.Read (); + while (hexDigit2 == '\n' || hexDigit2 == '\r') { + hexDigit2 = (char) source.Peek (); + if (hexDigit2 == '}') + break; + hexDigit2 = (char) source.Read (); + } + + if (Char.IsDigit (hexDigit1)) + digitValue1 = (uint) (hexDigit1 - '0'); + else if (Char.IsLower (hexDigit1)) + digitValue1 = (uint) (hexDigit1 - 'a' + 10); + else if (Char.IsUpper (hexDigit1)) + digitValue1 = (uint) (hexDigit1 - 'A' + 10); + else if (hexDigit1 == '\n' || hexDigit1 == '\r') + continue; + else + break; + + if (Char.IsDigit (hexDigit2)) + digitValue2 = (uint) (hexDigit2 - '0'); + else if (Char.IsLower (hexDigit2)) + digitValue2 = (uint) (hexDigit2 - 'a' + 10); + else if (Char.IsUpper (hexDigit2)) + digitValue2 = (uint) (hexDigit2 - 'A' + 10); + else if (hexDigit2 == '\n' || hexDigit2 == '\r') + continue; + else + break; + + picture.Data.WriteByte ((byte) checked (digitValue1 * 16 + digitValue2)); + + // We get the first hex digit at the end, since in the very first + // iteration we use rtf.major as the first hex digit + hexDigit1 = (char) source.Peek (); + if (hexDigit1 == '}') + break; + hexDigit1 = (char) source.Read (); + } + + + read_image_data = false; + break; + } + } + + if (picture.ImageType != Minor.Undefined && !read_image_data) { + this.picture = picture; + SetToken (TokenClass.Widget, Major.PictAttr, picture.ImageType, 0, String.Empty); + } + } + + private void ReadObjGroup(RTF rtf) { + rtf.SkipGroup(); + rtf.RouteToken(); + } + #endregion // Default Delegates + } +} diff --git a/source/ShiftUI/RTF/RTFException.cs b/source/ShiftUI/RTF/RTFException.cs new file mode 100644 index 0000000..adaa16c --- /dev/null +++ b/source/ShiftUI/RTF/RTFException.cs @@ -0,0 +1,87 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +using System; +using System.Text; + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + class RTFException : ApplicationException { + #region Local Variables + private int pos; + private int line; + private TokenClass token_class; + private Major major; + private Minor minor; + private int param; + private string text; + private string error_message; + #endregion // Local Variables + + #region Constructors + public RTFException(RTF rtf, string error_message) { + this.pos = rtf.LinePos; + this.line = rtf.LineNumber; + this.token_class = rtf.TokenClass; + this.major = rtf.Major; + this.minor = rtf.Minor; + this.param = rtf.Param; + this.text = rtf.Text; + this.error_message = error_message; + } + #endregion // Constructors + + #region Properties + public override string Message { + get { + StringBuilder sb; + + sb = new StringBuilder(); + sb.Append(error_message); + sb.Append("\n"); + + sb.Append("RTF Stream Info: Pos:" + pos + " Line:" + line); + sb.Append("\n"); + + sb.Append("TokenClass:" + token_class + ", "); + sb.Append("Major:" + String.Format("{0}", (int)major) + ", "); + sb.Append("Minor:" + String.Format("{0}", (int)minor) + ", "); + sb.Append("Param:" + String.Format("{0}", param) + ", "); + sb.Append("Text:" + text); + + return sb.ToString(); + } + } + #endregion // Properties + } +} diff --git a/source/ShiftUI/RTF/StandardCharCode.cs b/source/ShiftUI/RTF/StandardCharCode.cs new file mode 100644 index 0000000..bfa8ab1 --- /dev/null +++ b/source/ShiftUI/RTF/StandardCharCode.cs @@ -0,0 +1,392 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + enum StandardCharCode { + nothing = 0, + space = 1, + exclam = 2, + quotedbl = 3, + numbersign = 4, + dollar = 5, + percent = 6, + ampersand = 7, + quoteright = 8, + parenleft = 9, + parenright = 10, + asterisk = 11, + plus = 12, + comma = 13, + hyphen = 14, + period = 15, + slash = 16, + zero = 17, + one = 18, + two = 19, + three = 20, + four = 21, + five = 22, + six = 23, + seven = 24, + eight = 25, + nine = 26, + colon = 27, + semicolon = 28, + less = 29, + equal = 30, + greater = 31, + question = 32, + at = 33, + A = 34, + B = 35, + C = 36, + D = 37, + E = 38, + F = 39, + G = 40, + H = 41, + I = 42, + J = 43, + K = 44, + L = 45, + M = 46, + N = 47, + O = 48, + P = 49, + Q = 50, + R = 51, + S = 52, + T = 53, + U = 54, + V = 55, + W = 56, + X = 57, + Y = 58, + Z = 59, + bracketleft = 60, + backslash = 61, + bracketright = 62, + asciicircum = 63, + underscore = 64, + quoteleft = 65, + a = 66, + b = 67, + c = 68, + d = 69, + e = 70, + f = 71, + g = 72, + h = 73, + i = 74, + j = 75, + k = 76, + l = 77, + m = 78, + n = 79, + o = 80, + p = 81, + q = 82, + r = 83, + s = 84, + t = 85, + u = 86, + v = 87, + w = 88, + x = 89, + y = 90, + z = 91, + braceleft = 92, + bar = 93, + braceright = 94, + asciitilde = 95, + exclamdown = 96, + cent = 97, + sterling = 98, + fraction = 99, + yen = 100, + florin = 101, + section = 102, + currency = 103, + quotedblleft = 104, + guillemotleft = 105, + guilsinglleft = 106, + guilsinglright = 107, + fi = 108, + fl = 109, + endash = 110, + dagger = 111, + daggerdbl = 112, + periodcentered = 113, + paragraph = 114, + bullet = 115, + quotesinglbase = 116, + quotedblbase = 117, + quotedblright = 118, + guillemotright = 119, + ellipsis = 120, + perthousand = 121, + questiondown = 122, + grave = 123, + acute = 124, + circumflex = 125, + tilde = 126, + macron = 127, + breve = 128, + dotaccent = 129, + dieresis = 130, + ring = 131, + cedilla = 132, + hungarumlaut = 133, + ogonek = 134, + caron = 135, + emdash = 136, + AE = 137, + ordfeminine = 138, + Lslash = 139, + Oslash = 140, + OE = 141, + ordmasculine = 142, + ae = 143, + dotlessi = 144, + lslash = 145, + oslash = 146, + oe = 147, + germandbls = 148, + Aacute = 149, + Acircumflex = 150, + Adieresis = 151, + Agrave = 152, + Aring = 153, + Atilde = 154, + Ccedilla = 155, + Eacute = 156, + Ecircumflex = 157, + Edieresis = 158, + Egrave = 159, + Eth = 160, + Iacute = 161, + Icircumflex = 162, + Idieresis = 163, + Igrave = 164, + Ntilde = 165, + Oacute = 166, + Ocircumflex = 167, + Odieresis = 168, + Ograve = 169, + Otilde = 170, + Scaron = 171, + Thorn = 172, + Uacute = 173, + Ucircumflex = 174, + Udieresis = 175, + Ugrave = 176, + Yacute = 177, + Ydieresis = 178, + aacute = 179, + acircumflex = 180, + adieresis = 181, + agrave = 182, + aring = 183, + atilde = 184, + brokenbar = 185, + ccedilla = 186, + copyright = 187, + degree = 188, + divide = 189, + eacute = 190, + ecircumflex = 191, + edieresis = 192, + egrave = 193, + eth = 194, + iacute = 195, + icircumflex = 196, + idieresis = 197, + igrave = 198, + logicalnot = 199, + minus = 200, + multiply = 201, + ntilde = 202, + oacute = 203, + ocircumflex = 204, + odieresis = 205, + ograve = 206, + onehalf = 207, + onequarter = 208, + onesuperior = 209, + otilde = 210, + plusminus = 211, + registered = 212, + thorn = 213, + threequarters = 214, + threesuperior = 215, + trademark = 216, + twosuperior = 217, + uacute = 218, + ucircumflex = 219, + udieresis = 220, + ugrave = 221, + yacute = 222, + ydieresis = 223, + Alpha = 224, + Beta = 225, + Chi = 226, + Delta = 227, + Epsilon = 228, + Phi = 229, + Gamma = 230, + Eta = 231, + Iota = 232, + Kappa = 233, + Lambda = 234, + Mu = 235, + Nu = 236, + Omicron = 237, + Pi = 238, + Theta = 239, + Rho = 240, + Sigma = 241, + Tau = 242, + Upsilon = 243, + varUpsilon = 244, + Omega = 245, + Xi = 246, + Psi = 247, + Zeta = 248, + alpha = 249, + beta = 250, + chi = 251, + delta = 252, + epsilon = 253, + phi = 254, + varphi = 255, + gamma = 256, + eta = 257, + iota = 258, + kappa = 259, + lambda = 260, + mu = 261, + nu = 262, + omicron = 263, + pi = 264, + varpi = 265, + theta = 266, + vartheta = 267, + rho = 268, + sigma = 269, + varsigma = 270, + tau = 271, + upsilon = 272, + omega = 273, + xi = 274, + psi = 275, + zeta = 276, + nobrkspace = 277, + nobrkhyphen = 278, + lessequal = 279, + greaterequal = 280, + infinity = 281, + integral = 282, + notequal = 283, + radical = 284, + radicalex = 285, + approxequal = 286, + apple = 287, + partialdiff = 288, + opthyphen = 289, + formula = 290, + lozenge = 291, + universal = 292, + existential = 293, + suchthat = 294, + congruent = 295, + therefore = 296, + perpendicular = 297, + minute = 298, + club = 299, + diamond = 300, + heart = 301, + spade = 302, + arrowboth = 303, + arrowleft = 304, + arrowup = 305, + arrowright = 306, + arrowdown = 307, + second = 308, + proportional = 309, + equivalence = 310, + arrowvertex = 311, + arrowhorizex = 312, + carriagereturn = 313, + aleph = 314, + Ifraktur = 315, + Rfraktur = 316, + weierstrass = 317, + circlemultiply = 318, + circleplus = 319, + emptyset = 320, + intersection = 321, + union = 322, + propersuperset = 323, + reflexsuperset = 324, + notsubset = 325, + propersubset = 326, + reflexsubset = 327, + element = 328, + notelement = 329, + angle = 330, + gradient = 331, + product = 332, + logicaland = 333, + logicalor = 334, + arrowdblboth = 335, + arrowdblleft = 336, + arrowdblup = 337, + arrowdblright = 338, + arrowdbldown = 339, + angleleft = 340, + registersans = 341, + copyrightsans = 342, + trademarksans = 343, + angleright = 344, + mathplus = 345, + mathminus = 346, + mathasterisk = 347, + mathnumbersign = 348, + dotmath = 349, + mathequal = 350, + mathtilde = 351, + + MaxChar = 352 + } +} diff --git a/source/ShiftUI/RTF/StandardCharName.cs b/source/ShiftUI/RTF/StandardCharName.cs new file mode 100644 index 0000000..0ddcf4b --- /dev/null +++ b/source/ShiftUI/RTF/StandardCharName.cs @@ -0,0 +1,411 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + class StandardCharName { + public static string[] Names = { + "nothing", + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quoteright", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", + "bracketright", + "asciicircum", + "underscore", + "quoteleft", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", + "braceright", + "asciitilde", + "exclamdown", + "cent", + "sterling", + "fraction", + "yen", + "florin", + "section", + "currency", + "quotedblleft", + "guillemotleft", + "guilsinglleft", + "guilsinglright", + "fi", + "fl", + "endash", + "dagger", + "daggerdbl", + "periodcentered", + "paragraph", + "bullet", + "quotesinglbase", + "quotedblbase", + "quotedblright", + "guillemotright", + "ellipsis", + "perthousand", + "questiondown", + "grave", + "acute", + "circumflex", + "tilde", + "macron", + "breve", + "dotaccent", + "dieresis", + "ring", + "cedilla", + "hungarumlaut", + "ogonek", + "caron", + "emdash", + "AE", + "ordfeminine", + "Lslash", + "Oslash", + "OE", + "ordmasculine", + "ae", + "dotlessi", + "lslash", + "oslash", + "oe", + "germandbls", + "Aacute", + "Acircumflex", + "Adieresis", + "Agrave", + "Aring", + "Atilde", + "Ccedilla", + "Eacute", + "Ecircumflex", + "Edieresis", + "Egrave", + "Eth", + "Iacute", + "Icircumflex", + "Idieresis", + "Igrave", + "Ntilde", + "Oacute", + "Ocircumflex", + "Odieresis", + "Ograve", + "Otilde", + "Scaron", + "Thorn", + "Uacute", + "Ucircumflex", + "Udieresis", + "Ugrave", + "Yacute", + "Ydieresis", + "aacute", + "acircumflex", + "adieresis", + "agrave", + "aring", + "atilde", + "brokenbar", + "ccedilla", + "copyright", + "degree", + "divide", + "eacute", + "ecircumflex", + "edieresis", + "egrave", + "eth", + "iacute", + "icircumflex", + "idieresis", + "igrave", + "logicalnot", + "minus", + "multiply", + "ntilde", + "oacute", + "ocircumflex", + "odieresis", + "ograve", + "onehalf", + "onequarter", + "onesuperior", + "otilde", + "plusminus", + "registered", + "thorn", + "threequarters", + "threesuperior", + "trademark", + "twosuperior", + "uacute", + "ucircumflex", + "udieresis", + "ugrave", + "yacute", + "ydieresis", + "Alpha", + "Beta", + "Chi", + "Delta", + "Epsilon", + "Phi", + "Gamma", + "Eta", + "Iota", + "Kappa", + "Lambda", + "Mu", + "Nu", + "Omicron", + "Pi", + "Theta", + "Rho", + "Sigma", + "Tau", + "Upsilon", + "varUpsilon", + "Omega", + "Xi", + "Psi", + "Zeta", + "alpha", + "beta", + "chi", + "delta", + "epsilon", + "phi", + "varphi", + "gamma", + "eta", + "iota", + "kappa", + "lambda", + "mu", + "nu", + "omicron", + "pi", + "varpi", + "theta", + "vartheta", + "rho", + "sigma", + "varsigma", + "tau", + "upsilon", + "omega", + "xi", + "psi", + "zeta", + "nobrkspace", + "nobrkhyphen", + "lessequal", + "greaterequal", + "infinity", + "integral", + "notequal", + "radical", + "radicalex", + "approxequal", + "apple", + "partialdiff", + "opthyphen", + "formula", + "lozenge", + "universal", + "existential", + "suchthat", + "congruent", + "therefore", + "perpendicular", + "minute", + "club", + "diamond", + "heart", + "spade", + "arrowboth", + "arrowleft", + "arrowup", + "arrowright", + "arrowdown", + "second", + "proportional", + "equivalence", + "arrowvertex", + "arrowhorizex", + "carriagereturn", + "aleph", + "Ifraktur", + "Rfraktur", + "weierstrass", + "circlemultiply", + "circleplus", + "emptyset", + "intersection", + "union", + "propersuperset", + "reflexsuperset", + "notsubset", + "propersubset", + "reflexsubset", + "element", + "notelement", + "angle", + "gradient", + "product", + "logicaland", + "logicalor", + "arrowdblboth", + "arrowdblleft", + "arrowdblup", + "arrowdblright", + "arrowdbldown", + "angleleft", + "registersans", + "copyrightsans", + "trademarksans", + "angleright", + "mathplus", + "mathminus", + "mathasterisk", + "mathnumbersign", + "dotmath", + "mathequal", + "mathtilde" + }; + + /// <summary>Lookup name by ID</summary> + public static string Name(int index) { + if ((index < 0) || (index >= Names.Length)) { + return string.Empty; + } + + return Names[index]; + } + + /// <summary>Lookup ID by name (e.g. mathtilde)</summary> + public static int ID(string name) { + for (int i=0; i < Names.Length; i++) { + if (name.Equals(Names[i])) { + return i; + } + } + return 0; + } + } +} diff --git a/source/ShiftUI/RTF/Style.cs b/source/ShiftUI/RTF/Style.cs new file mode 100644 index 0000000..db1182d --- /dev/null +++ b/source/ShiftUI/RTF/Style.cs @@ -0,0 +1,211 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE +using System; + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + class Style { + #region Local Variables + public const int NoStyleNum = 222; + public const int NormalStyleNum = 0; + + private string name; + private StyleType type; + private bool additive; + private int num; + private int based_on; + private int next_par; + private bool expanding; + private StyleElement elements; + private Style next; + #endregion Local Variables + + #region Constructors + public Style(RTF rtf) { + num = -1; + type = StyleType.Paragraph; + based_on = NoStyleNum; + next_par = -1; + + lock (rtf) { + if (rtf.Styles == null) { + rtf.Styles = this; + } else { + Style s = rtf.Styles; + while (s.next != null) + s = s.next; + s.next = this; + } + } + } + #endregion // Constructors + + #region Properties + public string Name { + get { + return name; + } + + set { + name = value; + } + } + + public StyleType Type { + get { + return type; + } + + set { + type = value; + } + } + + public bool Additive { + get { + return additive; + } + + set { + additive = value; + } + } + + public int BasedOn { + get { + return based_on; + } + + set { + based_on = value; + } + } + + public StyleElement Elements { + get { + return elements; + } + + set { + elements = value; + } + } + + public bool Expanding { + get { + return expanding; + } + + set { + expanding = value; + } + } + + public int NextPar { + get { + return next_par; + } + + set { + next_par = value; + } + } + + public int Num { + get { + return num; + } + + set { + num = value; + } + } + #endregion // Properties + + #region Methods + public void Expand(RTF rtf) { + StyleElement se; + + if (num == -1) { + return; + } + + if (expanding) { + throw new Exception("Recursive style expansion"); + } + expanding = true; + + if (num != based_on) { + rtf.SetToken(TokenClass.Widget, Major.ParAttr, Minor.StyleNum, based_on, "\\s"); + rtf.RouteToken(); + } + + se = elements; + while (se != null) { + rtf.TokenClass = se.TokenClass; + rtf.Major = se.Major; + rtf.Minor = se.Minor; + rtf.Param = se.Param; + rtf.Text = se.Text; + rtf.RouteToken(); + } + + expanding = false; + } + + static public Style GetStyle(RTF rtf, int style_number) { + Style s; + + lock (rtf) { + s = GetStyle(rtf.Styles, style_number); + } + return s; + } + + static public Style GetStyle(Style start, int style_number) { + Style s; + + if (style_number == -1) { + return start; + } + + s = start; + + while ((s != null) && (s.num != style_number)) { + s = s.next; + } + return s; + } + #endregion // Methods + } +} diff --git a/source/ShiftUI/RTF/StyleElement.cs b/source/ShiftUI/RTF/StyleElement.cs new file mode 100644 index 0000000..7f80292 --- /dev/null +++ b/source/ShiftUI/RTF/StyleElement.cs @@ -0,0 +1,122 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + class StyleElement { + #region Local Variables + private TokenClass token_class; + private Major major; + private Minor minor; + private int param; + private string text; + private StyleElement next; + #endregion Local Variables + + #region Constructors + public StyleElement(Style s, TokenClass token_class, Major major, Minor minor, int param, string text) { + this.token_class = token_class; + this.major = major; + this.minor = minor; + this.param = param; + this.text = text; + + lock (s) { + if (s.Elements == null) { + s.Elements = this; + } else { + StyleElement se = s.Elements; + while (se.next != null) + se = se.next; + se.next = this; + } + } + } + #endregion // Constructors + + #region Properties + public TokenClass TokenClass { + get { + return token_class; + } + + set { + token_class = value; + } + } + + public Major Major { + get { + return major; + } + + set { + major = value; + } + } + + public Minor Minor { + get { + return minor; + } + + set { + minor = value; + } + } + + public int Param { + get { + return param; + } + + set { + param = value; + } + } + + public string Text { + get { + return text; + } + + set { + text = value; + } + } + #endregion // Properties + + #region Methods + #endregion // Methods + } +} diff --git a/source/ShiftUI/RTF/StyleType.cs b/source/ShiftUI/RTF/StyleType.cs new file mode 100644 index 0000000..76dd663 --- /dev/null +++ b/source/ShiftUI/RTF/StyleType.cs @@ -0,0 +1,41 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + enum StyleType { + Paragraph = 0, + Character = 1, + Section = 2 + } +} diff --git a/source/ShiftUI/RTF/TextMap.cs b/source/ShiftUI/RTF/TextMap.cs new file mode 100644 index 0000000..8c0a7b0 --- /dev/null +++ b/source/ShiftUI/RTF/TextMap.cs @@ -0,0 +1,440 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// This map is for convencience only, any app can create/use it's own +// StdCharCode -> <text> table + +using System.Collections; + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + class TextMap { + #region Local Variables + private string[] table; + #endregion // Local Variables + + #region Public Constructors + public TextMap() { + table = new string[(int)StandardCharCode.MaxChar]; + + for (int i = 0; i < (int)StandardCharCode.MaxChar; i++) { + table[i] = string.Empty; + } + } + #endregion // Public Constructors + + #region Public Instance Properties + internal string this[StandardCharCode c] { // FIXME - this should be public, if the whole namespace was public (ie standalone RTF parser) + get { + return table[(int)c]; + } + + set { + table[(int)c] = value; + } + } + + public string[] Table { + get { + return table; + } + } + #endregion // Public Instance Properties + + #region Public Static Methods + public static void SetupStandardTable(string[] table) + { + /* + table[(int)StandardCharCode.space] = " "; + table[(int)StandardCharCode.exclam] = "!"; + table[(int)StandardCharCode.quotedbl] = "\""; + table[(int)StandardCharCode.numbersign] = "#"; + table[(int)StandardCharCode.dollar] = "$"; + table[(int)StandardCharCode.percent] = "%"; + table[(int)StandardCharCode.ampersand] = "&"; + table[(int)StandardCharCode.quoteright] = "'"; + table[(int)StandardCharCode.parenleft] = "("; + table[(int)StandardCharCode.parenright] = ")"; + table[(int)StandardCharCode.asterisk] = "*"; + table[(int)StandardCharCode.plus] = "+"; + table[(int)StandardCharCode.comma] = ","; + table[(int)StandardCharCode.hyphen] = "-"; + table[(int)StandardCharCode.period] = "."; + table[(int)StandardCharCode.slash] = "/"; + table[(int)StandardCharCode.zero] = "0"; + table[(int)StandardCharCode.one] = "1"; + table[(int)StandardCharCode.two] = "2"; + table[(int)StandardCharCode.three] = "3"; + table[(int)StandardCharCode.four] = "4"; + table[(int)StandardCharCode.five] = "5"; + table[(int)StandardCharCode.six] = "6"; + table[(int)StandardCharCode.seven] = "7"; + table[(int)StandardCharCode.eight] = "8"; + table[(int)StandardCharCode.nine] = "9"; + table[(int)StandardCharCode.colon] = ":"; + table[(int)StandardCharCode.semicolon] = ";"; + table[(int)StandardCharCode.less] = "<"; + table[(int)StandardCharCode.equal] = "="; + table[(int)StandardCharCode.greater] = ">"; + table[(int)StandardCharCode.question] = "?"; + table[(int)StandardCharCode.at] = "@"; + table[(int)StandardCharCode.A] = "A"; + table[(int)StandardCharCode.B] = "B"; + table[(int)StandardCharCode.C] = "C"; + table[(int)StandardCharCode.D] = "D"; + table[(int)StandardCharCode.E] = "E"; + table[(int)StandardCharCode.F] = "F"; + table[(int)StandardCharCode.G] = "G"; + table[(int)StandardCharCode.H] = "H"; + table[(int)StandardCharCode.I] = "I"; + table[(int)StandardCharCode.J] = "J"; + table[(int)StandardCharCode.K] = "K"; + table[(int)StandardCharCode.L] = "L"; + table[(int)StandardCharCode.M] = "M"; + table[(int)StandardCharCode.N] = "N"; + table[(int)StandardCharCode.O] = "O"; + table[(int)StandardCharCode.P] = "P"; + table[(int)StandardCharCode.Q] = "Q"; + table[(int)StandardCharCode.R] = "R"; + table[(int)StandardCharCode.S] = "S"; + table[(int)StandardCharCode.T] = "T"; + table[(int)StandardCharCode.U] = "U"; + table[(int)StandardCharCode.V] = "V"; + table[(int)StandardCharCode.W] = "W"; + table[(int)StandardCharCode.X] = "X"; + table[(int)StandardCharCode.Y] = "Y"; + table[(int)StandardCharCode.Z] = "Z"; + table[(int)StandardCharCode.bracketleft] = "["; + table[(int)StandardCharCode.backslash] = "\\"; + table[(int)StandardCharCode.bracketright] = "]"; + table[(int)StandardCharCode.asciicircum] = "^"; + table[(int)StandardCharCode.underscore] = "_"; + table[(int)StandardCharCode.quoteleft] = "`"; + table[(int)StandardCharCode.a] = "a"; + table[(int)StandardCharCode.b] = "b"; + table[(int)StandardCharCode.c] = "c"; + table[(int)StandardCharCode.d] = "d"; + table[(int)StandardCharCode.e] = "e"; + table[(int)StandardCharCode.f] = "f"; + table[(int)StandardCharCode.g] = "g"; + table[(int)StandardCharCode.h] = "h"; + table[(int)StandardCharCode.i] = "i"; + table[(int)StandardCharCode.j] = "j"; + table[(int)StandardCharCode.k] = "k"; + table[(int)StandardCharCode.l] = "l"; + table[(int)StandardCharCode.m] = "m"; + table[(int)StandardCharCode.n] = "n"; + table[(int)StandardCharCode.o] = "o"; + table[(int)StandardCharCode.p] = "p"; + table[(int)StandardCharCode.q] = "q"; + table[(int)StandardCharCode.r] = "r"; + table[(int)StandardCharCode.s] = "s"; + table[(int)StandardCharCode.t] = "t"; + table[(int)StandardCharCode.u] = "u"; + table[(int)StandardCharCode.v] = "v"; + table[(int)StandardCharCode.w] = "w"; + table[(int)StandardCharCode.x] = "x"; + table[(int)StandardCharCode.y] = "y"; + table[(int)StandardCharCode.z] = "z"; + table[(int)StandardCharCode.braceleft] = "{"; + table[(int)StandardCharCode.bar] = "|"; + table[(int)StandardCharCode.braceright] = "}"; + table[(int)StandardCharCode.asciitilde] = "~"; + table[(int)StandardCharCode.AE] = "AE"; + table[(int)StandardCharCode.OE] = "OE"; + table[(int)StandardCharCode.acute] = "'"; + table[(int)StandardCharCode.ae] = "ae"; + table[(int)StandardCharCode.angleleft] = "<"; + table[(int)StandardCharCode.angleright] = ">"; + table[(int)StandardCharCode.arrowboth] = "<->"; + table[(int)StandardCharCode.arrowdblboth] = "<=>"; + table[(int)StandardCharCode.arrowdblleft] = "<="; + table[(int)StandardCharCode.arrowdblright] = "=>"; + table[(int)StandardCharCode.arrowleft] = "<-"; + table[(int)StandardCharCode.arrowright] = "->"; + table[(int)StandardCharCode.bullet] = "o"; + table[(int)StandardCharCode.cent] = "cent"; + table[(int)StandardCharCode.circumflex] = "^"; + table[(int)StandardCharCode.copyright] = "(c)"; + table[(int)StandardCharCode.copyrightsans] = "(c)"; + table[(int)StandardCharCode.degree] = "deg."; + table[(int)StandardCharCode.divide] = "/"; + table[(int)StandardCharCode.dotlessi] = "i"; + table[(int)StandardCharCode.ellipsis] = "..."; + table[(int)StandardCharCode.emdash] = "--"; + table[(int)StandardCharCode.endash] = "-"; + table[(int)StandardCharCode.fi] = "fi"; + table[(int)StandardCharCode.fl] = "fl"; + table[(int)StandardCharCode.fraction] = "/"; + table[(int)StandardCharCode.germandbls] = "ss"; + table[(int)StandardCharCode.grave] = "`"; + table[(int)StandardCharCode.greaterequal] = ">="; + table[(int)StandardCharCode.guillemotleft] = "<<"; + table[(int)StandardCharCode.guillemotright] = ">>"; + table[(int)StandardCharCode.guilsinglleft] = "<"; + table[(int)StandardCharCode.guilsinglright] = ">"; + table[(int)StandardCharCode.lessequal] = "<="; + table[(int)StandardCharCode.logicalnot] = "~"; + table[(int)StandardCharCode.mathasterisk] = "*"; + table[(int)StandardCharCode.mathequal] = "="; + table[(int)StandardCharCode.mathminus] = "-"; + table[(int)StandardCharCode.mathnumbersign] = "#"; + table[(int)StandardCharCode.mathplus] = "+"; + table[(int)StandardCharCode.mathtilde] = "~"; + table[(int)StandardCharCode.minus] = "-"; + table[(int)StandardCharCode.mu] = "u"; + table[(int)StandardCharCode.multiply] = "x"; + table[(int)StandardCharCode.nobrkhyphen] = "-"; + table[(int)StandardCharCode.nobrkspace] = ""; + table[(int)StandardCharCode.notequal] = "!="; + table[(int)StandardCharCode.oe] = "oe"; + table[(int)StandardCharCode.onehalf] = "1/2"; + table[(int)StandardCharCode.onequarter] = "1/4"; + table[(int)StandardCharCode.periodcentered] = "."; + table[(int)StandardCharCode.plusminus] = "+/-"; + table[(int)StandardCharCode.quotedblbase] = ",,"; + table[(int)StandardCharCode.quotedblleft] = "\""; + table[(int)StandardCharCode.quotedblright] = "\""; + table[(int)StandardCharCode.quotesinglbase] = ","; + table[(int)StandardCharCode.registered] = "reg."; + table[(int)StandardCharCode.registersans] = "reg."; + table[(int)StandardCharCode.threequarters] = "3/4"; + table[(int)StandardCharCode.tilde] = "~"; + table[(int)StandardCharCode.trademark] = "(TM)"; + table[(int)StandardCharCode.trademarksans] = "(TM)"; + + table[(int)StandardCharCode.aacute] = "\xE0"; + table[(int)StandardCharCode.questiondown] = "\xBF"; + + table[(int)StandardCharCode.udieresis] = "\xFC"; + table[(int)StandardCharCode.Udieresis] = "\xDC"; + table[(int)StandardCharCode.odieresis] = "\xF6"; + table[(int)StandardCharCode.Odieresis] = "\xD6"; + */ + + table [(int) StandardCharCode.formula] = "\x6"; + table [(int) StandardCharCode.nobrkhyphen] = "\x1e"; + table [(int) StandardCharCode.opthyphen] = "\x1f"; + table [(int) StandardCharCode.space] = " "; + table [(int) StandardCharCode.exclam] = "!"; + table [(int) StandardCharCode.quotedbl] = "\""; + table [(int) StandardCharCode.numbersign] = "#"; + table [(int) StandardCharCode.dollar] = "$"; + table [(int) StandardCharCode.percent] = "%"; + table [(int) StandardCharCode.ampersand] = "&"; + table [(int) StandardCharCode.parenleft] = "("; + table [(int) StandardCharCode.parenright] = ")"; + table [(int) StandardCharCode.asterisk] = "*"; + table [(int) StandardCharCode.plus] = "+"; + table [(int) StandardCharCode.comma] = ","; + table [(int) StandardCharCode.hyphen] = "-"; + table [(int) StandardCharCode.period] = "."; + table [(int) StandardCharCode.slash] = "/"; + table [(int) StandardCharCode.zero] = "0"; + table [(int) StandardCharCode.one] = "1"; + table [(int) StandardCharCode.two] = "2"; + table [(int) StandardCharCode.three] = "3"; + table [(int) StandardCharCode.four] = "4"; + table [(int) StandardCharCode.five] = "5"; + table [(int) StandardCharCode.six] = "6"; + table [(int) StandardCharCode.seven] = "7"; + table [(int) StandardCharCode.eight] = "8"; + table [(int) StandardCharCode.nine] = "9"; + table [(int) StandardCharCode.colon] = ":"; + table [(int) StandardCharCode.semicolon] = ";"; + table [(int) StandardCharCode.less] = "<"; + table [(int) StandardCharCode.equal] = "="; + table [(int) StandardCharCode.greater] = ">"; + table [(int) StandardCharCode.question] = "?"; + table [(int) StandardCharCode.at] = "@"; + table [(int) StandardCharCode.A] = "A"; + table [(int) StandardCharCode.B] = "B"; + table [(int) StandardCharCode.C] = "C"; + table [(int) StandardCharCode.D] = "D"; + table [(int) StandardCharCode.E] = "E"; + table [(int) StandardCharCode.F] = "F"; + table [(int) StandardCharCode.G] = "G"; + table [(int) StandardCharCode.H] = "H"; + table [(int) StandardCharCode.I] = "I"; + table [(int) StandardCharCode.J] = "J"; + table [(int) StandardCharCode.K] = "K"; + table [(int) StandardCharCode.L] = "L"; + table [(int) StandardCharCode.M] = "M"; + table [(int) StandardCharCode.N] = "N"; + table [(int) StandardCharCode.O] = "O"; + table [(int) StandardCharCode.P] = "P"; + table [(int) StandardCharCode.Q] = "Q"; + table [(int) StandardCharCode.R] = "R"; + table [(int) StandardCharCode.S] = "S"; + table [(int) StandardCharCode.T] = "T"; + table [(int) StandardCharCode.U] = "U"; + table [(int) StandardCharCode.V] = "V"; + table [(int) StandardCharCode.W] = "W"; + table [(int) StandardCharCode.X] = "X"; + table [(int) StandardCharCode.Y] = "Y"; + table [(int) StandardCharCode.Z] = "Z"; + table [(int) StandardCharCode.bracketleft] = "["; + table [(int) StandardCharCode.backslash] = "\\"; + table [(int) StandardCharCode.bracketright] = "]"; + table [(int) StandardCharCode.asciicircum] = "^"; + table [(int) StandardCharCode.underscore] = "_"; + table [(int) StandardCharCode.quoteleft] = "`"; + table [(int) StandardCharCode.a] = "a"; + table [(int) StandardCharCode.b] = "b"; + table [(int) StandardCharCode.c] = "c"; + table [(int) StandardCharCode.d] = "d"; + table [(int) StandardCharCode.e] = "e"; + table [(int) StandardCharCode.f] = "f"; + table [(int) StandardCharCode.g] = "g"; + table [(int) StandardCharCode.h] = "h"; + table [(int) StandardCharCode.i] = "i"; + table [(int) StandardCharCode.j] = "j"; + table [(int) StandardCharCode.k] = "k"; + table [(int) StandardCharCode.l] = "l"; + table [(int) StandardCharCode.m] = "m"; + table [(int) StandardCharCode.n] = "n"; + table [(int) StandardCharCode.o] = "o"; + table [(int) StandardCharCode.p] = "p"; + table [(int) StandardCharCode.q] = "q"; + table [(int) StandardCharCode.r] = "r"; + table [(int) StandardCharCode.s] = "s"; + table [(int) StandardCharCode.t] = "t"; + table [(int) StandardCharCode.u] = "u"; + table [(int) StandardCharCode.v] = "v"; + table [(int) StandardCharCode.w] = "w"; + table [(int) StandardCharCode.x] = "x"; + table [(int) StandardCharCode.y] = "y"; + table [(int) StandardCharCode.z] = "z"; + table [(int) StandardCharCode.braceleft] = "{"; + table [(int) StandardCharCode.bar] = "|"; + table [(int) StandardCharCode.braceright] = "}"; + table [(int) StandardCharCode.asciitilde] = "~"; + table [(int) StandardCharCode.nobrkspace] = "\xa0"; + table [(int) StandardCharCode.exclamdown] = "\xa1"; + table [(int) StandardCharCode.cent] = "\xa2"; + table [(int) StandardCharCode.sterling] = "\xa3"; + table [(int) StandardCharCode.currency] = "\xa4"; + table [(int) StandardCharCode.yen] = "\xa5"; + table [(int) StandardCharCode.brokenbar] = "\xa6"; + table [(int) StandardCharCode.section] = "\xa7"; + table [(int) StandardCharCode.dieresis] = "\xa8"; + table [(int) StandardCharCode.copyright] = "\xa9"; + table [(int) StandardCharCode.ordfeminine] = "\xaa"; + table [(int) StandardCharCode.guillemotleft] = "\xab"; + table [(int) StandardCharCode.logicalnot] = "\xac"; + table [(int) StandardCharCode.opthyphen] = "\xad"; + table [(int) StandardCharCode.registered] = "\xae"; + table [(int) StandardCharCode.macron] = "\xaf"; + table [(int) StandardCharCode.degree] = "\xb0"; + table [(int) StandardCharCode.plusminus] = "\xb1"; + table [(int) StandardCharCode.twosuperior] = "\xb2"; + table [(int) StandardCharCode.threesuperior] = "\xb3"; + table [(int) StandardCharCode.acute] = "\xb4"; + table [(int) StandardCharCode.mu] = "\xb5"; + table [(int) StandardCharCode.paragraph] = "\xb6"; + table [(int) StandardCharCode.periodcentered] = "\xb7"; + table [(int) StandardCharCode.cedilla] = "\xb8"; + table [(int) StandardCharCode.onesuperior] = "\xb9"; + table [(int) StandardCharCode.ordmasculine] = "\xba"; + table [(int) StandardCharCode.guillemotright] = "\xbb"; + table [(int) StandardCharCode.onequarter] = "\xbc"; + table [(int) StandardCharCode.onehalf] = "\xbd"; + table [(int) StandardCharCode.threequarters] = "\xbe"; + table [(int) StandardCharCode.questiondown] = "\xbf"; + table [(int) StandardCharCode.Agrave] = "\xc0"; + table [(int) StandardCharCode.Aacute] = "\xc1"; + table [(int) StandardCharCode.Acircumflex] = "\xc2"; + table [(int) StandardCharCode.Atilde] = "\xc3"; + table [(int) StandardCharCode.Adieresis] = "\xc4"; + table [(int) StandardCharCode.Aring] = "\xc5"; + table [(int) StandardCharCode.AE] = "\xc6"; + table [(int) StandardCharCode.Ccedilla] = "\xc7"; + table [(int) StandardCharCode.Egrave] = "\xc8"; + table [(int) StandardCharCode.Eacute] = "\xc9"; + table [(int) StandardCharCode.Ecircumflex] = "\xca"; + table [(int) StandardCharCode.Edieresis] = "\xcb"; + table [(int) StandardCharCode.Igrave] = "\xcc"; + table [(int) StandardCharCode.Iacute] = "\xcd"; + table [(int) StandardCharCode.Icircumflex] = "\xce"; + table [(int) StandardCharCode.Idieresis] = "\xcf"; + table [(int) StandardCharCode.Eth] = "\xd0"; + table [(int) StandardCharCode.Ntilde] = "\xd1"; + table [(int) StandardCharCode.Ograve] = "\xd2"; + table [(int) StandardCharCode.Oacute] = "\xd3"; + table [(int) StandardCharCode.Ocircumflex] = "\xd4"; + table [(int) StandardCharCode.Otilde] = "\xd5"; + table [(int) StandardCharCode.Odieresis] = "\xd6"; + table [(int) StandardCharCode.multiply] = "\xd7"; + table [(int) StandardCharCode.Oslash] = "\xd8"; + table [(int) StandardCharCode.Ugrave] = "\xd9"; + table [(int) StandardCharCode.Uacute] = "\xda"; + table [(int) StandardCharCode.Ucircumflex] = "\xdb"; + table [(int) StandardCharCode.Udieresis] = "\xdc"; + table [(int) StandardCharCode.Yacute] = "\xdd"; + table [(int) StandardCharCode.Thorn] = "\xde"; + table [(int) StandardCharCode.germandbls] = "\xdf"; + table [(int) StandardCharCode.agrave] = "\xe0"; + table [(int) StandardCharCode.aacute] = "\xe1"; + table [(int) StandardCharCode.acircumflex] = "\xe2"; + table [(int) StandardCharCode.atilde] = "\xe3"; + table [(int) StandardCharCode.adieresis] = "\xe4"; + table [(int) StandardCharCode.aring] = "\xe5"; + table [(int) StandardCharCode.ae] = "\xe6"; + table [(int) StandardCharCode.ccedilla] = "\xe7"; + table [(int) StandardCharCode.egrave] = "\xe8"; + table [(int) StandardCharCode.eacute] = "\xe9"; + table [(int) StandardCharCode.ecircumflex] = "\xea"; + table [(int) StandardCharCode.edieresis] = "\xeb"; + table [(int) StandardCharCode.igrave] = "\xec"; + table [(int) StandardCharCode.iacute] = "\xed"; + table [(int) StandardCharCode.icircumflex] = "\xee"; + table [(int) StandardCharCode.idieresis] = "\xef"; + table [(int) StandardCharCode.eth] = "\xf0"; + table [(int) StandardCharCode.ntilde] = "\xf1"; + table [(int) StandardCharCode.ograve] = "\xf2"; + table [(int) StandardCharCode.oacute] = "\xf3"; + table [(int) StandardCharCode.ocircumflex] = "\xf4"; + table [(int) StandardCharCode.otilde] = "\xf5"; + table [(int) StandardCharCode.odieresis] = "\xf6"; + table [(int) StandardCharCode.divide] = "\xf7"; + table [(int) StandardCharCode.oslash] = "\xf8"; + table [(int) StandardCharCode.ugrave] = "\xf9"; + table [(int) StandardCharCode.uacute] = "\xfa"; + table [(int) StandardCharCode.ucircumflex] = "\xfb"; + table [(int) StandardCharCode.udieresis] = "\xfc"; + table [(int) StandardCharCode.yacute] = "\xfd"; + table [(int) StandardCharCode.thorn] = "\xfe"; + table [(int) StandardCharCode.ydieresis] = "\xff"; + + } + #endregion // Public Static Methods + } +} diff --git a/source/ShiftUI/RTF/TokenClass.cs b/source/ShiftUI/RTF/TokenClass.cs new file mode 100644 index 0000000..2a1014d --- /dev/null +++ b/source/ShiftUI/RTF/TokenClass.cs @@ -0,0 +1,45 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2005 Novell, Inc. (http://www.novell.com) +// +// Authors: +// Peter Bartok ([email protected]) +// +// + +// COMPLETE + +namespace ShiftUI.RTF { + +#if RTF_LIB + public +#else + internal +#endif + enum TokenClass { + None = -1, + Unknown = 0, + Group = 1, + Text = 2, + Widget = 3, + EOF = 4, + MaxClass = 5 + } +} diff --git a/source/ShiftUI/RTF/rtf.csproj b/source/ShiftUI/RTF/rtf.csproj new file mode 100644 index 0000000..4cb3e58 --- /dev/null +++ b/source/ShiftUI/RTF/rtf.csproj @@ -0,0 +1,200 @@ +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.10.3077" + SchemaVersion = "2.0" + ProjectGuid = "{12D60959-776E-41E9-82BE-AA5DF4BB7CAE}" + > + <Build> + <Settings + ApplicationIcon = "" + AssemblyKeyContainerName = "" + AssemblyName = "rtf" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "Exe" + PreBuildEvent = "" + PostBuildEvent = "" + RootNamespace = "rtf" + RunPostBuildEvent = "OnBuildSuccess" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = "bin\Debug\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "1" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = "bin\Release\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "1" + /> + </Settings> + <References> + <Reference + Name = //"System.Drawing" + AssemblyName = //"System.Drawing" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll" + /> + <Reference + Name = "System" + AssemblyName = "System" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" + /> + <Reference + Name = "ShiftUI" + AssemblyName = "ShiftUI" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\ShiftUI.dll" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "Charcode.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Charset.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "CharsetFlags.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "CharsetType.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ClassDelegate.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Color.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "DestinationDelegate.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Font.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "KeysInit.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "KeyStruct.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Major.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Minor.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "RTF.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "RTFException.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "StandardCharCode.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "StandardCharName.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Style.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "StyleElement.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "StyleType.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "test.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TextMap.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TokenClass.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + diff --git a/source/ShiftUI/RTF/test.cs b/source/ShiftUI/RTF/test.cs new file mode 100644 index 0000000..b8c0f3c --- /dev/null +++ b/source/ShiftUI/RTF/test.cs @@ -0,0 +1,285 @@ +using System; +using System.Drawing; +using System.Drawing.Imaging; +using System.Drawing.Text; +using ShiftUI; +using System.Text; +using System.Threading; +using ShiftUI.RTF; +using System.IO; + +namespace TextTestClass { + public class Test { + static Test test; + int skip_width; + int skip_count; + private string rtf_string = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 testing 123testiong\\par\r\n}"; + private string rtf_string2 = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}{\\f1\\fmodern\\fprq1\\fcharset0 Courier;}{\\f2\\fswiss\\fprq2\\fcharset0 Arial;}}\r\n" + + "{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green0\\blue0;}\r\n" + + "{\\*\\generator Msftedit 5.41.15.1507;}\\viewkind4\\uc1\\pard\\f0\\fs20 I am in Arial 10pt\\par\r\n" + + "\\fs24 I am in Arial 12pt\\par\r\n" + + "\\f1 I am in Courier 12pt\\par\r\n" + + "\\cf1 I am in Courier 12pt Red\\par\r\n" + + "\\cf2\\f2\\fs20 I am in Arial 10pt\\par\r\n" + + "\\b I am in Arial 10pt Italic\\cf0\\b0\\f0\\par\r\n" + + "}"; + private string rtf_string3 = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}{" + + "\\f1\\fmodern\\fprq1\\fcharset0 Courier;}{\\f2\\fswiss\\fprq2\\fcharset0 Arial;}{\\f3\\fni" + + "l\\fcharset0 Impact;}{\\f4\\fnil\\fcharset0 Arial Unicode MS;}{\\f5\\fnil\\fcharset136 Arial Unicode MS;}{\\f6\\fnil\\fcharset0 MS" + + " Shell Dlg;}}" + + "{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green0\\blue0;}" + + "{\\*\\generator Msftedit 5.41.15.1507;}\\viewkind4\\uc1\\pard\\f0\\fs20 I am in Arial 1" + + "0pt\\par" + + "\\fs24 I am in Arial 12pt\\par" + + "\\f1 I am in Courier 12pt\\par" + + "\\cf1 I am in Courier 12pt Red\\par" + + "\\cf2\\f2\\fs20 I am in Arial 10pt\\par" + + "\\b I am in Arial 10pt Bold\\par" + + "\\i I am in Arial 10pt Bold Italic\\par" + + "\\ul I am in Arial 10pt Bold Italic Underline\\par" + + "\\ulnone\\b0\\i0\\strike I am in Arial 10pt Strikethrough\\par" + + "\\cf0\\strike0\\f3\\fs23 Some cyrilic character: \\u1034?\\par" + + "And 5 CJK characters: \\f4\\fs21\\u23854?\\u23854?\\u23854?\\u23854?\\u23854?\\f5\\fs17\\par" + + "Some special chars:\\par" + + "\\tab Tilde: ~\\par" + + "\\tab Questionmark:?\\par" + + "\\tab Yen: \\f5\\u165?\\f6\\fs17\\par" + + "\\tab Umlaut: \\'e4\\par" + + "\\f0\\fs20\\par" + + "}"; + + TextMap text; + + public Test() { + MemoryStream stream; + RTF rtf; + byte[] buffer; + + text = new TextMap(); + TextMap.SetupStandardTable(text.Table); + + buffer = new byte[rtf_string.Length]; + for (int i = 0; i < buffer.Length; i++) { + buffer[i] = (byte)rtf_string[i]; + } + stream = new MemoryStream(buffer); + rtf = new RTF(stream); + + skip_width = 0; + skip_count = 0; + + rtf.ClassCallback[TokenClass.Text] = new ClassDelegate(HandleText); + rtf.ClassCallback[TokenClass.Widget] = new ClassDelegate(HandleControl); + + rtf.Read(); + + stream.Close(); + } + + void HandleControl(RTF rtf) { + switch(rtf.Major) { + case Major.Unicode: { + switch(rtf.Minor) { + case Minor.UnicodeCharBytes: { + skip_width = rtf.Param; + break; + } + + case Minor.UnicodeChar: { + Console.Write("[Unicode {0:X4}]", rtf.Param); + skip_count += skip_width; + break; + } + } + break; + } + + case Major.Destination: { + Console.Write("[Got Destination control {0}]", rtf.Minor); + rtf.SkipGroup(); + break; + } + + case Major.CharAttr: { + switch(rtf.Minor) { + case Minor.ForeColor: { + ShiftUI.RTF.Color color; + + color = ShiftUI.RTF.Color.GetColor(rtf, rtf.Param); + if (color != null) { + if (color.Red == -1 && color.Green == -1 && color.Blue == -1) { + Console.Write("[Default Color]"); + } else { + Console.Write("[Color {0} [{1:X2}{2:X2}{3:X}]]", rtf.Param, color.Red, color.Green, color.Blue); + } + } + break; + } + + case Minor.FontSize: { + Console.Write("[Fontsize {0}]", rtf.Param); + break; + } + + case Minor.FontNum: { + ShiftUI.RTF.Font font; + + font = ShiftUI.RTF.Font.GetFont(rtf, rtf.Param); + if (font != null) { + Console.Write("[Font {0} [{1}]]", rtf.Param, font.Name); + } + break; + } + + case Minor.Plain: { + Console.Write("[Normal]"); + break; + } + + case Minor.Bold: { + if (rtf.Param == RTF.NoParam) { + Console.Write("[Bold]"); + } else { + Console.Write("[NoBold]"); + } + break; + } + + case Minor.Italic: { + if (rtf.Param == RTF.NoParam) { + Console.Write("[Italic]"); + } else { + Console.Write("[NoItalic]"); + } + break; + } + + case Minor.StrikeThru: { + if (rtf.Param == RTF.NoParam) { + Console.Write("[StrikeThru]"); + } else { + Console.Write("[NoStrikeThru]"); + } + break; + } + + case Minor.Underline: { + if (rtf.Param == RTF.NoParam) { + Console.Write("[Underline]"); + } else { + Console.Write("[NoUnderline]"); + } + break; + } + + case Minor.NoUnderline: { + Console.Write("[NoUnderline]"); + break; + } + } + break; + } + + case Major.SpecialChar: { + Console.Write("[Got SpecialChar control {0}]", rtf.Minor); + SpecialChar(rtf); + break; + } + } + } + + void SpecialChar(RTF rtf) { + switch(rtf.Minor) { + case Minor.Page: + case Minor.Sect: + case Minor.Row: + case Minor.Line: + case Minor.Par: { + Console.Write("\n"); + break; + } + + case Minor.Cell: { + Console.Write(" "); + break; + } + + case Minor.NoBrkSpace: { + Console.Write(" "); + break; + } + + case Minor.Tab: { + Console.Write("\t"); + break; + } + + case Minor.NoBrkHyphen: { + Console.Write("-"); + break; + } + + case Minor.Bullet: { + Console.Write("*"); + break; + } + + case Minor.EmDash: { + Console.Write(""); + break; + } + + case Minor.EnDash: { + Console.Write(""); + break; + } + + case Minor.LQuote: { + Console.Write(""); + break; + } + + case Minor.RQuote: { + Console.Write(""); + break; + } + + case Minor.LDblQuote: { + Console.Write(""); + break; + } + + case Minor.RDblQuote: { + Console.Write(""); + break; + } + + default: { + rtf.SkipGroup(); + break; + } + } + } + + + void HandleText(RTF rtf) { + if (skip_count > 0) { + skip_count--; + return; + } + if ((StandardCharCode)rtf.Minor != StandardCharCode.nothing) { + Console.Write("{0}", text[(StandardCharCode)rtf.Minor]); + } else { + if ((int)rtf.Major > 31 && (int)rtf.Major < 128) { + Console.Write("{0}", (char)rtf.Major); + } else { + Console.Write("[Literal:0x{0:X2}]", (int)rtf.Major); + } + } + } + + public static void Main() { + test = new Test(); + } + } +} |
