// // DomTableCell.cs // // Author: Kees van Spelde // // Copyright (c) 2013-2018 Magic-Sessions. (www.magic-sessions.com) // // 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 NON INFRINGEMENT. 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. // namespace MsgReader.Rtf { /// /// Dom table cell /// internal class DomTableCell : DomElement { #region Properties /// /// Row span /// public int RowSpan { get; set; } /// /// Col span /// public int ColSpan { get; set; } /// /// Left padding /// public int PaddingLeft { get; set; } /// /// Left padding in fact /// public int RuntimePaddingLeft { get { if (PaddingLeft != int.MinValue) return PaddingLeft; if (Parent != null) { var parent = ((DomTableRow) Parent).PaddingLeft; if (parent != int.MinValue) return parent; } return 0; } } /// /// Top padding /// public int PaddingTop { get; set; } /// /// Top padding in fact /// public int RuntimePaddingTop { get { if (PaddingTop != int.MinValue) return PaddingTop; if (Parent != null) { var parent = ((DomTableRow)Parent).PaddingTop; if (parent != int.MinValue) return parent; } return 0; } } /// /// Right padding /// public int PaddingRight { get; set; } /// /// Right padding in fact /// public int RuntimePaddingRight { get { if (PaddingRight != int.MinValue) { return PaddingRight; } if (Parent != null) { var parent = ((DomTableRow) Parent).PaddingRight; if (parent != int.MinValue) { return parent; } } return 0; } } /// /// Bottom padding /// public int PaddingBottom { get; set; } /// /// Bottom padding in fact /// public int RuntimePaddingBottom { get { if (PaddingBottom != int.MinValue) { return PaddingBottom; } if (Parent != null) { var p = ((DomTableRow) Parent).PaddingBottom; if (p != int.MinValue) { return p; } } return 0; } } /// /// Vertial alignment /// public RtfVerticalAlignment VerticalAlignment { get; set; } /// /// Format /// public DocumentFormatInfo Format { get; set; } /// /// Allow multiline /// public bool Multiline { get; set; } /// /// Left position /// public int Left { get; set; } /// /// Width /// public int Width { get; set; } /// /// Height /// public int Height { get; set; } /// /// Cell merged by another cell which this property specified /// public DomTableCell OverrideCell { get; set; } #endregion #region Constructor /// /// Initialize instance /// public DomTableCell() { Multiline = true; Format = new DocumentFormatInfo(); VerticalAlignment = RtfVerticalAlignment.Top; PaddingBottom = int.MinValue; PaddingRight = int.MinValue; PaddingTop = int.MinValue; PaddingLeft = int.MinValue; ColSpan = 1; RowSpan = 1; Height = 0; Width = 0; Left = 0; Format.BorderWidth = 1; } #endregion #region ToString public override string ToString() { if (OverrideCell == null) { if (RowSpan != 1 || ColSpan != 1) { return "Cell: RowSpan:" + RowSpan + " ColSpan:" + ColSpan + " Width:" + Width; } return "Cell:Width:" + Width; } return "Cell:Overrided"; } #endregion } }