| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Any CPU.Build.0 = Debug|Any CPU | {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU | {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU | ||||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU | |||||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|x86.ActiveCfg = Debug|Any CPU | {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|x86.ActiveCfg = Debug|Any CPU | ||||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|Any CPU.ActiveCfg = Release|Any CPU | {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|Any CPU.Build.0 = Release|Any CPU | {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|Any CPU.Build.0 = Release|Any CPU |
| <Compile Include="Footer.cs" /> | <Compile Include="Footer.cs" /> | ||||
| <Compile Include="CustomProperty.cs" /> | <Compile Include="CustomProperty.cs" /> | ||||
| <Compile Include="DocProperty.cs" /> | <Compile Include="DocProperty.cs" /> | ||||
| <Compile Include="FormattedText.cs" /> | |||||
| <Compile Include="Header.cs" /> | <Compile Include="Header.cs" /> | ||||
| <Compile Include="Headers.cs" /> | <Compile Include="Headers.cs" /> | ||||
| <Compile Include="HelperFunctions.cs" /> | <Compile Include="HelperFunctions.cs" /> |
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| namespace Novacode | |||||
| { | |||||
| public class FormattedText: IComparable | |||||
| { | |||||
| public FormattedText() | |||||
| { | |||||
| } | |||||
| public int index; | |||||
| public string text; | |||||
| public Formatting formatting; | |||||
| public int CompareTo(object obj) | |||||
| { | |||||
| FormattedText other = (FormattedText)obj; | |||||
| FormattedText tf = (FormattedText)obj; | |||||
| if (other.formatting == null || tf.formatting == null) | |||||
| return -1; | |||||
| return tf.formatting.CompareTo(other.formatting); | |||||
| } | |||||
| } | |||||
| } |
| /// <summary> | /// <summary> | ||||
| /// A text formatting. | /// A text formatting. | ||||
| /// </summary> | /// </summary> | ||||
| public class Formatting | |||||
| public class Formatting : IComparable | |||||
| { | { | ||||
| private XElement rPr; | private XElement rPr; | ||||
| private bool hidden; | private bool hidden; | ||||
| } | } | ||||
| } | } | ||||
| public static Formatting Parse(XElement rPr) | |||||
| { | |||||
| Formatting formatting = new Formatting(); | |||||
| // Build up the Formatting object. | |||||
| foreach (XElement option in rPr.Elements()) | |||||
| { | |||||
| switch (option.Name.LocalName) | |||||
| { | |||||
| case "lang": formatting.Language = new CultureInfo(option.Attribute(XName.Get("val", DocX.w.NamespaceName)).Value); break; | |||||
| case "spacing": formatting.Spacing = Double.Parse(option.Attribute(XName.Get("val", DocX.w.NamespaceName)).Value) / 20.0; break; | |||||
| case "position": formatting.Position = Int32.Parse(option.Attribute(XName.Get("val", DocX.w.NamespaceName)).Value) / 2; break; | |||||
| case "kern": formatting.Position = Int32.Parse(option.Attribute(XName.Get("val", DocX.w.NamespaceName)).Value) / 2; break; | |||||
| case "w": formatting.PercentageScale = Int32.Parse(option.Attribute(XName.Get("val", DocX.w.NamespaceName)).Value); break; | |||||
| case "rFonts": break; | |||||
| case "vanish": formatting.hidden = true; break; | |||||
| case "b": formatting.Bold = true; break; | |||||
| case "i": formatting.Italic = true; break; | |||||
| default: break; | |||||
| } | |||||
| } | |||||
| return formatting; | |||||
| } | |||||
| internal XElement Xml | internal XElement Xml | ||||
| { | { | ||||
| get | get | ||||
| /// <summary> | /// <summary> | ||||
| /// This formatting will apply Italic. | /// This formatting will apply Italic. | ||||
| /// </summary> | /// </summary> | ||||
| public bool Italic { get { return Italic; } set { italic = value; } } | |||||
| public bool Italic { get { return italic; } set { italic = value; } } | |||||
| /// <summary> | /// <summary> | ||||
| /// This formatting will apply StrickThrough. | /// This formatting will apply StrickThrough. | ||||
| /// --> | /// --> | ||||
| public FontFamily FontFamily { get { return fontFamily; } set { fontFamily = value; } } | public FontFamily FontFamily { get { return fontFamily; } set { fontFamily = value; } } | ||||
| public int CompareTo(object obj) | |||||
| { | |||||
| Formatting other = (Formatting)obj; | |||||
| if(other.hidden != this.hidden) | |||||
| return -1; | |||||
| if(other.bold != this.bold) | |||||
| return -1; | |||||
| if(other.italic != this.italic) | |||||
| return -1; | |||||
| if(other.strikethrough != this.strikethrough) | |||||
| return -1; | |||||
| if(other.script != this.script) | |||||
| return -1; | |||||
| if(other.highlight != this.highlight) | |||||
| return -1; | |||||
| if(other.size != this.size) | |||||
| return -1; | |||||
| if(other.fontColor != this.fontColor) | |||||
| return -1; | |||||
| if(other.underlineColor != this.underlineColor) | |||||
| return -1; | |||||
| if(other.underlineStyle != this.underlineStyle) | |||||
| return -1; | |||||
| if(other.misc != this.misc) | |||||
| return -1; | |||||
| if(other.capsStyle != this.capsStyle) | |||||
| return -1; | |||||
| if(other.fontFamily != this.fontFamily) | |||||
| return -1; | |||||
| if(other.percentageScale != this.percentageScale) | |||||
| return -1; | |||||
| if(other.kerning != this.kerning) | |||||
| return -1; | |||||
| if(other.position != this.position) | |||||
| return -1; | |||||
| if(other.spacing != this.spacing) | |||||
| return -1; | |||||
| if(other.language != this.language) | |||||
| return -1; | |||||
| return 0; | |||||
| } | |||||
| } | } | ||||
| } | } |
| GetTextRecursive(e, ref sb); | GetTextRecursive(e, ref sb); | ||||
| } | } | ||||
| internal static List<FormattedText> GetFormattedText(XElement e) | |||||
| { | |||||
| List<FormattedText> alist = new List<FormattedText>(); | |||||
| GetFormattedTextRecursive(e, ref alist); | |||||
| return alist; | |||||
| } | |||||
| internal static void GetFormattedTextRecursive(XElement Xml, ref List<FormattedText> alist) | |||||
| { | |||||
| FormattedText ft = ToFormattedText(Xml); | |||||
| FormattedText last = null; | |||||
| if (ft != null) | |||||
| { | |||||
| if (alist.Count() > 0) | |||||
| last = alist.Last(); | |||||
| if (last != null && last.CompareTo(ft) == 0) | |||||
| { | |||||
| // Update text of last entry. | |||||
| last.text += ft.text; | |||||
| } | |||||
| else | |||||
| { | |||||
| if (last != null) | |||||
| ft.index = last.index + last.text.Length; | |||||
| alist.Add(ft); | |||||
| } | |||||
| } | |||||
| if (Xml.HasElements) | |||||
| foreach (XElement e in Xml.Elements()) | |||||
| GetFormattedTextRecursive(e, ref alist); | |||||
| } | |||||
| internal static FormattedText ToFormattedText(XElement e) | |||||
| { | |||||
| // The text representation of e. | |||||
| String text = ToText(e); | |||||
| if (text == String.Empty) | |||||
| return null; | |||||
| // e is a w:t element, it must exist inside a w:r element, lets climb until we find it. | |||||
| while (!e.Name.Equals(XName.Get("r", DocX.w.NamespaceName))) | |||||
| e = e.Parent; | |||||
| // e is a w:r element, lets find the rPr element. | |||||
| XElement rPr = e.Element(XName.Get("rPr", DocX.w.NamespaceName)); | |||||
| FormattedText ft = new FormattedText(); | |||||
| ft.text = text; | |||||
| ft.index = 0; | |||||
| ft.formatting = null; | |||||
| // Return text with formatting. | |||||
| if (rPr != null) | |||||
| ft.formatting = Formatting.Parse(rPr); | |||||
| return ft; | |||||
| } | |||||
| internal static string ToText(XElement e) | internal static string ToText(XElement e) | ||||
| { | { | ||||
| switch (e.Name.LocalName) | switch (e.Name.LocalName) |
| using System.Drawing; | using System.Drawing; | ||||
| using System.Globalization; | using System.Globalization; | ||||
| namespace Novacode | namespace Novacode | ||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| } | } | ||||
| } | } | ||||
| /// <summary> | |||||
| /// Gets the formatted text value of this Paragraph. | |||||
| /// </summary> | |||||
| public List<FormattedText> MagicText | |||||
| { | |||||
| // Returns the underlying XElement's Value property. | |||||
| get | |||||
| { | |||||
| return HelperFunctions.GetFormattedText(Xml); | |||||
| } | |||||
| } | |||||
| //public Picture InsertPicture(Picture picture) | //public Picture InsertPicture(Picture picture) | ||||
| //{ | //{ | ||||
| // Picture newPicture = picture; | // Picture newPicture = picture; |
| internal Table(DocX document, XElement xml) | internal Table(DocX document, XElement xml) | ||||
| : base(document, xml) | : base(document, xml) | ||||
| { | { | ||||
| autofit = AutoFit.ColoumnWidth; | |||||
| autofit = AutoFit.ColumnWidth; | |||||
| this.Xml = xml; | this.Xml = xml; | ||||
| XElement properties = xml.Element(XName.Get("tblPr", DocX.w.NamespaceName)); | XElement properties = xml.Element(XName.Get("tblPr", DocX.w.NamespaceName)); | ||||
| string attributeValue = string.Empty; | string attributeValue = string.Empty; | ||||
| switch (value) | switch (value) | ||||
| { | { | ||||
| case AutoFit.ColoumnWidth: | |||||
| case AutoFit.ColumnWidth: | |||||
| { | { | ||||
| attributeValue = "dxa"; | attributeValue = "dxa"; | ||||
| break; | break; |
| public enum UnderlineStyle { none, singleLine, doubleLine, thick, dotted, dottedHeavy, dash, dashedHeavy, dashLong, dashLongHeavy, dotDash, dashDotHeavy, dotDotDash, dashDotDotHeavy, wave, wavyHeavy, wavyDouble, words }; | public enum UnderlineStyle { none, singleLine, doubleLine, thick, dotted, dottedHeavy, dash, dashedHeavy, dashLong, dashLongHeavy, dotDash, dashDotHeavy, dotDotDash, dashDotDotHeavy, wave, wavyHeavy, wavyDouble, words }; | ||||
| public enum StrikeThrough { none, strike, doubleStrike }; | public enum StrikeThrough { none, strike, doubleStrike }; | ||||
| public enum Misc { none, shadow, outline, outlineShadow, emboss, engrave }; | public enum Misc { none, shadow, outline, outlineShadow, emboss, engrave }; | ||||
| public enum CapsStyle { none, caps, smallCaps }; | |||||
| /// <summary> | |||||
| /// Change the caps style of text, for use with Append and AppendLine. | |||||
| /// </summary> | |||||
| public enum CapsStyle | |||||
| { | |||||
| /// <summary> | |||||
| /// No caps, make all characters are lowercase. | |||||
| /// </summary> | |||||
| none, | |||||
| /// <summary> | |||||
| /// All caps, make every character uppercase. | |||||
| /// </summary> | |||||
| caps, | |||||
| /// <summary> | |||||
| /// Small caps, make all characters capital but with a small font size. | |||||
| /// </summary> | |||||
| smallCaps }; | |||||
| /// <summary> | /// <summary> | ||||
| /// Designs\Styles that can be applied to a table. | /// Designs\Styles that can be applied to a table. | ||||
| /// </summary> | /// </summary> | ||||
| public enum TableDesign { Custom, TableNormal, TableGrid, LightShading, LightShadingAccent1, LightShadingAccent2, LightShadingAccent3, LightShadingAccent4, LightShadingAccent5, LightShadingAccent6, LightList, LightListAccent1, LightListAccent2, LightListAccent3, LightListAccent4, LightListAccent5, LightListAccent6, LightGrid, LightGridAccent1, LightGridAccent2, LightGridAccent3, LightGridAccent4, LightGridAccent5, LightGridAccent6, MediumShading1, MediumShading1Accent1, MediumShading1Accent2, MediumShading1Accent3, MediumShading1Accent4, MediumShading1Accent5, MediumShading1Accent6, MediumShading2, MediumShading2Accent1, MediumShading2Accent2, MediumShading2Accent3, MediumShading2Accent4, MediumShading2Accent5, MediumShading2Accent6, MediumList1, MediumList1Accent1, MediumList1Accent2, MediumList1Accent3, MediumList1Accent4, MediumList1Accent5, MediumList1Accent6, MediumList2, MediumList2Accent1, MediumList2Accent2, MediumList2Accent3, MediumList2Accent4, MediumList2Accent5, MediumList2Accent6, MediumGrid1, MediumGrid1Accent1, MediumGrid1Accent2, MediumGrid1Accent3, MediumGrid1Accent4, MediumGrid1Accent5, MediumGrid1Accent6, MediumGrid2, MediumGrid2Accent1, MediumGrid2Accent2, MediumGrid2Accent3, MediumGrid2Accent4, MediumGrid2Accent5, MediumGrid2Accent6, MediumGrid3, MediumGrid3Accent1, MediumGrid3Accent2, MediumGrid3Accent3, MediumGrid3Accent4, MediumGrid3Accent5, MediumGrid3Accent6, DarkList, DarkListAccent1, DarkListAccent2, DarkListAccent3, DarkListAccent4, DarkListAccent5, DarkListAccent6, ColorfulShading, ColorfulShadingAccent1, ColorfulShadingAccent2, ColorfulShadingAccent3, ColorfulShadingAccent4, ColorfulShadingAccent5, ColorfulShadingAccent6, ColorfulList, ColorfulListAccent1, ColorfulListAccent2, ColorfulListAccent3, ColorfulListAccent4, ColorfulListAccent5, ColorfulListAccent6, ColorfulGrid, ColorfulGridAccent1, ColorfulGridAccent2, ColorfulGridAccent3, ColorfulGridAccent4, ColorfulGridAccent5, ColorfulGridAccent6, None }; | public enum TableDesign { Custom, TableNormal, TableGrid, LightShading, LightShadingAccent1, LightShadingAccent2, LightShadingAccent3, LightShadingAccent4, LightShadingAccent5, LightShadingAccent6, LightList, LightListAccent1, LightListAccent2, LightListAccent3, LightListAccent4, LightListAccent5, LightListAccent6, LightGrid, LightGridAccent1, LightGridAccent2, LightGridAccent3, LightGridAccent4, LightGridAccent5, LightGridAccent6, MediumShading1, MediumShading1Accent1, MediumShading1Accent2, MediumShading1Accent3, MediumShading1Accent4, MediumShading1Accent5, MediumShading1Accent6, MediumShading2, MediumShading2Accent1, MediumShading2Accent2, MediumShading2Accent3, MediumShading2Accent4, MediumShading2Accent5, MediumShading2Accent6, MediumList1, MediumList1Accent1, MediumList1Accent2, MediumList1Accent3, MediumList1Accent4, MediumList1Accent5, MediumList1Accent6, MediumList2, MediumList2Accent1, MediumList2Accent2, MediumList2Accent3, MediumList2Accent4, MediumList2Accent5, MediumList2Accent6, MediumGrid1, MediumGrid1Accent1, MediumGrid1Accent2, MediumGrid1Accent3, MediumGrid1Accent4, MediumGrid1Accent5, MediumGrid1Accent6, MediumGrid2, MediumGrid2Accent1, MediumGrid2Accent2, MediumGrid2Accent3, MediumGrid2Accent4, MediumGrid2Accent5, MediumGrid2Accent6, MediumGrid3, MediumGrid3Accent1, MediumGrid3Accent2, MediumGrid3Accent3, MediumGrid3Accent4, MediumGrid3Accent5, MediumGrid3Accent6, DarkList, DarkListAccent1, DarkListAccent2, DarkListAccent3, DarkListAccent4, DarkListAccent5, DarkListAccent6, ColorfulShading, ColorfulShadingAccent1, ColorfulShadingAccent2, ColorfulShadingAccent3, ColorfulShadingAccent4, ColorfulShadingAccent5, ColorfulShadingAccent6, ColorfulList, ColorfulListAccent1, ColorfulListAccent2, ColorfulListAccent3, ColorfulListAccent4, ColorfulListAccent5, ColorfulListAccent6, ColorfulGrid, ColorfulGridAccent1, ColorfulGridAccent2, ColorfulGridAccent3, ColorfulGridAccent4, ColorfulGridAccent5, ColorfulGridAccent6, None }; | ||||
| public enum AutoFit { Contents, Window, ColoumnWidth }; | |||||
| /// <summary> | |||||
| /// How a Table should auto resize. | |||||
| /// </summary> | |||||
| public enum AutoFit | |||||
| { | |||||
| /// <summary> | |||||
| /// Autofit to Table contents. | |||||
| /// </summary> | |||||
| Contents, | |||||
| /// <summary> | |||||
| /// Autofit to Window. | |||||
| /// </summary> | |||||
| Window, | |||||
| /// <summary> | |||||
| /// Autofit to Column width. | |||||
| /// </summary> | |||||
| ColumnWidth | |||||
| }; | |||||
| public enum RectangleShapes | public enum RectangleShapes | ||||
| { | { | ||||
| }; | }; | ||||
| /// <summary> | /// <summary> | ||||
| /// Text alignment of a paragraph | |||||
| /// Text alignment of a Paragraph. | |||||
| /// </summary> | /// </summary> | ||||
| public enum Alignment | public enum Alignment | ||||
| { | { | ||||
| left, | left, | ||||
| /// <summary> | /// <summary> | ||||
| /// Align Paragraph as Centered. | |||||
| /// Align Paragraph as centered. | |||||
| /// </summary> | /// </summary> | ||||
| center, | center, | ||||