NanoXLSX.Formatting 3.1.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
12// TODO: Consider changing this namespace in a future major release.
13namespace NanoXLSX.Extensions
14{
18 public class PhoneticRun
19 {
20
21 #region enums
36
52 #endregion
53
54 private string text;
55
60 public string Text
61 {
62 get { return text; }
63 set
64 {
65 if (string.IsNullOrEmpty(value))
66 {
67 throw new FormatException("The text of the phonetic run cannot be null or empty");
68 }
69 text = XmlUtils.SanitizeXmlValue(value);
70 }
71 }
72
75 public uint StartBase { get; set; }
79 public uint EndBase { get; set; }
80
88 public PhoneticRun(string text, uint startBase, uint endBase)
89 {
90 Text = text;
91 StartBase = startBase;
92 EndBase = endBase;
93 }
94
100 {
101 return new PhoneticRun(this.Text, this.StartBase, this.EndBase);
102 }
103
109 public override bool Equals(object obj)
110 {
111 return obj is PhoneticRun run &&
112 text == run.text &&
113 StartBase == run.StartBase &&
114 EndBase == run.EndBase;
115 }
116
121 public override int GetHashCode()
122 {
123 var hashCode = -2139365225;
124 hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(text);
125 hashCode = hashCode * -1521134295 + StartBase.GetHashCode();
126 hashCode = hashCode * -1521134295 + EndBase.GetHashCode();
127 return hashCode;
128 }
129 }
130}
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.