NanoXLSX.Formatting 3.0.0
Loading...
Searching...
No Matches
PhoneticRun.cs
1/*
2 * NanoXLSX is a small .NET library to generate and read XLSX (Microsoft Excel 2007 or newer) files in an easy and native way
3 * Copyright Raphael Stoeckli © 2026
4 * This library is licensed under the MIT License.
5 * You find a copy of the license in project folder or on: http://opensource.org/licenses/MIT
6 */
7
8using System.Collections.Generic;
9using NanoXLSX.Exceptions;
10using NanoXLSX.Utils.Xml;
11
12namespace NanoXLSX.Extensions
13{
17 public class PhoneticRun
18 {
19
20 #region enums
35
51 #endregion
52
53 private string text;
54
59 public string Text
60 {
61 get { return text; }
62 set
63 {
64 if (string.IsNullOrEmpty(value))
65 {
66 throw new FormatException("The text of the phonetic run cannot be null or empty");
67 }
68 text = XmlUtils.SanitizeXmlValue(value);
69 }
70 }
71
74 public uint StartBase { get; set; }
78 public uint EndBase { get; set; }
79
87 public PhoneticRun(string text, uint startBase, uint endBase)
88 {
89 Text = text;
90 StartBase = startBase;
91 EndBase = endBase;
92 }
93
99 {
100 return new PhoneticRun(this.Text, this.StartBase, this.EndBase);
101 }
102
108 public override bool Equals(object obj)
109 {
110 return obj is PhoneticRun run &&
111 text == run.text &&
112 StartBase == run.StartBase &&
113 EndBase == run.EndBase;
114 }
115
120 public override int GetHashCode()
121 {
122 var hashCode = -2139365225;
123 hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(text);
124 hashCode = hashCode * -1521134295 + StartBase.GetHashCode();
125 hashCode = hashCode * -1521134295 + EndBase.GetHashCode();
126 return hashCode;
127 }
128 }
129}
string Text
The phonetic text to be displayed (Ruby text,like Furigana, Pinyin or Zhuyin).
PhoneticAlignment
Enumeration for phonetic text alignment.
@ Center
Center the phonetic characters over the base word, per word.
@ NoControl
Each phonetic character is left justified without respect to the base text (so it is not per word).
@ Distributed
Each phonetic character is distributed above each base word character, per word.
@ Left
Each phonetic character is left justified with respect to the base text., per word.
PhoneticType
Enumeration for phonetic text types.
@ FullwidthKatakana
Full-width Katakana characters for phonetic text.
@ NoConversion
No conversion for phonetic text.
@ HalfwidthKatakana
Half-width Katakana characters for phonetic text.
@ Hiragana
Hiragana characters for phonetic text.
uint StartBase
The start index of the base text (character where the Ruby text starts).
PhoneticRun Copy()
Creates a copy of the current phonetic run.
uint EndBase
The end index of the base text (character where the Ruby text ends).
override bool Equals(object obj)
Equals method to compare two phonetic runs.
override int GetHashCode()
Hash code of the current object.
PhoneticRun(string text, uint startBase, uint endBase)
Constructor to create a phonetic run.