First commit
Send all results
This commit is contained in:
		
							
								
								
									
										182
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Border.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										182
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Border.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,182 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents one border in a borders collection. The type determines its position in a cell,
 | 
			
		||||
    /// paragraph etc.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Border : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Border class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Border()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Border class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Border(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Border Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Border)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Clears the Border object. Additionally 'Border = null'
 | 
			
		||||
        /// is written to the DDL stream when serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Clear()
 | 
			
		||||
        {
 | 
			
		||||
            _fClear.Value = true;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value indicating whether the border visible is.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool Visible
 | 
			
		||||
        {
 | 
			
		||||
            get { return _visible.Value; }
 | 
			
		||||
            set { _visible.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _visible = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the line style of the border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public BorderStyle Style
 | 
			
		||||
        {
 | 
			
		||||
            get { return (BorderStyle)_style.Value; }
 | 
			
		||||
            set { _style.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(BorderStyle))]
 | 
			
		||||
        public NEnum _style = NEnum.NullValue(typeof(BorderStyle));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the line width of the border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit Width
 | 
			
		||||
        {
 | 
			
		||||
            get { return _width; }
 | 
			
		||||
            set { _width = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _width = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the color of the border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color Color
 | 
			
		||||
        {
 | 
			
		||||
            get { return _color; }
 | 
			
		||||
            set { _color = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Color _color = Color.Empty;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the name of this border ("top", "bottom"....).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Name
 | 
			
		||||
        {
 | 
			
		||||
            get { return ((Borders)_parent).GetMyName(this); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the information if the border is marked as cleared. Additionally 'xxx = null'
 | 
			
		||||
        /// is written to the DDL stream when serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool BorderCleared
 | 
			
		||||
        {
 | 
			
		||||
            get { return _fClear.Value; }
 | 
			
		||||
        }
 | 
			
		||||
        public NBool _fClear = new NBool(false);
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Border into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            throw new Exception("A Border cannot be serialized alone.");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Border into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Serialize(Serializer serializer, string name, Border refBorder)
 | 
			
		||||
        {
 | 
			
		||||
            if (_fClear.Value)
 | 
			
		||||
                serializer.WriteLine(name + " = null");
 | 
			
		||||
 | 
			
		||||
            int pos = serializer.BeginContent(name);
 | 
			
		||||
 | 
			
		||||
            if (!_visible.IsNull && (refBorder == null || (Visible != refBorder.Visible)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("Visible", Visible);
 | 
			
		||||
 | 
			
		||||
            if (!_style.IsNull && (refBorder == null || (Style != refBorder.Style)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("Style", Style);
 | 
			
		||||
 | 
			
		||||
            if (!_width.IsNull && (refBorder == null || (Width != refBorder.Width)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("Width", Width);
 | 
			
		||||
 | 
			
		||||
            if (!_color.IsNull && (refBorder == null || (Color != refBorder.Color)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("Color", Color);
 | 
			
		||||
 | 
			
		||||
            serializer.EndContent(pos);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the _meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Border))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										525
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Borders.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										525
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Borders.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,525 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// A Borders collection represents the eight border objects used for paragraphs, tables etc.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Borders : DocumentObject, IEnumerable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Borders class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Borders()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Borders class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Borders(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether a particular border exists.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool HasBorder(BorderType type)
 | 
			
		||||
        {
 | 
			
		||||
            if (!Enum.IsDefined(typeof(BorderType), type))
 | 
			
		||||
                throw new /*InvalidEnum*/ArgumentException(DomSR.InvalidEnumValue(type), "type");
 | 
			
		||||
 | 
			
		||||
            return GetBorderReadOnly(type) != null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Border GetBorderReadOnly(BorderType type)
 | 
			
		||||
        {
 | 
			
		||||
            switch (type)
 | 
			
		||||
            {
 | 
			
		||||
                case BorderType.Bottom:
 | 
			
		||||
                    return _bottom;
 | 
			
		||||
                case BorderType.DiagonalDown:
 | 
			
		||||
                    return _diagonalDown;
 | 
			
		||||
                case BorderType.DiagonalUp:
 | 
			
		||||
                    return _diagonalUp;
 | 
			
		||||
                case BorderType.Horizontal:
 | 
			
		||||
                case BorderType.Vertical:
 | 
			
		||||
                    return (Border)GetValue(type.ToString(), GV.GetNull);
 | 
			
		||||
                case BorderType.Left:
 | 
			
		||||
                    return _left;
 | 
			
		||||
                case BorderType.Right:
 | 
			
		||||
                    return _right;
 | 
			
		||||
                case BorderType.Top:
 | 
			
		||||
                    return _top;
 | 
			
		||||
            }
 | 
			
		||||
            if (!Enum.IsDefined(typeof(BorderType), type))
 | 
			
		||||
                throw new /*InvalidEnum*/ArgumentException(DomSR.InvalidEnumValue(type), "type");
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Borders Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Borders)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            Borders borders = (Borders)base.DeepCopy();
 | 
			
		||||
            if (borders._top != null)
 | 
			
		||||
            {
 | 
			
		||||
                borders._top = borders._top.Clone();
 | 
			
		||||
                borders._top._parent = borders;
 | 
			
		||||
            }
 | 
			
		||||
            if (borders._left != null)
 | 
			
		||||
            {
 | 
			
		||||
                borders._left = borders._left.Clone();
 | 
			
		||||
                borders._left._parent = borders;
 | 
			
		||||
            }
 | 
			
		||||
            if (borders._right != null)
 | 
			
		||||
            {
 | 
			
		||||
                borders._right = borders._right.Clone();
 | 
			
		||||
                borders._right._parent = borders;
 | 
			
		||||
            }
 | 
			
		||||
            if (borders._bottom != null)
 | 
			
		||||
            {
 | 
			
		||||
                borders._bottom = borders._bottom.Clone();
 | 
			
		||||
                borders._bottom._parent = borders;
 | 
			
		||||
            }
 | 
			
		||||
            if (borders._diagonalUp != null)
 | 
			
		||||
            {
 | 
			
		||||
                borders._diagonalUp = borders._diagonalUp.Clone();
 | 
			
		||||
                borders._diagonalUp._parent = borders;
 | 
			
		||||
            }
 | 
			
		||||
            if (borders._diagonalDown != null)
 | 
			
		||||
            {
 | 
			
		||||
                borders._diagonalDown = borders._diagonalDown.Clone();
 | 
			
		||||
                borders._diagonalDown._parent = borders;
 | 
			
		||||
            }
 | 
			
		||||
            return borders;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets an enumerator for the borders object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        IEnumerator IEnumerable.GetEnumerator()
 | 
			
		||||
        {
 | 
			
		||||
            Dictionary<string, Border> ht = new Dictionary<string, Border>();
 | 
			
		||||
            ht.Add("Top", _top);
 | 
			
		||||
            ht.Add("Left", _left);
 | 
			
		||||
            ht.Add("Bottom", _bottom);
 | 
			
		||||
            ht.Add("Right", _right);
 | 
			
		||||
            ht.Add("DiagonalUp", _diagonalUp);
 | 
			
		||||
            ht.Add("DiagonalDown", _diagonalDown);
 | 
			
		||||
 | 
			
		||||
            return new BorderEnumerator(ht);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Clears all Border objects from the collection. Additionally 'Borders = null'
 | 
			
		||||
        /// is written to the DDL stream when serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void ClearAll()
 | 
			
		||||
        {
 | 
			
		||||
            _clearAll = true;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the top border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Border Top
 | 
			
		||||
        {
 | 
			
		||||
            get { return _top ?? (_top = new Border(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _top = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Border _top;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the left border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Border Left
 | 
			
		||||
        {
 | 
			
		||||
            get { return _left ?? (_left = new Border(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _left = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Border _left;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the bottom border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Border Bottom
 | 
			
		||||
        {
 | 
			
		||||
            get { return _bottom ?? (_bottom = new Border(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _bottom = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Border _bottom;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the right border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Border Right
 | 
			
		||||
        {
 | 
			
		||||
            get { return _right ?? (_right = new Border(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _right = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Border _right;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the diagonalup border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Border DiagonalUp
 | 
			
		||||
        {
 | 
			
		||||
            get { return _diagonalUp ?? (_diagonalUp = new Border(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _diagonalUp = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Border _diagonalUp;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the diagonaldown border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Border DiagonalDown
 | 
			
		||||
        {
 | 
			
		||||
            get { return _diagonalDown ?? (_diagonalDown = new Border(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _diagonalDown = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Border _diagonalDown;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value indicating whether the borders are visible.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool Visible
 | 
			
		||||
        {
 | 
			
		||||
            get { return _visible.Value; }
 | 
			
		||||
            set { _visible.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _visible = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the line style of the borders.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public BorderStyle Style
 | 
			
		||||
        {
 | 
			
		||||
            get { return (BorderStyle)_style.Value; }
 | 
			
		||||
            set { _style.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(BorderStyle))]
 | 
			
		||||
        public NEnum _style = NEnum.NullValue(typeof(BorderStyle));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the standard width of the borders.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit Width
 | 
			
		||||
        {
 | 
			
		||||
            get { return _width; }
 | 
			
		||||
            set { _width = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _width = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the color of the borders.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color Color
 | 
			
		||||
        {
 | 
			
		||||
            get { return _color; }
 | 
			
		||||
            set { _color = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Color _color = Color.Empty;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the distance between text and the top border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit DistanceFromTop
 | 
			
		||||
        {
 | 
			
		||||
            get { return _distanceFromTop; }
 | 
			
		||||
            set { _distanceFromTop = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _distanceFromTop = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the distance between text and the bottom border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit DistanceFromBottom
 | 
			
		||||
        {
 | 
			
		||||
            get { return _distanceFromBottom; }
 | 
			
		||||
            set { _distanceFromBottom = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _distanceFromBottom = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the distance between text and the left border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit DistanceFromLeft
 | 
			
		||||
        {
 | 
			
		||||
            get { return _distanceFromLeft; }
 | 
			
		||||
            set { _distanceFromLeft = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _distanceFromLeft = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the distance between text and the right border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit DistanceFromRight
 | 
			
		||||
        {
 | 
			
		||||
            get { return _distanceFromRight; }
 | 
			
		||||
            set { _distanceFromRight = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _distanceFromRight = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the distance to all four borders to the specified value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit Distance
 | 
			
		||||
        {
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                DistanceFromTop = value;
 | 
			
		||||
                DistanceFromBottom = value;
 | 
			
		||||
                DistanceFromLeft = value;
 | 
			
		||||
                DistanceFromRight = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the information if the collection is marked as cleared. Additionally 'Borders = null'
 | 
			
		||||
        /// is written to the DDL stream when serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool BordersCleared
 | 
			
		||||
        {
 | 
			
		||||
            get { return _clearAll; }
 | 
			
		||||
            set { _clearAll = value; }
 | 
			
		||||
        }
 | 
			
		||||
        protected bool _clearAll;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Borders into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            Serialize(serializer, null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Borders into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Serialize(Serializer serializer, Borders refBorders)
 | 
			
		||||
        {
 | 
			
		||||
            if (_clearAll)
 | 
			
		||||
                serializer.WriteLine("Borders = null");
 | 
			
		||||
 | 
			
		||||
            int pos = serializer.BeginContent("Borders");
 | 
			
		||||
 | 
			
		||||
            if (!_visible.IsNull && (refBorders == null || refBorders._visible.IsNull || (Visible != refBorders.Visible)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("Visible", Visible);
 | 
			
		||||
 | 
			
		||||
            if (!_style.IsNull && (refBorders == null || (Style != refBorders.Style)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("Style", Style);
 | 
			
		||||
 | 
			
		||||
            if (!_width.IsNull && (refBorders == null || (_width.Value != refBorders._width.Value)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("Width", Width);
 | 
			
		||||
 | 
			
		||||
            if (!_color.IsNull && (refBorders == null || ((Color.Argb != refBorders.Color.Argb))))
 | 
			
		||||
                serializer.WriteSimpleAttribute("Color", Color);
 | 
			
		||||
 | 
			
		||||
            if (!_distanceFromTop.IsNull && (refBorders == null || (DistanceFromTop.Point != refBorders.DistanceFromTop.Point)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("DistanceFromTop", DistanceFromTop);
 | 
			
		||||
 | 
			
		||||
            if (!_distanceFromBottom.IsNull && (refBorders == null || (DistanceFromBottom.Point != refBorders.DistanceFromBottom.Point)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("DistanceFromBottom", DistanceFromBottom);
 | 
			
		||||
 | 
			
		||||
            if (!_distanceFromLeft.IsNull && (refBorders == null || (DistanceFromLeft.Point != refBorders.DistanceFromLeft.Point)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("DistanceFromLeft", DistanceFromLeft);
 | 
			
		||||
 | 
			
		||||
            if (!_distanceFromRight.IsNull && (refBorders == null || (DistanceFromRight.Point != refBorders.DistanceFromRight.Point)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("DistanceFromRight", DistanceFromRight);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Top"))
 | 
			
		||||
                _top.Serialize(serializer, "Top", null);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Left"))
 | 
			
		||||
                _left.Serialize(serializer, "Left", null);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Bottom"))
 | 
			
		||||
                _bottom.Serialize(serializer, "Bottom", null);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Right"))
 | 
			
		||||
                _right.Serialize(serializer, "Right", null);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("DiagonalDown"))
 | 
			
		||||
                _diagonalDown.Serialize(serializer, "DiagonalDown", null);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("DiagonalUp"))
 | 
			
		||||
                _diagonalUp.Serialize(serializer, "DiagonalUp", null);
 | 
			
		||||
 | 
			
		||||
            serializer.EndContent(pos);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a name of a border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string GetMyName(Border border)
 | 
			
		||||
        {
 | 
			
		||||
            if (border == _top)
 | 
			
		||||
                return "Top";
 | 
			
		||||
            if (border == _bottom)
 | 
			
		||||
                return "Bottom";
 | 
			
		||||
            if (border == _left)
 | 
			
		||||
                return "Left";
 | 
			
		||||
            if (border == _right)
 | 
			
		||||
                return "Right";
 | 
			
		||||
            if (border == _diagonalUp)
 | 
			
		||||
                return "DiagonalUp";
 | 
			
		||||
            if (border == _diagonalDown)
 | 
			
		||||
                return "DiagonalDown";
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns an enumerator that can iterate through the Borders.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public class BorderEnumerator : IEnumerator
 | 
			
		||||
        {
 | 
			
		||||
            int _index;
 | 
			
		||||
            readonly Dictionary<string, Border> _ht;
 | 
			
		||||
 | 
			
		||||
            /// <summary>
 | 
			
		||||
            /// Creates a new BorderEnumerator.
 | 
			
		||||
            /// </summary>
 | 
			
		||||
            public BorderEnumerator(Dictionary<string, Border> ht)
 | 
			
		||||
            {
 | 
			
		||||
                _ht = ht;
 | 
			
		||||
                _index = -1;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            /// <summary>
 | 
			
		||||
            /// Sets the enumerator to its initial position, which is before the first element in the border collection.
 | 
			
		||||
            /// </summary>
 | 
			
		||||
            public void Reset()
 | 
			
		||||
            {
 | 
			
		||||
                _index = -1;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            /// <summary>
 | 
			
		||||
            /// Gets the current element in the border collection.
 | 
			
		||||
            /// </summary>
 | 
			
		||||
            public Border Current
 | 
			
		||||
            {
 | 
			
		||||
                get
 | 
			
		||||
                {
 | 
			
		||||
                    IEnumerator enumerator = _ht.GetEnumerator();
 | 
			
		||||
                    enumerator.Reset();
 | 
			
		||||
                    for (int idx = 0; idx < _index + 1; idx++)
 | 
			
		||||
                        enumerator.MoveNext();
 | 
			
		||||
                    return ((DictionaryEntry)enumerator.Current).Value as Border;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            /// <summary>
 | 
			
		||||
            /// Gets the current element in the border collection.
 | 
			
		||||
            /// </summary>
 | 
			
		||||
            object IEnumerator.Current
 | 
			
		||||
            {
 | 
			
		||||
                get { return Current; }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            /// <summary>
 | 
			
		||||
            /// Advances the enumerator to the next element of the border collection.
 | 
			
		||||
            /// </summary>
 | 
			
		||||
            public bool MoveNext()
 | 
			
		||||
            {
 | 
			
		||||
                _index++;
 | 
			
		||||
                return (_index < _ht.Count);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Borders))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										199
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Character.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										199
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Character.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,199 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents a special character in paragraph text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    // TODO: So <20>ndern, dass symbolName und char in unterschiedlichen Feldern gespeichert werden.
 | 
			
		||||
    // TODO Remove German remarks!
 | 
			
		||||
    public class Character : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        // \space
 | 
			
		||||
        public static readonly Character Blank = new Character(SymbolName.Blank);
 | 
			
		||||
        public static readonly Character En = new Character(SymbolName.En);
 | 
			
		||||
        public static readonly Character Em = new Character(SymbolName.Em);
 | 
			
		||||
        public static readonly Character EmQuarter = new Character(SymbolName.EmQuarter);
 | 
			
		||||
        public static readonly Character Em4 = new Character(SymbolName.Em4);
 | 
			
		||||
 | 
			
		||||
        // used to serialize as \tab, \linebreak
 | 
			
		||||
        public static readonly Character Tab = new Character(SymbolName.Tab);
 | 
			
		||||
        public static readonly Character LineBreak = new Character(SymbolName.LineBreak);
 | 
			
		||||
        //public static readonly Character MarginBreak         = new Character(SymbolName.MarginBreak);
 | 
			
		||||
 | 
			
		||||
        // \symbol
 | 
			
		||||
        public static readonly Character Euro = new Character(SymbolName.Euro);
 | 
			
		||||
        public static readonly Character Copyright = new Character(SymbolName.Copyright);
 | 
			
		||||
        public static readonly Character Trademark = new Character(SymbolName.Trademark);
 | 
			
		||||
        public static readonly Character RegisteredTrademark = new Character(SymbolName.RegisteredTrademark);
 | 
			
		||||
        public static readonly Character Bullet = new Character(SymbolName.Bullet);
 | 
			
		||||
        public static readonly Character Not = new Character(SymbolName.Not);
 | 
			
		||||
        public static readonly Character EmDash = new Character(SymbolName.EmDash);
 | 
			
		||||
        public static readonly Character EnDash = new Character(SymbolName.EnDash);
 | 
			
		||||
        public static readonly Character NonBreakableBlank = new Character(SymbolName.NonBreakableBlank);
 | 
			
		||||
        public static readonly Character HardBlank = new Character(SymbolName.HardBlank);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Character class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Character class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Character class with the specified SymbolName.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Character(SymbolName name)
 | 
			
		||||
            : this()
 | 
			
		||||
        {
 | 
			
		||||
            // uint does not work, need cast to int.
 | 
			
		||||
            //SetValue("SymbolName", (int)(uint)name);
 | 
			
		||||
            _symbolName.Value = (int)name;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the SymbolName. Returns 0 if the type is defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SymbolName SymbolName
 | 
			
		||||
        {
 | 
			
		||||
            get { return (SymbolName)_symbolName.Value; }
 | 
			
		||||
            set { _symbolName.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(SymbolName))]
 | 
			
		||||
        public NEnum _symbolName = NEnum.NullValue(typeof(SymbolName));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the SymbolName as character. Returns 0 if the type is defined via an enum.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public char Char
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (((uint)_symbolName.Value & 0xF0000000) == 0)
 | 
			
		||||
                    return (char)_symbolName.Value;
 | 
			
		||||
                return '\0';
 | 
			
		||||
            }
 | 
			
		||||
            set { _symbolName.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the number of times the character is repeated.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Count
 | 
			
		||||
        {
 | 
			
		||||
            get { return _count.Value; }
 | 
			
		||||
            set { _count.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NInt _count = new NInt(1);
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Character into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            string text = String.Empty;
 | 
			
		||||
            if (_count == 1)
 | 
			
		||||
            {
 | 
			
		||||
                if ((SymbolName)_symbolName.Value == SymbolName.Tab)
 | 
			
		||||
                    text = "\\tab ";
 | 
			
		||||
                else if ((SymbolName)_symbolName.Value == SymbolName.LineBreak)
 | 
			
		||||
                    text = "\\linebreak\x0D\x0A";
 | 
			
		||||
                else if ((SymbolName)_symbolName.Value == SymbolName.ParaBreak)
 | 
			
		||||
                    text = "\x0D\x0A\x0D\x0A";
 | 
			
		||||
                //else if (symbolType == SymbolName.MarginBreak)
 | 
			
		||||
                //  text = "\\marginbreak ";
 | 
			
		||||
 | 
			
		||||
                if (text != "")
 | 
			
		||||
                {
 | 
			
		||||
                    serializer.Write(text);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (((uint)_symbolName.Value & 0xF0000000) == 0xF0000000)
 | 
			
		||||
            {
 | 
			
		||||
                // SymbolName == SpaceType?
 | 
			
		||||
                if (((uint)_symbolName.Value & 0xF1000000) == 0xF1000000)
 | 
			
		||||
                {
 | 
			
		||||
                    if ((SymbolName)_symbolName.Value == SymbolName.Blank)
 | 
			
		||||
                    {
 | 
			
		||||
                        //Note: Don't try to optimize it by leaving away the braces in case a single space is added.
 | 
			
		||||
                        //This would lead to confusion with '(' in directly following text.
 | 
			
		||||
                        text = "\\space(" + Count + ")";
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        if (_count == 1)
 | 
			
		||||
                            text = "\\space(" + SymbolName + ")";
 | 
			
		||||
                        else
 | 
			
		||||
                            text = "\\space(" + SymbolName + ", " + Count + ")";
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    text = "\\symbol(" + SymbolName + ")";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                // symbolType is a (unicode) character
 | 
			
		||||
                text = " \\chr(0x" + _symbolName.Value.ToString("X") + ")";
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            serializer.Write(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Character))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										83
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Chars.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Chars.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Character table by name.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public sealed class Chars
 | 
			
		||||
    {
 | 
			
		||||
        // ReSharper disable InconsistentNaming
 | 
			
		||||
        public const char Null = '\0';   // EOF
 | 
			
		||||
        public const char CR = '\x0D'; // ignored by scanner
 | 
			
		||||
        public const char LF = '\x0A';
 | 
			
		||||
        public const char BEL = '\a';   // Bell
 | 
			
		||||
        public const char BS = '\b';   // Backspace
 | 
			
		||||
        public const char FF = '\f';   // Formfeed
 | 
			
		||||
        public const char HT = '\t';   // Horizontal tab
 | 
			
		||||
        public const char VT = '\v';   // Vertical tab
 | 
			
		||||
        public const char NonBreakableSpace = (char)160;  // char(160)
 | 
			
		||||
        // ReSharper restore InconsistentNaming
 | 
			
		||||
 | 
			
		||||
        // The following names come from "PDF Reference Third Edition"
 | 
			
		||||
        // Appendix D.1, Latin Character Set and Encoding
 | 
			
		||||
        public const char Space = ' ';
 | 
			
		||||
        public const char QuoteDbl = '"';
 | 
			
		||||
        public const char QuoteSingle = '\'';
 | 
			
		||||
        public const char ParenLeft = '(';
 | 
			
		||||
        public const char ParenRight = ')';
 | 
			
		||||
        public const char BraceLeft = '{';
 | 
			
		||||
        public const char BraceRight = '}';
 | 
			
		||||
        public const char BracketLeft = '[';
 | 
			
		||||
        public const char BracketRight = ']';
 | 
			
		||||
        public const char Less = '<';
 | 
			
		||||
        public const char Greater = '>';
 | 
			
		||||
        public const char Equal = '=';
 | 
			
		||||
        public const char Period = '.';
 | 
			
		||||
        public const char Semicolon = ';';
 | 
			
		||||
        public const char Colon = ':';
 | 
			
		||||
        public const char Slash = '/';
 | 
			
		||||
        public const char Bar = '|';
 | 
			
		||||
        public const char BackSlash = '\\';
 | 
			
		||||
        public const char Percent = '%';
 | 
			
		||||
        public const char Dollar = '$';
 | 
			
		||||
        public const char At = '@';
 | 
			
		||||
        public const char NumberSign = '#';
 | 
			
		||||
        public const char Question = '?';
 | 
			
		||||
        public const char Hyphen = '-';  // char(45)
 | 
			
		||||
        public const char SoftHyphen = '<27>';  // char(173)
 | 
			
		||||
        public const char Currency = '<27>';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										697
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Color.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										697
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Color.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,697 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The Color class represents an ARGB color value.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [DebuggerDisplay("(A={A}, R={R}, G={G}, B={B} C={C}, M={M}, Y={Y}, K={K})")]
 | 
			
		||||
    public struct Color : INullableValue
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Color class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color(uint argb)
 | 
			
		||||
        {
 | 
			
		||||
            _isCmyk = false;
 | 
			
		||||
            _argb = argb;
 | 
			
		||||
            _a = _c = _m = _y = _k = 0f; // Compiler enforces this line of code
 | 
			
		||||
            InitCmykFromRgb();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Color class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color(byte r, byte g, byte b)
 | 
			
		||||
        {
 | 
			
		||||
            _isCmyk = false;
 | 
			
		||||
            _argb = 0xFF000000 | ((uint)r << 16) | ((uint)g << 8) | b;
 | 
			
		||||
            _a = _c = _m = _y = _k = 0f; // Compiler enforces this line of code
 | 
			
		||||
            InitCmykFromRgb();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Color class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color(byte a, byte r, byte g, byte b)
 | 
			
		||||
        {
 | 
			
		||||
            _isCmyk = false;
 | 
			
		||||
            _argb = ((uint)a << 24) | ((uint)r << 16) | ((uint)g << 8) | b;
 | 
			
		||||
            _a = _c = _m = _y = _k = 0f; // Compiler enforces this line of code
 | 
			
		||||
            InitCmykFromRgb();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Color class with a CMYK color.
 | 
			
		||||
        /// All values must be in a range between 0 to 100 percent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color(double alpha, double cyan, double magenta, double yellow, double black)
 | 
			
		||||
        {
 | 
			
		||||
            _isCmyk = true;
 | 
			
		||||
            _a = (float)(alpha > 100 ? 100 : (alpha < 0 ? 0 : alpha));
 | 
			
		||||
            _c = (float)(cyan > 100 ? 100 : (cyan < 0 ? 0 : cyan));
 | 
			
		||||
            _m = (float)(magenta > 100 ? 100 : (magenta < 0 ? 0 : magenta));
 | 
			
		||||
            _y = (float)(yellow > 100 ? 100 : (yellow < 0 ? 0 : yellow));
 | 
			
		||||
            _k = (float)(black > 100 ? 100 : (black < 0 ? 0 : black));
 | 
			
		||||
            _argb = 0; // Compiler enforces this line of code
 | 
			
		||||
            InitRgbFromCmyk();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Color class with a CMYK color.
 | 
			
		||||
        /// All values must be in a range between 0 to 100 percent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color(double cyan, double magenta, double yellow, double black)
 | 
			
		||||
            : this(100, cyan, magenta, yellow, black)
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        void InitCmykFromRgb()
 | 
			
		||||
        {
 | 
			
		||||
            // Similar formula as in PDFsharp
 | 
			
		||||
            _isCmyk = false;
 | 
			
		||||
            int c = 255 - (int)R;
 | 
			
		||||
            int m = 255 - (int)G;
 | 
			
		||||
            int y = 255 - (int)B;
 | 
			
		||||
            int k = Math.Min(c, Math.Min(m, y));
 | 
			
		||||
            if (k == 255)
 | 
			
		||||
                _c = _m = _y = 0;
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                float black = 255f - k;
 | 
			
		||||
                _c = 100f * (c - k) / black;
 | 
			
		||||
                _m = 100f * (m - k) / black;
 | 
			
		||||
                _y = 100f * (y - k) / black;
 | 
			
		||||
            }
 | 
			
		||||
            _k = 100f * k / 255f;
 | 
			
		||||
            _a = A / 2.55f;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void InitRgbFromCmyk()
 | 
			
		||||
        {
 | 
			
		||||
            // Similar formula as in PDFsharp
 | 
			
		||||
            _isCmyk = true;
 | 
			
		||||
            float black = _k * 2.55f + 0.5f;
 | 
			
		||||
            float factor = (255f - black) / 100f;
 | 
			
		||||
            byte a = (byte)(_a * 2.55 + 0.5);
 | 
			
		||||
            byte r = (byte)(255 - Math.Min(255f, _c * factor + black));
 | 
			
		||||
            byte g = (byte)(255 - Math.Min(255f, _m * factor + black));
 | 
			
		||||
            byte b = (byte)(255 - Math.Min(255f, _y * factor + black));
 | 
			
		||||
            _argb = ((uint)a << 24) | ((uint)r << 16) | ((uint)g << 8) | b;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a value indicating whether this instance is a CMYK color.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsCmyk
 | 
			
		||||
        {
 | 
			
		||||
            get { return _isCmyk; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this color is empty.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsEmpty
 | 
			
		||||
        {
 | 
			
		||||
            get { return this == Empty; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        object INullableValue.GetValue()
 | 
			
		||||
        {
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the given value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void INullableValue.SetValue(object value)
 | 
			
		||||
        {
 | 
			
		||||
            if (value is uint)
 | 
			
		||||
                _argb = (uint)value;
 | 
			
		||||
            else
 | 
			
		||||
                this = Parse(value.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Resets this instance, i.e. IsNull() will return true afterwards.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void INullableValue.SetNull()
 | 
			
		||||
        {
 | 
			
		||||
            this = Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance is null (not set).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        bool INullableValue.IsNull
 | 
			
		||||
        {
 | 
			
		||||
            get { return this == Empty; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance is null (not set).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsNull
 | 
			
		||||
        {
 | 
			
		||||
            get { return this == Empty; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the ARGB value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public uint Argb
 | 
			
		||||
        {
 | 
			
		||||
            get { return _argb; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (_isCmyk)
 | 
			
		||||
                    throw new InvalidOperationException("Cannot change a CMYK color.");
 | 
			
		||||
                _argb = value;
 | 
			
		||||
                InitCmykFromRgb();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the RGB value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public uint RGB
 | 
			
		||||
        {
 | 
			
		||||
            get { return _argb; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (_isCmyk)
 | 
			
		||||
                    throw new InvalidOperationException("Cannot change a CMYK color.");
 | 
			
		||||
                _argb = value;
 | 
			
		||||
                InitCmykFromRgb();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Calls base class Equals.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override bool Equals(Object obj)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is Color)
 | 
			
		||||
            {
 | 
			
		||||
                Color color = (Color)obj;
 | 
			
		||||
                if (_isCmyk ^ color._isCmyk)
 | 
			
		||||
                    return false;
 | 
			
		||||
                if (_isCmyk)
 | 
			
		||||
                    return _a == color._a && _c == color._c && _m == color._m && _y == color._y && _k == color._k;
 | 
			
		||||
                return _argb == color._argb;
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the ARGB value that this Color instance represents.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override int GetHashCode()
 | 
			
		||||
        {
 | 
			
		||||
            return (int)_argb ^ _a.GetHashCode() ^ _c.GetHashCode() ^ _m.GetHashCode() ^ _y.GetHashCode() ^ _k.GetHashCode();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Compares two color objects. True if both argb values are equal, false otherwise.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static bool operator ==(Color color1, Color color2)
 | 
			
		||||
        {
 | 
			
		||||
            if (color1._isCmyk ^ color2._isCmyk)
 | 
			
		||||
                return false;
 | 
			
		||||
            if (color1._isCmyk)
 | 
			
		||||
                return color1._a == color2._a && color1._c == color2._c && color1._m == color2._m && color1._y == color2._y && color1._k == color2._k;
 | 
			
		||||
            return color1._argb == color2._argb;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Compares two color objects. True if both argb values are not equal, false otherwise.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static bool operator !=(Color color1, Color color2)
 | 
			
		||||
        {
 | 
			
		||||
            return !(color1 == color2);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Parses the string and returns a color object.
 | 
			
		||||
        /// Throws ArgumentException if color is invalid.
 | 
			
		||||
        /// Supports four different formats for hex colors.
 | 
			
		||||
        /// Format 1: uses prefix "0x", followed by as many hex digits as needed. Important: do not forget the opacity, so use 7 or 8 digits.
 | 
			
		||||
        /// Format 2: uses prefix "#", followed by exactly 8 digits including opacity.
 | 
			
		||||
        /// Format 3: uses prefix "#", followed by exactly 6 digits; opacity will be 0xff.
 | 
			
		||||
        /// Format 4: uses prefix "#", followed by exactly 3 digits; opacity will be 0xff; "#ccc" will be treated as "#ffcccccc", "#d24" will be treated as "#ffdd2244".
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="color">integer, hex or color name.</param>
 | 
			
		||||
        public static Color Parse(string color)
 | 
			
		||||
        {
 | 
			
		||||
            if (color == null)
 | 
			
		||||
                throw new ArgumentNullException("color");
 | 
			
		||||
            if (color == "")
 | 
			
		||||
                throw new ArgumentException("color");
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                uint clr;
 | 
			
		||||
                // Must use Enum.Parse because Enum.IsDefined is case sensitive
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    object obj = Enum.Parse(typeof(ColorName), color, true);
 | 
			
		||||
                    clr = (uint)obj;
 | 
			
		||||
                    return new Color(clr);
 | 
			
		||||
                }
 | 
			
		||||
                catch
 | 
			
		||||
                {
 | 
			
		||||
                    // Ignore exception because it's not a ColorName.
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                NumberStyles numberStyle = NumberStyles.Integer;
 | 
			
		||||
                string number = color.ToLower();
 | 
			
		||||
                if (number.StartsWith("0x"))
 | 
			
		||||
                {
 | 
			
		||||
                    numberStyle = NumberStyles.HexNumber;
 | 
			
		||||
                    number = color.Substring(2);
 | 
			
		||||
                }
 | 
			
		||||
                else if (number.StartsWith("#"))
 | 
			
		||||
                {
 | 
			
		||||
                    numberStyle = NumberStyles.HexNumber;
 | 
			
		||||
                    switch (color.Length)
 | 
			
		||||
                    {
 | 
			
		||||
                        case 9:
 | 
			
		||||
                            number = color.Substring(1);
 | 
			
		||||
                            break;
 | 
			
		||||
                        case 7:
 | 
			
		||||
                            number = "ff" + color.Substring(1);
 | 
			
		||||
                            break;
 | 
			
		||||
                        case 4:
 | 
			
		||||
                            number = "ff" + color.Substring(1,1) + color.Substring(1, 1) + 
 | 
			
		||||
                                     color.Substring(2, 1) + color.Substring(2, 1) + 
 | 
			
		||||
                                     color.Substring(3, 1) + color.Substring(3, 1);
 | 
			
		||||
                            break;
 | 
			
		||||
                        default:
 | 
			
		||||
                            throw new ArgumentException(DomSR.InvalidColorString(color), "color");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                clr = uint.Parse(number, numberStyle);
 | 
			
		||||
                return new Color(clr);
 | 
			
		||||
            }
 | 
			
		||||
            catch (FormatException ex)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentException(DomSR.InvalidColorString(color), ex);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the alpha (transparency) part of the RGB Color.
 | 
			
		||||
        /// The values is in the range between 0 to 255.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public uint A
 | 
			
		||||
        {
 | 
			
		||||
            get { return (_argb & 0xFF000000) >> 24; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the red part of the Color.
 | 
			
		||||
        /// The values is in the range between 0 to 255.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public uint R
 | 
			
		||||
        {
 | 
			
		||||
            get { return (_argb & 0xFF0000) >> 16; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the green part of the Color.
 | 
			
		||||
        /// The values is in the range between 0 to 255.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public uint G
 | 
			
		||||
        {
 | 
			
		||||
            get { return (_argb & 0x00FF00) >> 8; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the blue part of the Color.
 | 
			
		||||
        /// The values is in the range between 0 to 255.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public uint B
 | 
			
		||||
        {
 | 
			
		||||
            get { return _argb & 0x0000FF; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the alpha (transparency) part of the CMYK Color.
 | 
			
		||||
        /// The values is in the range between 0 (transparent) to 100 (opaque) percent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double Alpha
 | 
			
		||||
        {
 | 
			
		||||
            get { return _a; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the cyan part of the Color.
 | 
			
		||||
        /// The values is in the range between 0 to 100 percent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double C
 | 
			
		||||
        {
 | 
			
		||||
            get { return _c; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the magenta part of the Color.
 | 
			
		||||
        /// The values is in the range between 0 to 100 percent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double M
 | 
			
		||||
        {
 | 
			
		||||
            get { return _m; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the yellow part of the Color.
 | 
			
		||||
        /// The values is in the range between 0 to 100 percent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double Y
 | 
			
		||||
        {
 | 
			
		||||
            get { return _y; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the key (black) part of the Color.
 | 
			
		||||
        /// The values is in the range between 0 to 100 percent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double K
 | 
			
		||||
        {
 | 
			
		||||
            get { return _k; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a non transparent color brightened in terms of transparency if any is given(A < 255),
 | 
			
		||||
        /// otherwise this instance itself.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color GetMixedTransparencyColor()
 | 
			
		||||
        {
 | 
			
		||||
            int alpha = (int)A;
 | 
			
		||||
            if (alpha == 0xFF)
 | 
			
		||||
                return this;
 | 
			
		||||
 | 
			
		||||
            int red = (int)R;
 | 
			
		||||
            int green = (int)G;
 | 
			
		||||
            int blue = (int)B;
 | 
			
		||||
 | 
			
		||||
            double whiteFactor = 1 - alpha / 255.0;
 | 
			
		||||
 | 
			
		||||
            red = (int)(red + (255 - red) * whiteFactor);
 | 
			
		||||
            green = (int)(green + (255 - green) * whiteFactor);
 | 
			
		||||
            blue = (int)(blue + (255 - blue) * whiteFactor);
 | 
			
		||||
            return new Color((uint)(0xFF << 24 | (red << 16) | (green << 8) | blue));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the Color object in its hexadecimal value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override string ToString()
 | 
			
		||||
        {
 | 
			
		||||
            if (_stdColors == null)
 | 
			
		||||
            {
 | 
			
		||||
#if !SILVERLIGHT
 | 
			
		||||
                Array colorNames = Enum.GetNames(typeof(ColorName));
 | 
			
		||||
                Array colorValues = Enum.GetValues(typeof(ColorName));
 | 
			
		||||
                int count = colorNames.GetLength(0);
 | 
			
		||||
                _stdColors = new Dictionary<uint, string>(count);
 | 
			
		||||
                for (int index = 0; index < count; index++)
 | 
			
		||||
                {
 | 
			
		||||
                    string c = (string)colorNames.GetValue(index);
 | 
			
		||||
                    uint d = (uint)colorValues.GetValue(index);
 | 
			
		||||
                    // Some color are double named...
 | 
			
		||||
                    // Aqua == Cyan
 | 
			
		||||
                    // Fuchsia == Magenta
 | 
			
		||||
                    Style key = new Style();
 | 
			
		||||
                    if (!_stdColors.ContainsKey(d))
 | 
			
		||||
                        _stdColors.Add(d, c);
 | 
			
		||||
                }
 | 
			
		||||
#else
 | 
			
		||||
        _stdColors = new Dictionary<uint, string>();
 | 
			
		||||
        _stdColors.Add(0xFFF0F8FF, "AliceBlue");
 | 
			
		||||
        _stdColors.Add(0xFFFAEBD7, "AntiqueWhite");
 | 
			
		||||
        _stdColors.Add(0xFF00FFFF, "Aqua");
 | 
			
		||||
        _stdColors.Add(0xFF7FFFD4, "Aquamarine");
 | 
			
		||||
        _stdColors.Add(0xFFF0FFFF, "Azure");
 | 
			
		||||
        _stdColors.Add(0xFFF5F5DC, "Beige");
 | 
			
		||||
        _stdColors.Add(0xFFFFE4C4, "Bisque");
 | 
			
		||||
        _stdColors.Add(0xFF000000, "Black");
 | 
			
		||||
        _stdColors.Add(0xFFFFEBCD, "BlanchedAlmond");
 | 
			
		||||
        _stdColors.Add(0xFF0000FF, "Blue");
 | 
			
		||||
        _stdColors.Add(0xFF8A2BE2, "BlueViolet");
 | 
			
		||||
        _stdColors.Add(0xFFA52A2A, "Brown");
 | 
			
		||||
        _stdColors.Add(0xFFDEB887, "BurlyWood");
 | 
			
		||||
        _stdColors.Add(0xFF5F9EA0, "CadetBlue");
 | 
			
		||||
        _stdColors.Add(0xFF7FFF00, "Chartreuse");
 | 
			
		||||
        _stdColors.Add(0xFFD2691E, "Chocolate");
 | 
			
		||||
        _stdColors.Add(0xFFFF7F50, "Coral");
 | 
			
		||||
        _stdColors.Add(0xFF6495ED, "CornflowerBlue");
 | 
			
		||||
        _stdColors.Add(0xFFFFF8DC, "Cornsilk");
 | 
			
		||||
        _stdColors.Add(0xFFDC143C, "Crimson");
 | 
			
		||||
        //_stdColors.Add(0xFF00FFFF, "Cyan"); already added as "Aqua"
 | 
			
		||||
        _stdColors.Add(0xFF00008B, "DarkBlue");
 | 
			
		||||
        _stdColors.Add(0xFF008B8B, "DarkCyan");
 | 
			
		||||
        _stdColors.Add(0xFFB8860B, "DarkGoldenrod");
 | 
			
		||||
        _stdColors.Add(0xFFA9A9A9, "DarkGray");
 | 
			
		||||
        _stdColors.Add(0xFF006400, "DarkGreen");
 | 
			
		||||
        _stdColors.Add(0xFFBDB76B, "DarkKhaki");
 | 
			
		||||
        _stdColors.Add(0xFF8B008B, "DarkMagenta");
 | 
			
		||||
        _stdColors.Add(0xFF556B2F, "DarkOliveGreen");
 | 
			
		||||
        _stdColors.Add(0xFFFF8C00, "DarkOrange");
 | 
			
		||||
        _stdColors.Add(0xFF9932CC, "DarkOrchid");
 | 
			
		||||
        _stdColors.Add(0xFF8B0000, "DarkRed");
 | 
			
		||||
        _stdColors.Add(0xFFE9967A, "DarkSalmon");
 | 
			
		||||
        _stdColors.Add(0xFF8FBC8B, "DarkSeaGreen");
 | 
			
		||||
        _stdColors.Add(0xFF483D8B, "DarkSlateBlue");
 | 
			
		||||
        _stdColors.Add(0xFF2F4F4F, "DarkSlateGray");
 | 
			
		||||
        _stdColors.Add(0xFF00CED1, "DarkTurquoise");
 | 
			
		||||
        _stdColors.Add(0xFF9400D3, "DarkViolet");
 | 
			
		||||
        _stdColors.Add(0xFFFF1493, "DeepPink");
 | 
			
		||||
        _stdColors.Add(0xFF00BFFF, "DeepSkyBlue");
 | 
			
		||||
        _stdColors.Add(0xFF696969, "DimGray");
 | 
			
		||||
        _stdColors.Add(0xFF1E90FF, "DodgerBlue");
 | 
			
		||||
        _stdColors.Add(0xFFB22222, "Firebrick");
 | 
			
		||||
        _stdColors.Add(0xFFFFFAF0, "FloralWhite");
 | 
			
		||||
        _stdColors.Add(0xFF228B22, "ForestGreen");
 | 
			
		||||
        _stdColors.Add(0xFFFF00FF, "Fuchsia");
 | 
			
		||||
        _stdColors.Add(0xFFDCDCDC, "Gainsboro");
 | 
			
		||||
        _stdColors.Add(0xFFF8F8FF, "GhostWhite");
 | 
			
		||||
        _stdColors.Add(0xFFFFD700, "Gold");
 | 
			
		||||
        _stdColors.Add(0xFFDAA520, "Goldenrod");
 | 
			
		||||
        _stdColors.Add(0xFF808080, "Gray");
 | 
			
		||||
        _stdColors.Add(0xFF008000, "Green");
 | 
			
		||||
        _stdColors.Add(0xFFADFF2F, "GreenYellow");
 | 
			
		||||
        _stdColors.Add(0xFFF0FFF0, "Honeydew");
 | 
			
		||||
        _stdColors.Add(0xFFFF69B4, "HotPink");
 | 
			
		||||
        _stdColors.Add(0xFFCD5C5C, "IndianRed");
 | 
			
		||||
        _stdColors.Add(0xFF4B0082, "Indigo");
 | 
			
		||||
        _stdColors.Add(0xFFFFFFF0, "Ivory");
 | 
			
		||||
        _stdColors.Add(0xFFF0E68C, "Khaki");
 | 
			
		||||
        _stdColors.Add(0xFFE6E6FA, "Lavender");
 | 
			
		||||
        _stdColors.Add(0xFFFFF0F5, "LavenderBlush");
 | 
			
		||||
        _stdColors.Add(0xFF7CFC00, "LawnGreen");
 | 
			
		||||
        _stdColors.Add(0xFFFFFACD, "LemonChiffon");
 | 
			
		||||
        _stdColors.Add(0xFFADD8E6, "LightBlue");
 | 
			
		||||
        _stdColors.Add(0xFFF08080, "LightCoral");
 | 
			
		||||
        _stdColors.Add(0xFFE0FFFF, "LightCyan");
 | 
			
		||||
        _stdColors.Add(0xFFFAFAD2, "LightGoldenrodYellow");
 | 
			
		||||
        _stdColors.Add(0xFFD3D3D3, "LightGray");
 | 
			
		||||
        _stdColors.Add(0xFF90EE90, "LightGreen");
 | 
			
		||||
        _stdColors.Add(0xFFFFB6C1, "LightPink");
 | 
			
		||||
        _stdColors.Add(0xFFFFA07A, "LightSalmon");
 | 
			
		||||
        _stdColors.Add(0xFF20B2AA, "LightSeaGreen");
 | 
			
		||||
        _stdColors.Add(0xFF87CEFA, "LightSkyBlue");
 | 
			
		||||
        _stdColors.Add(0xFF778899, "LightSlateGray");
 | 
			
		||||
        _stdColors.Add(0xFFB0C4DE, "LightSteelBlue");
 | 
			
		||||
        _stdColors.Add(0xFFFFFFE0, "LightYellow");
 | 
			
		||||
        _stdColors.Add(0xFF00FF00, "Lime");
 | 
			
		||||
        _stdColors.Add(0xFF32CD32, "LimeGreen");
 | 
			
		||||
        _stdColors.Add(0xFFFAF0E6, "Linen");
 | 
			
		||||
        // _stdColors.Add(0xFFFF00FF, "Magenta"); already added as "Fuchsia"
 | 
			
		||||
        _stdColors.Add(0xFF800000, "Maroon");
 | 
			
		||||
        _stdColors.Add(0xFF66CDAA, "MediumAquamarine");
 | 
			
		||||
        _stdColors.Add(0xFF0000CD, "MediumBlue");
 | 
			
		||||
        _stdColors.Add(0xFFBA55D3, "MediumOrchid");
 | 
			
		||||
        _stdColors.Add(0xFF9370DB, "MediumPurple");
 | 
			
		||||
        _stdColors.Add(0xFF3CB371, "MediumSeaGreen");
 | 
			
		||||
        _stdColors.Add(0xFF7B68EE, "MediumSlateBlue");
 | 
			
		||||
        _stdColors.Add(0xFF00FA9A, "MediumSpringGreen");
 | 
			
		||||
        _stdColors.Add(0xFF48D1CC, "MediumTurquoise");
 | 
			
		||||
        _stdColors.Add(0xFFC71585, "MediumVioletRed");
 | 
			
		||||
        _stdColors.Add(0xFF191970, "MidnightBlue");
 | 
			
		||||
        _stdColors.Add(0xFFF5FFFA, "MintCream");
 | 
			
		||||
        _stdColors.Add(0xFFFFE4E1, "MistyRose");
 | 
			
		||||
        _stdColors.Add(0xFFFFE4B5, "Moccasin");
 | 
			
		||||
        _stdColors.Add(0xFFFFDEAD, "NavajoWhite");
 | 
			
		||||
        _stdColors.Add(0xFF000080, "Navy");
 | 
			
		||||
        _stdColors.Add(0xFFFDF5E6, "OldLace");
 | 
			
		||||
        _stdColors.Add(0xFF808000, "Olive");
 | 
			
		||||
        _stdColors.Add(0xFF6B8E23, "OliveDrab");
 | 
			
		||||
        _stdColors.Add(0xFFFFA500, "Orange");
 | 
			
		||||
        _stdColors.Add(0xFFFF4500, "OrangeRed");
 | 
			
		||||
        _stdColors.Add(0xFFDA70D6, "Orchid");
 | 
			
		||||
        _stdColors.Add(0xFFEEE8AA, "PaleGoldenrod");
 | 
			
		||||
        _stdColors.Add(0xFF98FB98, "PaleGreen");
 | 
			
		||||
        _stdColors.Add(0xFFAFEEEE, "PaleTurquoise");
 | 
			
		||||
        _stdColors.Add(0xFFDB7093, "PaleVioletRed");
 | 
			
		||||
        _stdColors.Add(0xFFFFEFD5, "PapayaWhip");
 | 
			
		||||
        _stdColors.Add(0xFFFFDAB9, "PeachPuff");
 | 
			
		||||
        _stdColors.Add(0xFFCD853F, "Peru");
 | 
			
		||||
        _stdColors.Add(0xFFFFC0CB, "Pink");
 | 
			
		||||
        _stdColors.Add(0xFFDDA0DD, "Plum");
 | 
			
		||||
        _stdColors.Add(0xFFB0E0E6, "PowderBlue");
 | 
			
		||||
        _stdColors.Add(0xFF800080, "Purple");
 | 
			
		||||
        _stdColors.Add(0xFFFF0000, "Red");
 | 
			
		||||
        _stdColors.Add(0xFFBC8F8F, "RosyBrown");
 | 
			
		||||
        _stdColors.Add(0xFF4169E1, "RoyalBlue");
 | 
			
		||||
        _stdColors.Add(0xFF8B4513, "SaddleBrown");
 | 
			
		||||
        _stdColors.Add(0xFFFA8072, "Salmon");
 | 
			
		||||
        _stdColors.Add(0xFFF4A460, "SandyBrown");
 | 
			
		||||
        _stdColors.Add(0xFF2E8B57, "SeaGreen");
 | 
			
		||||
        _stdColors.Add(0xFFFFF5EE, "SeaShell");
 | 
			
		||||
        _stdColors.Add(0xFFA0522D, "Sienna");
 | 
			
		||||
        _stdColors.Add(0xFFC0C0C0, "Silver");
 | 
			
		||||
        _stdColors.Add(0xFF87CEEB, "SkyBlue");
 | 
			
		||||
        _stdColors.Add(0xFF6A5ACD, "SlateBlue");
 | 
			
		||||
        _stdColors.Add(0xFF708090, "SlateGray");
 | 
			
		||||
        _stdColors.Add(0xFFFFFAFA, "Snow");
 | 
			
		||||
        _stdColors.Add(0xFF00FF7F, "SpringGreen");
 | 
			
		||||
        _stdColors.Add(0xFF4682B4, "SteelBlue");
 | 
			
		||||
        _stdColors.Add(0xFFD2B48C, "Tan");
 | 
			
		||||
        _stdColors.Add(0xFF008080, "Teal");
 | 
			
		||||
        _stdColors.Add(0xFFD8BFD8, "Thistle");
 | 
			
		||||
        _stdColors.Add(0xFFFF6347, "Tomato");
 | 
			
		||||
        _stdColors.Add(0x00FFFFFF, "Transparent");
 | 
			
		||||
        _stdColors.Add(0xFF40E0D0, "Turquoise");
 | 
			
		||||
        _stdColors.Add(0xFFEE82EE, "Violet");
 | 
			
		||||
        _stdColors.Add(0xFFF5DEB3, "Wheat");
 | 
			
		||||
        _stdColors.Add(0xFFFFFFFF, "White");
 | 
			
		||||
        _stdColors.Add(0xFFF5F5F5, "WhiteSmoke");
 | 
			
		||||
        _stdColors.Add(0xFFFFFF00, "Yellow");
 | 
			
		||||
        _stdColors.Add(0xFF9ACD32, "YellowGreen");
 | 
			
		||||
#endif
 | 
			
		||||
            }
 | 
			
		||||
            if (_isCmyk)
 | 
			
		||||
            {
 | 
			
		||||
                string s;
 | 
			
		||||
                if (Alpha == 100.0)
 | 
			
		||||
                    s = String.Format(CultureInfo.InvariantCulture, "CMYK({0:0.##},{1:0.##},{2:0.##},{3:0.##})", C, M, Y, K);
 | 
			
		||||
                else
 | 
			
		||||
                    s = String.Format(CultureInfo.InvariantCulture, "CMYK({0:0.##},{1:0.##},{2:0.##},{3:0.##},{4:0.##})", Alpha, C, M, Y, K);
 | 
			
		||||
                return s;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                if (_stdColors.ContainsKey(_argb))
 | 
			
		||||
                    return _stdColors[_argb];
 | 
			
		||||
                if ((_argb & 0xFF000000) == 0xFF000000)
 | 
			
		||||
                    return "RGB(" +
 | 
			
		||||
                           ((_argb & 0xFF0000) >> 16) + "," +
 | 
			
		||||
                           ((_argb & 0x00FF00) >> 8) + "," +
 | 
			
		||||
                           (_argb & 0x0000FF) + ")";
 | 
			
		||||
                return "0x" + _argb.ToString("X");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        static Dictionary<uint, string> _stdColors;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates an RGB color from an existing color with a new alpha (transparency) value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Color FromRgbColor(byte a, Color color)
 | 
			
		||||
        {
 | 
			
		||||
            return new Color(a, (byte)color.R, (byte)color.G, (byte)color.B);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates an RGB color from red, green, and blue.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Color FromRgb(byte r, byte g, byte b)
 | 
			
		||||
        {
 | 
			
		||||
            return new Color(255, r, g, b);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates an RGB color from alpha, red, green, and blue.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Color FromArgb(byte alpha, byte r, byte g, byte b)
 | 
			
		||||
        {
 | 
			
		||||
            return new Color(alpha, r, g, b);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a Color structure from the specified CMYK values.
 | 
			
		||||
        /// All values must be in a range between 0 to 100 percent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Color FromCmyk(double cyan, double magenta, double yellow, double black)
 | 
			
		||||
        {
 | 
			
		||||
            return new Color(cyan, magenta, yellow, black);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a Color structure from the specified CMYK values.
 | 
			
		||||
        /// All values must be in a range between 0 to 100 percent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Color FromCmyk(double alpha, double cyan, double magenta, double yellow, double black)
 | 
			
		||||
        {
 | 
			
		||||
            return new Color(alpha, cyan, magenta, yellow, black);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a CMYK color from an existing color with a new alpha (transparency) value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Color FromCmykColor(double alpha, Color color)
 | 
			
		||||
        {
 | 
			
		||||
            return new Color(alpha, color.C, color.M, color.Y, color.K);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        uint _argb; // ARGB
 | 
			
		||||
        bool _isCmyk;
 | 
			
		||||
        private float _a; // \
 | 
			
		||||
        private float _c; // |
 | 
			
		||||
        private float _m; // |--- alpha + CMYK
 | 
			
		||||
        private float _y; // |
 | 
			
		||||
        private float _k; // /
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Represents a null color.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Empty = new Color(0);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										745
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Colors.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										745
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Colors.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,745 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents 141 predefined colors.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class Colors
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF0F8FF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color AliceBlue = new Color(0xFFF0F8FF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFAEBD7.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color AntiqueWhite = new Color(0xFFFAEBD7);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF00FFFF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Aqua = new Color(0xFF00FFFF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF7FFFD4.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Aquamarine = new Color(0xFF7FFFD4);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF0FFFF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Azure = new Color(0xFFF0FFFF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF5F5DC.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Beige = new Color(0xFFF5F5DC);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFE4C4.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Bisque = new Color(0xFFFFE4C4);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF000000.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Black = new Color(0xFF000000);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFEBCD.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color BlanchedAlmond = new Color(0xFFFFEBCD);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF0000FF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Blue = new Color(0xFF0000FF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF8A2BE2.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color BlueViolet = new Color(0xFF8A2BE2);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFA52A2A.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Brown = new Color(0xFFA52A2A);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFDEB887.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color BurlyWood = new Color(0xFFDEB887);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF5F9EA0.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color CadetBlue = new Color(0xFF5F9EA0);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF7FFF00.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Chartreuse = new Color(0xFF7FFF00);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFD2691E.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Chocolate = new Color(0xFFD2691E);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFF7F50.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Coral = new Color(0xFFFF7F50);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF6495ED.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color CornflowerBlue = new Color(0xFF6495ED);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFF8DC.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Cornsilk = new Color(0xFFFFF8DC);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFDC143C.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Crimson = new Color(0xFFDC143C);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF00FFFF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Cyan = new Color(0xFF00FFFF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF00008B.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkBlue = new Color(0xFF00008B);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF008B8B.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkCyan = new Color(0xFF008B8B);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFB8860B.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkGoldenrod = new Color(0xFFB8860B);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFA9A9A9.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkGray = new Color(0xFFA9A9A9);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF006400.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkGreen = new Color(0xFF006400);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFBDB76B.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkKhaki = new Color(0xFFBDB76B);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF8B008B.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkMagenta = new Color(0xFF8B008B);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF556B2F.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkOliveGreen = new Color(0xFF556B2F);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFF8C00.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkOrange = new Color(0xFFFF8C00);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF9932CC.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkOrchid = new Color(0xFF9932CC);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF8B0000.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkRed = new Color(0xFF8B0000);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFE9967A.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkSalmon = new Color(0xFFE9967A);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF8FBC8B.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkSeaGreen = new Color(0xFF8FBC8B);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF483D8B.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkSlateBlue = new Color(0xFF483D8B);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF2F4F4F.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkSlateGray = new Color(0xFF2F4F4F);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF00CED1.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkTurquoise = new Color(0xFF00CED1);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF9400D3.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DarkViolet = new Color(0xFF9400D3);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFF1493.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DeepPink = new Color(0xFFFF1493);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF00BFFF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DeepSkyBlue = new Color(0xFF00BFFF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF696969.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DimGray = new Color(0xFF696969);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF1E90FF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color DodgerBlue = new Color(0xFF1E90FF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFB22222.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Firebrick = new Color(0xFFB22222);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFFAF0.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color FloralWhite = new Color(0xFFFFFAF0);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF228B22.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color ForestGreen = new Color(0xFF228B22);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFF00FF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Fuchsia = new Color(0xFFFF00FF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFDCDCDC.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Gainsboro = new Color(0xFFDCDCDC);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF8F8FF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color GhostWhite = new Color(0xFFF8F8FF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFD700.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Gold = new Color(0xFFFFD700);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFDAA520.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Goldenrod = new Color(0xFFDAA520);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF808080.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Gray = new Color(0xFF808080);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF008000.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Green = new Color(0xFF008000);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFADFF2F.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color GreenYellow = new Color(0xFFADFF2F);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF0FFF0.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Honeydew = new Color(0xFFF0FFF0);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFF69B4.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color HotPink = new Color(0xFFFF69B4);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFCD5C5C.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color IndianRed = new Color(0xFFCD5C5C);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF4B0082.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Indigo = new Color(0xFF4B0082);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFFFF0.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Ivory = new Color(0xFFFFFFF0);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF0E68C.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Khaki = new Color(0xFFF0E68C);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFE6E6FA.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Lavender = new Color(0xFFE6E6FA);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFF0F5.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LavenderBlush = new Color(0xFFFFF0F5);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF7CFC00.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LawnGreen = new Color(0xFF7CFC00);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFFACD.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LemonChiffon = new Color(0xFFFFFACD);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFADD8E6.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightBlue = new Color(0xFFADD8E6);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF08080.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightCoral = new Color(0xFFF08080);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFE0FFFF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightCyan = new Color(0xFFE0FFFF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFAFAD2.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightGoldenrodYellow = new Color(0xFFFAFAD2);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFD3D3D3.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightGray = new Color(0xFFD3D3D3);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF90EE90.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightGreen = new Color(0xFF90EE90);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFB6C1.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightPink = new Color(0xFFFFB6C1);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFA07A.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightSalmon = new Color(0xFFFFA07A);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF20B2AA.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightSeaGreen = new Color(0xFF20B2AA);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF87CEFA.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightSkyBlue = new Color(0xFF87CEFA);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF778899.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightSlateGray = new Color(0xFF778899);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFB0C4DE.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightSteelBlue = new Color(0xFFB0C4DE);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFFFE0.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LightYellow = new Color(0xFFFFFFE0);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF00FF00.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Lime = new Color(0xFF00FF00);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF32CD32.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color LimeGreen = new Color(0xFF32CD32);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFAF0E6.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Linen = new Color(0xFFFAF0E6);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFF00FF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Magenta = new Color(0xFFFF00FF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF800000.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Maroon = new Color(0xFF800000);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF66CDAA.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MediumAquamarine = new Color(0xFF66CDAA);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF0000CD.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MediumBlue = new Color(0xFF0000CD);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFBA55D3.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MediumOrchid = new Color(0xFFBA55D3);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF9370DB.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MediumPurple = new Color(0xFF9370DB);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF3CB371.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MediumSeaGreen = new Color(0xFF3CB371);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF7B68EE.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MediumSlateBlue = new Color(0xFF7B68EE);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF00FA9A.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MediumSpringGreen = new Color(0xFF00FA9A);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF48D1CC.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MediumTurquoise = new Color(0xFF48D1CC);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFC71585.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MediumVioletRed = new Color(0xFFC71585);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF191970.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MidnightBlue = new Color(0xFF191970);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF5FFFA.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MintCream = new Color(0xFFF5FFFA);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFE4E1.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color MistyRose = new Color(0xFFFFE4E1);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFE4B5.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Moccasin = new Color(0xFFFFE4B5);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFDEAD.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color NavajoWhite = new Color(0xFFFFDEAD);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF000080.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Navy = new Color(0xFF000080);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFDF5E6.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color OldLace = new Color(0xFFFDF5E6);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF808000.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Olive = new Color(0xFF808000);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF6B8E23.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color OliveDrab = new Color(0xFF6B8E23);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFA500.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Orange = new Color(0xFFFFA500);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFF4500.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color OrangeRed = new Color(0xFFFF4500);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFDA70D6.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Orchid = new Color(0xFFDA70D6);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFEEE8AA.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color PaleGoldenrod = new Color(0xFFEEE8AA);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF98FB98.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color PaleGreen = new Color(0xFF98FB98);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFAFEEEE.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color PaleTurquoise = new Color(0xFFAFEEEE);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFDB7093.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color PaleVioletRed = new Color(0xFFDB7093);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFEFD5.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color PapayaWhip = new Color(0xFFFFEFD5);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFDAB9.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color PeachPuff = new Color(0xFFFFDAB9);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFCD853F.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Peru = new Color(0xFFCD853F);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFC0CB.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Pink = new Color(0xFFFFC0CB);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFDDA0DD.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Plum = new Color(0xFFDDA0DD);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFB0E0E6.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color PowderBlue = new Color(0xFFB0E0E6);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF800080.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Purple = new Color(0xFF800080);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFF0000.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Red = new Color(0xFFFF0000);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFBC8F8F.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color RosyBrown = new Color(0xFFBC8F8F);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF4169E1.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color RoyalBlue = new Color(0xFF4169E1);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF8B4513.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color SaddleBrown = new Color(0xFF8B4513);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFA8072.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Salmon = new Color(0xFFFA8072);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF4A460.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color SandyBrown = new Color(0xFFF4A460);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF2E8B57.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color SeaGreen = new Color(0xFF2E8B57);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFF5EE.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color SeaShell = new Color(0xFFFFF5EE);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFA0522D.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Sienna = new Color(0xFFA0522D);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFC0C0C0.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Silver = new Color(0xFFC0C0C0);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF87CEEB.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color SkyBlue = new Color(0xFF87CEEB);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF6A5ACD.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color SlateBlue = new Color(0xFF6A5ACD);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF708090.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color SlateGray = new Color(0xFF708090);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFFAFA.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Snow = new Color(0xFFFFFAFA);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF00FF7F.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color SpringGreen = new Color(0xFF00FF7F);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF4682B4.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color SteelBlue = new Color(0xFF4682B4);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFD2B48C.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Tan = new Color(0xFFD2B48C);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF008080.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Teal = new Color(0xFF008080);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFD8BFD8.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Thistle = new Color(0xFFD8BFD8);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFF6347.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Tomato = new Color(0xFFFF6347);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #00FFFFFF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Transparent = new Color(0x00FFFFFF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF40E0D0.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Turquoise = new Color(0xFF40E0D0);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFEE82EE.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Violet = new Color(0xFFEE82EE);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF5DEB3.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Wheat = new Color(0xFFF5DEB3);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFFFFF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color White = new Color(0xFFFFFFFF);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFF5F5F5.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color WhiteSmoke = new Color(0xFFF5F5F5);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FFFFFF00.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color Yellow = new Color(0xFFFFFF00);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the system-defined color that has the ARGB value of #FF9ACD32.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Color YellowGreen = new Color(0xFF9ACD32);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										173
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/DdlEncoder.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										173
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/DdlEncoder.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,173 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Provides functions for encoding and decoding of DDL text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public sealed class DdlEncoder
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DdlEncoder class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        DdlEncoder()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts a string into a text phrase.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string StringToText(string str)
 | 
			
		||||
        {
 | 
			
		||||
            if (str == null)
 | 
			
		||||
                return null;
 | 
			
		||||
 | 
			
		||||
            int length = str.Length;
 | 
			
		||||
            StringBuilder strb = new StringBuilder(length + (length >> 2));
 | 
			
		||||
            for (int index = 0; index < length; ++index)
 | 
			
		||||
            {
 | 
			
		||||
                // Don't convert characters into DDL.
 | 
			
		||||
                char ch = str[index];
 | 
			
		||||
                switch (ch)
 | 
			
		||||
                {
 | 
			
		||||
                    case '\\':
 | 
			
		||||
                        strb.Append("\\\\");
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    case '{':
 | 
			
		||||
                        strb.Append("\\{");
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    case '}':
 | 
			
		||||
                        strb.Append("\\}");
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    // escape comments
 | 
			
		||||
                    case '/':
 | 
			
		||||
                        if (index < length - 1 && str[index + 1] == '/')
 | 
			
		||||
                        {
 | 
			
		||||
                            strb.Append("\\//");
 | 
			
		||||
                            ++index;
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                            strb.Append("/");
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    default:
 | 
			
		||||
                        strb.Append(ch);
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return strb.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts a string into a string literal (a quoted string).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string StringToLiteral(string str)
 | 
			
		||||
        {
 | 
			
		||||
            int length = 0;
 | 
			
		||||
            if (str == null || (length = str.Length) == 0)
 | 
			
		||||
                return "\"\"";
 | 
			
		||||
 | 
			
		||||
            StringBuilder strb = new StringBuilder(length + (int)(length >> 2));
 | 
			
		||||
            strb.Append("\"");
 | 
			
		||||
            for (int index = 0; index < length; ++index)
 | 
			
		||||
            {
 | 
			
		||||
                char ch = str[index];
 | 
			
		||||
                switch (ch)
 | 
			
		||||
                {
 | 
			
		||||
                    case '\\':
 | 
			
		||||
                        strb.Append("\\\\");
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    case '"':
 | 
			
		||||
                        strb.Append("\\\"");
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    default:
 | 
			
		||||
                        strb.Append(ch);
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            strb.Append("\"");
 | 
			
		||||
 | 
			
		||||
            return strb.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Scans the given string for characters which are invalid for identifiers.
 | 
			
		||||
        /// Strings are limited to 64 characters.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static bool IsDdeIdentifier(string name)
 | 
			
		||||
        {
 | 
			
		||||
            if (String.IsNullOrEmpty(name))
 | 
			
		||||
                return false;
 | 
			
		||||
 | 
			
		||||
            int len = name.Length;
 | 
			
		||||
            if (len > 64)
 | 
			
		||||
                return false;
 | 
			
		||||
 | 
			
		||||
            for (int index = 0; index < len; index++)
 | 
			
		||||
            {
 | 
			
		||||
                char ch = name[index];
 | 
			
		||||
                if (ch == ' ')
 | 
			
		||||
                    return false;
 | 
			
		||||
 | 
			
		||||
                if (index == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!Char.IsLetter(ch) && ch != '_')
 | 
			
		||||
                        return false;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    if (!Char.IsLetterOrDigit(ch) && ch != '_')
 | 
			
		||||
                        return false;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Quotes the given name, if it contains characters which are invalid for identifiers.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string QuoteIfNameContainsBlanks(string name)
 | 
			
		||||
        {
 | 
			
		||||
            if (IsDdeIdentifier(name))
 | 
			
		||||
                return name;
 | 
			
		||||
            return "\"" + name + "\"";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,83 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Under Construction.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
 | 
			
		||||
    public class DdlVisibleAttribute : Attribute
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DdlVisibleAttribute class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DdlVisibleAttribute()
 | 
			
		||||
        {
 | 
			
		||||
            _visible = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DdlVisibleAttribute class with the specified visibility.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DdlVisibleAttribute(bool visible)
 | 
			
		||||
        {
 | 
			
		||||
            _visible = visible;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the visibility.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool Visible
 | 
			
		||||
        {
 | 
			
		||||
            get { return _visible; }
 | 
			
		||||
            set { _visible = value; }
 | 
			
		||||
        }
 | 
			
		||||
        bool _visible;
 | 
			
		||||
 | 
			
		||||
        public bool CanAddValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _canAddValue; }
 | 
			
		||||
            set { _canAddValue = value; }
 | 
			
		||||
        }
 | 
			
		||||
        bool _canAddValue;
 | 
			
		||||
 | 
			
		||||
        public bool CanRemoveValue
 | 
			
		||||
        {
 | 
			
		||||
            get { return _canRemoveValue; }
 | 
			
		||||
            set { _canRemoveValue = value; }
 | 
			
		||||
        }
 | 
			
		||||
        bool _canRemoveValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										375
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Document.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										375
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Document.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,375 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents a MigraDoc document.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public sealed class Document : DocumentObject, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Document class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Document()
 | 
			
		||||
        {
 | 
			
		||||
            _styles = new Styles(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Document Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Document)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            Document document = (Document)base.DeepCopy();
 | 
			
		||||
            if (document._info != null)
 | 
			
		||||
            {
 | 
			
		||||
                document._info = document._info.Clone();
 | 
			
		||||
                document._info._parent = document;
 | 
			
		||||
            }
 | 
			
		||||
            if (document._styles != null)
 | 
			
		||||
            {
 | 
			
		||||
                document._styles = document._styles.Clone();
 | 
			
		||||
                document._styles._parent = document;
 | 
			
		||||
            }
 | 
			
		||||
            if (document._sections != null)
 | 
			
		||||
            {
 | 
			
		||||
                document._sections = document._sections.Clone();
 | 
			
		||||
                document._sections._parent = document;
 | 
			
		||||
            }
 | 
			
		||||
            return document;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// public function used by renderers to bind this instance to it. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void BindToRenderer(object renderer)
 | 
			
		||||
        {
 | 
			
		||||
            if (_renderer != null && renderer != null && !ReferenceEquals(_renderer, renderer))
 | 
			
		||||
            {
 | 
			
		||||
                throw new InvalidOperationException("The document is already bound to another renderer. " +
 | 
			
		||||
                  "A MigraDoc document can be rendered by only one renderer, because the rendering process " +
 | 
			
		||||
                  "modifies its public structure. If you want to render a MigraDoc document on different renderers, " +
 | 
			
		||||
                  "you must create a copy of it using the Clone function.");
 | 
			
		||||
            }
 | 
			
		||||
            _renderer = renderer;
 | 
			
		||||
        }
 | 
			
		||||
        object _renderer;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Indicates whether the document is bound to a renderer. A bound document must not be modified anymore.
 | 
			
		||||
        /// Modifying it leads to undefined results of the rendering process.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsBoundToRenderer
 | 
			
		||||
        {
 | 
			
		||||
            get { return _renderer != null; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new section to the document.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Section AddSection()
 | 
			
		||||
        {
 | 
			
		||||
            return Sections.AddSection();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new style to the document styles.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="name">Name of the style.</param>
 | 
			
		||||
        /// <param name="baseStyle">Name of the base style.</param>
 | 
			
		||||
        public Style AddStyle(string name, string baseStyle)
 | 
			
		||||
        {
 | 
			
		||||
            if (name == null || baseStyle == null)
 | 
			
		||||
                throw new ArgumentNullException(name == null ? "name" : "baseStyle");
 | 
			
		||||
            if (name == "" || baseStyle == "")
 | 
			
		||||
                throw new ArgumentException(name == "" ? "name" : "baseStyle");
 | 
			
		||||
 | 
			
		||||
            return Styles.AddStyle(name, baseStyle);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new section to the document.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Section section)
 | 
			
		||||
        {
 | 
			
		||||
            Sections.Add(section);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new style to the document styles.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Style style)
 | 
			
		||||
        {
 | 
			
		||||
            Styles.Add(style);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the last section of the document, or null, if the document has no sections.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Section LastSection
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return (_sections != null && _sections.Count > 0) ?
 | 
			
		||||
                  _sections.LastObject as Section : null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a comment associated with this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Comment
 | 
			
		||||
        {
 | 
			
		||||
            get { return _comment.Value; }
 | 
			
		||||
            set { _comment.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _comment = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the document info.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentInfo Info
 | 
			
		||||
        {
 | 
			
		||||
            get { return _info ?? (_info = new DocumentInfo(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _info = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public DocumentInfo _info;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the styles of the document.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Styles Styles
 | 
			
		||||
        {
 | 
			
		||||
            get { return _styles ?? (_styles = new Styles(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _styles = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Styles _styles;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the default tab stop position.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit DefaultTabStop
 | 
			
		||||
        {
 | 
			
		||||
            get { return _defaultTabStop; }
 | 
			
		||||
            set { _defaultTabStop = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _defaultTabStop = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the default page setup.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageSetup DefaultPageSetup
 | 
			
		||||
        {
 | 
			
		||||
            get { return PageSetup.DefaultPageSetup; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the location of the Footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FootnoteLocation FootnoteLocation
 | 
			
		||||
        {
 | 
			
		||||
            get { return (FootnoteLocation)_footnoteLocation.Value; }
 | 
			
		||||
            set { _footnoteLocation.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(FootnoteLocation))]
 | 
			
		||||
        public NEnum _footnoteLocation = NEnum.NullValue(typeof(FootnoteLocation));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the rule which is used to determine the footnote number on a new page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FootnoteNumberingRule FootnoteNumberingRule
 | 
			
		||||
        {
 | 
			
		||||
            get { return (FootnoteNumberingRule)_footnoteNumberingRule.Value; }
 | 
			
		||||
            set { _footnoteNumberingRule.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(FootnoteNumberingRule))]
 | 
			
		||||
        public NEnum _footnoteNumberingRule = NEnum.NullValue(typeof(FootnoteNumberingRule));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the type of number which is used for the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FootnoteNumberStyle FootnoteNumberStyle
 | 
			
		||||
        {
 | 
			
		||||
            get { return (FootnoteNumberStyle)_footnoteNumberStyle.Value; }
 | 
			
		||||
            set { _footnoteNumberStyle.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(FootnoteNumberStyle))]
 | 
			
		||||
        public NEnum _footnoteNumberStyle = NEnum.NullValue(typeof(FootnoteNumberStyle));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the starting number of the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int FootnoteStartingNumber
 | 
			
		||||
        {
 | 
			
		||||
            get { return _footnoteStartingNumber.Value; }
 | 
			
		||||
            set { _footnoteStartingNumber.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NInt _footnoteStartingNumber = NInt.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the path for images used by the document.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string ImagePath
 | 
			
		||||
        {
 | 
			
		||||
            get { return _imagePath.Value; }
 | 
			
		||||
            set { _imagePath.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _imagePath = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value indicating whether to use the CMYK color model when rendered as PDF.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool UseCmykColor
 | 
			
		||||
        {
 | 
			
		||||
            get { return _useCmykColor.Value; }
 | 
			
		||||
            set { _useCmykColor.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _useCmykColor = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the sections of the document.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Sections Sections
 | 
			
		||||
        {
 | 
			
		||||
            get { return _sections ?? (_sections = new Sections(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _sections = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Sections _sections;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the DDL file name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string DdlFile
 | 
			
		||||
        {
 | 
			
		||||
            get { return _ddlFile; }
 | 
			
		||||
        }
 | 
			
		||||
        public string _ddlFile = "";
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Document into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            serializer.WriteComment(_comment.Value);
 | 
			
		||||
            serializer.WriteLine("\\document");
 | 
			
		||||
 | 
			
		||||
            int pos = serializer.BeginAttributes();
 | 
			
		||||
            if (!IsNull("Info"))
 | 
			
		||||
                Info.Serialize(serializer);
 | 
			
		||||
            if (!_defaultTabStop.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("DefaultTabStop", DefaultTabStop);
 | 
			
		||||
            if (!_footnoteLocation.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("FootnoteLocation", FootnoteLocation);
 | 
			
		||||
            if (!_footnoteNumberingRule.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("FootnoteNumberingRule", FootnoteNumberingRule);
 | 
			
		||||
            if (!_footnoteNumberStyle.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("FootnoteNumberStyle", FootnoteNumberStyle);
 | 
			
		||||
            if (!_footnoteStartingNumber.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("FootnoteStartingNumber", FootnoteStartingNumber);
 | 
			
		||||
            if (!_imagePath.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("ImagePath", ImagePath);
 | 
			
		||||
            if (!_useCmykColor.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("UseCmykColor", UseCmykColor);
 | 
			
		||||
            serializer.EndAttributes(pos);
 | 
			
		||||
 | 
			
		||||
            serializer.BeginContent();
 | 
			
		||||
            Styles.Serialize(serializer);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Sections"))
 | 
			
		||||
                Sections.Serialize(serializer);
 | 
			
		||||
            serializer.EndContent();
 | 
			
		||||
            serializer.Flush();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and all its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitDocument(this);
 | 
			
		||||
            if (visitChildren)
 | 
			
		||||
            {
 | 
			
		||||
                ((IVisitable)Styles).AcceptVisitor(visitor, true);
 | 
			
		||||
                ((IVisitable)Sections).AcceptVisitor(visitor, true);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Document))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,239 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Tables;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents a collection of document elements.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class DocumentElements : DocumentObjectCollection, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DocumentElements class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentElements()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DocumentElements class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentElements(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a document object by its index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new DocumentObject this[int index]
 | 
			
		||||
        {
 | 
			
		||||
            get { return base[index]; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new DocumentElements Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (DocumentElements)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph()
 | 
			
		||||
        {
 | 
			
		||||
            Paragraph paragraph = new Paragraph();
 | 
			
		||||
            Add(paragraph);
 | 
			
		||||
            return paragraph;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph with the specified text to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph(string text)
 | 
			
		||||
        {
 | 
			
		||||
            Paragraph paragraph = new Paragraph();
 | 
			
		||||
            paragraph.AddText(text);
 | 
			
		||||
            Add(paragraph);
 | 
			
		||||
            return paragraph;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph with the specified text and style to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph(string text, string style)
 | 
			
		||||
        {
 | 
			
		||||
            Paragraph paragraph = new Paragraph();
 | 
			
		||||
            paragraph.AddText(text);
 | 
			
		||||
            paragraph.Style = style;
 | 
			
		||||
            Add(paragraph);
 | 
			
		||||
            return paragraph;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new table to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Table AddTable()
 | 
			
		||||
        {
 | 
			
		||||
            Table tbl = new Table();
 | 
			
		||||
            Add(tbl);
 | 
			
		||||
            return tbl;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new legend to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Legend AddLegend()
 | 
			
		||||
        {
 | 
			
		||||
            Legend legend = new Legend();
 | 
			
		||||
            Add(legend);
 | 
			
		||||
            return legend;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Add a manual page break.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void AddPageBreak()
 | 
			
		||||
        {
 | 
			
		||||
            PageBreak pageBreak = new PageBreak();
 | 
			
		||||
            Add(pageBreak);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new barcode to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Barcode AddBarcode()
 | 
			
		||||
        {
 | 
			
		||||
            Barcode barcode = new Barcode();
 | 
			
		||||
            Add(barcode);
 | 
			
		||||
            return barcode;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new chart with the specified type to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Chart AddChart(ChartType type)
 | 
			
		||||
        {
 | 
			
		||||
            Chart chart = AddChart();
 | 
			
		||||
            chart.Type = type;
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new chart with the specified type to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Chart AddChart()
 | 
			
		||||
        {
 | 
			
		||||
            Chart chart = new Chart();
 | 
			
		||||
            chart.Type = ChartType.Line;
 | 
			
		||||
            Add(chart);
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new image to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Image AddImage(string name)
 | 
			
		||||
        {
 | 
			
		||||
            Image image = new Image();
 | 
			
		||||
            image.Name = name;
 | 
			
		||||
            Add(image);
 | 
			
		||||
            return image;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new text frame to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TextFrame AddTextFrame()
 | 
			
		||||
        {
 | 
			
		||||
            TextFrame textFrame = new TextFrame();
 | 
			
		||||
            Add(textFrame);
 | 
			
		||||
            return textFrame;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts DocumentElements into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            int count = Count;
 | 
			
		||||
            if (count == 1 && this[0] is Paragraph)
 | 
			
		||||
            {
 | 
			
		||||
                // Omit keyword if paragraph has no attributes set.
 | 
			
		||||
                Paragraph paragraph = (Paragraph)this[0];
 | 
			
		||||
                if (paragraph.Style == "" && paragraph.IsNull("Format"))
 | 
			
		||||
                {
 | 
			
		||||
                    paragraph.SerializeContentOnly = true;
 | 
			
		||||
                    paragraph.Serialize(serializer);
 | 
			
		||||
                    paragraph.SerializeContentOnly = false;
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            for (int index = 0; index < count; index++)
 | 
			
		||||
            {
 | 
			
		||||
                DocumentObject documentElement = this[index];
 | 
			
		||||
                documentElement.Serialize(serializer);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitDocumentElements(this);
 | 
			
		||||
 | 
			
		||||
            foreach (DocumentObject docObject in this)
 | 
			
		||||
            {
 | 
			
		||||
                if (docObject is IVisitable)
 | 
			
		||||
                    ((IVisitable)docObject).AcceptVisitor(visitor, visitChildren);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(DocumentElements))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										155
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/DocumentInfo.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/DocumentInfo.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,155 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains information about document content, author etc.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class DocumentInfo : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DocumentInfo class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentInfo()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DocumentInfo class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentInfo(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new DocumentInfo Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (DocumentInfo)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the document title.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Title
 | 
			
		||||
        {
 | 
			
		||||
            get { return _title.Value; }
 | 
			
		||||
            set { _title.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _title = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the document author.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Author
 | 
			
		||||
        {
 | 
			
		||||
            get { return _author.Value; }
 | 
			
		||||
            set { _author.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _author = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets keywords related to the document.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Keywords
 | 
			
		||||
        {
 | 
			
		||||
            get { return _keywords.Value; }
 | 
			
		||||
            set { _keywords.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _keywords = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the subject of the document.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Subject
 | 
			
		||||
        {
 | 
			
		||||
            get { return _subject.Value; }
 | 
			
		||||
            set { _subject.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _subject = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a comment associated with this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Comment
 | 
			
		||||
        {
 | 
			
		||||
            get { return _comment.Value; }
 | 
			
		||||
            set { _comment.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _comment = NString.NullValue;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts DocumentInfo into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            serializer.WriteComment(_comment.Value);
 | 
			
		||||
            int pos = serializer.BeginContent("Info");
 | 
			
		||||
 | 
			
		||||
            if (Title != String.Empty)
 | 
			
		||||
                serializer.WriteSimpleAttribute("Title", Title);
 | 
			
		||||
 | 
			
		||||
            if (Subject != String.Empty)
 | 
			
		||||
                serializer.WriteSimpleAttribute("Subject", Subject);
 | 
			
		||||
 | 
			
		||||
            if (Author != String.Empty)
 | 
			
		||||
                serializer.WriteSimpleAttribute("Author", Author);
 | 
			
		||||
 | 
			
		||||
            if (Keywords != String.Empty)
 | 
			
		||||
                serializer.WriteSimpleAttribute("Keywords", Keywords);
 | 
			
		||||
 | 
			
		||||
            serializer.EndContent(pos);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(DocumentInfo))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,261 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Base class of all objects of the MigraDoc Document Object Model.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public abstract class DocumentObject : ICloneable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DocumentObject class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentObject()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DocumentObject class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentObject(DocumentObject parent)
 | 
			
		||||
        {
 | 
			
		||||
            Debug.Assert(parent != null, "Parent must not be null.");
 | 
			
		||||
            _parent = parent;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of the DocumentObject. The parent of the new object is null.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public object Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected virtual object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            DocumentObject value = (DocumentObject)MemberwiseClone();
 | 
			
		||||
            value._parent = null;
 | 
			
		||||
            return value;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates an object using the default constructor.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public object CreateValue(string name)
 | 
			
		||||
        {
 | 
			
		||||
            ValueDescriptor vd = Meta[name];
 | 
			
		||||
            if (vd != null)
 | 
			
		||||
                return vd.CreateValue();
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the parent object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentObject Parent
 | 
			
		||||
        {
 | 
			
		||||
            get { return _parent; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(RefOnly = true)]
 | 
			
		||||
        public DocumentObject _parent;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the document of the object, or null, if the object is not associated with a document.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Document Document
 | 
			
		||||
        {
 | 
			
		||||
            // TODO Have to reset _document when _parent changes.
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_document != null)
 | 
			
		||||
                    return _document;
 | 
			
		||||
                DocumentObject doc = Parent;
 | 
			
		||||
                Document document = doc as Document;
 | 
			
		||||
                if (document != null)
 | 
			
		||||
                    return _document = document;
 | 
			
		||||
                // Call document at the parent - recursive call instead of while loop - and all parent objects will also update their _document fields.
 | 
			
		||||
                // Next call to Document from a sibbling will succeed without climbing all the way up.
 | 
			
		||||
                if (doc != null)
 | 
			
		||||
                    return _document = doc.Document;
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private Document _document;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the section of the object, or null, if the object is not associated with a section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Section Section
 | 
			
		||||
        {
 | 
			
		||||
            // TODO Have to reset _section when _parent changes.
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_section != null)
 | 
			
		||||
                    return _section;
 | 
			
		||||
                DocumentObject doc = Parent;
 | 
			
		||||
                if (doc != null)
 | 
			
		||||
                {
 | 
			
		||||
                    Section section = doc as Section;
 | 
			
		||||
                    if (section != null)
 | 
			
		||||
                        return _section = section;
 | 
			
		||||
                    return _section = doc.Section;
 | 
			
		||||
                }
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private Section _section;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts DocumentObject into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public abstract void Serialize(Serializer serializer);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the value with the specified name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual object GetValue(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return GetValue(name, GV.ReadWrite);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the value with the specified name and value flags.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual object GetValue(string name, GV flags)
 | 
			
		||||
        {
 | 
			
		||||
            return Meta.GetValue(this, name, flags);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the given value and sets its parent afterwards.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual void SetValue(string name, object val)
 | 
			
		||||
        {
 | 
			
		||||
            Meta.SetValue(this, name, val);
 | 
			
		||||
            DocumentObject documentObject = val as DocumentObject;
 | 
			
		||||
            if (documentObject != null)
 | 
			
		||||
                (documentObject)._parent = this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance has a value of the given name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual bool HasValue(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Meta.HasValue(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether the value of the given name is null.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual bool IsNull(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Meta.IsNull(this, name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Resets the value of the given name, i.e. IsNull(name) will return true afterwards.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual void SetNull(string name)
 | 
			
		||||
        {
 | 
			
		||||
            Meta.SetNull(this, name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance is null (not set).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual bool IsNull()
 | 
			
		||||
        {
 | 
			
		||||
            return Meta.IsNull(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Resets this instance, i.e. IsNull() will return true afterwards.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual void SetNull()
 | 
			
		||||
        {
 | 
			
		||||
            Meta.SetNull(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value that contains arbitrary information about this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public object Tag
 | 
			
		||||
        {
 | 
			
		||||
            get { return _tag; }
 | 
			
		||||
            set { _tag = value; }
 | 
			
		||||
        }
 | 
			
		||||
        object _tag;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public abstract Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the parent of the specified value.
 | 
			
		||||
        /// If a parent is already set, an ArgumentException will be thrown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected void SetParent(DocumentObject val)
 | 
			
		||||
        {
 | 
			
		||||
            if (val != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (val.Parent != null)
 | 
			
		||||
                    throw new ArgumentException(DomSR.ParentAlreadySet(val, this));
 | 
			
		||||
 | 
			
		||||
                val._parent = this;
 | 
			
		||||
                val._document = null;
 | 
			
		||||
                val._section = null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// When overridden in a derived class resets cached values
 | 
			
		||||
        /// (like column index).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual void ResetCachedValues()
 | 
			
		||||
        {
 | 
			
		||||
            _document = null;
 | 
			
		||||
            _section = null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,346 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Base class of all collections of the MigraDoc Document Object Model.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public abstract class DocumentObjectCollection : DocumentObject, IList, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DocumentObjectCollection class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentObjectCollection()
 | 
			
		||||
        {
 | 
			
		||||
            _elements = new List<object>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the DocumentObjectCollection class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentObjectCollection(DocumentObject parent)
 | 
			
		||||
            : base(parent)
 | 
			
		||||
        {
 | 
			
		||||
            _elements = new List<object>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the first value in the Collection, if there is any, otherwise null.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentObject First
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return Count > 0 ? this[0] : null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new DocumentObjectCollection Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (DocumentObjectCollection)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            DocumentObjectCollection coll = (DocumentObjectCollection)base.DeepCopy();
 | 
			
		||||
 | 
			
		||||
            int count = Count;
 | 
			
		||||
            coll._elements = new List<object>(count);
 | 
			
		||||
            for (int index = 0; index < count; ++index)
 | 
			
		||||
            {
 | 
			
		||||
                DocumentObject doc = this[index];
 | 
			
		||||
                if (doc != null)
 | 
			
		||||
                {
 | 
			
		||||
                    doc = doc.Clone() as DocumentObject;
 | 
			
		||||
                    doc._parent = coll;
 | 
			
		||||
                }
 | 
			
		||||
                coll._elements.Add(doc);
 | 
			
		||||
            }
 | 
			
		||||
            return coll;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Copies the entire collection to a compatible one-dimensional System.Array,
 | 
			
		||||
        /// starting at the specified index of the target array.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void CopyTo(Array array, int index)
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotImplementedException("TODO");
 | 
			
		||||
            //this .elements.CopyTo(array, index);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a value indicating whether the Collection is read-only.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        bool IList.IsReadOnly
 | 
			
		||||
        {
 | 
			
		||||
            get { return false; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a value indicating whether the Collection has a fixed size.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        bool IList.IsFixedSize
 | 
			
		||||
        {
 | 
			
		||||
            get { return false; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a value indicating whether access to the Collection is synchronized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        bool ICollection.IsSynchronized
 | 
			
		||||
        {
 | 
			
		||||
            get { return false; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets an object that can be used to synchronize access to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        object ICollection.SyncRoot
 | 
			
		||||
        {
 | 
			
		||||
            get { return null; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the number of elements actually contained in the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Count
 | 
			
		||||
        {
 | 
			
		||||
            get { return _elements.Count; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Removes all elements from the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Clear()
 | 
			
		||||
        {
 | 
			
		||||
            ((IList)this).Clear();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Inserts an object at the specified index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual void InsertObject(int index, DocumentObject val)
 | 
			
		||||
        {
 | 
			
		||||
            SetParent(val);
 | 
			
		||||
            ((IList)this).Insert(index, val);
 | 
			
		||||
            // Call ResetCachedValues for all objects moved by the Insert operation.
 | 
			
		||||
            int count = ((IList)this).Count;
 | 
			
		||||
            for (int idx = index + 1; idx < count; ++idx)
 | 
			
		||||
            {
 | 
			
		||||
                DocumentObject obj = (DocumentObject)((IList)this)[idx];
 | 
			
		||||
                obj.ResetCachedValues();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines the index of a specific item in the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int IndexOf(DocumentObject val)
 | 
			
		||||
        {
 | 
			
		||||
            return ((IList)this).IndexOf(val);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the element at the specified index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual DocumentObject this[int index]
 | 
			
		||||
        {
 | 
			
		||||
            get { return _elements[index] as DocumentObject; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _elements[index] = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the last element or null, if no such element exists.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentObject LastObject
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                int count = _elements.Count;
 | 
			
		||||
                if (count > 0)
 | 
			
		||||
                    return (DocumentObject)_elements[count - 1];
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Removes the element at the specified index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void RemoveObjectAt(int index)
 | 
			
		||||
        {
 | 
			
		||||
            ((IList)this).RemoveAt(index);
 | 
			
		||||
            // Call ResetCachedValues for all objects moved by the RemoveAt operation.
 | 
			
		||||
            int count = ((IList)this).Count;
 | 
			
		||||
            for (int idx = index; idx < count; ++idx)
 | 
			
		||||
            {
 | 
			
		||||
                DocumentObject obj = (DocumentObject)((IList)this)[idx];
 | 
			
		||||
                obj.ResetCachedValues();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Inserts the object into the collection and sets its parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual void Add(DocumentObject value)
 | 
			
		||||
        {
 | 
			
		||||
            SetParent(value);
 | 
			
		||||
            _elements.Add(value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance is null.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override bool IsNull()
 | 
			
		||||
        {
 | 
			
		||||
            if (!Meta.IsNull(this))
 | 
			
		||||
                return false;
 | 
			
		||||
            if (_elements == null)
 | 
			
		||||
                return true;
 | 
			
		||||
            foreach (DocumentObject docObject in _elements)
 | 
			
		||||
            {
 | 
			
		||||
                if (docObject != null && !docObject.IsNull())
 | 
			
		||||
                    return false;
 | 
			
		||||
            }
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitDocumentObjectCollection(this);
 | 
			
		||||
 | 
			
		||||
            foreach (DocumentObject docobj in this)
 | 
			
		||||
            {
 | 
			
		||||
                IVisitable visitable = docobj as IVisitable;
 | 
			
		||||
                if (visitable != null)
 | 
			
		||||
                    visitable.AcceptVisitor(visitor, visitChildren);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns an enumerator that can iterate through this collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public IEnumerator GetEnumerator()
 | 
			
		||||
        {
 | 
			
		||||
            return _elements.GetEnumerator();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        List<object> _elements;
 | 
			
		||||
 | 
			
		||||
        #region IList Members
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the element at the specified index. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        object IList.this[int index]
 | 
			
		||||
        {
 | 
			
		||||
            get { return _elements[index]; }
 | 
			
		||||
            set { _elements[index] = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Removes the item at the specified index from the Collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IList.RemoveAt(int index)
 | 
			
		||||
        {
 | 
			
		||||
            _elements.RemoveAt(index);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Inserts an object at the specified index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IList.Insert(int index, object value)
 | 
			
		||||
        {
 | 
			
		||||
            _elements.Insert(index, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Removes the first occurrence of the specific object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IList.Remove(object value)
 | 
			
		||||
        {
 | 
			
		||||
            _elements.Remove(value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether an element exists.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        bool IList.Contains(object value)
 | 
			
		||||
        {
 | 
			
		||||
            return _elements.Contains(value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines the index of a specific item in the Collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        int IList.IndexOf(object value)
 | 
			
		||||
        {
 | 
			
		||||
            return _elements.IndexOf(value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds an item to the Collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        int IList.Add(object value)
 | 
			
		||||
        {
 | 
			
		||||
            _elements.Add(value);
 | 
			
		||||
            return _elements.Count - 1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Removes all items from the Collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IList.Clear()
 | 
			
		||||
        {
 | 
			
		||||
            _elements.Clear();
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,94 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Provides relational information between document objects.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class DocumentRelations
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether the specified documentObject has a
 | 
			
		||||
        /// parent of the given type somewhere within the document hierarchy.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="documentObject">The document object to check.</param>
 | 
			
		||||
        /// <param name="type">The parent type to search for.</param>
 | 
			
		||||
        public static bool HasParentOfType(DocumentObject documentObject, Type type)
 | 
			
		||||
        {
 | 
			
		||||
            if (documentObject == null)
 | 
			
		||||
                throw new ArgumentNullException("documentObject");
 | 
			
		||||
 | 
			
		||||
            if (type == null)
 | 
			
		||||
                throw new ArgumentNullException("type");
 | 
			
		||||
 | 
			
		||||
            return GetParentOfType(documentObject, type) != null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the direct parent of the given document object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="documentObject">The document object the parent is searched for.</param>
 | 
			
		||||
        public static DocumentObject GetParent(DocumentObject documentObject)
 | 
			
		||||
        {
 | 
			
		||||
            if (documentObject == null)
 | 
			
		||||
                throw new ArgumentNullException("documentObject");
 | 
			
		||||
 | 
			
		||||
            return documentObject.Parent;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a parent of the document object with the given type somewhere within the document hierarchy.
 | 
			
		||||
        /// Returns null if none exists.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="documentObject">The document object the parent is searched for.</param>
 | 
			
		||||
        /// <param name="type">The parent type to search for.</param>
 | 
			
		||||
        public static DocumentObject GetParentOfType(DocumentObject documentObject, Type type)
 | 
			
		||||
        {
 | 
			
		||||
            if (documentObject == null)
 | 
			
		||||
                throw new ArgumentNullException("documentObject");
 | 
			
		||||
 | 
			
		||||
            if (type == null)
 | 
			
		||||
                throw new ArgumentNullException("type");
 | 
			
		||||
 | 
			
		||||
            if (documentObject._parent != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (documentObject._parent.GetType() == type)
 | 
			
		||||
                    return documentObject._parent;
 | 
			
		||||
                return GetParentOfType(documentObject._parent, type);
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										277
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/DomSR.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										277
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/DomSR.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,277 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using System.Resources;
 | 
			
		||||
#if DEBUG
 | 
			
		||||
using System.Text.RegularExpressions;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// String resources of MigraDoc.DocumentObjectModel. Provides all localized text strings
 | 
			
		||||
    /// for this assembly.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    static class DomSR
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Loads the message from the resource associated with the enum type and formats it
 | 
			
		||||
        /// using 'String.Format'. Because this function is intended to be used during error
 | 
			
		||||
        /// handling it never raises an exception.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="id">The type of the parameter identifies the resource
 | 
			
		||||
        /// and the name of the enum identifies the message in the resource.</param>
 | 
			
		||||
        /// <param name="args">Parameters passed through 'String.Format'.</param>
 | 
			
		||||
        /// <returns>The formatted message.</returns>
 | 
			
		||||
        public static string FormatMessage(DomMsgID id, params object[] args)
 | 
			
		||||
        {
 | 
			
		||||
            string message;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                message = GetString(id);
 | 
			
		||||
                if (message != null)
 | 
			
		||||
                {
 | 
			
		||||
#if DEBUG
 | 
			
		||||
                    if (Regex.Matches(message, @"\{[0-9]\}").Count > args.Length)
 | 
			
		||||
                    {
 | 
			
		||||
                        //TODO too many placeholders or too less args...
 | 
			
		||||
                    }
 | 
			
		||||
#endif
 | 
			
		||||
                    message = String.Format(message, args);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                    message = "<<<error: message not found>>>";
 | 
			
		||||
                return message;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                message = "public ERROR while formatting error message: " + ex;
 | 
			
		||||
            }
 | 
			
		||||
            return message;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string CompareJustCells
 | 
			
		||||
        {
 | 
			
		||||
            get { return "Only cells can be compared by this Comparer."; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the localized message identified by the specified DomMsgID.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string GetString(DomMsgID id)
 | 
			
		||||
        {
 | 
			
		||||
            return ResMngr.GetString(id.ToString());
 | 
			
		||||
        }
 | 
			
		||||
        #region How to use
 | 
			
		||||
#if true_
 | 
			
		||||
    // Message with no parameter is property.
 | 
			
		||||
    public static string SampleMessage1
 | 
			
		||||
    {
 | 
			
		||||
      // In the first place English only
 | 
			
		||||
      get { return "This is sample message 1."; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Message with no parameter is property.
 | 
			
		||||
    public static string SampleMessage2
 | 
			
		||||
    {
 | 
			
		||||
      // Then localized:
 | 
			
		||||
      get { return DomSR.GetString(DomMsgID.SampleMessage1); }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Message with parameters is function.
 | 
			
		||||
    public static string SampleMessage3(string parm)
 | 
			
		||||
    {
 | 
			
		||||
      // In the first place English only
 | 
			
		||||
      //return String.Format("This is sample message 2: {0}.", parm);
 | 
			
		||||
    }
 | 
			
		||||
    public static string SampleMessage4(string parm)
 | 
			
		||||
    {
 | 
			
		||||
      // Then localized:
 | 
			
		||||
      return String.Format(GetString(DomMsgID.SampleMessage2), parm);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region General Messages
 | 
			
		||||
 | 
			
		||||
        public static string StyleExpected
 | 
			
		||||
        {
 | 
			
		||||
            get { return GetString(DomMsgID.StyleExpected); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string BaseStyleRequired
 | 
			
		||||
        {
 | 
			
		||||
            get { return GetString(DomMsgID.BaseStyleRequired); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string EmptyBaseStyle
 | 
			
		||||
        {
 | 
			
		||||
            get { return GetString(DomMsgID.EmptyBaseStyle); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidFieldFormat(string format)
 | 
			
		||||
        {
 | 
			
		||||
            return FormatMessage(DomMsgID.InvalidFieldFormat, format);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidInfoFieldName(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return FormatMessage(DomMsgID.InvalidInfoFieldName, name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string UndefinedBaseStyle(string baseStyle)
 | 
			
		||||
        {
 | 
			
		||||
            return FormatMessage(DomMsgID.UndefinedBaseStyle, baseStyle);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidValueName(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return FormatMessage(DomMsgID.InvalidValueName, name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidUnitValue(string unitValue)
 | 
			
		||||
        {
 | 
			
		||||
            return FormatMessage(DomMsgID.InvalidUnitValue, unitValue);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidUnitType(string unitType)
 | 
			
		||||
        {
 | 
			
		||||
            return FormatMessage(DomMsgID.InvalidUnitType, unitType);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidEnumValue<T>(T value) where T : struct
 | 
			
		||||
        {
 | 
			
		||||
            // ... where T : enum
 | 
			
		||||
            //   -or-
 | 
			
		||||
            // ... where T : Enum
 | 
			
		||||
            // is not implemented in C# because nobody has done this.
 | 
			
		||||
            // See Eric Lippert on this topic: http://stackoverflow.com/questions/1331739/enum-type-constraints-in-c-sharp
 | 
			
		||||
#if !NETFX_CORE
 | 
			
		||||
            Debug.Assert(typeof (T).IsSubclassOf(typeof(Enum)));
 | 
			
		||||
#else
 | 
			
		||||
            Debug.Assert(typeof(T).GetTypeInfo().IsSubclassOf(typeof(Enum)));
 | 
			
		||||
#endif
 | 
			
		||||
            return FormatMessage(DomMsgID.InvalidEnumValue, value, typeof(T).Name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidEnumForLeftPosition
 | 
			
		||||
        {
 | 
			
		||||
            get { return GetString(DomMsgID.InvalidEnumForLeftPosition); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidEnumForTopPosition
 | 
			
		||||
        {
 | 
			
		||||
            get { return GetString(DomMsgID.InvalidEnumForTopPosition); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidColorString(string colorString)
 | 
			
		||||
        {
 | 
			
		||||
            return FormatMessage(DomMsgID.InvalidColorString, colorString);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidFontSize(double value)
 | 
			
		||||
        {
 | 
			
		||||
            return FormatMessage(DomMsgID.InvalidFontSize, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InsertNullNotAllowed()
 | 
			
		||||
        {
 | 
			
		||||
            return "Insert null not allowed.";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string ParentAlreadySet(DocumentObject value, DocumentObject docObject)
 | 
			
		||||
        {
 | 
			
		||||
            return String.Format("Value of type '{0}' must be cloned before set into '{1}'.",
 | 
			
		||||
              value.GetType(), docObject.GetType());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string MissingObligatoryProperty(string propertyName, string className)
 | 
			
		||||
        {
 | 
			
		||||
            return String.Format("ObigatoryProperty '{0}' not set in '{1}'.", propertyName, className);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string InvalidDocumentObjectType
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return "The given document object is not valid in this context.";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region DdlReader Messages
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Resource Manager
 | 
			
		||||
 | 
			
		||||
        public static ResourceManager ResMngr
 | 
			
		||||
        {
 | 
			
		||||
            // ReSharper disable ConvertIfStatementToNullCoalescingExpression
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_resmngr == null)
 | 
			
		||||
                {
 | 
			
		||||
#if !NETFX_CORE
 | 
			
		||||
                    _resmngr = new ResourceManager("MigraDoc.DocumentObjectModel.Resources.Messages", Assembly.GetExecutingAssembly());
 | 
			
		||||
#else
 | 
			
		||||
                    _resmngr = new ResourceManager("MigraDoc.DocumentObjectModel.Resources.Messages", typeof(DomSR).GetTypeInfo().Assembly);
 | 
			
		||||
#endif
 | 
			
		||||
                }
 | 
			
		||||
                return _resmngr;
 | 
			
		||||
            }
 | 
			
		||||
            // ReSharper restore ConvertIfStatementToNullCoalescingExpression
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#if !SILVERLIGHT
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes all messages defined by DomMsgID.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [Conditional("DEBUG")]
 | 
			
		||||
        public static void TestResourceMessages()
 | 
			
		||||
        {
 | 
			
		||||
            string[] names = Enum.GetNames(typeof(DomMsgID));
 | 
			
		||||
            foreach (string name in names)
 | 
			
		||||
            {
 | 
			
		||||
                string message = String.Format("{0}: '{1}'", name, ResMngr.GetString(name));
 | 
			
		||||
                Debug.WriteLine(message);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
        static ResourceManager _resmngr;
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										464
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Font.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										464
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Font.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,464 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Font represents the formatting of characters in a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public sealed class Font : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Font class that can be used as a template.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Font()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Font class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Font(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Font class with the specified name and size.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Font(string name, Unit size)
 | 
			
		||||
        {
 | 
			
		||||
            _name.Value = name;
 | 
			
		||||
            _size.Value = size;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Font class with the specified name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Font(string name)
 | 
			
		||||
        {
 | 
			
		||||
            _name.Value = name;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a copy of the Font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Font Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Font)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Applies all non-null properties of a font to this font if the given font's property is different from the given refFont's property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void ApplyFont(Font font, Font refFont)
 | 
			
		||||
        {
 | 
			
		||||
            if (font == null)
 | 
			
		||||
                throw new ArgumentNullException("font");
 | 
			
		||||
 | 
			
		||||
            if ((!font._name.IsNull && font._name.Value != "") && (refFont == null || font.Name != refFont.Name))
 | 
			
		||||
                Name = font.Name;
 | 
			
		||||
 | 
			
		||||
            if (!font._size.IsNull && (refFont == null || font.Size != refFont.Size))
 | 
			
		||||
                Size = font.Size;
 | 
			
		||||
 | 
			
		||||
            if (!font._bold.IsNull && (refFont == null || font.Bold != refFont.Bold))
 | 
			
		||||
                Bold = font.Bold;
 | 
			
		||||
 | 
			
		||||
            if (!font._italic.IsNull && (refFont == null || font.Italic != refFont.Italic))
 | 
			
		||||
                Italic = font.Italic;
 | 
			
		||||
 | 
			
		||||
            if (!font._subscript.IsNull && (refFont == null || font.Subscript != refFont.Subscript))
 | 
			
		||||
                Subscript = font.Subscript;
 | 
			
		||||
            else if (!font._superscript.IsNull && (refFont == null || font.Superscript != refFont.Superscript))
 | 
			
		||||
                Superscript = font.Superscript;
 | 
			
		||||
 | 
			
		||||
            if (!font._underline.IsNull && (refFont == null || font.Underline != refFont.Underline))
 | 
			
		||||
                Underline = font.Underline;
 | 
			
		||||
 | 
			
		||||
            if (!font._color.IsNull && (refFont == null || font.Color.Argb != refFont.Color.Argb))
 | 
			
		||||
                Color = font.Color;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Applies all non-null properties of a font to this font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void ApplyFont(Font font)
 | 
			
		||||
        {
 | 
			
		||||
            if (font == null)
 | 
			
		||||
                throw new ArgumentNullException("font");
 | 
			
		||||
 | 
			
		||||
            if (!font._name.IsNull && font._name.Value != "")
 | 
			
		||||
                Name = font.Name;
 | 
			
		||||
 | 
			
		||||
            if (!font._size.IsNull)
 | 
			
		||||
                Size = font.Size;
 | 
			
		||||
 | 
			
		||||
            if (!font._bold.IsNull)
 | 
			
		||||
                Bold = font.Bold;
 | 
			
		||||
 | 
			
		||||
            if (!font._italic.IsNull)
 | 
			
		||||
                Italic = font.Italic;
 | 
			
		||||
 | 
			
		||||
            if (!font._subscript.IsNull)
 | 
			
		||||
                Subscript = font.Subscript;
 | 
			
		||||
            else if (!font._superscript.IsNull)
 | 
			
		||||
                Superscript = font.Superscript;
 | 
			
		||||
 | 
			
		||||
            if (!font._underline.IsNull)
 | 
			
		||||
                Underline = font.Underline;
 | 
			
		||||
 | 
			
		||||
            if (!font._color.IsNull)
 | 
			
		||||
                Color = font.Color;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the name of the font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Name
 | 
			
		||||
        {
 | 
			
		||||
            get { return _name.Value; }
 | 
			
		||||
            set { _name.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _name = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the size of the font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit Size
 | 
			
		||||
        {
 | 
			
		||||
            get { return _size; }
 | 
			
		||||
            set { _size = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _size = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the bold property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool Bold
 | 
			
		||||
        {
 | 
			
		||||
            get { return _bold.Value; }
 | 
			
		||||
            set { _bold.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _bold = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the italic property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool Italic
 | 
			
		||||
        {
 | 
			
		||||
            get { return _italic.Value; }
 | 
			
		||||
            set { _italic.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _italic = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        // THHO4STLA Implementation for Strikethrough in the forum: http://forum.pdfsharp.net/viewtopic.php?p=4636#p4636
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the underline property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Underline Underline
 | 
			
		||||
        {
 | 
			
		||||
            get { return (Underline)_underline.Value; }
 | 
			
		||||
            set { _underline.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(Underline))]
 | 
			
		||||
        public NEnum _underline = NEnum.NullValue(typeof(Underline));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the color property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color Color
 | 
			
		||||
        {
 | 
			
		||||
            get { return _color; }
 | 
			
		||||
            set { _color = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Color _color = Color.Empty;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the superscript property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool Superscript
 | 
			
		||||
        {
 | 
			
		||||
            get { return _superscript.Value; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _superscript.Value = value;
 | 
			
		||||
                _subscript.SetNull();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _superscript = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the subscript property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool Subscript
 | 
			
		||||
        {
 | 
			
		||||
            get { return _subscript.Value; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _subscript.Value = value;
 | 
			
		||||
                _superscript.SetNull();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _subscript = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        //  + .Name = "Arial"
 | 
			
		||||
        //  + .Size = 8
 | 
			
		||||
        //  + .Bold = False
 | 
			
		||||
        //  + .Italic = False
 | 
			
		||||
        //  + .Underline = wdUnderlineDouble
 | 
			
		||||
        //  * .UnderlineColor = wdColorOrange
 | 
			
		||||
        //    .StrikeThrough = False
 | 
			
		||||
        //    .DoubleStrikeThrough = False
 | 
			
		||||
        //    .Outline = False
 | 
			
		||||
        //    .Emboss = False
 | 
			
		||||
        //    .Shadow = False
 | 
			
		||||
        //    .Hidden = False
 | 
			
		||||
        //  * .SmallCaps = False
 | 
			
		||||
        //  * .AllCaps = False
 | 
			
		||||
        //  + .Color = wdColorAutomatic
 | 
			
		||||
        //    .Engrave = False
 | 
			
		||||
        //  + .Superscript = False
 | 
			
		||||
        //  + .Subscript = False
 | 
			
		||||
        //  * .Spacing = 0
 | 
			
		||||
        //  * .Scaling = 100
 | 
			
		||||
        //  * .Position = 0
 | 
			
		||||
        //    .Kerning = 0
 | 
			
		||||
        //    .Animation = wdAnimationNone
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a value indicating whether the specified font exists.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [Obsolete("This function is removed from DocumentObjectModel and always returns false.")]
 | 
			
		||||
        public static bool Exists(string fontName)
 | 
			
		||||
        {
 | 
			
		||||
            //System.Drawing.FontFamily[] families = System.Drawing.FontFamily.Families;
 | 
			
		||||
            //foreach (System.Drawing.FontFamily family in families)
 | 
			
		||||
            //{
 | 
			
		||||
            //  if (String.Compare(family.Name, fontName, true) == 0)
 | 
			
		||||
            //    return true;
 | 
			
		||||
            //}
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Get a bitmask of all non-null properties.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private FontProperties CheckWhatIsNotNull()
 | 
			
		||||
        {
 | 
			
		||||
            FontProperties fp = FontProperties.None;
 | 
			
		||||
            if (!_name.IsNull)
 | 
			
		||||
                fp |= FontProperties.Name;
 | 
			
		||||
            if (!_size.IsNull)
 | 
			
		||||
                fp |= FontProperties.Size;
 | 
			
		||||
            if (!_bold.IsNull)
 | 
			
		||||
                fp |= FontProperties.Bold;
 | 
			
		||||
            if (!_italic.IsNull)
 | 
			
		||||
                fp |= FontProperties.Italic;
 | 
			
		||||
            if (!_underline.IsNull)
 | 
			
		||||
                fp |= FontProperties.Underline;
 | 
			
		||||
            if (!_color.IsNull)
 | 
			
		||||
                fp |= FontProperties.Color;
 | 
			
		||||
            if (!_superscript.IsNull)
 | 
			
		||||
                fp |= FontProperties.Superscript;
 | 
			
		||||
            if (!_subscript.IsNull)
 | 
			
		||||
                fp |= FontProperties.Subscript;
 | 
			
		||||
            return fp;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Font into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            Serialize(serializer, null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Font into DDL. Properties with the same value as in an optionally given
 | 
			
		||||
        /// font are not serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Serialize(Serializer serializer, Font font)
 | 
			
		||||
        {
 | 
			
		||||
            if (Parent is FormattedText)
 | 
			
		||||
            {
 | 
			
		||||
                string fontStyle = "";
 | 
			
		||||
                if (((FormattedText)Parent)._style.IsNull)
 | 
			
		||||
                {
 | 
			
		||||
                    // Check if we can use a DDL keyword.
 | 
			
		||||
                    FontProperties notNull = CheckWhatIsNotNull();
 | 
			
		||||
                    if (notNull == FontProperties.Size)
 | 
			
		||||
                    {
 | 
			
		||||
                        serializer.Write("\\fontsize(" + _size + ")");
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (notNull == FontProperties.Bold && _bold.Value)
 | 
			
		||||
                    {
 | 
			
		||||
                        serializer.Write("\\bold");
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (notNull == FontProperties.Italic && _italic.Value)
 | 
			
		||||
                    {
 | 
			
		||||
                        serializer.Write("\\italic");
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (notNull == FontProperties.Color)
 | 
			
		||||
                    {
 | 
			
		||||
                        serializer.Write("\\fontcolor(" + _color + ")");
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                    fontStyle = "(\"" + ((FormattedText)Parent).Style + "\")";
 | 
			
		||||
 | 
			
		||||
                //bool needBlank = false;  // nice, but later...
 | 
			
		||||
                serializer.Write("\\font" + fontStyle + "[");
 | 
			
		||||
 | 
			
		||||
                if (!_name.IsNull && _name.Value != "")
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Name", Name);
 | 
			
		||||
 | 
			
		||||
#if DEBUG_ // Test
 | 
			
		||||
                if (!_size.IsNull && Size != 0 && Size.Point == 0)
 | 
			
		||||
                    GetType();
 | 
			
		||||
#endif
 | 
			
		||||
                if ((!_size.IsNull))
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Size", Size);
 | 
			
		||||
 | 
			
		||||
                if (!_bold.IsNull)
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Bold", Bold);
 | 
			
		||||
 | 
			
		||||
                if (!_italic.IsNull)
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Italic", Italic);
 | 
			
		||||
 | 
			
		||||
                if (!_underline.IsNull)
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Underline", Underline);
 | 
			
		||||
 | 
			
		||||
                if (!_superscript.IsNull)
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Superscript", Superscript);
 | 
			
		||||
 | 
			
		||||
                if (!_subscript.IsNull)
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Subscript", Subscript);
 | 
			
		||||
 | 
			
		||||
                if (!_color.IsNull)
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Color", Color);
 | 
			
		||||
 | 
			
		||||
                serializer.Write("]");
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                int pos = serializer.BeginContent("Font");
 | 
			
		||||
 | 
			
		||||
#if true
 | 
			
		||||
                // Don't write null values if font is null.
 | 
			
		||||
                // Do write null values if font is not null!
 | 
			
		||||
                if ((!_name.IsNull && Name != String.Empty && font == null) ||
 | 
			
		||||
                    (font != null && !_name.IsNull && Name != String.Empty && Name != font.Name))
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Name", Name);
 | 
			
		||||
 | 
			
		||||
#if DEBUG_
 | 
			
		||||
        // Test
 | 
			
		||||
        if (!_size.IsNull && Size != 0 && Size.Point == 0)
 | 
			
		||||
          GetType();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                if (!_size.IsNull &&
 | 
			
		||||
                    (font == null || Size != font.Size))
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Size", Size);
 | 
			
		||||
                // NBool and NEnum have to be compared directly to check whether the value Null is.
 | 
			
		||||
                if (!_bold.IsNull && (font == null || Bold != font.Bold || font._bold.IsNull))
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Bold", Bold);
 | 
			
		||||
 | 
			
		||||
                if (!_italic.IsNull && (font == null || Italic != font.Italic || font._italic.IsNull))
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Italic", Italic);
 | 
			
		||||
 | 
			
		||||
                if (!_underline.IsNull && (font == null || Underline != font.Underline || font._underline.IsNull))
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Underline", Underline);
 | 
			
		||||
 | 
			
		||||
                if (!_superscript.IsNull && (font == null || Superscript != font.Superscript || font._superscript.IsNull))
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Superscript", Superscript);
 | 
			
		||||
 | 
			
		||||
                if (!_subscript.IsNull && (font == null || Subscript != font.Subscript || font._subscript.IsNull))
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Subscript", Subscript);
 | 
			
		||||
 | 
			
		||||
                if (!_color.IsNull && (font == null || Color.Argb != font.Color.Argb))// && Color.RGB != Color.Transparent.RGB)
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Color", Color);
 | 
			
		||||
#else
 | 
			
		||||
        if ((!this .name.IsNull && Name != String.Empty) && (font == null || Name != font.Name))
 | 
			
		||||
          serializer.WriteSimpleAttribute("Name", Name);
 | 
			
		||||
 | 
			
		||||
        if (!this .size.IsNull && (font == null || Size != font.Size))
 | 
			
		||||
          serializer.WriteSimpleAttribute("Size", Size);
 | 
			
		||||
        //NBool and NEnum have to be compared directly to check whether the value Null is
 | 
			
		||||
        if (!this .bold.IsNull && (font == null || Bold != font.Bold))
 | 
			
		||||
          serializer.WriteSimpleAttribute("Bold", Bold);
 | 
			
		||||
 | 
			
		||||
        if (!this .italic.IsNull && (font == null || Italic != font.Italic))
 | 
			
		||||
          serializer.WriteSimpleAttribute("Italic", Italic);
 | 
			
		||||
 | 
			
		||||
        if (!this .underline.IsNull && (font == null || Underline != font.Underline))
 | 
			
		||||
          serializer.WriteSimpleAttribute("Underline", Underline);
 | 
			
		||||
 | 
			
		||||
        if (!this .superscript.IsNull && (font == null || Superscript != font.Superscript))
 | 
			
		||||
          serializer.WriteSimpleAttribute("Superscript", Superscript);
 | 
			
		||||
 | 
			
		||||
        if (!this .subscript.IsNull && (font == null || Subscript != font.Subscript))
 | 
			
		||||
          serializer.WriteSimpleAttribute("Subscript", Subscript);
 | 
			
		||||
 | 
			
		||||
        if (!this .color.IsNull && (font == null || Color.Argb != font.Color.Argb))// && Color.RGB != Color.Transparent.RGB)
 | 
			
		||||
          serializer.WriteSimpleAttribute("Color", Color);
 | 
			
		||||
#endif
 | 
			
		||||
                serializer.EndContent(pos);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Font))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										252
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Footnote.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										252
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Footnote.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,252 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Tables;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents a footnote in a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Footnote : DocumentObject, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Footnote class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote()
 | 
			
		||||
        {
 | 
			
		||||
            //NYI: Nested footnote check!
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Footnote class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Footnote class with a text the Footnote shall content.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote(string content)
 | 
			
		||||
            : this()
 | 
			
		||||
        {
 | 
			
		||||
            Elements.AddParagraph(content);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Footnote Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Footnote)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            Footnote footnote = (Footnote)base.DeepCopy();
 | 
			
		||||
            if (footnote._elements != null)
 | 
			
		||||
            {
 | 
			
		||||
                footnote._elements = footnote._elements.Clone();
 | 
			
		||||
                footnote._elements._parent = footnote;
 | 
			
		||||
            }
 | 
			
		||||
            if (footnote._format != null)
 | 
			
		||||
            {
 | 
			
		||||
                footnote._format = footnote._format.Clone();
 | 
			
		||||
                footnote._format._parent = footnote;
 | 
			
		||||
            }
 | 
			
		||||
            return footnote;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph to the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddParagraph();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph with the specified text to the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph(string text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddParagraph(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new table to the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Table AddTable()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddTable();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new image to the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Image AddImage(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddImage(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph to the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Paragraph paragraph)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(paragraph);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new table to the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Table table)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(table);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new image to the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Image image)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(image);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the collection of paragraph elements that defines the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentElements Elements
 | 
			
		||||
        {
 | 
			
		||||
            get { return _elements ?? (_elements = new DocumentElements(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _elements = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(ItemType = typeof(DocumentObject))]
 | 
			
		||||
        public DocumentElements _elements;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the character to be used to mark the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Reference
 | 
			
		||||
        {
 | 
			
		||||
            get { return _reference.Value; }
 | 
			
		||||
            set { _reference.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _reference = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the style name of the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Style
 | 
			
		||||
        {
 | 
			
		||||
            get { return _style.Value; }
 | 
			
		||||
            set { _style.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _style = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the format of the footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphFormat Format
 | 
			
		||||
        {
 | 
			
		||||
            get { return _format ?? (_format = new ParagraphFormat(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _format = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public ParagraphFormat _format;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Footnote into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            serializer.WriteLine("\\footnote");
 | 
			
		||||
 | 
			
		||||
            int pos = serializer.BeginAttributes();
 | 
			
		||||
            if (_reference.Value != string.Empty)
 | 
			
		||||
                serializer.WriteSimpleAttribute("Reference", Reference);
 | 
			
		||||
            if (_style.Value != string.Empty)
 | 
			
		||||
                serializer.WriteSimpleAttribute("Style", Style);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Format"))
 | 
			
		||||
                _format.Serialize(serializer, "Format", null);
 | 
			
		||||
 | 
			
		||||
            serializer.EndAttributes(pos);
 | 
			
		||||
 | 
			
		||||
            pos = serializer.BeginContent();
 | 
			
		||||
            if (!IsNull("Elements"))
 | 
			
		||||
                _elements.Serialize(serializer);
 | 
			
		||||
            serializer.EndContent(pos);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitFootnote(this);
 | 
			
		||||
 | 
			
		||||
            if (visitChildren && _elements != null)
 | 
			
		||||
                ((IVisitable)_elements).AcceptVisitor(visitor, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Footnote))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,634 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Fields;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents the format of a text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class FormattedText : DocumentObject, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the FormattedText class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the FormattedText class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new FormattedText Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (FormattedText)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            FormattedText formattedText = (FormattedText)base.DeepCopy();
 | 
			
		||||
            if (formattedText._font != null)
 | 
			
		||||
            {
 | 
			
		||||
                formattedText._font = formattedText._font.Clone();
 | 
			
		||||
                formattedText._font._parent = formattedText;
 | 
			
		||||
            }
 | 
			
		||||
            if (formattedText._elements != null)
 | 
			
		||||
            {
 | 
			
		||||
                formattedText._elements = formattedText._elements.Clone();
 | 
			
		||||
                formattedText._elements._parent = formattedText;
 | 
			
		||||
            }
 | 
			
		||||
            return formattedText;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Bookmark.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public BookmarkField AddBookmark(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddBookmark(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a single character repeated the specified number of times to the formatted text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddChar(char ch, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChar(ch, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a single character to the formatted text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddChar(char ch)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChar(ch);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageField AddPageField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddPageField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageRefField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageRefField AddPageRefField(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddPageRefField(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new NumPagesField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public NumPagesField AddNumPagesField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddNumPagesField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SectionField AddSectionField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddSectionField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionPagesField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SectionPagesField AddSectionPagesField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddSectionPagesField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateField AddDateField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddDateField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateField AddDateField(string format)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddDateField(format);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new InfoField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public InfoField AddInfoField(InfoFieldType iType)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddInfoField(iType);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote with the specified text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote AddFootnote(string text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFootnote(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote AddFootnote()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFootnote();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a text phrase to the formatted text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="text">Content of the new text object.</param>
 | 
			
		||||
        /// <returns>Returns a new Text object.</returns>
 | 
			
		||||
        public Text AddText(string text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddText(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(TextFormat textFormat)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(textFormat);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText with the given Font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(Font font)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(font);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText with the given text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, TextFormat textFormat)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text, textFormat);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, Font font)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text, font);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, string style)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text, style);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Hyperlink of Type "Local", 
 | 
			
		||||
        /// i.e. the target is a Bookmark within the Document
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink AddHyperlink(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddHyperlink(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Hyperlink
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink AddHyperlink(string name, HyperlinkType type)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddHyperlink(name, type);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Image object
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Image AddImage(string fileName)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddImage(fileName);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a Symbol object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(SymbolName symbolType)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(symbolType);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds one or more Symbol objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(SymbolName symbolType, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(symbolType, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a Symbol object defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(char ch)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(ch);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds one or more Symbol objects defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(char ch, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(ch, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds one or more Symbol objects defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddSpace(int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddSpace(count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a horizontal tab.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void AddTab()
 | 
			
		||||
        {
 | 
			
		||||
            Elements.AddTab();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a line break.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void AddLineBreak()
 | 
			
		||||
        {
 | 
			
		||||
            Elements.AddLineBreak();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Bookmark
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(BookmarkField bookmark)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(bookmark);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(PageField pageField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(pageField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageRefField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(PageRefField pageRefField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(pageRefField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new NumPagesField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(NumPagesField numPagesField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(numPagesField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(SectionField sectionField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(sectionField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionPagesField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(SectionPagesField sectionPagesField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(sectionPagesField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(DateField dateField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(dateField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new InfoField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(InfoField infoField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(infoField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Footnote footnote)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(footnote);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Text
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Text text)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(FormattedText formattedText)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(formattedText);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Hyperlink
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Hyperlink hyperlink)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(hyperlink);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Image
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Image image)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(image);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Character
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Character character)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(character);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the font object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Font Font
 | 
			
		||||
        {
 | 
			
		||||
            get { return _font ?? (_font = new Font(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _font = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Font _font;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the style name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Style
 | 
			
		||||
        {
 | 
			
		||||
            get { return _style.Value; }
 | 
			
		||||
            set { _style.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _style = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the name of the font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public string FontName
 | 
			
		||||
        {
 | 
			
		||||
            get { return Font.Name; }
 | 
			
		||||
            set { Font.Name = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the name of the font.
 | 
			
		||||
        /// For public use only.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public string Name
 | 
			
		||||
        {
 | 
			
		||||
            get { return Font.Name; }
 | 
			
		||||
            set { Font.Name = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the size in point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit Size
 | 
			
		||||
        {
 | 
			
		||||
            get { return Font.Size; }
 | 
			
		||||
            set { Font.Size = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the bold property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public bool Bold
 | 
			
		||||
        {
 | 
			
		||||
            get { return Font.Bold; }
 | 
			
		||||
            set { Font.Bold = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the italic property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public bool Italic
 | 
			
		||||
        {
 | 
			
		||||
            get { return Font.Italic; }
 | 
			
		||||
            set { Font.Italic = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the underline property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Underline Underline
 | 
			
		||||
        {
 | 
			
		||||
            get { return Font.Underline; }
 | 
			
		||||
            set { Font.Underline = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the color property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Color Color
 | 
			
		||||
        {
 | 
			
		||||
            get { return Font.Color; }
 | 
			
		||||
            set { Font.Color = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the superscript property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public bool Superscript
 | 
			
		||||
        {
 | 
			
		||||
            get { return Font.Superscript; }
 | 
			
		||||
            set { Font.Superscript = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the subscript property.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public bool Subscript
 | 
			
		||||
        {
 | 
			
		||||
            get { return Font.Subscript; }
 | 
			
		||||
            set { Font.Subscript = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the collection of paragraph elements that defines the FormattedText.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphElements Elements
 | 
			
		||||
        {
 | 
			
		||||
            get { return _elements ?? (_elements = new ParagraphElements(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _elements = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(ItemType = typeof(DocumentObject))]
 | 
			
		||||
        public ParagraphElements _elements;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts FormattedText into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            bool isFormatted = false;
 | 
			
		||||
            if (!IsNull("Font"))
 | 
			
		||||
            {
 | 
			
		||||
                Font.Serialize(serializer);
 | 
			
		||||
                isFormatted = true;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                if (!_style.IsNull)
 | 
			
		||||
                {
 | 
			
		||||
                    serializer.Write("\\font(\"" + Style + "\")");
 | 
			
		||||
                    isFormatted = true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (isFormatted)
 | 
			
		||||
                serializer.Write("{");
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Elements"))
 | 
			
		||||
                Elements.Serialize(serializer);
 | 
			
		||||
 | 
			
		||||
            if (isFormatted)
 | 
			
		||||
                serializer.Write("}");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitFormattedText(this);
 | 
			
		||||
 | 
			
		||||
            if (visitChildren && _elements != null)
 | 
			
		||||
                ((IVisitable)_elements).AcceptVisitor(visitor, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(FormattedText))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										348
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/HeaderFooter.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										348
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/HeaderFooter.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,348 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Tables;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents a header or footer object in a section.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class HeaderFooter : DocumentObject, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the HeaderFooter class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HeaderFooter()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the HeaderFooter class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HeaderFooter(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new HeaderFooter Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (HeaderFooter)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            HeaderFooter headerFooter = (HeaderFooter)base.DeepCopy();
 | 
			
		||||
            if (headerFooter._format != null)
 | 
			
		||||
            {
 | 
			
		||||
                headerFooter._format = headerFooter._format.Clone();
 | 
			
		||||
                headerFooter._format._parent = headerFooter;
 | 
			
		||||
            }
 | 
			
		||||
            if (headerFooter._elements != null)
 | 
			
		||||
            {
 | 
			
		||||
                headerFooter._elements = headerFooter._elements.Clone();
 | 
			
		||||
                headerFooter._elements._parent = headerFooter;
 | 
			
		||||
            }
 | 
			
		||||
            return headerFooter;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddParagraph();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph with the specified text to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph(string paragraphText)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddParagraph(paragraphText);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new chart with the specified type to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Chart AddChart(ChartType type)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChart(type);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new chart to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Chart AddChart()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChart();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new table to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Table AddTable()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddTable();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Image to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Image AddImage(string fileName)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddImage(fileName);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new textframe to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TextFrame AddTextFrame()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddTextFrame();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Paragraph paragraph)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(paragraph);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new chart to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Chart chart)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(chart);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new table to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Table table)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(table);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new image to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Image image)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(image);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new text frame to the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(TextFrame textFrame)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(textFrame);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns true if this is a headers, false otherwise.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsHeader
 | 
			
		||||
        {
 | 
			
		||||
            get { return ((HeadersFooters)_parent).IsHeader; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns true if this is a footer, false otherwise.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsFooter
 | 
			
		||||
        {
 | 
			
		||||
            get { return ((HeadersFooters)_parent).IsFooter; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns true if this is a first page header or footer, false otherwise.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsFirstPage
 | 
			
		||||
        {
 | 
			
		||||
            get { return ((HeadersFooters)_parent)._firstPage == this; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns true if this is an even page header or footer, false otherwise.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsEvenPage
 | 
			
		||||
        {
 | 
			
		||||
            get { return ((HeadersFooters)_parent)._evenPage == this; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns true if this is a primary header or footer, false otherwise.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsPrimary
 | 
			
		||||
        {
 | 
			
		||||
            get { return ((HeadersFooters)_parent)._primary == this; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the style name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Style
 | 
			
		||||
        {
 | 
			
		||||
            get { return _style.Value; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                // Just save style name. 
 | 
			
		||||
                Style style = Document.Styles[value];
 | 
			
		||||
                if (style != null)
 | 
			
		||||
                    _style.Value = value;
 | 
			
		||||
                else
 | 
			
		||||
                    throw new ArgumentException("Invalid style name '" + value + "'.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _style = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the paragraph format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphFormat Format
 | 
			
		||||
        {
 | 
			
		||||
            get { return _format ?? (_format = new ParagraphFormat(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _format = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public ParagraphFormat _format;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the collection of document objects that defines the header or footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentElements Elements
 | 
			
		||||
        {
 | 
			
		||||
            get { return _elements ?? (_elements = new DocumentElements(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _elements = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(ItemType = typeof(DocumentObject))]
 | 
			
		||||
        public DocumentElements _elements;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a comment associated with this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Comment
 | 
			
		||||
        {
 | 
			
		||||
            get { return _comment.Value; }
 | 
			
		||||
            set { _comment.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _comment = NString.NullValue;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts HeaderFooter into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            HeadersFooters headersfooters = (HeadersFooters)_parent;
 | 
			
		||||
            if (headersfooters.Primary == this)
 | 
			
		||||
                Serialize(serializer, "primary");
 | 
			
		||||
            else if (headersfooters.EvenPage == this)
 | 
			
		||||
                Serialize(serializer, "evenpage");
 | 
			
		||||
            else if (headersfooters.FirstPage == this)
 | 
			
		||||
                Serialize(serializer, "firstpage");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts HeaderFooter into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Serialize(Serializer serializer, string prefix)
 | 
			
		||||
        {
 | 
			
		||||
            serializer.WriteComment(_comment.Value);
 | 
			
		||||
            serializer.WriteLine("\\" + prefix + (IsHeader ? "header" : "footer"));
 | 
			
		||||
 | 
			
		||||
            int pos = serializer.BeginAttributes();
 | 
			
		||||
            if (!IsNull("Format"))
 | 
			
		||||
                _format.Serialize(serializer, "Format", null);
 | 
			
		||||
            serializer.EndAttributes(pos);
 | 
			
		||||
 | 
			
		||||
            serializer.BeginContent();
 | 
			
		||||
            if (!IsNull("Elements"))
 | 
			
		||||
                _elements.Serialize(serializer);
 | 
			
		||||
            serializer.EndContent();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitHeaderFooter(this);
 | 
			
		||||
 | 
			
		||||
            if (visitChildren && _elements != null)
 | 
			
		||||
                ((IVisitable)_elements).AcceptVisitor(visitor, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance is null (not set).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override bool IsNull()
 | 
			
		||||
        {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(HeaderFooter))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,214 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents the collection of HeaderFooter objects.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class HeadersFooters : DocumentObject, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the HeadersFooters class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HeadersFooters()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the HeadersFooters class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HeadersFooters(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new HeadersFooters Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (HeadersFooters)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            HeadersFooters headersFooters = (HeadersFooters)base.DeepCopy();
 | 
			
		||||
            if (headersFooters._evenPage != null)
 | 
			
		||||
            {
 | 
			
		||||
                headersFooters._evenPage = headersFooters._evenPage.Clone();
 | 
			
		||||
                headersFooters._evenPage._parent = headersFooters;
 | 
			
		||||
            }
 | 
			
		||||
            if (headersFooters._firstPage != null)
 | 
			
		||||
            {
 | 
			
		||||
                headersFooters._firstPage = headersFooters._firstPage.Clone();
 | 
			
		||||
                headersFooters._firstPage._parent = headersFooters;
 | 
			
		||||
            }
 | 
			
		||||
            if (headersFooters._primary != null)
 | 
			
		||||
            {
 | 
			
		||||
                headersFooters._primary = headersFooters._primary.Clone();
 | 
			
		||||
                headersFooters._primary._parent = headersFooters;
 | 
			
		||||
            }
 | 
			
		||||
            return headersFooters;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns true if this collection contains headers, false otherwise.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsHeader
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                Section sec = (Section)_parent;
 | 
			
		||||
                return sec._headers == this;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns true if this collection contains footers, false otherwise.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsFooter
 | 
			
		||||
        {
 | 
			
		||||
            get { return !IsHeader; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether a particular header or footer exists.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool HasHeaderFooter(HeaderFooterIndex index)
 | 
			
		||||
        {
 | 
			
		||||
            return !IsNull(index.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the even page HeaderFooter of the HeadersFooters object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HeaderFooter EvenPage
 | 
			
		||||
        {
 | 
			
		||||
            get { return _evenPage ?? (_evenPage = new HeaderFooter(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _evenPage = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public HeaderFooter _evenPage;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the first page HeaderFooter of the HeadersFooters object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HeaderFooter FirstPage
 | 
			
		||||
        {
 | 
			
		||||
            get { return _firstPage ?? (_firstPage = new HeaderFooter(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _firstPage = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public HeaderFooter _firstPage;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the primary HeaderFooter of the HeadersFooters object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HeaderFooter Primary
 | 
			
		||||
        {
 | 
			
		||||
            get { return _primary ?? (_primary = new HeaderFooter(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _primary = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public HeaderFooter _primary;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts HeadersFooters into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            bool hasPrimary = HasHeaderFooter(HeaderFooterIndex.Primary);
 | 
			
		||||
            bool hasEvenPage = HasHeaderFooter(HeaderFooterIndex.EvenPage);
 | 
			
		||||
            bool hasFirstPage = HasHeaderFooter(HeaderFooterIndex.FirstPage);
 | 
			
		||||
 | 
			
		||||
            // \primary...
 | 
			
		||||
            if (hasPrimary)
 | 
			
		||||
                Primary.Serialize(serializer, "primary");
 | 
			
		||||
 | 
			
		||||
            // \even... 
 | 
			
		||||
            if (hasEvenPage)
 | 
			
		||||
                EvenPage.Serialize(serializer, "evenpage");
 | 
			
		||||
 | 
			
		||||
            // \firstpage...
 | 
			
		||||
            if (hasFirstPage)
 | 
			
		||||
                FirstPage.Serialize(serializer, "firstpage");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitHeadersFooters(this);
 | 
			
		||||
 | 
			
		||||
            if (visitChildren)
 | 
			
		||||
            {
 | 
			
		||||
                if (HasHeaderFooter(HeaderFooterIndex.Primary))
 | 
			
		||||
                    ((IVisitable)_primary).AcceptVisitor(visitor, true);
 | 
			
		||||
                if (HasHeaderFooter(HeaderFooterIndex.EvenPage))
 | 
			
		||||
                    ((IVisitable)_evenPage).AcceptVisitor(visitor, true);
 | 
			
		||||
                if (HasHeaderFooter(HeaderFooterIndex.FirstPage))
 | 
			
		||||
                    ((IVisitable)_firstPage).AcceptVisitor(visitor, true);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(HeadersFooters))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										529
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Hyperlink.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										529
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Hyperlink.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,529 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Fields;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// A Hyperlink is used to reference targets in the document (Local), on a drive (File) or a network (Web).
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Hyperlink : DocumentObject, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Hyperlink class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Hyperlink class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Hyperlink class with the text the hyperlink shall content.
 | 
			
		||||
        /// The type will be treated as Local by default.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink(string name, string text)
 | 
			
		||||
            : this()
 | 
			
		||||
        {
 | 
			
		||||
            Name = name;
 | 
			
		||||
            Elements.AddText(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Hyperlink class with the type and text the hyperlink shall
 | 
			
		||||
        /// represent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink(string name, HyperlinkType type, string text)
 | 
			
		||||
            : this()
 | 
			
		||||
        {
 | 
			
		||||
            Name = name;
 | 
			
		||||
            Type = type;
 | 
			
		||||
            Elements.AddText(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Hyperlink Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Hyperlink)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            Hyperlink hyperlink = (Hyperlink)base.DeepCopy();
 | 
			
		||||
            if (hyperlink._elements != null)
 | 
			
		||||
            {
 | 
			
		||||
                hyperlink._elements = hyperlink._elements.Clone();
 | 
			
		||||
                hyperlink._elements._parent = hyperlink;
 | 
			
		||||
            }
 | 
			
		||||
            return hyperlink;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a text phrase to the hyperlink.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddText(String text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddText(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a single character repeated the specified number of times to the hyperlink.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddChar(char ch, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChar(ch, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a single character to the hyperlink.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddChar(char ch)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChar(ch);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds one or more Symbol objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(SymbolName symbolType, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(symbolType, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a Symbol object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(SymbolName symbolType)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(symbolType);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds one or more Symbol objects defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(char ch, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(ch, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a Symbol object defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(char ch)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(ch);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a space character as many as count.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddSpace(int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddSpace(count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a horizontal tab.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void AddTab()
 | 
			
		||||
        {
 | 
			
		||||
            Elements.AddTab();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(TextFormat textFormat)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(textFormat);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText with the given Font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(Font font)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(font);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText with the given text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, TextFormat textFormat)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text, textFormat);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, Font font)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text, font);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, string style)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text, style);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Bookmark.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public BookmarkField AddBookmark(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddBookmark(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageField AddPageField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddPageField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageRefField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageRefField AddPageRefField(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddPageRefField(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new NumPagesField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public NumPagesField AddNumPagesField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddNumPagesField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SectionField AddSectionField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddSectionField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionPagesField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SectionPagesField AddSectionPagesField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddSectionPagesField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateField AddDateField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddDateField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateField AddDateField(string format)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddDateField(format);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new InfoField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public InfoField AddInfoField(InfoFieldType iType)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddInfoField(iType);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote with the specified text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote AddFootnote(string text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFootnote(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote AddFootnote()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFootnote();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Image object
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Image AddImage(string fileName)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddImage(fileName);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Bookmark
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(BookmarkField bookmark)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(bookmark);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(PageField pageField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(pageField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageRefField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(PageRefField pageRefField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(pageRefField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new NumPagesField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(NumPagesField numPagesField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(numPagesField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(SectionField sectionField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(sectionField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionPagesField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(SectionPagesField sectionPagesField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(sectionPagesField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(DateField dateField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(dateField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new InfoField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(InfoField infoField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(infoField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Footnote footnote)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(footnote);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Text
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Text text)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(FormattedText formattedText)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(formattedText);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Image
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Image image)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(image);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Character
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Character character)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(character);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the font object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Font Font
 | 
			
		||||
        {
 | 
			
		||||
            get { return _font ?? (_font = new Font(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _font = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Font _font;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the target name of the Hyperlink, e.g. an URL or a bookmark's name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Name
 | 
			
		||||
        {
 | 
			
		||||
            get { return _name.Value; }
 | 
			
		||||
            set { _name.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _name = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the target type of the Hyperlink.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HyperlinkType Type
 | 
			
		||||
        {
 | 
			
		||||
            get { return (HyperlinkType)_type.Value; }
 | 
			
		||||
            set { _type.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(HyperlinkType))]
 | 
			
		||||
        public NEnum _type = NEnum.NullValue(typeof(HyperlinkType));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the ParagraphElements of the Hyperlink specifying its 'clickable area'.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphElements Elements
 | 
			
		||||
        {
 | 
			
		||||
            get { return _elements ?? (_elements = new ParagraphElements(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _elements = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(ItemType = typeof(DocumentObject))]
 | 
			
		||||
        public ParagraphElements _elements;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Hyperlink into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (_name.Value == string.Empty)
 | 
			
		||||
                throw new InvalidOperationException(DomSR.MissingObligatoryProperty("Name", "Hyperlink"));
 | 
			
		||||
            serializer.Write("\\hyperlink");
 | 
			
		||||
            string str = "[Name = \"" + Name.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
 | 
			
		||||
            if (!_type.IsNull)
 | 
			
		||||
                str += " Type = " + Type;
 | 
			
		||||
            str += "]";
 | 
			
		||||
            serializer.Write(str);
 | 
			
		||||
            serializer.Write("{");
 | 
			
		||||
            if (_elements != null)
 | 
			
		||||
                _elements.Serialize(serializer);
 | 
			
		||||
            serializer.Write("}");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Hyperlink))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region IDomVisitable Members
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitHyperlink(this);
 | 
			
		||||
            if (visitChildren && _elements != null)
 | 
			
		||||
            {
 | 
			
		||||
                ((IVisitable)_elements).AcceptVisitor(visitor, true);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										128
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/ImageHelper.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/ImageHelper.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,128 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Deals with image file names, searches along the image path, checks if images exist etc.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class ImageHelper
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the first existing image from the subfolders.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string GetImageName(string root, string filename, string imagePath)
 | 
			
		||||
        {
 | 
			
		||||
            List<string> subfolders = new List<string>(imagePath.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries));
 | 
			
		||||
            subfolders.Add("");
 | 
			
		||||
 | 
			
		||||
            foreach (string subfolder in subfolders)
 | 
			
		||||
            {
 | 
			
		||||
                string fullname = System.IO.Path.Combine(System.IO.Path.Combine(root, subfolder), filename);
 | 
			
		||||
                int pageNumber;
 | 
			
		||||
                string realFile = ExtractPageNumber(fullname, out pageNumber);
 | 
			
		||||
 | 
			
		||||
#if !NETFX_CORE
 | 
			
		||||
                if (System.IO.File.Exists(realFile))
 | 
			
		||||
                    return fullname;
 | 
			
		||||
#else
 | 
			
		||||
                throw new NotImplementedException();
 | 
			
		||||
                //if (System.IO.File.Exists(realFile))
 | 
			
		||||
                //    return fullname;
 | 
			
		||||
#endif
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a value indicating whether the filename given in the referenceFilename exists in the subfolders.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static bool InSubfolder(string root, string filename, string imagePath, string referenceFilename)
 | 
			
		||||
        {
 | 
			
		||||
            List<string> subfolders = new List<string>(imagePath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
 | 
			
		||||
            subfolders.Add("");
 | 
			
		||||
 | 
			
		||||
            foreach (string subfolder in subfolders)
 | 
			
		||||
            {
 | 
			
		||||
                string fullname = System.IO.Path.Combine(System.IO.Path.Combine(root, subfolder), filename);
 | 
			
		||||
                int pageNumber;
 | 
			
		||||
                string realFile = ExtractPageNumber(fullname, out pageNumber);
 | 
			
		||||
#if !NETFX_CORE
 | 
			
		||||
                if (System.IO.File.Exists(realFile))
 | 
			
		||||
                {
 | 
			
		||||
                    if (fullname == referenceFilename)
 | 
			
		||||
                        return true;
 | 
			
		||||
                }
 | 
			
		||||
#else
 | 
			
		||||
                throw new NotImplementedException();
 | 
			
		||||
#endif
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Extracts the page number if the path has the form 'MyFile.pdf#123' and returns
 | 
			
		||||
        /// the actual path without the number sign and the following digits.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string ExtractPageNumber(string path, out int pageNumber)
 | 
			
		||||
        {
 | 
			
		||||
            // Note: duplicated from class XPdfForm
 | 
			
		||||
            if (path == null)
 | 
			
		||||
                throw new ArgumentNullException("path");
 | 
			
		||||
 | 
			
		||||
            pageNumber = 0;
 | 
			
		||||
            int length = path.Length;
 | 
			
		||||
            if (length != 0)
 | 
			
		||||
            {
 | 
			
		||||
                length--;
 | 
			
		||||
                if (Char.IsDigit(path, length))
 | 
			
		||||
                {
 | 
			
		||||
                    while (Char.IsDigit(path, length) && length >= 0)
 | 
			
		||||
                        length--;
 | 
			
		||||
                    if (length > 0 && path[length] == '#')
 | 
			
		||||
                    {
 | 
			
		||||
                        // must have at least one dot left of colon to distinguish from e.g. '#123'
 | 
			
		||||
                        if (path.IndexOf('.') != -1)
 | 
			
		||||
                        {
 | 
			
		||||
                            pageNumber = Int32.Parse(path.Substring(length + 1));
 | 
			
		||||
                            path = path.Substring(0, length);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return path;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										123
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/ListInfo.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/ListInfo.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,123 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// A ListInfo is the representation of a series of paragraphs as a list.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class ListInfo : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the ListInfo class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ListInfo()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the ListInfo class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ListInfo(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new ListInfo Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (ListInfo)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the type of the list.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ListType ListType
 | 
			
		||||
        {
 | 
			
		||||
            get { return (ListType)_listType.Value; }
 | 
			
		||||
            set { _listType.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(ListType))]
 | 
			
		||||
        public NEnum _listType = NEnum.NullValue(typeof(ListType));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the left indent of the list symbol.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit NumberPosition
 | 
			
		||||
        {
 | 
			
		||||
            get { return _numberPosition; }
 | 
			
		||||
            set { _numberPosition = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _numberPosition = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value indicating whether
 | 
			
		||||
        /// the previous list numbering should be continued.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool ContinuePreviousList
 | 
			
		||||
        {
 | 
			
		||||
            get { return _continuePreviousList.Value; }
 | 
			
		||||
            set { _continuePreviousList.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _continuePreviousList = NBool.NullValue;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts ListInfo into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (!_listType.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("ListInfo.ListType", ListType);
 | 
			
		||||
            if (!_numberPosition.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("ListInfo.NumberPosition", NumberPosition);
 | 
			
		||||
            if (!_continuePreviousList.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("ListInfo.ContinuePreviousList", ContinuePreviousList);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(ListInfo))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,78 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// A PageBreak is used to put following elements on a new page.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class PageBreak : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the PageBreak class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageBreak()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the PageBreak class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageBreak(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new PageBreak Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (PageBreak)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts PageBreak into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            serializer.WriteLine("\\pagebreak");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(PageBreak))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										467
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/PageSetup.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										467
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/PageSetup.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,467 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents the page setup of a section.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class PageSetup : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the PageSetup class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageSetup()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the PageSetup class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageSetup(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new PageSetup Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (PageSetup)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the page's size and height for the given PageFormat.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static void GetPageSize(PageFormat pageFormat, out Unit pageWidth, out Unit pageHeight)
 | 
			
		||||
        {
 | 
			
		||||
            //Sizes in mm:
 | 
			
		||||
            pageWidth = 0;
 | 
			
		||||
            pageHeight = 0;
 | 
			
		||||
            const int A0Height = 1189;
 | 
			
		||||
            const int A0Width = 841;
 | 
			
		||||
            int height = 0;
 | 
			
		||||
            int width = 0;
 | 
			
		||||
            switch (pageFormat)
 | 
			
		||||
            {
 | 
			
		||||
                case PageFormat.A0:
 | 
			
		||||
                    height = A0Height;
 | 
			
		||||
                    width = A0Width;
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.A1:
 | 
			
		||||
                    height = A0Width;
 | 
			
		||||
                    width = A0Height / 2;
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.A2:
 | 
			
		||||
                    height = A0Height / 2;
 | 
			
		||||
                    width = A0Width / 2;
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.A3:
 | 
			
		||||
                    height = A0Width / 2;
 | 
			
		||||
                    width = A0Height / 4;
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.A4:
 | 
			
		||||
                    height = A0Height / 4;
 | 
			
		||||
                    width = A0Width / 4;
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.A5:
 | 
			
		||||
                    height = A0Width / 4;
 | 
			
		||||
                    width = A0Height / 8;
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.A6:
 | 
			
		||||
                    height = A0Height / 8;
 | 
			
		||||
                    width = A0Width / 8;
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.B5:
 | 
			
		||||
                    height = 257;
 | 
			
		||||
                    width = 182;
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.Letter:
 | 
			
		||||
                    pageWidth = Unit.FromPoint(612);
 | 
			
		||||
                    pageHeight = Unit.FromPoint(792);
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.Legal:
 | 
			
		||||
                    pageWidth = Unit.FromPoint(612);
 | 
			
		||||
                    pageHeight = Unit.FromPoint(1008);
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.Ledger:
 | 
			
		||||
                    pageWidth = Unit.FromPoint(1224);
 | 
			
		||||
                    pageHeight = Unit.FromPoint(792);
 | 
			
		||||
                    break;
 | 
			
		||||
                case PageFormat.P11x17:
 | 
			
		||||
                    pageWidth = Unit.FromPoint(792);
 | 
			
		||||
                    pageHeight = Unit.FromPoint(1224);
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
            if (height > 0)
 | 
			
		||||
                pageHeight = Unit.FromMillimeter(height);
 | 
			
		||||
            if (width > 0)
 | 
			
		||||
                pageWidth = Unit.FromMillimeter(width);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value which defines whether the section starts on next, odd or even page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public BreakType SectionStart
 | 
			
		||||
        {
 | 
			
		||||
            get { return (BreakType)_sectionStart.Value; }
 | 
			
		||||
            set { _sectionStart.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(BreakType))]
 | 
			
		||||
        public NEnum _sectionStart = NEnum.NullValue(typeof(BreakType));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the page orientation of the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Orientation Orientation
 | 
			
		||||
        {
 | 
			
		||||
            get { return (Orientation)_orientation.Value; }
 | 
			
		||||
            set { _orientation.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(Orientation))]
 | 
			
		||||
        public NEnum _orientation = NEnum.NullValue(typeof(Orientation));
 | 
			
		||||
 | 
			
		||||
        private bool IsLandscape
 | 
			
		||||
        {
 | 
			
		||||
            get { return Orientation == Orientation.Landscape; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // TODO To be compatible with Word, PageWidth should always return the actual width (e.g. 21 cm for DIN A 4 portrait and 29.7 cm for DIN A 4 landscape).
 | 
			
		||||
        // TODO Pagemargins are also "moving": portrait-left becomes landscape-top
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the page width. If Orientation is set to Landscape, the PageWidth specifies the height of the page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit PageWidth
 | 
			
		||||
        {
 | 
			
		||||
            get { return _pageWidth; }
 | 
			
		||||
            set { _pageWidth = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _pageWidth = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the effective page width, depending on the Orientation this will either be the height or the width.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit EffectivePageWidth
 | 
			
		||||
        {
 | 
			
		||||
            get { return IsLandscape ? PageHeight : PageWidth; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the starting number for the first section page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int StartingNumber
 | 
			
		||||
        {
 | 
			
		||||
            get { return _startingNumber.Value; }
 | 
			
		||||
            set { _startingNumber.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NInt _startingNumber = NInt.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the page height. If Orientation is set to Landscape, the PageHeight specifies the width of the page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit PageHeight
 | 
			
		||||
        {
 | 
			
		||||
            get { return _pageHeight; }
 | 
			
		||||
            set { _pageHeight = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _pageHeight = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the effective page height, depending on the Orientation this will either be the height or the width.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit EffectivePageHeight
 | 
			
		||||
        {
 | 
			
		||||
            get { return IsLandscape ? PageWidth : PageHeight; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the top margin of the pages in the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit TopMargin
 | 
			
		||||
        {
 | 
			
		||||
            get { return _topMargin; }
 | 
			
		||||
            set { _topMargin = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _topMargin = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the bottom margin of the pages in the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit BottomMargin
 | 
			
		||||
        {
 | 
			
		||||
            get { return _bottomMargin; }
 | 
			
		||||
            set { _bottomMargin = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _bottomMargin = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the left margin of the pages in the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit LeftMargin
 | 
			
		||||
        {
 | 
			
		||||
            get { return _leftMargin; }
 | 
			
		||||
            set { _leftMargin = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _leftMargin = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the right margin of the pages in the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit RightMargin
 | 
			
		||||
        {
 | 
			
		||||
            get { return _rightMargin; }
 | 
			
		||||
            set { _rightMargin = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _rightMargin = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value which defines whether the odd and even pages
 | 
			
		||||
        /// of the section have different header and footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool OddAndEvenPagesHeaderFooter
 | 
			
		||||
        {
 | 
			
		||||
            get { return _oddAndEvenPagesHeaderFooter.Value; }
 | 
			
		||||
            set { _oddAndEvenPagesHeaderFooter.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _oddAndEvenPagesHeaderFooter = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value which define whether the section has a different
 | 
			
		||||
        /// first page header and footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool DifferentFirstPageHeaderFooter
 | 
			
		||||
        {
 | 
			
		||||
            get { return _differentFirstPageHeaderFooter.Value; }
 | 
			
		||||
            set { _differentFirstPageHeaderFooter.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _differentFirstPageHeaderFooter = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the distance between the header and the page top
 | 
			
		||||
        /// of the pages in the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit HeaderDistance
 | 
			
		||||
        {
 | 
			
		||||
            get { return _headerDistance; }
 | 
			
		||||
            set { _headerDistance = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _headerDistance = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the distance between the footer and the page bottom
 | 
			
		||||
        /// of the pages in the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit FooterDistance
 | 
			
		||||
        {
 | 
			
		||||
            get { return _footerDistance; }
 | 
			
		||||
            set { _footerDistance = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _footerDistance = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value which defines whether the odd and even pages
 | 
			
		||||
        /// of the section should change left and right margin.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool MirrorMargins
 | 
			
		||||
        {
 | 
			
		||||
            get { return _mirrorMargins.Value; }
 | 
			
		||||
            set { _mirrorMargins.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _mirrorMargins = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value which defines whether a page should break horizontally.
 | 
			
		||||
        /// Currently only tables are supported.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool HorizontalPageBreak
 | 
			
		||||
        {
 | 
			
		||||
            get { return _horizontalPageBreak.Value; }
 | 
			
		||||
            set { _horizontalPageBreak.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _horizontalPageBreak = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the page format of the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageFormat PageFormat
 | 
			
		||||
        {
 | 
			
		||||
            get { return (PageFormat)_pageFormat.Value; }
 | 
			
		||||
            set { _pageFormat.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(PageFormat))]
 | 
			
		||||
        public NEnum _pageFormat = NEnum.NullValue(typeof(PageFormat));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a comment associated with this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Comment
 | 
			
		||||
        {
 | 
			
		||||
            get { return _comment.Value; }
 | 
			
		||||
            set { _comment.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _comment = NString.NullValue;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the PageSetup of the previous section, or null, if the page setup belongs 
 | 
			
		||||
        /// to the first section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageSetup PreviousPageSetup()
 | 
			
		||||
        {
 | 
			
		||||
            Section section = Parent as Section;
 | 
			
		||||
            if (section != null)
 | 
			
		||||
            {
 | 
			
		||||
                section = section.PreviousSection();
 | 
			
		||||
                if (section != null)
 | 
			
		||||
                    return section.PageSetup;
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a PageSetup object with default values for all properties.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static PageSetup DefaultPageSetup
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_defaultPageSetup == null)
 | 
			
		||||
                {
 | 
			
		||||
                    _defaultPageSetup = new PageSetup();
 | 
			
		||||
                    _defaultPageSetup.PageFormat = PageFormat.A4;
 | 
			
		||||
                    _defaultPageSetup.SectionStart = BreakType.BreakNextPage;
 | 
			
		||||
                    _defaultPageSetup.Orientation = Orientation.Portrait;
 | 
			
		||||
                    _defaultPageSetup.PageWidth = "21cm";
 | 
			
		||||
                    _defaultPageSetup.PageHeight = "29.7cm";
 | 
			
		||||
                    _defaultPageSetup.TopMargin = "2.5cm";
 | 
			
		||||
                    _defaultPageSetup.BottomMargin = "2cm";
 | 
			
		||||
                    _defaultPageSetup.LeftMargin = "2.5cm";
 | 
			
		||||
                    _defaultPageSetup.RightMargin = "2.5cm";
 | 
			
		||||
                    _defaultPageSetup.HeaderDistance = "1.25cm";
 | 
			
		||||
                    _defaultPageSetup.FooterDistance = "1.25cm";
 | 
			
		||||
                    _defaultPageSetup.OddAndEvenPagesHeaderFooter = false;
 | 
			
		||||
                    _defaultPageSetup.DifferentFirstPageHeaderFooter = false;
 | 
			
		||||
                    _defaultPageSetup.MirrorMargins = false;
 | 
			
		||||
                    _defaultPageSetup.HorizontalPageBreak = false;
 | 
			
		||||
                }
 | 
			
		||||
                return _defaultPageSetup;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        static PageSetup _defaultPageSetup;
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts PageSetup into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            serializer.WriteComment(_comment.Value);
 | 
			
		||||
            int pos = serializer.BeginContent("PageSetup");
 | 
			
		||||
 | 
			
		||||
            if (!_pageHeight.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("PageHeight", PageHeight);
 | 
			
		||||
 | 
			
		||||
            if (!_pageWidth.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("PageWidth", PageWidth);
 | 
			
		||||
 | 
			
		||||
            if (!_orientation.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("Orientation", Orientation);
 | 
			
		||||
 | 
			
		||||
            if (!_leftMargin.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("LeftMargin", LeftMargin);
 | 
			
		||||
 | 
			
		||||
            if (!_rightMargin.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("RightMargin", RightMargin);
 | 
			
		||||
 | 
			
		||||
            if (!_topMargin.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("TopMargin", TopMargin);
 | 
			
		||||
 | 
			
		||||
            if (!_bottomMargin.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("BottomMargin", BottomMargin);
 | 
			
		||||
 | 
			
		||||
            if (!_footerDistance.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("FooterDistance", FooterDistance);
 | 
			
		||||
 | 
			
		||||
            if (!_headerDistance.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("HeaderDistance", HeaderDistance);
 | 
			
		||||
 | 
			
		||||
            if (!_oddAndEvenPagesHeaderFooter.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("OddAndEvenPagesHeaderFooter", OddAndEvenPagesHeaderFooter);
 | 
			
		||||
 | 
			
		||||
            if (!_differentFirstPageHeaderFooter.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("DifferentFirstPageHeaderFooter", DifferentFirstPageHeaderFooter);
 | 
			
		||||
 | 
			
		||||
            if (!_sectionStart.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("SectionStart", SectionStart);
 | 
			
		||||
 | 
			
		||||
            if (!_pageFormat.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("PageFormat", PageFormat);
 | 
			
		||||
 | 
			
		||||
            if (!_mirrorMargins.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("MirrorMargins", MirrorMargins);
 | 
			
		||||
 | 
			
		||||
            if (!_horizontalPageBreak.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("HorizontalPageBreak", HorizontalPageBreak);
 | 
			
		||||
 | 
			
		||||
            if (!_startingNumber.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("StartingNumber", StartingNumber);
 | 
			
		||||
 | 
			
		||||
            serializer.EndContent(pos);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(PageSetup))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										622
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Paragraph.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										622
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Paragraph.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,622 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Fields;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents a paragraph which is used to build up a document with text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Paragraph : DocumentObject, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Paragraph class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Paragraph class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Paragraph Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Paragraph)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            Paragraph paragraph = (Paragraph)base.DeepCopy();
 | 
			
		||||
            if (paragraph._format != null)
 | 
			
		||||
            {
 | 
			
		||||
                paragraph._format = paragraph._format.Clone();
 | 
			
		||||
                paragraph._format._parent = paragraph;
 | 
			
		||||
            }
 | 
			
		||||
            if (paragraph._elements != null)
 | 
			
		||||
            {
 | 
			
		||||
                paragraph._elements = paragraph._elements.Clone();
 | 
			
		||||
                paragraph._elements._parent = paragraph;
 | 
			
		||||
            }
 | 
			
		||||
            return paragraph;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a text phrase to the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddText(String text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddText(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a single character repeated the specified number of times to the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddChar(char ch, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChar(ch, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a single character to the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddChar(char ch)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChar(ch);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds one or more Symbol objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(SymbolName symbolType, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(symbolType, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a Symbol object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(SymbolName symbolType)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(symbolType);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds one or more Symbol objects defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(char ch, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(ch, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a Symbol object defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(char ch)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddCharacter(ch);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a space character as many as count.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddSpace(int count)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddSpace(count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a horizontal tab.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void AddTab()
 | 
			
		||||
        {
 | 
			
		||||
            Elements.AddTab();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a line break.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void AddLineBreak()
 | 
			
		||||
        {
 | 
			
		||||
            Elements.AddLineBreak();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(TextFormat textFormat)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(textFormat);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText with the given Font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(Font font)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(font);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText with the given text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, TextFormat textFormat)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text, textFormat);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, Font font)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text, font);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, string style)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFormattedText(text, style);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Hyperlink of Type "Local", 
 | 
			
		||||
        /// i.e. the Target is a Bookmark within the Document
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink AddHyperlink(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddHyperlink(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Hyperlink
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink AddHyperlink(string name, HyperlinkType type)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddHyperlink(name, type);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Bookmark.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public BookmarkField AddBookmark(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddBookmark(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageField AddPageField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddPageField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageRefField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageRefField AddPageRefField(string name)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddPageRefField(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new NumPagesField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public NumPagesField AddNumPagesField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddNumPagesField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SectionField AddSectionField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddSectionField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionPagesField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SectionPagesField AddSectionPagesField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddSectionPagesField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateField AddDateField()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddDateField();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateField AddDateField(string format)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddDateField(format);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new InfoField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public InfoField AddInfoField(InfoFieldType iType)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddInfoField(iType);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote with the specified text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote AddFootnote(string text)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFootnote(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote AddFootnote()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddFootnote();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Image object
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Image AddImage(string fileName)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddImage(fileName);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Bookmark
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(BookmarkField bookmark)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(bookmark);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(PageField pageField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(pageField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageRefField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(PageRefField pageRefField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(pageRefField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new NumPagesField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(NumPagesField numPagesField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(numPagesField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(SectionField sectionField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(sectionField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionPagesField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(SectionPagesField sectionPagesField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(sectionPagesField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(DateField dateField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(dateField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new InfoField
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(InfoField infoField)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(infoField);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Footnote footnote)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(footnote);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Text
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Text text)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(FormattedText formattedText)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(formattedText);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Hyperlink
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Hyperlink hyperlink)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(hyperlink);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Image
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Image image)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(image);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Character
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Character character)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(character);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the style name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Style
 | 
			
		||||
        {
 | 
			
		||||
            get { return _style.Value; }
 | 
			
		||||
            set { _style.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _style = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the ParagraphFormat object of the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphFormat Format
 | 
			
		||||
        {
 | 
			
		||||
            get { return _format ?? (_format = new ParagraphFormat(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _format = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public ParagraphFormat _format;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the collection of document objects that defines the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphElements Elements
 | 
			
		||||
        {
 | 
			
		||||
            get { return _elements ?? (_elements = new ParagraphElements(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _elements = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public ParagraphElements _elements;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a comment associated with this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Comment
 | 
			
		||||
        {
 | 
			
		||||
            get { return _comment.Value; }
 | 
			
		||||
            set { _comment.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _comment = NString.NullValue;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitParagraph(this);
 | 
			
		||||
 | 
			
		||||
            if (visitChildren && _elements != null)
 | 
			
		||||
                ((IVisitable)_elements).AcceptVisitor(visitor, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// For public use only.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool SerializeContentOnly
 | 
			
		||||
        {
 | 
			
		||||
            get { return _serializeContentOnly; }
 | 
			
		||||
            set { _serializeContentOnly = value; }
 | 
			
		||||
        }
 | 
			
		||||
        bool _serializeContentOnly;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Paragraph into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (!_serializeContentOnly)
 | 
			
		||||
            {
 | 
			
		||||
                serializer.WriteComment(_comment.Value);
 | 
			
		||||
                serializer.WriteLine("\\paragraph");
 | 
			
		||||
 | 
			
		||||
                int pos = serializer.BeginAttributes();
 | 
			
		||||
 | 
			
		||||
                if (_style.Value != "")
 | 
			
		||||
                    serializer.WriteLine("Style = \"" + _style.Value + "\"");
 | 
			
		||||
 | 
			
		||||
                if (!IsNull("Format"))
 | 
			
		||||
                    _format.Serialize(serializer, "Format", null);
 | 
			
		||||
 | 
			
		||||
                serializer.EndAttributes(pos);
 | 
			
		||||
 | 
			
		||||
                serializer.BeginContent();
 | 
			
		||||
                if (!IsNull("Elements"))
 | 
			
		||||
                    Elements.Serialize(serializer);
 | 
			
		||||
                serializer.CloseUpLine();
 | 
			
		||||
                serializer.EndContent();
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Elements.Serialize(serializer);
 | 
			
		||||
                serializer.CloseUpLine();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Paragraph))); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns an array of Paragraphs that are separated by parabreaks. Null if no parabreak is found.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph[] SplitOnParaBreak()
 | 
			
		||||
        {
 | 
			
		||||
            if (_elements == null)
 | 
			
		||||
                return null;
 | 
			
		||||
 | 
			
		||||
            int startIdx = 0;
 | 
			
		||||
            List<Paragraph> paragraphs = new List<Paragraph>();
 | 
			
		||||
            for (int idx = 0; idx < Elements.Count; ++idx)
 | 
			
		||||
            {
 | 
			
		||||
                DocumentObject element = Elements[idx];
 | 
			
		||||
                if (element is Character)
 | 
			
		||||
                {
 | 
			
		||||
                    Character character = (Character)element;
 | 
			
		||||
                    if (character.SymbolName == SymbolName.ParaBreak)
 | 
			
		||||
                    {
 | 
			
		||||
                        Paragraph paragraph = new Paragraph();
 | 
			
		||||
                        paragraph.Format = Format.Clone();
 | 
			
		||||
                        paragraph.Style = Style;
 | 
			
		||||
                        paragraph.Elements = SubsetElements(startIdx, idx - 1);
 | 
			
		||||
                        startIdx = idx + 1;
 | 
			
		||||
                        paragraphs.Add(paragraph);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (startIdx == 0) //No paragraph breaks given.
 | 
			
		||||
                return null;
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Paragraph paragraph = new Paragraph();
 | 
			
		||||
                paragraph.Format = Format.Clone();
 | 
			
		||||
                paragraph.Style = Style;
 | 
			
		||||
                paragraph.Elements = SubsetElements(startIdx, _elements.Count - 1);
 | 
			
		||||
                paragraphs.Add(paragraph);
 | 
			
		||||
 | 
			
		||||
                return paragraphs.ToArray();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a subset of the paragraphs elements.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="startIdx">Start index of the required subset.</param>
 | 
			
		||||
        /// <param name="endIdx">End index of the required subset.</param>
 | 
			
		||||
        /// <returns>A ParagraphElements object with cloned elements.</returns>
 | 
			
		||||
        private ParagraphElements SubsetElements(int startIdx, int endIdx)
 | 
			
		||||
        {
 | 
			
		||||
            ParagraphElements paragraphElements = new ParagraphElements();
 | 
			
		||||
            for (int idx = startIdx; idx <= endIdx; ++idx)
 | 
			
		||||
                paragraphElements.Add((DocumentObject)_elements[idx].Clone());
 | 
			
		||||
            return paragraphElements;
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,457 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Fields;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// A ParagraphElements collection contains the individual objects of a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class ParagraphElements : DocumentObjectCollection
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the ParagraphElements class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphElements()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the ParagraphElements class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphElements(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a ParagraphElement by its index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new DocumentObject this[int index]
 | 
			
		||||
        {
 | 
			
		||||
            get { return base[index] as DocumentObject; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new ParagraphElements Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (ParagraphElements)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a Text object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="text">Content of the new Text object.</param>
 | 
			
		||||
        /// <returns>Returns a new Text object.</returns>
 | 
			
		||||
        public Text AddText(string text)
 | 
			
		||||
        {
 | 
			
		||||
            if (text == null)
 | 
			
		||||
                throw new ArgumentNullException("text");
 | 
			
		||||
#if true
 | 
			
		||||
            Text txt = null;
 | 
			
		||||
            string[] lines = text.Split('\n');
 | 
			
		||||
            int lineCount = lines.Length;
 | 
			
		||||
            for (int line = 0; line < lineCount; line++)
 | 
			
		||||
            {
 | 
			
		||||
                string[] tabParts = lines[line].Split('\t');
 | 
			
		||||
                int count = tabParts.Length;
 | 
			
		||||
                for (int idx = 0; idx < count; idx++)
 | 
			
		||||
                {
 | 
			
		||||
                    if (tabParts[idx].Length != 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        txt = new Text(tabParts[idx]);
 | 
			
		||||
                        Add(txt);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (idx < count - 1)
 | 
			
		||||
                        AddTab();
 | 
			
		||||
                }
 | 
			
		||||
                if (line < lineCount - 1)
 | 
			
		||||
                    AddLineBreak();
 | 
			
		||||
            }
 | 
			
		||||
            return txt;
 | 
			
		||||
#else
 | 
			
		||||
      Text txt = new Text();
 | 
			
		||||
      txt.Content = text;
 | 
			
		||||
      Add(txt);
 | 
			
		||||
      return txt;
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a single character repeated the specified number of times to the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddChar(char ch, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return AddText(new string(ch, count));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a single character to the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text AddChar(char ch)
 | 
			
		||||
        {
 | 
			
		||||
            return AddText(new string(ch, 1));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a Character object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(SymbolName symbolType)
 | 
			
		||||
        {
 | 
			
		||||
            return AddCharacter(symbolType, 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds one or more Character objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(SymbolName symbolType, int count)
 | 
			
		||||
        {
 | 
			
		||||
            Character character = new Character();
 | 
			
		||||
            Add(character);
 | 
			
		||||
            character.SymbolName = symbolType;
 | 
			
		||||
            character.Count = count;
 | 
			
		||||
            return character;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a Character object defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(char ch)
 | 
			
		||||
        {
 | 
			
		||||
            return AddCharacter((SymbolName)ch, 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds one or more Character objects defined by a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddCharacter(char ch, int count)
 | 
			
		||||
        {
 | 
			
		||||
            return AddCharacter((SymbolName)ch, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a space character as many as count.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddSpace(int count)
 | 
			
		||||
        {
 | 
			
		||||
            return AddCharacter(SymbolName.Blank, count);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a horizontal tab.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddTab()
 | 
			
		||||
        {
 | 
			
		||||
            return AddCharacter(SymbolName.Tab, 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a line break.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Character AddLineBreak()
 | 
			
		||||
        {
 | 
			
		||||
            return AddCharacter(SymbolName.LineBreak, 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText()
 | 
			
		||||
        {
 | 
			
		||||
            FormattedText formattedText = new FormattedText();
 | 
			
		||||
            Add(formattedText);
 | 
			
		||||
            return formattedText;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(TextFormat textFormat)
 | 
			
		||||
        {
 | 
			
		||||
            FormattedText formattedText = AddFormattedText();
 | 
			
		||||
 | 
			
		||||
            if ((textFormat & TextFormat.Bold) == TextFormat.Bold)
 | 
			
		||||
                formattedText.Bold = true;
 | 
			
		||||
            if ((textFormat & TextFormat.NotBold) == TextFormat.NotBold)
 | 
			
		||||
                formattedText.Bold = false;
 | 
			
		||||
            if ((textFormat & TextFormat.Italic) == TextFormat.Italic)
 | 
			
		||||
                formattedText.Italic = true;
 | 
			
		||||
            if ((textFormat & TextFormat.NotItalic) == TextFormat.NotItalic)
 | 
			
		||||
                formattedText.Italic = false;
 | 
			
		||||
            if ((textFormat & TextFormat.Underline) == TextFormat.Underline)
 | 
			
		||||
                formattedText.Underline = Underline.Single;
 | 
			
		||||
            if ((textFormat & TextFormat.NoUnderline) == TextFormat.NoUnderline)
 | 
			
		||||
                formattedText.Underline = Underline.None;
 | 
			
		||||
 | 
			
		||||
            return formattedText;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText with the given Font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(Font font)
 | 
			
		||||
        {
 | 
			
		||||
            FormattedText formattedText = new FormattedText();
 | 
			
		||||
            formattedText.Font.ApplyFont(font);
 | 
			
		||||
            Add(formattedText);
 | 
			
		||||
            return formattedText;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText with the given text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text)
 | 
			
		||||
        {
 | 
			
		||||
            FormattedText formattedText = new FormattedText();
 | 
			
		||||
            formattedText.AddText(text);
 | 
			
		||||
            Add(formattedText);
 | 
			
		||||
            return formattedText;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, TextFormat textFormat)
 | 
			
		||||
        {
 | 
			
		||||
            FormattedText formattedText = AddFormattedText(textFormat);
 | 
			
		||||
            formattedText.AddText(text);
 | 
			
		||||
            return formattedText;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, Font font)
 | 
			
		||||
        {
 | 
			
		||||
            FormattedText formattedText = AddFormattedText(font);
 | 
			
		||||
            formattedText.AddText(text);
 | 
			
		||||
            return formattedText;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new FormattedText object with the given text and style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public FormattedText AddFormattedText(string text, string style)
 | 
			
		||||
        {
 | 
			
		||||
            FormattedText formattedText = AddFormattedText(text);
 | 
			
		||||
            formattedText.Style = style;
 | 
			
		||||
            return formattedText;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Hyperlink of Type "Local", i.e. the Target is a Bookmark within the Document
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink AddHyperlink(string name)
 | 
			
		||||
        {
 | 
			
		||||
            Hyperlink hyperlink = new Hyperlink();
 | 
			
		||||
            hyperlink.Name = name;
 | 
			
		||||
            Add(hyperlink);
 | 
			
		||||
            return hyperlink;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Hyperlink
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Hyperlink AddHyperlink(string name, HyperlinkType type)
 | 
			
		||||
        {
 | 
			
		||||
            Hyperlink hyperlink = new Hyperlink();
 | 
			
		||||
            hyperlink.Name = name;
 | 
			
		||||
            hyperlink.Type = type;
 | 
			
		||||
            Add(hyperlink);
 | 
			
		||||
            return hyperlink;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Bookmark.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public BookmarkField AddBookmark(string name)
 | 
			
		||||
        {
 | 
			
		||||
            BookmarkField fieldBookmark = new BookmarkField();
 | 
			
		||||
            fieldBookmark.Name = name;
 | 
			
		||||
            Add(fieldBookmark);
 | 
			
		||||
            return fieldBookmark;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new PageField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageField AddPageField()
 | 
			
		||||
        {
 | 
			
		||||
            PageField fieldPage = new PageField();
 | 
			
		||||
            Add(fieldPage);
 | 
			
		||||
            return fieldPage;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new RefFieldPage.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageRefField AddPageRefField(string name)
 | 
			
		||||
        {
 | 
			
		||||
            PageRefField fieldPageRef = new PageRefField();
 | 
			
		||||
            fieldPageRef.Name = name;
 | 
			
		||||
            Add(fieldPageRef);
 | 
			
		||||
            return fieldPageRef;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new NumPagesField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public NumPagesField AddNumPagesField()
 | 
			
		||||
        {
 | 
			
		||||
            NumPagesField fieldNumPages = new NumPagesField();
 | 
			
		||||
            Add(fieldNumPages);
 | 
			
		||||
            return fieldNumPages;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SectionField AddSectionField()
 | 
			
		||||
        {
 | 
			
		||||
            SectionField fieldSection = new SectionField();
 | 
			
		||||
            Add(fieldSection);
 | 
			
		||||
            return fieldSection;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new SectionPagesField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SectionPagesField AddSectionPagesField()
 | 
			
		||||
        {
 | 
			
		||||
            SectionPagesField fieldSectionPages = new SectionPagesField();
 | 
			
		||||
            Add(fieldSectionPages);
 | 
			
		||||
            return fieldSectionPages;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// 
 | 
			
		||||
        public DateField AddDateField()
 | 
			
		||||
        {
 | 
			
		||||
            DateField fieldDate = new DateField();
 | 
			
		||||
            Add(fieldDate);
 | 
			
		||||
            return fieldDate;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new DateField with the given format.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateField AddDateField(string format)
 | 
			
		||||
        {
 | 
			
		||||
            DateField fieldDate = new DateField();
 | 
			
		||||
            fieldDate.Format = format;
 | 
			
		||||
            Add(fieldDate);
 | 
			
		||||
            return fieldDate;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new InfoField with the given type.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public InfoField AddInfoField(InfoFieldType iType)
 | 
			
		||||
        {
 | 
			
		||||
            InfoField fieldInfo = new InfoField();
 | 
			
		||||
            fieldInfo.Name = iType.ToString();
 | 
			
		||||
            Add(fieldInfo);
 | 
			
		||||
            return fieldInfo;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote with the specified Text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote AddFootnote(string text)
 | 
			
		||||
        {
 | 
			
		||||
            Footnote footnote = new Footnote();
 | 
			
		||||
            Paragraph par = footnote.Elements.AddParagraph();
 | 
			
		||||
            par.AddText(text);
 | 
			
		||||
            Add(footnote);
 | 
			
		||||
            return footnote;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Footnote.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Footnote AddFootnote()
 | 
			
		||||
        {
 | 
			
		||||
            Footnote footnote = new Footnote();
 | 
			
		||||
            Add(footnote);
 | 
			
		||||
            return footnote;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Image.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Image AddImage(string name)
 | 
			
		||||
        {
 | 
			
		||||
            Image image = new Image();
 | 
			
		||||
            image.Name = name;
 | 
			
		||||
            Add(image);
 | 
			
		||||
            return image;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Add(DocumentObject docObj)
 | 
			
		||||
        {
 | 
			
		||||
            base.Add(docObj);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts ParagraphElements into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            int count = Count;
 | 
			
		||||
            for (int index = 0; index < count; ++index)
 | 
			
		||||
            {
 | 
			
		||||
                DocumentObject element = this[index];
 | 
			
		||||
                element.Serialize(serializer);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(ParagraphElements))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,479 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// A ParagraphFormat represents the formatting of a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class ParagraphFormat : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the ParagraphFormat class that can be used as a template.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphFormat()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the ParagraphFormat class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphFormat(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new ParagraphFormat Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (ParagraphFormat)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            ParagraphFormat format = (ParagraphFormat)base.DeepCopy();
 | 
			
		||||
            if (format._font != null)
 | 
			
		||||
            {
 | 
			
		||||
                format._font = format._font.Clone();
 | 
			
		||||
                format._font._parent = format;
 | 
			
		||||
            }
 | 
			
		||||
            if (format._shading != null)
 | 
			
		||||
            {
 | 
			
		||||
                format._shading = format._shading.Clone();
 | 
			
		||||
                format._shading._parent = format;
 | 
			
		||||
            }
 | 
			
		||||
            if (format._borders != null)
 | 
			
		||||
            {
 | 
			
		||||
                format._borders = format._borders.Clone();
 | 
			
		||||
                format._borders._parent = format;
 | 
			
		||||
            }
 | 
			
		||||
            if (format._tabStops != null)
 | 
			
		||||
            {
 | 
			
		||||
                format._tabStops = format._tabStops.Clone();
 | 
			
		||||
                format._tabStops._parent = format;
 | 
			
		||||
            }
 | 
			
		||||
            if (format._listInfo != null)
 | 
			
		||||
            {
 | 
			
		||||
                format._listInfo = format._listInfo.Clone();
 | 
			
		||||
                format._listInfo._parent = format;
 | 
			
		||||
            }
 | 
			
		||||
            return format;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop AddTabStop(Unit position)
 | 
			
		||||
        {
 | 
			
		||||
            return TabStops.AddTabStop(position);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection and sets its alignment and leader.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop AddTabStop(Unit position, TabAlignment alignment, TabLeader leader)
 | 
			
		||||
        {
 | 
			
		||||
            return TabStops.AddTabStop(position, alignment, leader);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection and sets its leader.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop AddTabStop(Unit position, TabLeader leader)
 | 
			
		||||
        {
 | 
			
		||||
            return TabStops.AddTabStop(position, leader);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection and sets its alignment.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop AddTabStop(Unit position, TabAlignment alignment)
 | 
			
		||||
        {
 | 
			
		||||
            return TabStops.AddTabStop(position, alignment);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection marked to remove the tab stop at
 | 
			
		||||
        /// the given position.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void RemoveTabStop(Unit position)
 | 
			
		||||
        {
 | 
			
		||||
            TabStops.RemoveTabStop(position);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(TabStop tabStop)
 | 
			
		||||
        {
 | 
			
		||||
            TabStops.AddTabStop(tabStop);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Clears all TapStop objects from the collection. Additionally 'TabStops = null'
 | 
			
		||||
        /// is written to the DDL stream when serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void ClearAll()
 | 
			
		||||
        {
 | 
			
		||||
            TabStops.ClearAll();
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the Alignment of the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphAlignment Alignment
 | 
			
		||||
        {
 | 
			
		||||
            get { return (ParagraphAlignment)_alignment.Value; }
 | 
			
		||||
            set { _alignment.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(ParagraphAlignment))]
 | 
			
		||||
        public NEnum _alignment = NEnum.NullValue(typeof(ParagraphAlignment));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the Borders object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Borders Borders
 | 
			
		||||
        {
 | 
			
		||||
            get { return _borders ?? (_borders = new Borders(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _borders = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Borders _borders;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the indent of the first line in the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit FirstLineIndent
 | 
			
		||||
        {
 | 
			
		||||
            get { return _firstLineIndent; }
 | 
			
		||||
            set { _firstLineIndent = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _firstLineIndent = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the Font object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Font Font
 | 
			
		||||
        {
 | 
			
		||||
            get { return _font ?? (_font = new Font(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _font = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Font _font;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value indicating whether to keep all the paragraph's lines on the same page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool KeepTogether
 | 
			
		||||
        {
 | 
			
		||||
            get { return _keepTogether.Value; }
 | 
			
		||||
            set { _keepTogether.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _keepTogether = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value indicating whether this and the next paragraph stay on the same page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool KeepWithNext
 | 
			
		||||
        {
 | 
			
		||||
            get { return _keepWithNext.Value; }
 | 
			
		||||
            set { _keepWithNext.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _keepWithNext = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the left indent of the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit LeftIndent
 | 
			
		||||
        {
 | 
			
		||||
            get { return _leftIndent; }
 | 
			
		||||
            set { _leftIndent = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _leftIndent = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the space between lines on the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit LineSpacing
 | 
			
		||||
        {
 | 
			
		||||
            get { return _lineSpacing; }
 | 
			
		||||
            set { _lineSpacing = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _lineSpacing = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the rule which is used to define the line spacing.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public LineSpacingRule LineSpacingRule
 | 
			
		||||
        {
 | 
			
		||||
            get { return (LineSpacingRule)_lineSpacingRule.Value; }
 | 
			
		||||
            set { _lineSpacingRule.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(LineSpacingRule))]
 | 
			
		||||
        public NEnum _lineSpacingRule = NEnum.NullValue(typeof(LineSpacingRule));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the ListInfo object of the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ListInfo ListInfo
 | 
			
		||||
        {
 | 
			
		||||
            get { return _listInfo ?? (_listInfo = new ListInfo(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _listInfo = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public ListInfo _listInfo;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the out line level of the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public OutlineLevel OutlineLevel
 | 
			
		||||
        {
 | 
			
		||||
            get { return (OutlineLevel)_outlineLevel.Value; }
 | 
			
		||||
            set { _outlineLevel.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(OutlineLevel))]
 | 
			
		||||
        public NEnum _outlineLevel = NEnum.NullValue(typeof(OutlineLevel));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value indicating whether a page break is inserted before the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool PageBreakBefore
 | 
			
		||||
        {
 | 
			
		||||
            get { return _pageBreakBefore.Value; }
 | 
			
		||||
            set { _pageBreakBefore.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _pageBreakBefore = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the right indent of the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit RightIndent
 | 
			
		||||
        {
 | 
			
		||||
            get { return _rightIndent; }
 | 
			
		||||
            set { _rightIndent = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _rightIndent = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the shading object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Shading Shading
 | 
			
		||||
        {
 | 
			
		||||
            get { return _shading ?? (_shading = new Shading(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _shading = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Shading _shading;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the space that's inserted after the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit SpaceAfter
 | 
			
		||||
        {
 | 
			
		||||
            get { return _spaceAfter; }
 | 
			
		||||
            set { _spaceAfter = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _spaceAfter = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the space that's inserted before the paragraph.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit SpaceBefore
 | 
			
		||||
        {
 | 
			
		||||
            get { return _spaceBefore; }
 | 
			
		||||
            set { _spaceBefore = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _spaceBefore = Unit.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Indicates whether the ParagraphFormat has a TabStops collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool HasTabStops
 | 
			
		||||
        {
 | 
			
		||||
            get { return _tabStops != null; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Get the TabStops collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStops TabStops
 | 
			
		||||
        {
 | 
			
		||||
            get { return _tabStops ?? (_tabStops = new TabStops(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _tabStops = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public TabStops _tabStops;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value indicating whether a line from the paragraph stays alone in a page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool WidowControl
 | 
			
		||||
        {
 | 
			
		||||
            get { return _widowControl.Value; }
 | 
			
		||||
            set { _widowControl.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _widowControl = NBool.NullValue;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts ParagraphFormat into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (_parent is Style)
 | 
			
		||||
                Serialize(serializer, "ParagraphFormat", null);
 | 
			
		||||
            else
 | 
			
		||||
                Serialize(serializer, "Format", null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts ParagraphFormat into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Serialize(Serializer serializer, string name, ParagraphFormat refFormat)
 | 
			
		||||
        {
 | 
			
		||||
            int pos = serializer.BeginContent(name);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Font") && Parent.GetType() != typeof(Style))
 | 
			
		||||
                Font.Serialize(serializer);
 | 
			
		||||
 | 
			
		||||
            // If a refFormat is specified, it is important to compare the fields and not the properties.
 | 
			
		||||
            // Only the fields holds the public information whether a value is NULL. In contrast to the
 | 
			
		||||
            // Efw.Application framework the nullable values and all the meta stuff is kept public to
 | 
			
		||||
            // give the user the illusion of simplicity.
 | 
			
		||||
 | 
			
		||||
            if (!_alignment.IsNull && (refFormat == null || (_alignment != refFormat._alignment)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("Alignment", Alignment);
 | 
			
		||||
 | 
			
		||||
            if (!_leftIndent.IsNull && (refFormat == null || (_leftIndent != refFormat._leftIndent)))
 | 
			
		||||
                serializer.WriteSimpleAttribute("LeftIndent", LeftIndent);
 | 
			
		||||
 | 
			
		||||
            if (!_firstLineIndent.IsNull && (refFormat == null || _firstLineIndent != refFormat._firstLineIndent))
 | 
			
		||||
                serializer.WriteSimpleAttribute("FirstLineIndent", FirstLineIndent);
 | 
			
		||||
 | 
			
		||||
            if (!_rightIndent.IsNull && (refFormat == null || _rightIndent != refFormat._rightIndent))
 | 
			
		||||
                serializer.WriteSimpleAttribute("RightIndent", RightIndent);
 | 
			
		||||
 | 
			
		||||
            if (!_spaceBefore.IsNull && (refFormat == null || _spaceBefore != refFormat._spaceBefore))
 | 
			
		||||
                serializer.WriteSimpleAttribute("SpaceBefore", SpaceBefore);
 | 
			
		||||
 | 
			
		||||
            if (!_spaceAfter.IsNull && (refFormat == null || _spaceAfter != refFormat._spaceAfter))
 | 
			
		||||
                serializer.WriteSimpleAttribute("SpaceAfter", SpaceAfter);
 | 
			
		||||
 | 
			
		||||
            if (!_lineSpacingRule.IsNull && (refFormat == null || _lineSpacingRule != refFormat._lineSpacingRule))
 | 
			
		||||
                serializer.WriteSimpleAttribute("LineSpacingRule", LineSpacingRule);
 | 
			
		||||
 | 
			
		||||
            if (!_lineSpacing.IsNull && (refFormat == null || _lineSpacing != refFormat._lineSpacing))
 | 
			
		||||
                serializer.WriteSimpleAttribute("LineSpacing", LineSpacing);
 | 
			
		||||
 | 
			
		||||
            if (!_keepTogether.IsNull && (refFormat == null || _keepTogether != refFormat._keepTogether))
 | 
			
		||||
                serializer.WriteSimpleAttribute("KeepTogether", KeepTogether);
 | 
			
		||||
 | 
			
		||||
            if (!_keepWithNext.IsNull && (refFormat == null || _keepWithNext != refFormat._keepWithNext))
 | 
			
		||||
                serializer.WriteSimpleAttribute("KeepWithNext", KeepWithNext);
 | 
			
		||||
 | 
			
		||||
            if (!_widowControl.IsNull && (refFormat == null || _widowControl != refFormat._widowControl))
 | 
			
		||||
                serializer.WriteSimpleAttribute("WidowControl", WidowControl);
 | 
			
		||||
 | 
			
		||||
            if (!_pageBreakBefore.IsNull && (refFormat == null || _pageBreakBefore != refFormat._pageBreakBefore))
 | 
			
		||||
                serializer.WriteSimpleAttribute("PageBreakBefore", PageBreakBefore);
 | 
			
		||||
 | 
			
		||||
            if (!_outlineLevel.IsNull && (refFormat == null || _outlineLevel != refFormat._outlineLevel))
 | 
			
		||||
                serializer.WriteSimpleAttribute("OutlineLevel", OutlineLevel);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("ListInfo"))
 | 
			
		||||
                ListInfo.Serialize(serializer);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("TabStops"))
 | 
			
		||||
                _tabStops.Serialize(serializer);
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Borders"))
 | 
			
		||||
            {
 | 
			
		||||
                if (refFormat != null)
 | 
			
		||||
                    _borders.Serialize(serializer, refFormat.Borders);
 | 
			
		||||
                else
 | 
			
		||||
                    _borders.Serialize(serializer, null);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("Shading"))
 | 
			
		||||
                _shading.Serialize(serializer);
 | 
			
		||||
 | 
			
		||||
            serializer.EndContent(pos);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(ParagraphFormat))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										378
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Section.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										378
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Section.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,378 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Tables;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// A Section is a collection of document objects sharing the same header, footer, 
 | 
			
		||||
    /// and page setup.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Section : DocumentObject, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Section class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Section()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Section class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Section(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Section Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Section)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            Section section = (Section)base.DeepCopy();
 | 
			
		||||
            if (section._pageSetup != null)
 | 
			
		||||
            {
 | 
			
		||||
                section._pageSetup = section._pageSetup.Clone();
 | 
			
		||||
                section._pageSetup._parent = section;
 | 
			
		||||
            }
 | 
			
		||||
            if (section._headers != null)
 | 
			
		||||
            {
 | 
			
		||||
                section._headers = section._headers.Clone();
 | 
			
		||||
                section._headers._parent = section;
 | 
			
		||||
            }
 | 
			
		||||
            if (section._footers != null)
 | 
			
		||||
            {
 | 
			
		||||
                section._footers = section._footers.Clone();
 | 
			
		||||
                section._footers._parent = section;
 | 
			
		||||
            }
 | 
			
		||||
            if (section._elements != null)
 | 
			
		||||
            {
 | 
			
		||||
                section._elements = section._elements.Clone();
 | 
			
		||||
                section._elements._parent = section;
 | 
			
		||||
            }
 | 
			
		||||
            return section;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the previous section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Section PreviousSection()
 | 
			
		||||
        {
 | 
			
		||||
            Sections sections = Parent as Sections;
 | 
			
		||||
            int index = sections.IndexOf(this);
 | 
			
		||||
            if (index > 0)
 | 
			
		||||
                return sections[index - 1];
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddParagraph();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph with the specified text to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph(string paragraphText)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddParagraph(paragraphText);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph with the specified text and style to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph AddParagraph(string paragraphText, string style)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddParagraph(paragraphText, style);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new chart with the specified type to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Chart AddChart(ChartType type)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChart(type);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new chart to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Chart AddChart()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddChart();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new table to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Table AddTable()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddTable();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a manual page break.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void AddPageBreak()
 | 
			
		||||
        {
 | 
			
		||||
            Elements.AddPageBreak();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new Image to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Image AddImage(string fileName)
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddImage(fileName);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new textframe to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TextFrame AddTextFrame()
 | 
			
		||||
        {
 | 
			
		||||
            return Elements.AddTextFrame();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new paragraph to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Paragraph paragraph)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(paragraph);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new chart to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Chart chart)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(chart);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new table to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Table table)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(table);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new image to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(Image image)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(image);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new text frame to the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Add(TextFrame textFrame)
 | 
			
		||||
        {
 | 
			
		||||
            Elements.Add(textFrame);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the PageSetup object
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PageSetup PageSetup
 | 
			
		||||
        {
 | 
			
		||||
            get { return _pageSetup ?? (_pageSetup = new PageSetup(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _pageSetup = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public PageSetup _pageSetup;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the HeadersFooters collection containing the headers.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HeadersFooters Headers
 | 
			
		||||
        {
 | 
			
		||||
            get { return _headers ?? (_headers = new HeadersFooters(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _headers = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public HeadersFooters _headers;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the HeadersFooters collection containing the footers.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public HeadersFooters Footers
 | 
			
		||||
        {
 | 
			
		||||
            get { return _footers ?? (_footers = new HeadersFooters(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _footers = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public HeadersFooters _footers;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the document elements that build the section's content.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentElements Elements
 | 
			
		||||
        {
 | 
			
		||||
            get { return _elements ?? (_elements = new DocumentElements(this)); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _elements = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public DocumentElements _elements;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a comment associated with this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Comment
 | 
			
		||||
        {
 | 
			
		||||
            get { return _comment.Value; }
 | 
			
		||||
            set { _comment.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _comment = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the last paragraph of this section, or null, if no paragraph exists is this section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Paragraph LastParagraph
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                int count = _elements.Count;
 | 
			
		||||
                for (int idx = count - 1; idx >= 0; idx--)
 | 
			
		||||
                {
 | 
			
		||||
                    if (_elements[idx] is Paragraph)
 | 
			
		||||
                        return (Paragraph)_elements[idx];
 | 
			
		||||
                }
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the last table of this section, or null, if no table exists is this section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Table LastTable
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                int count = _elements.Count;
 | 
			
		||||
                for (int idx = count - 1; idx >= 0; idx--)
 | 
			
		||||
                {
 | 
			
		||||
                    if (_elements[idx] is Table)
 | 
			
		||||
                        return (Table)_elements[idx];
 | 
			
		||||
                }
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Section into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            serializer.WriteComment(_comment.Value);
 | 
			
		||||
            serializer.WriteLine("\\section");
 | 
			
		||||
 | 
			
		||||
            int pos = serializer.BeginAttributes();
 | 
			
		||||
            if (!IsNull("PageSetup"))
 | 
			
		||||
                PageSetup.Serialize(serializer);
 | 
			
		||||
            serializer.EndAttributes(pos);
 | 
			
		||||
 | 
			
		||||
            serializer.BeginContent();
 | 
			
		||||
            if (!IsNull("headers"))
 | 
			
		||||
                _headers.Serialize(serializer);
 | 
			
		||||
            if (!IsNull("footers"))
 | 
			
		||||
                _footers.Serialize(serializer);
 | 
			
		||||
            if (!IsNull("elements"))
 | 
			
		||||
                _elements.Serialize(serializer);
 | 
			
		||||
 | 
			
		||||
            serializer.EndContent();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitSection(this);
 | 
			
		||||
 | 
			
		||||
            if (visitChildren && _headers != null)
 | 
			
		||||
                ((IVisitable)_headers).AcceptVisitor(visitor, true);
 | 
			
		||||
            if (visitChildren && _footers != null)
 | 
			
		||||
                ((IVisitable)_footers).AcceptVisitor(visitor, true);
 | 
			
		||||
            if (visitChildren && _elements != null)
 | 
			
		||||
                ((IVisitable)_elements).AcceptVisitor(visitor, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Section))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										116
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Sections.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Sections.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,116 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents the collection of document sections.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Sections : DocumentObjectCollection, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Sections class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Sections()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Sections class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Sections(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a section by its index. First section has index 0.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Section this[int index]
 | 
			
		||||
        {
 | 
			
		||||
            get { return base[index] as Section; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Sections Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Sections)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Section AddSection()
 | 
			
		||||
        {
 | 
			
		||||
            Section section = new Section();
 | 
			
		||||
            Add(section);
 | 
			
		||||
            return section;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Sections into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            int count = Count;
 | 
			
		||||
            for (int index = 0; index < count; ++index)
 | 
			
		||||
            {
 | 
			
		||||
                Section section = this[index];
 | 
			
		||||
                section.Serialize(serializer);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitSections(this);
 | 
			
		||||
            foreach (Section section in this)
 | 
			
		||||
                ((IVisitable)section).AcceptVisitor(visitor, visitChildren);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Sections))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										605
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Serializer.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										605
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Serializer.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,605 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Object to be passed to the Serialize function of a DocumentObject to convert
 | 
			
		||||
    /// it into DDL.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public sealed class Serializer
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// A Serializer object for converting MDDOM into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="textWriter">A TextWriter to write DDL in.</param>
 | 
			
		||||
        /// <param name="indent">Indent of a new block. Default is 2.</param>
 | 
			
		||||
        /// <param name="initialIndent">Initial indent to start with.</param>
 | 
			
		||||
        public Serializer(TextWriter textWriter, int indent, int initialIndent)
 | 
			
		||||
        {
 | 
			
		||||
            if (textWriter == null)
 | 
			
		||||
                throw new ArgumentNullException("textWriter");
 | 
			
		||||
 | 
			
		||||
            _textWriter = textWriter;
 | 
			
		||||
            _indent = indent;
 | 
			
		||||
            _writeIndent = initialIndent;
 | 
			
		||||
            if (textWriter is StreamWriter)
 | 
			
		||||
                WriteStamp();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Serializer class with the specified TextWriter.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Serializer(TextWriter textWriter) : this(textWriter, 2, 0) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Serializer class with the specified TextWriter and indentation.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Serializer(TextWriter textWriter, int indent) : this(textWriter, indent, 0) { }
 | 
			
		||||
 | 
			
		||||
        readonly TextWriter _textWriter;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the indentation for a new indentation level.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Indent
 | 
			
		||||
        {
 | 
			
		||||
            get { return _indent; }
 | 
			
		||||
            set { _indent = value; }
 | 
			
		||||
        }
 | 
			
		||||
        int _indent = 2;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the initial indentation which precede every line.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int InitialIndent
 | 
			
		||||
        {
 | 
			
		||||
            get { return _writeIndent; }
 | 
			
		||||
            set { _writeIndent = value; }
 | 
			
		||||
        }
 | 
			
		||||
        int _writeIndent;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Increases indent of DDL code.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IncreaseIndent()
 | 
			
		||||
        {
 | 
			
		||||
            _writeIndent += _indent;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Decreases indent of DDL code.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void DecreaseIndent()
 | 
			
		||||
        {
 | 
			
		||||
            _writeIndent -= _indent;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the header for a DDL file containing copyright and creation time information.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void WriteStamp()
 | 
			
		||||
        {
 | 
			
		||||
            if (_fWriteStamp)
 | 
			
		||||
            {
 | 
			
		||||
                WriteComment("Created by empira MigraDoc Document Object Model");
 | 
			
		||||
                WriteComment(String.Format("generated file created {0:d} at {0:t}", DateTime.Now));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Appends a string indented without line feed.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Write(string str)
 | 
			
		||||
        {
 | 
			
		||||
            string wrappedStr = DoWordWrap(str);
 | 
			
		||||
            if (wrappedStr.Length < str.Length && wrappedStr != "")
 | 
			
		||||
            {
 | 
			
		||||
                WriteLineToStream(wrappedStr);
 | 
			
		||||
                Write(str.Substring(wrappedStr.Length));
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                WriteToStream(str);
 | 
			
		||||
            CommitText();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes a string indented with line feed.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void WriteLine(string str)
 | 
			
		||||
        {
 | 
			
		||||
            string wrappedStr = DoWordWrap(str);
 | 
			
		||||
            if (wrappedStr.Length < str.Length)
 | 
			
		||||
            {
 | 
			
		||||
                WriteLineToStream(wrappedStr);
 | 
			
		||||
                WriteLine(str.Substring(wrappedStr.Length));
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                WriteLineToStream(wrappedStr);
 | 
			
		||||
            CommitText();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the part of the string str that fits into the line (up to 80 chars).
 | 
			
		||||
        /// If Wordwrap is impossible it returns the input-string str itself.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        string DoWordWrap(string str)
 | 
			
		||||
        {
 | 
			
		||||
            if (str.Length + _writeIndent < LineBreakBeyond)
 | 
			
		||||
                return str;
 | 
			
		||||
 | 
			
		||||
            int idxCRLF = str.IndexOf("\x0D\x0A", StringComparison.Ordinal);
 | 
			
		||||
            if (idxCRLF > 0 && idxCRLF + _writeIndent <= LineBreakBeyond)
 | 
			
		||||
                return str.Substring(0, idxCRLF + 1);
 | 
			
		||||
 | 
			
		||||
            int splitIndexBlank = str.Substring(0, LineBreakBeyond - _writeIndent).LastIndexOf(" ", StringComparison.Ordinal);
 | 
			
		||||
            int splitIndexCRLF = str.Substring(0, LineBreakBeyond - _writeIndent).LastIndexOf("\x0D\x0A", StringComparison.Ordinal);
 | 
			
		||||
            int splitIndex = Math.Max(splitIndexBlank, splitIndexCRLF);
 | 
			
		||||
            if (splitIndex == -1)
 | 
			
		||||
                splitIndex = Math.Min(str.IndexOf(" ", LineBreakBeyond - _writeIndent + 1, StringComparison.Ordinal),
 | 
			
		||||
                                             str.IndexOf("\x0D\x0A", LineBreakBeyond - _writeIndent + 1, StringComparison.Ordinal));
 | 
			
		||||
            return splitIndex > 0 ? str.Substring(0, splitIndex) : str;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes an empty line.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void WriteLine()
 | 
			
		||||
        {
 | 
			
		||||
            WriteLine(String.Empty);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Write a line without committing (without marking the text as serialized).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void WriteLineNoCommit(string str)
 | 
			
		||||
        {
 | 
			
		||||
            WriteLineToStream(str);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Write a line without committing (without marking the text as serialized).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void WriteLineNoCommit()
 | 
			
		||||
        {
 | 
			
		||||
            WriteLineNoCommit(String.Empty);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes a text as comment and automatically word-wraps it.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void WriteComment(string comment)
 | 
			
		||||
        {
 | 
			
		||||
            if (String.IsNullOrEmpty(comment))
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            // if string contains CR/LF, split up recursively
 | 
			
		||||
            int crlf = comment.IndexOf("\x0D\x0A", StringComparison.Ordinal);
 | 
			
		||||
            if (crlf != -1)
 | 
			
		||||
            {
 | 
			
		||||
                WriteComment(comment.Substring(0, crlf));
 | 
			
		||||
                WriteComment(comment.Substring(crlf + 2));
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            CloseUpLine();
 | 
			
		||||
            int len;
 | 
			
		||||
            int chopBeyond = LineBreakBeyond - _indent - "// ".Length;
 | 
			
		||||
            while ((len = comment.Length) > 0)
 | 
			
		||||
            {
 | 
			
		||||
                string wrt;
 | 
			
		||||
                if (len <= chopBeyond)
 | 
			
		||||
                {
 | 
			
		||||
                    wrt = "// " + comment;
 | 
			
		||||
                    comment = String.Empty;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    int idxChop;
 | 
			
		||||
                    if ((idxChop = comment.LastIndexOf(' ', chopBeyond)) == -1 &&
 | 
			
		||||
                        (idxChop = comment.IndexOf(' ', chopBeyond)) == -1)
 | 
			
		||||
                    {
 | 
			
		||||
                        wrt = "// " + comment;
 | 
			
		||||
                        comment = String.Empty;
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        wrt = "// " + comment.Substring(0, idxChop);
 | 
			
		||||
                        comment = comment.Substring(idxChop + 1);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                WriteLineToStream(wrt);
 | 
			
		||||
                CommitText();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes a line break if the current position is not at the beginning
 | 
			
		||||
        /// of a new line.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void CloseUpLine()
 | 
			
		||||
        {
 | 
			
		||||
            if (_linePos > 0)
 | 
			
		||||
                WriteLine();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Effectively writes text to the stream. The text is automatically indented and
 | 
			
		||||
        /// word-wrapped. A given text gets never word-wrapped to keep comments or string
 | 
			
		||||
        /// literals unbroken.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void WriteToStream(string text, bool fLineBreak, bool fAutoIndent)
 | 
			
		||||
        {
 | 
			
		||||
            // if string contains CR/LF, split up recursively
 | 
			
		||||
            int crlf = text.IndexOf("\x0D\x0A", StringComparison.Ordinal);
 | 
			
		||||
            if (crlf != -1)
 | 
			
		||||
            {
 | 
			
		||||
                WriteToStream(text.Substring(0, crlf), true, fAutoIndent);
 | 
			
		||||
                WriteToStream(text.Substring(crlf + 2), fLineBreak, fAutoIndent);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            int len = text.Length;
 | 
			
		||||
            if (len > 0)
 | 
			
		||||
            {
 | 
			
		||||
                if (_linePos > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    // does not work
 | 
			
		||||
                    // if (IsBlankRequired(this .lastChar, _text[0]))
 | 
			
		||||
                    //   _text = "<22>" + _text;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    if (fAutoIndent)
 | 
			
		||||
                    {
 | 
			
		||||
                        text = Indentation + text;
 | 
			
		||||
                        len += _writeIndent;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                _textWriter.Write(text);
 | 
			
		||||
                _linePos += len;
 | 
			
		||||
                // wordwrap required?
 | 
			
		||||
                if (_linePos > LineBreakBeyond)
 | 
			
		||||
                {
 | 
			
		||||
                    fLineBreak = true;
 | 
			
		||||
                    //this .textWriter.Write("//<2F>");  // for debugging only
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                    _lastChar = text[len - 1];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (fLineBreak)
 | 
			
		||||
            {
 | 
			
		||||
                _textWriter.WriteLine(String.Empty);  // what a line break is may depend on encoding
 | 
			
		||||
                _linePos = 0;
 | 
			
		||||
                _lastChar = '\x0A';
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Write the text into the stream without breaking it and adds an indentation to it.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void WriteToStream(string text)
 | 
			
		||||
        {
 | 
			
		||||
            WriteToStream(text, false, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Write a line to the stream.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void WriteLineToStream(string text)
 | 
			
		||||
        {
 | 
			
		||||
            WriteToStream(text, true, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ///// <summary>
 | 
			
		||||
        ///// Mighty function to figure out if a blank is required as separator.
 | 
			
		||||
        ///// // Does not work without context...
 | 
			
		||||
        ///// </summary>
 | 
			
		||||
        //bool IsBlankRequired(char left, char right)
 | 
			
		||||
        //{
 | 
			
		||||
        //    if (left == ' ' || right == ' ')
 | 
			
		||||
        //        return false;
 | 
			
		||||
 | 
			
		||||
        //    // 1st try
 | 
			
		||||
        //    bool leftLetterOrDigit = Char.IsLetterOrDigit(left);
 | 
			
		||||
        //    bool rightLetterOrDigit = Char.IsLetterOrDigit(right);
 | 
			
		||||
 | 
			
		||||
        //    if (leftLetterOrDigit && rightLetterOrDigit)
 | 
			
		||||
        //        return true;
 | 
			
		||||
 | 
			
		||||
        //    return false;
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Start attribute part.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int BeginAttributes()
 | 
			
		||||
        {
 | 
			
		||||
            int pos = Position;
 | 
			
		||||
            WriteLineNoCommit("[");
 | 
			
		||||
            IncreaseIndent();
 | 
			
		||||
            BeginBlock();
 | 
			
		||||
            return pos;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Start attribute part.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int BeginAttributes(string str)
 | 
			
		||||
        {
 | 
			
		||||
            int pos = Position;
 | 
			
		||||
            WriteLineNoCommit(str);
 | 
			
		||||
            WriteLineNoCommit("[");
 | 
			
		||||
            IncreaseIndent();
 | 
			
		||||
            BeginBlock();
 | 
			
		||||
            return pos;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// End attribute part.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool EndAttributes()
 | 
			
		||||
        {
 | 
			
		||||
            DecreaseIndent();
 | 
			
		||||
            WriteLineNoCommit("]");
 | 
			
		||||
            return EndBlock();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// End attribute part.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool EndAttributes(int pos)
 | 
			
		||||
        {
 | 
			
		||||
            bool commit = EndAttributes();
 | 
			
		||||
            if (!commit)
 | 
			
		||||
                Position = pos;
 | 
			
		||||
            return commit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Write attribute of type Unit, Color, int, float, double, bool, string or enum.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void WriteSimpleAttribute(string valueName, object value)
 | 
			
		||||
        {
 | 
			
		||||
            INullableValue ival = value as INullableValue;
 | 
			
		||||
            if (ival != null)
 | 
			
		||||
                value = ival.GetValue();
 | 
			
		||||
 | 
			
		||||
            Type type = value.GetType();
 | 
			
		||||
 | 
			
		||||
            if (type == typeof(Unit))
 | 
			
		||||
            {
 | 
			
		||||
                string strUnit = value.ToString();
 | 
			
		||||
                if (((Unit)value).Type == UnitType.Point)
 | 
			
		||||
                    WriteLine(valueName + " = " + strUnit);
 | 
			
		||||
                else
 | 
			
		||||
                    WriteLine(valueName + " = \"" + strUnit + "\"");
 | 
			
		||||
            }
 | 
			
		||||
            else if (type == typeof(float))
 | 
			
		||||
            {
 | 
			
		||||
                WriteLine(valueName + " = " + ((float)value).ToString(CultureInfo.InvariantCulture));
 | 
			
		||||
            }
 | 
			
		||||
            else if (type == typeof(double))
 | 
			
		||||
            {
 | 
			
		||||
                WriteLine(valueName + " = " + ((double)value).ToString(CultureInfo.InvariantCulture));
 | 
			
		||||
            }
 | 
			
		||||
            else if (type == typeof(bool))
 | 
			
		||||
            {
 | 
			
		||||
                WriteLine(valueName + " = " + value.ToString().ToLower());
 | 
			
		||||
            }
 | 
			
		||||
            else if (type == typeof(string))
 | 
			
		||||
            {
 | 
			
		||||
                StringBuilder sb = new StringBuilder(value.ToString());
 | 
			
		||||
                sb.Replace("\\", "\\\\");
 | 
			
		||||
                sb.Replace("\"", "\\\"");
 | 
			
		||||
                WriteLine(valueName + " = \"" + sb + "\"");
 | 
			
		||||
            }
 | 
			
		||||
#if !NETFX_CORE
 | 
			
		||||
            else if (type == typeof(int) || type.BaseType == typeof(Enum) || type == typeof(Color))
 | 
			
		||||
#else
 | 
			
		||||
            else if (type == typeof(int) || type.GetTypeInfo().BaseType == typeof(Enum) || type == typeof(Color))
 | 
			
		||||
#endif
 | 
			
		||||
            {
 | 
			
		||||
                WriteLine(valueName + " = " + value);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                string message = String.Format("Type '{0}' of value '{1}' not supported", type, valueName);
 | 
			
		||||
                Debug.Assert(false, message);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Start content part.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int BeginContent()
 | 
			
		||||
        {
 | 
			
		||||
            int pos = Position;
 | 
			
		||||
            WriteLineNoCommit("{");
 | 
			
		||||
            IncreaseIndent();
 | 
			
		||||
            BeginBlock();
 | 
			
		||||
            return pos;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Start content part.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int BeginContent(string str)
 | 
			
		||||
        {
 | 
			
		||||
            int pos = Position;
 | 
			
		||||
            WriteLineNoCommit(str);
 | 
			
		||||
            WriteLineNoCommit("{");
 | 
			
		||||
            IncreaseIndent();
 | 
			
		||||
            BeginBlock();
 | 
			
		||||
            return pos;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// End content part.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool EndContent()
 | 
			
		||||
        {
 | 
			
		||||
            DecreaseIndent();
 | 
			
		||||
            WriteLineNoCommit("}");
 | 
			
		||||
            return EndBlock();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// End content part.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool EndContent(int pos)
 | 
			
		||||
        {
 | 
			
		||||
            bool commit = EndContent();
 | 
			
		||||
            if (!commit)
 | 
			
		||||
                Position = pos;
 | 
			
		||||
            return commit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Starts a new nesting block.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int BeginBlock()
 | 
			
		||||
        {
 | 
			
		||||
            int pos = Position;
 | 
			
		||||
            if (_stackIdx + 1 >= _commitTextStack.Length)
 | 
			
		||||
                throw new ArgumentException("Block nesting level exhausted.");
 | 
			
		||||
            _stackIdx += 1;
 | 
			
		||||
            _commitTextStack[_stackIdx] = false;
 | 
			
		||||
            return pos;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Ends a nesting block.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool EndBlock()
 | 
			
		||||
        {
 | 
			
		||||
            if (_stackIdx <= 0)
 | 
			
		||||
                throw new ArgumentException("Block nesting level underflow.");
 | 
			
		||||
            _stackIdx -= 1;
 | 
			
		||||
            if (_commitTextStack[_stackIdx + 1])
 | 
			
		||||
                _commitTextStack[_stackIdx] = _commitTextStack[_stackIdx + 1];
 | 
			
		||||
            return _commitTextStack[_stackIdx + 1];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Ends a nesting block.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool EndBlock(int pos)
 | 
			
		||||
        {
 | 
			
		||||
            bool commit = EndBlock();
 | 
			
		||||
            if (!commit)
 | 
			
		||||
                Position = pos;
 | 
			
		||||
            return commit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the position within the underlying stream.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        int Position
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                _textWriter.Flush();
 | 
			
		||||
                StreamWriter streamWriter = _textWriter as StreamWriter;
 | 
			
		||||
                if (streamWriter != null)
 | 
			
		||||
                    return (int)streamWriter.BaseStream.Position;
 | 
			
		||||
 | 
			
		||||
                StringWriter stringWriter = _textWriter as StringWriter;
 | 
			
		||||
                if (stringWriter != null)
 | 
			
		||||
                    return stringWriter.GetStringBuilder().Length;
 | 
			
		||||
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _textWriter.Flush();
 | 
			
		||||
                StreamWriter streamWriter = _textWriter as StreamWriter;
 | 
			
		||||
                if (streamWriter != null)
 | 
			
		||||
                    streamWriter.BaseStream.SetLength(value);
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    StringWriter stringWriter = _textWriter as StringWriter;
 | 
			
		||||
                    if (stringWriter != null)
 | 
			
		||||
                        stringWriter.GetStringBuilder().Length = value;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Flushes the buffers of the underlying text writer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Flush()
 | 
			
		||||
        {
 | 
			
		||||
            _textWriter.Flush();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns an indent string of blanks.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        static string Ind(int indent)
 | 
			
		||||
        {
 | 
			
		||||
            return new String(' ', indent);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets an indent string of current indent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        string Indentation
 | 
			
		||||
        {
 | 
			
		||||
            get { return Ind(_writeIndent); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Marks the current block as 'committed'. That means the block contains
 | 
			
		||||
        /// serialized data.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private void CommitText()
 | 
			
		||||
        {
 | 
			
		||||
            _commitTextStack[_stackIdx] = true;
 | 
			
		||||
        }
 | 
			
		||||
        int _stackIdx;
 | 
			
		||||
        readonly bool[] _commitTextStack = new bool[32];
 | 
			
		||||
 | 
			
		||||
        int _linePos;
 | 
			
		||||
        const int LineBreakBeyond = 200;
 | 
			
		||||
        char _lastChar;
 | 
			
		||||
        bool _fWriteStamp = false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										136
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Shading.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Shading.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,136 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Shading represents the background color of a document object.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public sealed class Shading : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Shading class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Shading()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Shading class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Shading(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Shading Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Shading)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Clears the Shading object. Additionally 'Shading = null'
 | 
			
		||||
        /// is written to the DDL stream when serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Clear()
 | 
			
		||||
        {
 | 
			
		||||
            _isCleared = true;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a value indicating whether the shading is visible.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool Visible
 | 
			
		||||
        {
 | 
			
		||||
            get { return _visible.Value; }
 | 
			
		||||
            set { _visible.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _visible = NBool.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the shading color.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Color Color
 | 
			
		||||
        {
 | 
			
		||||
            get { return _color; }
 | 
			
		||||
            set { _color = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Color _color = Color.Empty;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the information if the shading is marked as cleared. Additionally 'Shading = null'
 | 
			
		||||
        /// is written to the DDL stream when serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsCleared
 | 
			
		||||
        {
 | 
			
		||||
            get { return _isCleared; }
 | 
			
		||||
        }
 | 
			
		||||
        public bool _isCleared = false;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Shading into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (_isCleared)
 | 
			
		||||
                serializer.WriteLine("Shading = null");
 | 
			
		||||
 | 
			
		||||
            int pos = serializer.BeginContent("Shading");
 | 
			
		||||
 | 
			
		||||
            if (!_visible.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("Visible", Visible);
 | 
			
		||||
 | 
			
		||||
            if (!_color.IsNull)
 | 
			
		||||
                serializer.WriteSimpleAttribute("Color", Color);
 | 
			
		||||
 | 
			
		||||
            serializer.EndContent(pos);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Shading))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										452
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Style.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										452
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Style.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,452 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents style templates for paragraph or character formatting.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public sealed class Style : DocumentObject, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Style class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Style()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Style class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Style(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Style class with name and base style name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Style(string name, string baseStyleName)
 | 
			
		||||
            : this()
 | 
			
		||||
        {
 | 
			
		||||
            // baseStyleName can be null or empty
 | 
			
		||||
            if (name == null)
 | 
			
		||||
                throw new ArgumentNullException("name");
 | 
			
		||||
            if (name == "")
 | 
			
		||||
                throw new ArgumentException("name");
 | 
			
		||||
 | 
			
		||||
            _name.Value = name;
 | 
			
		||||
            _baseStyle.Value = baseStyleName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Style Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Style)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Implements the deep copy of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        protected override object DeepCopy()
 | 
			
		||||
        {
 | 
			
		||||
            Style style = (Style)base.DeepCopy();
 | 
			
		||||
            if (style._paragraphFormat != null)
 | 
			
		||||
            {
 | 
			
		||||
                style._paragraphFormat = style._paragraphFormat.Clone();
 | 
			
		||||
                style._paragraphFormat._parent = style;
 | 
			
		||||
            }
 | 
			
		||||
            return style;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the value with the specified name and value access.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override object GetValue(string name, GV flags) //newStL
 | 
			
		||||
        {
 | 
			
		||||
            if (name == null)
 | 
			
		||||
                throw new ArgumentNullException("name");
 | 
			
		||||
            if (name == "")
 | 
			
		||||
                throw new ArgumentException("name");
 | 
			
		||||
 | 
			
		||||
            if (name.ToLower().StartsWith("font"))
 | 
			
		||||
                return ParagraphFormat.GetValue(name);
 | 
			
		||||
            return base.GetValue(name, flags);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Indicates whether the style is read-only. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsReadOnly { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the font of ParagraphFormat. 
 | 
			
		||||
        /// Calling style.Font is just a shortcut to style.ParagraphFormat.Font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Font Font
 | 
			
		||||
        {
 | 
			
		||||
            get { return ParagraphFormat.Font; }
 | 
			
		||||
            // SetParent will be called inside ParagraphFormat.
 | 
			
		||||
            set { ParagraphFormat.Font = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the name of the style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Name
 | 
			
		||||
        {
 | 
			
		||||
            get { return _name.Value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _name = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the ParagraphFormat. To prevent read-only styles from being modified, a copy of its ParagraphFormat
 | 
			
		||||
        /// is returned in this case.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ParagraphFormat ParagraphFormat
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_paragraphFormat == null)
 | 
			
		||||
                    _paragraphFormat = new ParagraphFormat(this);
 | 
			
		||||
                if (IsReadOnly)
 | 
			
		||||
                    return _paragraphFormat.Clone();
 | 
			
		||||
                return _paragraphFormat;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                SetParent(value);
 | 
			
		||||
                _paragraphFormat = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public ParagraphFormat _paragraphFormat;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the name of the base style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string BaseStyle
 | 
			
		||||
        {
 | 
			
		||||
            get { return _baseStyle.Value; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (value == null || value == "" && _baseStyle.Value != "")
 | 
			
		||||
                    throw new ArgumentException(DomSR.EmptyBaseStyle);
 | 
			
		||||
 | 
			
		||||
                // Self assignment is allowed
 | 
			
		||||
                if (String.Compare(_baseStyle.Value, value, StringComparison.OrdinalIgnoreCase) == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    _baseStyle.Value = value;  // character case may change...
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (String.Compare(_name.Value, DefaultParagraphName, StringComparison.OrdinalIgnoreCase) == 0 ||
 | 
			
		||||
                    String.Compare(_name.Value, DefaultParagraphFontName, StringComparison.OrdinalIgnoreCase) == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    string msg = String.Format("Style '{0}' has no base style and that cannot be altered.", _name);
 | 
			
		||||
                    throw new ArgumentException(msg);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                Styles styles = (Styles)_parent;
 | 
			
		||||
                // The base style must exists
 | 
			
		||||
                int idxBaseStyle = styles.GetIndex(value);
 | 
			
		||||
                if (idxBaseStyle == -1)
 | 
			
		||||
                {
 | 
			
		||||
                    string msg = String.Format("Base style '{0}' does not exist.", value);
 | 
			
		||||
                    throw new ArgumentException(msg);
 | 
			
		||||
                }
 | 
			
		||||
                if (idxBaseStyle > 1)
 | 
			
		||||
                {
 | 
			
		||||
                    // Is this style in the base style chain of the new base style
 | 
			
		||||
                    Style style = styles[idxBaseStyle] as Style;
 | 
			
		||||
                    while (style != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (style == this)
 | 
			
		||||
                        {
 | 
			
		||||
                            string msg = String.Format("Base style '{0}' leads to a circular dependency.", value);
 | 
			
		||||
                            throw new ArgumentException(msg);
 | 
			
		||||
                        }
 | 
			
		||||
                        style = styles[style.BaseStyle];
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                // Now setting new base style is safe
 | 
			
		||||
                _baseStyle.Value = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _baseStyle = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the StyleType of the style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public StyleType Type
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                //old
 | 
			
		||||
                //if (IsNull("Type"))
 | 
			
		||||
                //{
 | 
			
		||||
                //  if (String.Compare (this .baseStyle.Value, DefaultParagraphFontName, true) == 0)
 | 
			
		||||
                //    SetValue("Type", StyleType.Character);
 | 
			
		||||
                //  else
 | 
			
		||||
                //  {
 | 
			
		||||
                //    Style bsStyle = GetBaseStyle();
 | 
			
		||||
                //    if (bsStyle == null)
 | 
			
		||||
                //      throw new ArgumentException("User defined style has no valid base Style.");
 | 
			
		||||
                //
 | 
			
		||||
                //    SetValue("Type", bsStyle.Type);
 | 
			
		||||
                //  }
 | 
			
		||||
                //}
 | 
			
		||||
                //return styleType;
 | 
			
		||||
 | 
			
		||||
                if (_styleType.IsNull)
 | 
			
		||||
                {
 | 
			
		||||
                    if (String.Compare(_baseStyle.Value, DefaultParagraphFontName, StringComparison.OrdinalIgnoreCase) == 0)
 | 
			
		||||
                        _styleType.Value = (int)StyleType.Character;
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        Style baseStyle = GetBaseStyle();
 | 
			
		||||
                        if (baseStyle == null)
 | 
			
		||||
                            throw new InvalidOperationException("User defined style has no valid base Style.");
 | 
			
		||||
 | 
			
		||||
                        _styleType.Value = (int)baseStyle.Type;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return (StyleType)_styleType.Value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(StyleType))]
 | 
			
		||||
        public NEnum _styleType = NEnum.NullValue(typeof(StyleType));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether the style is the style Normal or DefaultParagraphFont.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsRootStyle
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return String.Compare(Name, DefaultParagraphFontName, StringComparison.OrdinalIgnoreCase) == 0 ||
 | 
			
		||||
                       String.Compare(Name, DefaultParagraphName, StringComparison.OrdinalIgnoreCase) == 0;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Get the BaseStyle of the current style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Style GetBaseStyle()
 | 
			
		||||
        {
 | 
			
		||||
            if (IsRootStyle)
 | 
			
		||||
                return null;
 | 
			
		||||
 | 
			
		||||
            Styles styles = Parent as Styles;
 | 
			
		||||
            if (styles == null)
 | 
			
		||||
                throw new InvalidOperationException("A parent object is required for this operation; access failed");
 | 
			
		||||
            if (_baseStyle.Value == "")
 | 
			
		||||
                throw new ArgumentException("User defined Style defined without a BaseStyle");
 | 
			
		||||
 | 
			
		||||
            // TODO Remove German remarks!
 | 
			
		||||
            //REVIEW KlPo4StLa Spezialbehandlung f<>r den DefaultParagraphFont kr<6B>ppelig(DefaultParagraphFont wird bei Zugriff <20>ber styles["name"] nicht zur<75>ckgeliefert).
 | 
			
		||||
            if (_baseStyle.Value == DefaultParagraphFontName)
 | 
			
		||||
                return styles[0];
 | 
			
		||||
 | 
			
		||||
            return styles[_baseStyle.Value];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Indicates whether the style is a predefined (build in) style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool BuildIn
 | 
			
		||||
        {
 | 
			
		||||
            get { return _buildIn.Value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NBool _buildIn = NBool.NullValue;
 | 
			
		||||
        // TODO: rename to builtIn.
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a comment associated with this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Comment
 | 
			
		||||
        {
 | 
			
		||||
            get { return _comment.Value; }
 | 
			
		||||
            set { _comment.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _comment = NString.NullValue;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        // Names of the root styles. Root styles have no BaseStyle.
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Name of the default character style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public const string DefaultParagraphFontName = StyleNames.DefaultParagraphFont;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Name of the default paragraph style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public const string DefaultParagraphName = StyleNames.Normal;
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Style into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
#if DEBUG_ // Test
 | 
			
		||||
      if (Name == StyleNames.Heading1 || Name == StyleNames.Heading2)
 | 
			
		||||
        Name.GetType();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
            // For build-in styles all properties that differ from their default values
 | 
			
		||||
            // are serialized.
 | 
			
		||||
            // For user-defined styles all non-null properties are serialized.
 | 
			
		||||
            Styles buildInStyles = Styles.BuildInStyles;
 | 
			
		||||
            Style refStyle = null;
 | 
			
		||||
            Font refFont = null;
 | 
			
		||||
            ParagraphFormat refFormat = null;
 | 
			
		||||
 | 
			
		||||
            serializer.WriteComment(_comment.Value);
 | 
			
		||||
            if (_buildIn.Value)
 | 
			
		||||
            {
 | 
			
		||||
                // BaseStyle is never null, but empty only for "Normal" and "DefaultParagraphFont"
 | 
			
		||||
                if (BaseStyle == "")
 | 
			
		||||
                {
 | 
			
		||||
                    // case: style is "Normal"
 | 
			
		||||
                    if (String.Compare(_name.Value, DefaultParagraphName, StringComparison.OrdinalIgnoreCase) != 0)
 | 
			
		||||
                        throw new ArgumentException("public Error: BaseStyle not set.");
 | 
			
		||||
 | 
			
		||||
                    refStyle = buildInStyles[buildInStyles.GetIndex(Name)];
 | 
			
		||||
                    refFormat = refStyle.ParagraphFormat;
 | 
			
		||||
                    refFont = refFormat.Font;
 | 
			
		||||
                    string name = DdlEncoder.QuoteIfNameContainsBlanks(Name);
 | 
			
		||||
                    serializer.WriteLineNoCommit(name);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    // case: any build-in style except "Normal"
 | 
			
		||||
                    refStyle = buildInStyles[buildInStyles.GetIndex(Name)];
 | 
			
		||||
                    refFormat = refStyle.ParagraphFormat;
 | 
			
		||||
                    refFont = refFormat.Font;
 | 
			
		||||
                    if (String.Compare(BaseStyle, refStyle.BaseStyle, StringComparison.OrdinalIgnoreCase) == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        // case: build-in style with unmodified base style name
 | 
			
		||||
                        string name = DdlEncoder.QuoteIfNameContainsBlanks(Name);
 | 
			
		||||
                        serializer.WriteLineNoCommit(name);
 | 
			
		||||
                        // It's fine if we have the predefined base style, but ...
 | 
			
		||||
                        // ... the base style may have been modified or may even have a modified base style.
 | 
			
		||||
                        // Methinks it's wrong to compare with the built-in style, so let's compare with the
 | 
			
		||||
                        // real base style:
 | 
			
		||||
                        refStyle = Document.Styles[Document.Styles.GetIndex(_baseStyle.Value)];
 | 
			
		||||
                        refFormat = refStyle.ParagraphFormat;
 | 
			
		||||
                        refFont = refFormat.Font;
 | 
			
		||||
                        // Note: we must write "Underline = none" if the base style has "Underline = single" - we cannot
 | 
			
		||||
                        // detect this if we compare with the built-in style that has no underline.
 | 
			
		||||
                        // Known problem: Default values like "OutlineLevel = Level1" will now be serialized
 | 
			
		||||
                        // TODO: optimize...
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        // case: build-in style with modified base style name
 | 
			
		||||
                        string name = DdlEncoder.QuoteIfNameContainsBlanks(Name);
 | 
			
		||||
                        string baseName = DdlEncoder.QuoteIfNameContainsBlanks(BaseStyle);
 | 
			
		||||
                        serializer.WriteLine(name + " : " + baseName);
 | 
			
		||||
                        refStyle = Document.Styles[Document.Styles.GetIndex(_baseStyle.Value)];
 | 
			
		||||
                        refFormat = refStyle.ParagraphFormat;
 | 
			
		||||
                        refFont = refFormat.Font;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                // case: user-defined style; base style always exists
 | 
			
		||||
 | 
			
		||||
                string name = DdlEncoder.QuoteIfNameContainsBlanks(Name);
 | 
			
		||||
                string baseName = DdlEncoder.QuoteIfNameContainsBlanks(BaseStyle);
 | 
			
		||||
                serializer.WriteLine(name + " : " + baseName);
 | 
			
		||||
 | 
			
		||||
#if true
 | 
			
		||||
                Style refStyle0 = Document.Styles[Document.Styles.GetIndex(_baseStyle.Value)];
 | 
			
		||||
                refStyle = Document.Styles[_baseStyle.Value];
 | 
			
		||||
                refFormat = refStyle != null ? refStyle.ParagraphFormat : null;
 | 
			
		||||
#else
 | 
			
		||||
        refFormat = null;
 | 
			
		||||
#endif
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            serializer.BeginContent();
 | 
			
		||||
 | 
			
		||||
            if (!IsNull("ParagraphFormat"))
 | 
			
		||||
            {
 | 
			
		||||
                if (!ParagraphFormat.IsNull("Font"))
 | 
			
		||||
                    Font.Serialize(serializer, refFormat != null ? refFormat.Font : null);
 | 
			
		||||
 | 
			
		||||
                if (Type == StyleType.Paragraph)
 | 
			
		||||
                    ParagraphFormat.Serialize(serializer, "ParagraphFormat", refFormat);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            serializer.EndContent();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets all properties to Null that have the same value as the base style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private void Optimize()
 | 
			
		||||
        {
 | 
			
		||||
            // just here as a reminder to do it...
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitStyle(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Style))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,61 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Enumerates the predefined style names.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class StyleNames
 | 
			
		||||
    {
 | 
			
		||||
        public const string DefaultParagraphFont = "DefaultParagraphFont";
 | 
			
		||||
        public const string Normal = "Normal";
 | 
			
		||||
        public const string Heading1 = "Heading1";
 | 
			
		||||
        public const string Heading2 = "Heading2";
 | 
			
		||||
        public const string Heading3 = "Heading3";
 | 
			
		||||
        public const string Heading4 = "Heading4";
 | 
			
		||||
        public const string Heading5 = "Heading5";
 | 
			
		||||
        public const string Heading6 = "Heading6";
 | 
			
		||||
        public const string Heading7 = "Heading7";
 | 
			
		||||
        public const string Heading8 = "Heading8";
 | 
			
		||||
        public const string Heading9 = "Heading9";
 | 
			
		||||
        // TODO Verify if "List" exists with Word.
 | 
			
		||||
        public const string List = "List";
 | 
			
		||||
        public const string Footnote = "Footnote";
 | 
			
		||||
        public const string Header = "Header";
 | 
			
		||||
        public const string Footer = "Footer";
 | 
			
		||||
        public const string Hyperlink = "Hyperlink";
 | 
			
		||||
        public const string InvalidStyleName = "InvalidStyleName";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										447
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Styles.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										447
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Styles.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,447 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.Visitors;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents the collection of all styles.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Styles : DocumentObjectCollection, IVisitable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Styles class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Styles()
 | 
			
		||||
        {
 | 
			
		||||
            SetupStyles();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Styles class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Styles(DocumentObject parent)
 | 
			
		||||
            : base(parent)
 | 
			
		||||
        {
 | 
			
		||||
            SetupStyles();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Styles Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Styles)base.DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a style by its name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Style this[string styleName]
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                int count = Count;
 | 
			
		||||
                // index starts from 1; DefaultParagraphFont cannot be modified.
 | 
			
		||||
                for (int index = 1; index < count; ++index)
 | 
			
		||||
                {
 | 
			
		||||
                    Style style = this[index];
 | 
			
		||||
                    if (String.Compare(style.Name, styleName, StringComparison.OrdinalIgnoreCase) == 0)
 | 
			
		||||
                        return style;
 | 
			
		||||
                }
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a style by index. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Style this[int index]
 | 
			
		||||
        {
 | 
			
		||||
            get { return (Style)base[index]; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the index of a style by name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="styleName">Name of the style looking for.</param>
 | 
			
		||||
        /// <returns>Index or -1 if it does not exist.</returns>
 | 
			
		||||
        public int GetIndex(string styleName)
 | 
			
		||||
        {
 | 
			
		||||
            if (styleName == null)
 | 
			
		||||
                throw new ArgumentNullException("styleName");
 | 
			
		||||
 | 
			
		||||
            int count = Count;
 | 
			
		||||
            for (int index = 0; index < count; ++index)
 | 
			
		||||
            {
 | 
			
		||||
                Style style = this[index];
 | 
			
		||||
                if (String.Compare(style.Name, styleName, StringComparison.OrdinalIgnoreCase) == 0)
 | 
			
		||||
                    return index;
 | 
			
		||||
            }
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new style to the styles collection.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="name">Name of the style.</param>
 | 
			
		||||
        /// <param name="baseStyleName">Name of the base style.</param>
 | 
			
		||||
        public Style AddStyle(string name, string baseStyleName)
 | 
			
		||||
        {
 | 
			
		||||
            if (name == null || baseStyleName == null)
 | 
			
		||||
                throw new ArgumentNullException(name == null ? "name" : "baseStyleName");
 | 
			
		||||
            if (name == "" || baseStyleName == "")
 | 
			
		||||
                throw new ArgumentException(name == "" ? "name" : "baseStyleName");
 | 
			
		||||
 | 
			
		||||
            Style style = new Style();
 | 
			
		||||
            style._name.Value = name;
 | 
			
		||||
            style._baseStyle.Value = baseStyleName;
 | 
			
		||||
            Add(style);
 | 
			
		||||
            // Add(style) may add a clone of style, therefore we return the style by name.
 | 
			
		||||
            return this[name];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a DocumentObject to the styles collection. Will sometimes add a clone of the DocumentObject, not the object passed as parameter.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Add(DocumentObject value)
 | 
			
		||||
        {
 | 
			
		||||
            if (value == null)
 | 
			
		||||
                throw new ArgumentNullException("value");
 | 
			
		||||
 | 
			
		||||
            Style style = value as Style;
 | 
			
		||||
            if (style == null)
 | 
			
		||||
                throw new InvalidOperationException(DomSR.StyleExpected);
 | 
			
		||||
 | 
			
		||||
            bool isRootStyle = style.IsRootStyle;
 | 
			
		||||
 | 
			
		||||
            if (style.BaseStyle == "" && !isRootStyle)
 | 
			
		||||
                throw new ArgumentException(DomSR.UndefinedBaseStyle(style.BaseStyle));
 | 
			
		||||
 | 
			
		||||
            Style baseStyle = null;
 | 
			
		||||
            int styleIndex = GetIndex(style.BaseStyle);
 | 
			
		||||
 | 
			
		||||
            if (styleIndex != -1)
 | 
			
		||||
                baseStyle = this[styleIndex] as Style;
 | 
			
		||||
            else if (!isRootStyle)
 | 
			
		||||
                throw new ArgumentException(DomSR.UndefinedBaseStyle(style.BaseStyle));
 | 
			
		||||
 | 
			
		||||
            if (baseStyle != null)
 | 
			
		||||
                style._styleType.Value = (int)baseStyle.Type;
 | 
			
		||||
 | 
			
		||||
            int index = GetIndex(style.Name);
 | 
			
		||||
 | 
			
		||||
            if (index >= 0)
 | 
			
		||||
            {
 | 
			
		||||
                // Here a clone of the object will be added to the list, not the original object.
 | 
			
		||||
                style = style.Clone();
 | 
			
		||||
                style._parent = this;
 | 
			
		||||
                ((IList)this)[index] = style;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                base.Add(value);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the default paragraph style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Style Normal
 | 
			
		||||
        {
 | 
			
		||||
            get { return this[Style.DefaultParagraphName]; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets a comment associated with this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Comment
 | 
			
		||||
        {
 | 
			
		||||
            get { return _comment.Value; }
 | 
			
		||||
            set { _comment.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _comment = NString.NullValue;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initialize the built-in styles.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void SetupStyles()
 | 
			
		||||
        {
 | 
			
		||||
            Style style;
 | 
			
		||||
 | 
			
		||||
            // First standard style.
 | 
			
		||||
            style = new Style(Style.DefaultParagraphFontName, null);
 | 
			
		||||
            style.IsReadOnly = true;
 | 
			
		||||
            style._styleType.Value = (int)StyleType.Character;
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Normal 'Standard' (Paragraph Style).
 | 
			
		||||
            style = new Style(Style.DefaultParagraphName, null);
 | 
			
		||||
            style._styleType.Value = (int)StyleType.Paragraph;
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.Font.Name = "Arial";  // Not "Verdana" anymore.
 | 
			
		||||
            style.Font.Size = 10;
 | 
			
		||||
            style.Font.Bold = false;
 | 
			
		||||
            style.Font.Italic = false;
 | 
			
		||||
            style.Font.Underline = Underline.None;
 | 
			
		||||
            style.Font.Color = Colors.Black;
 | 
			
		||||
            style.Font.Subscript = false;
 | 
			
		||||
            style.Font.Superscript = false;
 | 
			
		||||
            style.ParagraphFormat.Alignment = ParagraphAlignment.Left;
 | 
			
		||||
            style.ParagraphFormat.FirstLineIndent = 0;
 | 
			
		||||
            style.ParagraphFormat.LeftIndent = 0;
 | 
			
		||||
            style.ParagraphFormat.RightIndent = 0;
 | 
			
		||||
            style.ParagraphFormat.KeepTogether = false;
 | 
			
		||||
            style.ParagraphFormat.KeepWithNext = false;
 | 
			
		||||
            style.ParagraphFormat.SpaceBefore = 0;
 | 
			
		||||
            style.ParagraphFormat.SpaceAfter = 0;
 | 
			
		||||
            style.ParagraphFormat.LineSpacing = 10;
 | 
			
		||||
            style.ParagraphFormat.LineSpacingRule = LineSpacingRule.Single;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.BodyText;
 | 
			
		||||
            style.ParagraphFormat.PageBreakBefore = false;
 | 
			
		||||
            style.ParagraphFormat.WidowControl = true;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Heading1 '<27>berschrift 1' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Heading1, StyleNames.Normal);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Heading2 '<27>berschrift 2' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Heading2, StyleNames.Heading1);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level2;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Heading3 '<27>berschrift 3' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Heading3, StyleNames.Heading2);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level3;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Heading4 '<27>berschrift 4' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Heading4, StyleNames.Heading3);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level4;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Heading5 '<27>berschrift 5' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Heading5, StyleNames.Heading4);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level5;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Heading6 '<27>berschrift 6' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Heading6, StyleNames.Heading5);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level6;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Heading7 '<27>berschrift 7' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Heading7, StyleNames.Heading6);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level7;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Heading8 '<27>berschrift 8' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Heading8, StyleNames.Heading7);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level8;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Heading9 '<27>berschrift 9' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Heading9, StyleNames.Heading8);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level9;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // List 'Liste' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.List, StyleNames.Normal);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Footnote 'Fu<46>note' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Footnote, StyleNames.Normal);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Header 'Kopfzeile' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Header, StyleNames.Normal);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // -33: Footer 'Fu<46>zeile' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.Footer, StyleNames.Normal);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // Hyperlink 'Hyperlink' (Character Style).
 | 
			
		||||
            style = new Style(StyleNames.Hyperlink, StyleNames.DefaultParagraphFont);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            Add(style);
 | 
			
		||||
 | 
			
		||||
            // InvalidStyleName 'Ung<6E>ltiger Formatvorlagenname' (Paragraph Style).
 | 
			
		||||
            style = new Style(StyleNames.InvalidStyleName, StyleNames.Normal);
 | 
			
		||||
            style._buildIn.Value = true;
 | 
			
		||||
            style.Font.Bold = true;
 | 
			
		||||
            style.Font.Underline = Underline.Dash;
 | 
			
		||||
            style.Font.Color = new Color(0xFF00FF00);
 | 
			
		||||
            Add(style);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Styles into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            serializer.WriteComment(_comment.Value);
 | 
			
		||||
            int pos = serializer.BeginContent("\\styles");
 | 
			
		||||
 | 
			
		||||
            // A style can only be added to Styles if its base style exists. Therefore the
 | 
			
		||||
            // styles collection is consistent at any one time by definition. But because it 
 | 
			
		||||
            // is possible to change the base style of a style, the sequence of the styles 
 | 
			
		||||
            // in the styles collection can be in an order that a style comes before its base
 | 
			
		||||
            // style. The styles in an DDL file must be ordered such that each style appears
 | 
			
		||||
            // after its base style. We cannot simply reorder the styles collection, because
 | 
			
		||||
            // the predefined styles are expected at a fixed position.
 | 
			
		||||
            // The solution is to reorder the styles during serialization.
 | 
			
		||||
            int count = Count;
 | 
			
		||||
            bool[] fSerialized = new bool[count];  // already serialized
 | 
			
		||||
            fSerialized[0] = true;                       // consider DefaultParagraphFont as serialized
 | 
			
		||||
            bool[] fSerializePending = new bool[count];  // currently serializing
 | 
			
		||||
            bool newLine = false;  // gets true if at least one style was written
 | 
			
		||||
            //Start from 1 and do not serialize DefaultParagraphFont
 | 
			
		||||
            for (int index = 1; index < count; index++)
 | 
			
		||||
            {
 | 
			
		||||
                if (!fSerialized[index])
 | 
			
		||||
                {
 | 
			
		||||
                    Style style = this[index];
 | 
			
		||||
                    SerializeStyle(serializer, index, ref fSerialized, ref fSerializePending, ref newLine);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            serializer.EndContent(pos);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Serialize a style, but serialize its base style first (if that was not yet done).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void SerializeStyle(Serializer serializer, int index, ref bool[] fSerialized, ref bool[] fSerializePending,
 | 
			
		||||
          ref bool newLine)
 | 
			
		||||
        {
 | 
			
		||||
            Style style = this[index];
 | 
			
		||||
 | 
			
		||||
            // It is not possible to modify the default paragraph font
 | 
			
		||||
            if (style.Name == Style.DefaultParagraphFontName)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            // Circular dependencies cannot occur if changing the base style is implemented
 | 
			
		||||
            // correctly. But before we proof that, we check it here.
 | 
			
		||||
            if (fSerializePending[index])
 | 
			
		||||
            {
 | 
			
		||||
                string message = String.Format("Circular dependency detected according to style '{0}'.", style.Name);
 | 
			
		||||
                throw new InvalidOperationException(message);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Only style 'Normal' has no base style
 | 
			
		||||
            if (style.BaseStyle != "")
 | 
			
		||||
            {
 | 
			
		||||
                int idxBaseStyle = GetIndex(style.BaseStyle);
 | 
			
		||||
                if (idxBaseStyle != -1)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!fSerialized[idxBaseStyle])
 | 
			
		||||
                    {
 | 
			
		||||
                        fSerializePending[index] = true;
 | 
			
		||||
                        SerializeStyle(serializer, idxBaseStyle, ref fSerialized, ref fSerializePending, ref newLine);
 | 
			
		||||
                        fSerializePending[index] = false;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            int pos2 = serializer.BeginBlock();
 | 
			
		||||
            if (newLine)
 | 
			
		||||
                serializer.WriteLineNoCommit();
 | 
			
		||||
            style.Serialize(serializer);
 | 
			
		||||
            if (serializer.EndBlock(pos2))
 | 
			
		||||
                newLine = true;
 | 
			
		||||
            fSerialized[index] = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Allows the visitor object to visit the document object and its child objects.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            visitor.VisitStyles(this);
 | 
			
		||||
 | 
			
		||||
            Dictionary<Style, object> visitedStyles = new Dictionary<Style, object>();
 | 
			
		||||
            foreach (Style style in this)
 | 
			
		||||
                VisitStyle(visitedStyles, style, visitor, visitChildren);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Ensures that base styles are visited first.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void VisitStyle(Dictionary<Style, object> visitedStyles, Style style, DocumentObjectVisitor visitor, bool visitChildren)
 | 
			
		||||
        {
 | 
			
		||||
            if (!visitedStyles.ContainsKey(style))
 | 
			
		||||
            {
 | 
			
		||||
                Style baseStyle = style.GetBaseStyle();
 | 
			
		||||
                if (baseStyle != null && !visitedStyles.ContainsKey(baseStyle)) //baseStyle != ""
 | 
			
		||||
                    VisitStyle(visitedStyles, baseStyle, visitor, visitChildren);
 | 
			
		||||
                ((IVisitable)style).AcceptVisitor(visitor, visitChildren);
 | 
			
		||||
                visitedStyles.Add(style, null);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static readonly Styles BuildInStyles = new Styles();
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Styles))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										143
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/TabStop.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										143
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/TabStop.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,143 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents a tab inside a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class TabStop : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the TabStop class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the TabStop class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the TabStop class with the specified position.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop(Unit position)
 | 
			
		||||
            : this()
 | 
			
		||||
        {
 | 
			
		||||
            _position = position;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new TabStop Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (TabStop)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the tab stop position.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit Position
 | 
			
		||||
        {
 | 
			
		||||
            get { return _position; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public Unit _position = Unit.NullValue;  // always defined
 | 
			
		||||
        // useful enhancement: 'Position = Center' and 'Position = Right'
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the alignment of the tabstop.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabAlignment Alignment
 | 
			
		||||
        {
 | 
			
		||||
            get { return (TabAlignment)_alignment.Value; }
 | 
			
		||||
            set { _alignment.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(TabAlignment))]
 | 
			
		||||
        public NEnum _alignment = NEnum.NullValue(typeof(TabAlignment));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the character which is used as a leader for the tabstop.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabLeader Leader
 | 
			
		||||
        {
 | 
			
		||||
            get { return (TabLeader)_leader.Value; }
 | 
			
		||||
            set { _leader.Value = (int)value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV(Type = typeof(TabLeader))]
 | 
			
		||||
        public NEnum _leader = NEnum.NullValue(typeof(TabLeader));
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Generates a '+=' in DDL if it is true, otherwise '-='.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool AddTab = true;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts TabStop into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (AddTab)
 | 
			
		||||
            {
 | 
			
		||||
                serializer.WriteLine("TabStops +=");
 | 
			
		||||
                serializer.BeginContent();
 | 
			
		||||
                serializer.WriteSimpleAttribute("Position", Position);
 | 
			
		||||
                if (!_alignment.IsNull)
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Alignment", Alignment);
 | 
			
		||||
                if (!_leader.IsNull)
 | 
			
		||||
                    serializer.WriteSimpleAttribute("Leader", Leader);
 | 
			
		||||
                serializer.EndContent();
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                serializer.WriteLine("TabStops -= \"" + Position + "\"");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(TabStop))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										247
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/TabStops.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										247
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/TabStops.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,247 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// A TabStops collection represents all TabStop objects in a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class TabStops : DocumentObjectCollection
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Specifies the minimal spacing between two TabStop positions.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly double TabStopPrecision = 1.5;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the TabStops class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStops()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the TabStops class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStops(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new TabStops Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (TabStops)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a TabStop by its index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new TabStop this[int index]
 | 
			
		||||
        {
 | 
			
		||||
            get { return base[index] as TabStop; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a TabStop by its position.
 | 
			
		||||
        /// Note that also Removed TabStops are taken into account.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop GetTabStopAt(Unit position)
 | 
			
		||||
        {
 | 
			
		||||
            int count = Count;
 | 
			
		||||
            for (int index = 0; index < count; index++)
 | 
			
		||||
            {
 | 
			
		||||
                TabStop tabStop = (TabStop)this[index];
 | 
			
		||||
                if (Math.Abs(tabStop.Position.Point - position.Point) < TabStopPrecision)
 | 
			
		||||
                    return tabStop;
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns whether a TabStop exists at the given position.
 | 
			
		||||
        /// Note that also Removed TabStops are taken into account
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool TabStopExists(Unit position)
 | 
			
		||||
        {
 | 
			
		||||
            return GetTabStopAt(position) != null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection. If a TabStop with the same position
 | 
			
		||||
        /// already exists, it is replaced by the new TabStop.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop AddTabStop(TabStop tabStop)
 | 
			
		||||
        {
 | 
			
		||||
            if (tabStop == null)
 | 
			
		||||
                throw new ArgumentNullException("tabStop");
 | 
			
		||||
 | 
			
		||||
            if (TabStopExists(tabStop.Position))
 | 
			
		||||
            {
 | 
			
		||||
                int index = IndexOf(GetTabStopAt(tabStop.Position));
 | 
			
		||||
                RemoveObjectAt(index);
 | 
			
		||||
                InsertObject(index, tabStop);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                int count = Count;
 | 
			
		||||
                for (int index = 0; index < count; index++)
 | 
			
		||||
                {
 | 
			
		||||
                    if (tabStop.Position.Point < ((TabStop)this[index]).Position.Point)
 | 
			
		||||
                    {
 | 
			
		||||
                        InsertObject(index, tabStop);
 | 
			
		||||
                        return tabStop;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                Add(tabStop);
 | 
			
		||||
            }
 | 
			
		||||
            return tabStop;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object at the specified position to the collection. If a TabStop with the
 | 
			
		||||
        /// same position already exists, it is replaced by the new TabStop.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop AddTabStop(Unit position)
 | 
			
		||||
        {
 | 
			
		||||
            if (TabStopExists(position))
 | 
			
		||||
                return GetTabStopAt(position);
 | 
			
		||||
 | 
			
		||||
            TabStop tab = new TabStop(position);
 | 
			
		||||
            return AddTabStop(tab);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection and sets its alignment and leader.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop AddTabStop(Unit position, TabAlignment alignment, TabLeader leader)
 | 
			
		||||
        {
 | 
			
		||||
            TabStop tab = AddTabStop(position);
 | 
			
		||||
            tab.Alignment = alignment;
 | 
			
		||||
            tab.Leader = leader;
 | 
			
		||||
            return tab;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection and sets its leader.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop AddTabStop(Unit position, TabLeader leader)
 | 
			
		||||
        {
 | 
			
		||||
            TabStop tab = AddTabStop(position);
 | 
			
		||||
            tab.Leader = leader;
 | 
			
		||||
            return tab;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection and sets its alignment.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TabStop AddTabStop(Unit position, TabAlignment alignment)
 | 
			
		||||
        {
 | 
			
		||||
            TabStop tab = AddTabStop(position);
 | 
			
		||||
            tab.Alignment = alignment;
 | 
			
		||||
            return tab;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a TabStop object to the collection marked to remove the tab stop at
 | 
			
		||||
        /// the given position.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void RemoveTabStop(Unit position)
 | 
			
		||||
        {
 | 
			
		||||
            TabStop tab = AddTabStop(position);
 | 
			
		||||
            tab.AddTab = false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Clears all TabStop objects from the collection. Additionally 'TabStops = null'
 | 
			
		||||
        /// is written to the DDL stream when serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void ClearAll()
 | 
			
		||||
        {
 | 
			
		||||
            Clear();
 | 
			
		||||
            _fClearAll = true;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the information if the collection is marked as cleared. Additionally 'TabStops = null'
 | 
			
		||||
        /// is written to the DDL stream when serialized.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool TabsCleared
 | 
			
		||||
        {
 | 
			
		||||
            get { return _fClearAll; }
 | 
			
		||||
        }
 | 
			
		||||
        public bool _fClearAll = false;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region public
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts TabStops into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (_fClearAll)
 | 
			
		||||
                serializer.WriteLine("TabStops = null");
 | 
			
		||||
 | 
			
		||||
            int count = Count;
 | 
			
		||||
            for (int index = 0; index < count; index++)
 | 
			
		||||
            {
 | 
			
		||||
                TabStop tabstop = this[index];
 | 
			
		||||
                tabstop.Serialize(serializer);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance is null (not set).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override bool IsNull()
 | 
			
		||||
        {
 | 
			
		||||
            // Only non empty and not cleared tabstops (TabStops = null) are null.
 | 
			
		||||
            if (base.IsNull())
 | 
			
		||||
                return !_fClearAll;
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(TabStops))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										101
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Text.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Text.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,101 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents text in a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Text : DocumentObject
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Text class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Text class with the specified parent.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text(DocumentObject parent) : base(parent) { }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Text class with a string as paragraph content.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Text(string content)
 | 
			
		||||
            : this()
 | 
			
		||||
        {
 | 
			
		||||
            Content = content;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a deep copy of this object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public new Text Clone()
 | 
			
		||||
        {
 | 
			
		||||
            return (Text)DeepCopy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the text content.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Content
 | 
			
		||||
        {
 | 
			
		||||
            get { return _content.Value; }
 | 
			
		||||
            set { _content.Value = value; }
 | 
			
		||||
        }
 | 
			
		||||
        [DV]
 | 
			
		||||
        public NString _content = NString.NullValue;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts Text into DDL.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override void Serialize(Serializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            string text = DdlEncoder.StringToText(_content.Value);
 | 
			
		||||
            // To make DDL more readable write soft hypens as keywords.
 | 
			
		||||
            text = text.Replace(new string((char)173, 1), "\\-");
 | 
			
		||||
            serializer.Write(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the meta object of this instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Meta Meta
 | 
			
		||||
        {
 | 
			
		||||
            get { return _meta ?? (_meta = new Meta(typeof(Text))); }
 | 
			
		||||
        }
 | 
			
		||||
        static Meta _meta;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,161 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2009 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#if false
 | 
			
		||||
using System;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using System.ComponentModel;
 | 
			
		||||
using System.Drawing;
 | 
			
		||||
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Provides functionality to measure the width of text during document design time.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public sealed class TextMeasurement
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the TextMeasurement class with the specified font.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public TextMeasurement(Font font)
 | 
			
		||||
        {
 | 
			
		||||
            if (font == null)
 | 
			
		||||
                throw new ArgumentNullException("font");
 | 
			
		||||
 | 
			
		||||
            this.font = font;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#if !SILVERLIGHT
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Returns the size of the bounding box of the specified text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public System.Drawing.SizeF MeasureString(string text, UnitType unitType)
 | 
			
		||||
    {
 | 
			
		||||
      if (text == null)
 | 
			
		||||
        throw new ArgumentNullException("text");
 | 
			
		||||
 | 
			
		||||
      if (!Enum.IsDefined(typeof(UnitType), unitType))
 | 
			
		||||
        throw new InvalidEnumArgumentException();
 | 
			
		||||
 | 
			
		||||
      System.Drawing.Graphics graphics = Realize();
 | 
			
		||||
 | 
			
		||||
      SizeF size = graphics.MeasureString(text, this .gdiFont, new PointF(0, 0), System.Drawing.StringFormat.GenericTypographic);
 | 
			
		||||
      switch (unitType)
 | 
			
		||||
      {
 | 
			
		||||
        case UnitType.Point:
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        case UnitType.Centimeter:
 | 
			
		||||
          size.Width = (float)(size.Width * 2.54 / 72);
 | 
			
		||||
          size.Height = (float)(size.Height * 2.54 / 72);
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        case UnitType.Inch:
 | 
			
		||||
          size.Width = size.Width / 72;
 | 
			
		||||
          size.Height = size.Height / 72;
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        case UnitType.Millimeter:
 | 
			
		||||
          size.Width = (float)(size.Width * 25.4 / 72);
 | 
			
		||||
          size.Height = (float)(size.Height * 25.4 / 72);
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        case UnitType.Pica:
 | 
			
		||||
          size.Width = size.Width / 12;
 | 
			
		||||
          size.Height = size.Height / 12;
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
          Debug.Assert(false, "Missing unit type");
 | 
			
		||||
          break;
 | 
			
		||||
      }
 | 
			
		||||
      return size;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Returns the size of the bounding box of the specified text in point.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public SizeF MeasureString(string text)
 | 
			
		||||
    {
 | 
			
		||||
      return MeasureString(text, UnitType.Point);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets or sets the font used for measurement.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public Font Font
 | 
			
		||||
    {
 | 
			
		||||
      get { return this .font; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (value == null)
 | 
			
		||||
          throw new ArgumentNullException("value");
 | 
			
		||||
        if (this .font != value)
 | 
			
		||||
        {
 | 
			
		||||
          this .font = value;
 | 
			
		||||
          this .gdiFont = null;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    Font font;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Initializes appropriate GDI+ objects.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Graphics Realize()
 | 
			
		||||
    {
 | 
			
		||||
      if (this .graphics == null)
 | 
			
		||||
        this .graphics = Graphics.FromHwnd(IntPtr.Zero);
 | 
			
		||||
 | 
			
		||||
      this .graphics.PageUnit = GraphicsUnit.Point;
 | 
			
		||||
 | 
			
		||||
      if (this .gdiFont == null)
 | 
			
		||||
      {
 | 
			
		||||
        System.Drawing.FontStyle style = System.Drawing.FontStyle.Regular;
 | 
			
		||||
        if (this .font.Bold)
 | 
			
		||||
          style |= System.Drawing.FontStyle.Bold;
 | 
			
		||||
        if (this .font.Italic)
 | 
			
		||||
          style |= System.Drawing.FontStyle.Italic;
 | 
			
		||||
 | 
			
		||||
        this .gdiFont = new System.Drawing.Font(this.font.Name, this.font.Size, style, System.Drawing.GraphicsUnit.Point);
 | 
			
		||||
      }
 | 
			
		||||
      return this .graphics;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    System.Drawing.Font gdiFont;
 | 
			
		||||
    System.Drawing.Graphics graphics;
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										766
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Unit.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										766
									
								
								MigraDoc.DocumentObjectModel/DocumentObjectModel/Unit.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,766 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using MigraDoc.DocumentObjectModel.publics;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// A Unit consists of a numerical value and a UnitType like Centimeter, Millimeter, or Inch.
 | 
			
		||||
    /// Several conversions between different measures are supported.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public struct Unit : IFormattable, INullableValue
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Unit class with type set to point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit(double point)
 | 
			
		||||
        {
 | 
			
		||||
            _value = (float)point;
 | 
			
		||||
            _type = UnitType.Point;
 | 
			
		||||
            _initialized = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the Unit class.
 | 
			
		||||
        /// Throws System.ArgumentException if <code>type</code> is invalid.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Unit(double value, UnitType type)
 | 
			
		||||
        {
 | 
			
		||||
            if (!Enum.IsDefined(typeof(UnitType), type))
 | 
			
		||||
                throw new /*InvalidEnum*/ArgumentException(DomSR.InvalidEnumValue(type), "type");
 | 
			
		||||
 | 
			
		||||
            _value = (float)value;
 | 
			
		||||
            _type = type;
 | 
			
		||||
            _initialized = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance is empty.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsEmpty
 | 
			
		||||
        {
 | 
			
		||||
            get { return IsNull; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the value of the unit.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        object INullableValue.GetValue()
 | 
			
		||||
        {
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the unit to the given value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void INullableValue.SetValue(object value)
 | 
			
		||||
        {
 | 
			
		||||
            if (value == null)
 | 
			
		||||
                throw new ArgumentNullException("value");
 | 
			
		||||
 | 
			
		||||
            if (value is Unit)
 | 
			
		||||
                this = (Unit)value;
 | 
			
		||||
            else
 | 
			
		||||
                this = value.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Resets this instance,
 | 
			
		||||
        /// i.e. IsNull() will return true afterwards.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void INullableValue.SetNull()
 | 
			
		||||
        {
 | 
			
		||||
            _value = 0;
 | 
			
		||||
            _type = UnitType.Point;
 | 
			
		||||
            _initialized = false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Explicit interface implementations cannot contain access specifiers, i.e. they are accessible by a
 | 
			
		||||
        // cast operator only, e.g. ((IDomValue)obj).IsNull.
 | 
			
		||||
        // Therefore the second IsNull-Property is used as a handy shortcut.
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance is null (not set).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        bool INullableValue.IsNull
 | 
			
		||||
        {
 | 
			
		||||
            get { return IsNull; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Determines whether this instance is null (not set).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsNull
 | 
			
		||||
        {
 | 
			
		||||
            get { return !_initialized; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region Properties
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the raw value of the object without any conversion.
 | 
			
		||||
        /// To determine the UnitType use property <code>Type</code>.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double Value
 | 
			
		||||
        {
 | 
			
		||||
            get { return (IsNull ? 0 : _value); }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _value = (float)value;
 | 
			
		||||
                _initialized = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the UnitType of the object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public UnitType Type
 | 
			
		||||
        {
 | 
			
		||||
            get { return _type; }
 | 
			
		||||
            set { _type = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the value in point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double Point
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (IsNull)
 | 
			
		||||
                    return 0;
 | 
			
		||||
 | 
			
		||||
                switch (_type)
 | 
			
		||||
                {
 | 
			
		||||
                    case UnitType.Centimeter:
 | 
			
		||||
                        return _value * 72 / 2.54;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Inch:
 | 
			
		||||
                        return _value * 72;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Millimeter:
 | 
			
		||||
                        return _value * 72 / 25.4;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Pica:
 | 
			
		||||
                        return _value * 12;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Point:
 | 
			
		||||
                        return _value;
 | 
			
		||||
 | 
			
		||||
                    default:
 | 
			
		||||
                        Debug.Assert(false, "Missing unit type.");
 | 
			
		||||
                        return 0;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _value = (float)value;
 | 
			
		||||
                _type = UnitType.Point;
 | 
			
		||||
                _initialized = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //[Obsolete("Use Point")]
 | 
			
		||||
        //public double Pt
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return Point; }
 | 
			
		||||
        //    set { Point = value; }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the value in centimeter.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double Centimeter
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (IsNull)
 | 
			
		||||
                    return 0;
 | 
			
		||||
 | 
			
		||||
                switch (_type)
 | 
			
		||||
                {
 | 
			
		||||
                    case UnitType.Centimeter:
 | 
			
		||||
                        return _value;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Inch:
 | 
			
		||||
                        return _value * 2.54;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Millimeter:
 | 
			
		||||
                        return _value / 10;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Pica:
 | 
			
		||||
                        return _value * 12 * 2.54 / 72;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Point:
 | 
			
		||||
                        return _value * 2.54 / 72;
 | 
			
		||||
 | 
			
		||||
                    default:
 | 
			
		||||
                        Debug.Assert(false, "Missing unit type");
 | 
			
		||||
                        return 0;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _value = (float)value;
 | 
			
		||||
                _type = UnitType.Centimeter;
 | 
			
		||||
                _initialized = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //[Obsolete("Use Centimeter")]
 | 
			
		||||
        //public double Cm
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return Centimeter; }
 | 
			
		||||
        //    set { Centimeter = value; }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the value in inch.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double Inch
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (IsNull)
 | 
			
		||||
                    return 0;
 | 
			
		||||
 | 
			
		||||
                switch (_type)
 | 
			
		||||
                {
 | 
			
		||||
                    case UnitType.Centimeter:
 | 
			
		||||
                        return _value / 2.54;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Inch:
 | 
			
		||||
                        return _value;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Millimeter:
 | 
			
		||||
                        return _value / 25.4;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Pica:
 | 
			
		||||
                        return _value * 12 / 72;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Point:
 | 
			
		||||
                        return _value / 72;
 | 
			
		||||
 | 
			
		||||
                    default:
 | 
			
		||||
                        Debug.Assert(false, "Missing unit type");
 | 
			
		||||
                        return 0;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _value = (float)value;
 | 
			
		||||
                _type = UnitType.Inch;
 | 
			
		||||
                _initialized = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //[Obsolete("Use Inch")]
 | 
			
		||||
        //public double In
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return Inch; }
 | 
			
		||||
        //    set { Inch = value; }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the value in millimeter.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double Millimeter
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (IsNull)
 | 
			
		||||
                    return 0;
 | 
			
		||||
 | 
			
		||||
                switch (_type)
 | 
			
		||||
                {
 | 
			
		||||
                    case UnitType.Centimeter:
 | 
			
		||||
                        return _value * 10;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Inch:
 | 
			
		||||
                        return _value * 25.4;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Millimeter:
 | 
			
		||||
                        return _value;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Pica:
 | 
			
		||||
                        return _value * 12 * 25.4 / 72;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Point:
 | 
			
		||||
                        return _value * 25.4 / 72;
 | 
			
		||||
 | 
			
		||||
                    default:
 | 
			
		||||
                        Debug.Assert(false, "Missing unit type");
 | 
			
		||||
                        return 0;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _value = (float)value;
 | 
			
		||||
                _type = UnitType.Millimeter;
 | 
			
		||||
                _initialized = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //[Obsolete("Use Millimeter")]
 | 
			
		||||
        //public double Mm
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return Millimeter; }
 | 
			
		||||
        //    set { Millimeter = value; }
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the value in pica.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double Pica
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (IsNull)
 | 
			
		||||
                    return 0;
 | 
			
		||||
 | 
			
		||||
                switch (_type)
 | 
			
		||||
                {
 | 
			
		||||
                    case UnitType.Centimeter:
 | 
			
		||||
                        return _value * 72 / 2.54 / 12;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Inch:
 | 
			
		||||
                        return _value * 72 / 12;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Millimeter:
 | 
			
		||||
                        return _value * 72 / 25.4 / 12;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Pica:
 | 
			
		||||
                        return _value;
 | 
			
		||||
 | 
			
		||||
                    case UnitType.Point:
 | 
			
		||||
                        return _value / 12;
 | 
			
		||||
 | 
			
		||||
                    default:
 | 
			
		||||
                        Debug.Assert(false, "Missing unit type");
 | 
			
		||||
                        return 0;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _value = (float)value;
 | 
			
		||||
                _type = UnitType.Pica;
 | 
			
		||||
                _initialized = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //[Obsolete("Use Pica")]
 | 
			
		||||
        //public double Pc
 | 
			
		||||
        //{
 | 
			
		||||
        //    get { return Pica; }
 | 
			
		||||
        //    set { Pica = value; }
 | 
			
		||||
        //}
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Methods
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the object as string using the format information.
 | 
			
		||||
        /// Measure will be added to the end of the string.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string ToString(System.IFormatProvider formatProvider)
 | 
			
		||||
        {
 | 
			
		||||
            if (IsNull)
 | 
			
		||||
                return 0.ToString(formatProvider);
 | 
			
		||||
 | 
			
		||||
            string valuestring = _value.ToString(formatProvider) + GetSuffix();
 | 
			
		||||
            return valuestring;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the object as string using the format.
 | 
			
		||||
        /// Measure will be added to the end of the string.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string ToString(string format)
 | 
			
		||||
        {
 | 
			
		||||
            if (IsNull)
 | 
			
		||||
                return 0.ToString(format);
 | 
			
		||||
 | 
			
		||||
            string valuestring = _value.ToString(format) + GetSuffix();
 | 
			
		||||
            return valuestring;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the object as string using the specified format and format information.
 | 
			
		||||
        /// Measure will be added to the end of the string.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        string IFormattable.ToString(string format, IFormatProvider formatProvider)
 | 
			
		||||
        {
 | 
			
		||||
            if (IsNull)
 | 
			
		||||
                return 0.ToString(format, formatProvider);
 | 
			
		||||
 | 
			
		||||
            string valuestring = _value.ToString(format, formatProvider) + GetSuffix();
 | 
			
		||||
            return valuestring;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the object as string. Measure will be added to the end of the string.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override string ToString()
 | 
			
		||||
        {
 | 
			
		||||
            if (IsNull)
 | 
			
		||||
                return 0.ToString(System.Globalization.CultureInfo.InvariantCulture);
 | 
			
		||||
 | 
			
		||||
            string valuestring = _value.ToString(System.Globalization.CultureInfo.InvariantCulture) + GetSuffix();
 | 
			
		||||
            return valuestring;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns the type of the object as a string like 'pc', 'cm', or 'in'. Empty string is equal to 'pt'.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        string GetSuffix()
 | 
			
		||||
        {
 | 
			
		||||
            switch (_type)
 | 
			
		||||
            {
 | 
			
		||||
                case UnitType.Centimeter:
 | 
			
		||||
                    return "cm";
 | 
			
		||||
 | 
			
		||||
                case UnitType.Inch:
 | 
			
		||||
                    return "in";
 | 
			
		||||
 | 
			
		||||
                case UnitType.Millimeter:
 | 
			
		||||
                    return "mm";
 | 
			
		||||
 | 
			
		||||
                case UnitType.Pica:
 | 
			
		||||
                    return "pc";
 | 
			
		||||
 | 
			
		||||
                case UnitType.Point:
 | 
			
		||||
                    //Point is default, so leave this blank.
 | 
			
		||||
                    return "";
 | 
			
		||||
 | 
			
		||||
                default:
 | 
			
		||||
                    Debug.Assert(false, "Missing unit type");
 | 
			
		||||
                    return "";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns a Unit object. Sets type to centimeter.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Unit FromCentimeter(double value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Unit.Zero;
 | 
			
		||||
            unit._value = (float)value;
 | 
			
		||||
            unit._type = UnitType.Centimeter;
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //[Obsolete("Use FromCentimer")]
 | 
			
		||||
        //public static Unit FromCm(double value)
 | 
			
		||||
        //{
 | 
			
		||||
        //    return FromCentimeter(value);
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns a Unit object. Sets type to millimeter.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Unit FromMillimeter(double value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Unit.Zero;
 | 
			
		||||
            unit._value = (float)value;
 | 
			
		||||
            unit._type = UnitType.Millimeter;
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ///// <summary>
 | 
			
		||||
        ///// Returns a Unit object. Sets type to millimeter.
 | 
			
		||||
        ///// </summary>
 | 
			
		||||
        //[Obsolete("Use FromMillimeter")]
 | 
			
		||||
        //public static Unit FromMm(double value)
 | 
			
		||||
        //{
 | 
			
		||||
        //    return FromMillimeter(value);
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns a Unit object. Sets type to point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Unit FromPoint(double value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Unit.Zero;
 | 
			
		||||
            unit._value = (float)value;
 | 
			
		||||
            unit._type = UnitType.Point;
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns a Unit object. Sets type to inch.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Unit FromInch(double value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Unit.Zero;
 | 
			
		||||
            unit._value = (float)value;
 | 
			
		||||
            unit._type = UnitType.Inch;
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns a Unit object. Sets type to pica.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Unit FromPica(double value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Unit.Zero;
 | 
			
		||||
            unit._value = (float)value;
 | 
			
		||||
            unit._type = UnitType.Pica;
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts a string to a Unit object.
 | 
			
		||||
        /// If the string contains a suffix like 'cm' or 'in' the object will be converted
 | 
			
		||||
        /// to the appropriate type, otherwise point is assumed.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static implicit operator Unit(string value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Zero;
 | 
			
		||||
            value = value.Trim();
 | 
			
		||||
 | 
			
		||||
            // For Germans...
 | 
			
		||||
            value = value.Replace(',', '.');
 | 
			
		||||
 | 
			
		||||
            int count = value.Length;
 | 
			
		||||
            int valLen = 0;
 | 
			
		||||
            for (; valLen < count; )
 | 
			
		||||
            {
 | 
			
		||||
                char ch = value[valLen];
 | 
			
		||||
                if (ch == '.' || ch == '-' || ch == '+' || Char.IsNumber(ch))
 | 
			
		||||
                    valLen++;
 | 
			
		||||
                else
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            unit._value = 1;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                unit._value = float.Parse(value.Substring(0, valLen).Trim(), System.Globalization.CultureInfo.InvariantCulture);
 | 
			
		||||
            }
 | 
			
		||||
            catch (FormatException ex)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentException(DomSR.InvalidUnitValue(value), ex);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            string typeStr = value.Substring(valLen).Trim().ToLower();
 | 
			
		||||
            unit._type = UnitType.Point;
 | 
			
		||||
            switch (typeStr)
 | 
			
		||||
            {
 | 
			
		||||
                case "cm":
 | 
			
		||||
                    unit._type = UnitType.Centimeter;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case "in":
 | 
			
		||||
                    unit._type = UnitType.Inch;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case "mm":
 | 
			
		||||
                    unit._type = UnitType.Millimeter;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case "pc":
 | 
			
		||||
                    unit._type = UnitType.Pica;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case "":
 | 
			
		||||
                case "pt":
 | 
			
		||||
                    unit._type = UnitType.Point;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                default:
 | 
			
		||||
                    throw new ArgumentException(DomSR.InvalidUnitType(typeStr));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts an int to a Unit object with type set to point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static implicit operator Unit(int value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Zero;
 | 
			
		||||
            unit._value = value;
 | 
			
		||||
            unit._type = UnitType.Point;
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts a float to a Unit object with type set to point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static implicit operator Unit(float value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Zero;
 | 
			
		||||
            unit._value = value;
 | 
			
		||||
            unit._type = UnitType.Point;
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts a double to a Unit object with type set to point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static implicit operator Unit(double value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Zero;
 | 
			
		||||
            unit._value = (float)value;
 | 
			
		||||
            unit._type = UnitType.Point;
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns a double value as point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static implicit operator double(Unit value)
 | 
			
		||||
        {
 | 
			
		||||
            return value.Point;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Returns a float value as point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static implicit operator float(Unit value)
 | 
			
		||||
        {
 | 
			
		||||
            return (float)value.Point;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Memberwise comparison. To compare by value, 
 | 
			
		||||
        /// use code like Math.Abs(a.Point - b.Point) < 1e-5.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static bool operator ==(Unit l, Unit r)
 | 
			
		||||
        {
 | 
			
		||||
            // ReSharper disable CompareOfFloatsByEqualityOperator
 | 
			
		||||
            return (l._initialized == r._initialized && l._type == r._type && l._value == r._value);
 | 
			
		||||
            // ReSharper restore CompareOfFloatsByEqualityOperator
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Memberwise comparison. To compare by value, 
 | 
			
		||||
        /// use code like Math.Abs(a.Point - b.Point) < 1e-5.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static bool operator !=(Unit l, Unit r)
 | 
			
		||||
        {
 | 
			
		||||
            return !(l == r);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Calls base class Equals.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override bool Equals(Object obj)
 | 
			
		||||
        {
 | 
			
		||||
            return base.Equals(obj);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Calls base class GetHashCode.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override int GetHashCode()
 | 
			
		||||
        {
 | 
			
		||||
            return base.GetHashCode();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// This member is intended to be used by XmlDomainObjectReader only.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static Unit Parse(string value)
 | 
			
		||||
        {
 | 
			
		||||
            Unit unit = Zero;
 | 
			
		||||
            unit = value;
 | 
			
		||||
            return unit;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts an existing object from one unit into another unit type.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void ConvertType(UnitType type)
 | 
			
		||||
        {
 | 
			
		||||
            if (_type == type)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            switch (type)
 | 
			
		||||
            {
 | 
			
		||||
                case UnitType.Centimeter:
 | 
			
		||||
                    _value = (float)Centimeter;
 | 
			
		||||
                    _type = UnitType.Centimeter;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case UnitType.Inch:
 | 
			
		||||
                    _value = (float)Inch;
 | 
			
		||||
                    _type = UnitType.Inch;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case UnitType.Millimeter:
 | 
			
		||||
                    _value = (float)Millimeter;
 | 
			
		||||
                    _type = UnitType.Millimeter;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case UnitType.Pica:
 | 
			
		||||
                    _value = (float)Pica;
 | 
			
		||||
                    _type = UnitType.Pica;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case UnitType.Point:
 | 
			
		||||
                    _value = (float)Point;
 | 
			
		||||
                    _type = UnitType.Point;
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                default:
 | 
			
		||||
                    if (!Enum.IsDefined(typeof(UnitType), type))
 | 
			
		||||
                        throw new ArgumentException(DomSR.InvalidUnitType(type.ToString()));
 | 
			
		||||
 | 
			
		||||
                    // Remember missing unit type.
 | 
			
		||||
                    Debug.Assert(false, "Missing unit type");
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Represents the uninitialized Unit object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Unit Empty = new Unit();
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Represents an initialized Unit object with value 0 and unit type point.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Unit Zero = new Unit(0);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Represents the uninitialized Unit object. Same as Unit.Empty.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static readonly Unit NullValue = Empty;
 | 
			
		||||
 | 
			
		||||
        bool _initialized;
 | 
			
		||||
        float _value;
 | 
			
		||||
        UnitType _type;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,96 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the style of the line of the Border object.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum BorderStyle
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// No border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        None,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// A single solid line.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Single,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// A dotted line.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Dot,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// A dashed line (small gaps).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        DashSmallGap,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// A dashed line (large gaps).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        DashLargeGap,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Alternating dashes and dots.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        DashDot,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// A dash followed by two dots.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        DashDotDot,
 | 
			
		||||
 | 
			
		||||
        /* --- unsupported ---
 | 
			
		||||
          Double                = 7,
 | 
			
		||||
          Triple                = 8,
 | 
			
		||||
          ThinThickSmallGap     = 9,
 | 
			
		||||
          ThickThinSmallGap     = 10,
 | 
			
		||||
          ThinThickThinSmallGap = 11,
 | 
			
		||||
          ThinThickMedGap       = 12,
 | 
			
		||||
          ThickThinMedGap       = 13,
 | 
			
		||||
          ThinThickThinMedGap   = 14,
 | 
			
		||||
          ThinThickLargeGap     = 15,
 | 
			
		||||
          ThickThinLargeGap     = 16,
 | 
			
		||||
          ThinThickThinLargeGap = 17,
 | 
			
		||||
          SingleWavy            = 18,
 | 
			
		||||
          DoubleWavy            = 19,
 | 
			
		||||
          DashDotStroked        = 20,
 | 
			
		||||
          Emboss3D              = 21,
 | 
			
		||||
          Engrave3D             = 22,
 | 
			
		||||
          LineStyleOutset       = 23, //!!!newEG 02-07-22
 | 
			
		||||
          LineStyleInset        = 24  //!!!newEG 02-07-22
 | 
			
		||||
        */
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,51 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the type of the Border object and therefore its position.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum BorderType
 | 
			
		||||
    {
 | 
			
		||||
        Top,
 | 
			
		||||
        Left,
 | 
			
		||||
        Bottom,
 | 
			
		||||
        Right,
 | 
			
		||||
        Horizontal,  // not used in MigraDoc 1.2
 | 
			
		||||
        Vertical,    // not used in MigraDoc 1.2
 | 
			
		||||
        DiagonalDown,
 | 
			
		||||
        DiagonalUp
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,55 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the page break in a new section.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum BreakType
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Breaks at the next page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        BreakNextPage,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Breaks at the next even page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        BreakEvenPage,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Breaks at the next odd page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        BreakOddPage
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,182 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// public color names.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    enum ColorName : uint
 | 
			
		||||
    {
 | 
			
		||||
        AliceBlue = 0xFFF0F8FF,
 | 
			
		||||
        AntiqueWhite = 0xFFFAEBD7,
 | 
			
		||||
        Aqua = 0xFF00FFFF,
 | 
			
		||||
        Aquamarine = 0xFF7FFFD4,
 | 
			
		||||
        Azure = 0xFFF0FFFF,
 | 
			
		||||
        Beige = 0xFFF5F5DC,
 | 
			
		||||
        Bisque = 0xFFFFE4C4,
 | 
			
		||||
        Black = 0xFF000000,
 | 
			
		||||
        BlanchedAlmond = 0xFFFFEBCD,
 | 
			
		||||
        Blue = 0xFF0000FF,
 | 
			
		||||
        BlueViolet = 0xFF8A2BE2,
 | 
			
		||||
        Brown = 0xFFA52A2A,
 | 
			
		||||
        BurlyWood = 0xFFDEB887,
 | 
			
		||||
        CadetBlue = 0xFF5F9EA0,
 | 
			
		||||
        Chartreuse = 0xFF7FFF00,
 | 
			
		||||
        Chocolate = 0xFFD2691E,
 | 
			
		||||
        Coral = 0xFFFF7F50,
 | 
			
		||||
        CornflowerBlue = 0xFF6495ED,
 | 
			
		||||
        Cornsilk = 0xFFFFF8DC,
 | 
			
		||||
        Crimson = 0xFFDC143C,
 | 
			
		||||
        Cyan = 0xFF00FFFF,
 | 
			
		||||
        DarkBlue = 0xFF00008B,
 | 
			
		||||
        DarkCyan = 0xFF008B8B,
 | 
			
		||||
        DarkGoldenrod = 0xFFB8860B,
 | 
			
		||||
        DarkGray = 0xFFA9A9A9,
 | 
			
		||||
        DarkGreen = 0xFF006400,
 | 
			
		||||
        DarkKhaki = 0xFFBDB76B,
 | 
			
		||||
        DarkMagenta = 0xFF8B008B,
 | 
			
		||||
        DarkOliveGreen = 0xFF556B2F,
 | 
			
		||||
        DarkOrange = 0xFFFF8C00,
 | 
			
		||||
        DarkOrchid = 0xFF9932CC,
 | 
			
		||||
        DarkRed = 0xFF8B0000,
 | 
			
		||||
        DarkSalmon = 0xFFE9967A,
 | 
			
		||||
        DarkSeaGreen = 0xFF8FBC8B,
 | 
			
		||||
        DarkSlateBlue = 0xFF483D8B,
 | 
			
		||||
        DarkSlateGray = 0xFF2F4F4F,
 | 
			
		||||
        DarkTurquoise = 0xFF00CED1,
 | 
			
		||||
        DarkViolet = 0xFF9400D3,
 | 
			
		||||
        DeepPink = 0xFFFF1493,
 | 
			
		||||
        DeepSkyBlue = 0xFF00BFFF,
 | 
			
		||||
        DimGray = 0xFF696969,
 | 
			
		||||
        DodgerBlue = 0xFF1E90FF,
 | 
			
		||||
        Firebrick = 0xFFB22222,
 | 
			
		||||
        FloralWhite = 0xFFFFFAF0,
 | 
			
		||||
        ForestGreen = 0xFF228B22,
 | 
			
		||||
        Fuchsia = 0xFFFF00FF,
 | 
			
		||||
        Gainsboro = 0xFFDCDCDC,
 | 
			
		||||
        GhostWhite = 0xFFF8F8FF,
 | 
			
		||||
        Gold = 0xFFFFD700,
 | 
			
		||||
        Goldenrod = 0xFFDAA520,
 | 
			
		||||
        Gray = 0xFF808080,
 | 
			
		||||
        Green = 0xFF008000,
 | 
			
		||||
        GreenYellow = 0xFFADFF2F,
 | 
			
		||||
        Honeydew = 0xFFF0FFF0,
 | 
			
		||||
        HotPink = 0xFFFF69B4,
 | 
			
		||||
        IndianRed = 0xFFCD5C5C,
 | 
			
		||||
        Indigo = 0xFF4B0082,
 | 
			
		||||
        Ivory = 0xFFFFFFF0,
 | 
			
		||||
        Khaki = 0xFFF0E68C,
 | 
			
		||||
        Lavender = 0xFFE6E6FA,
 | 
			
		||||
        LavenderBlush = 0xFFFFF0F5,
 | 
			
		||||
        LawnGreen = 0xFF7CFC00,
 | 
			
		||||
        LemonChiffon = 0xFFFFFACD,
 | 
			
		||||
        LightBlue = 0xFFADD8E6,
 | 
			
		||||
        LightCoral = 0xFFF08080,
 | 
			
		||||
        LightCyan = 0xFFE0FFFF,
 | 
			
		||||
        LightGoldenrodYellow = 0xFFFAFAD2,
 | 
			
		||||
        LightGray = 0xFFD3D3D3,
 | 
			
		||||
        LightGreen = 0xFF90EE90,
 | 
			
		||||
        LightPink = 0xFFFFB6C1,
 | 
			
		||||
        LightSalmon = 0xFFFFA07A,
 | 
			
		||||
        LightSeaGreen = 0xFF20B2AA,
 | 
			
		||||
        LightSkyBlue = 0xFF87CEFA,
 | 
			
		||||
        LightSlateGray = 0xFF778899,
 | 
			
		||||
        LightSteelBlue = 0xFFB0C4DE,
 | 
			
		||||
        LightYellow = 0xFFFFFFE0,
 | 
			
		||||
        Lime = 0xFF00FF00,
 | 
			
		||||
        LimeGreen = 0xFF32CD32,
 | 
			
		||||
        Linen = 0xFFFAF0E6,
 | 
			
		||||
        Magenta = 0xFFFF00FF,
 | 
			
		||||
        Maroon = 0xFF800000,
 | 
			
		||||
        MediumAquamarine = 0xFF66CDAA,
 | 
			
		||||
        MediumBlue = 0xFF0000CD,
 | 
			
		||||
        MediumOrchid = 0xFFBA55D3,
 | 
			
		||||
        MediumPurple = 0xFF9370DB,
 | 
			
		||||
        MediumSeaGreen = 0xFF3CB371,
 | 
			
		||||
        MediumSlateBlue = 0xFF7B68EE,
 | 
			
		||||
        MediumSpringGreen = 0xFF00FA9A,
 | 
			
		||||
        MediumTurquoise = 0xFF48D1CC,
 | 
			
		||||
        MediumVioletRed = 0xFFC71585,
 | 
			
		||||
        MidnightBlue = 0xFF191970,
 | 
			
		||||
        MintCream = 0xFFF5FFFA,
 | 
			
		||||
        MistyRose = 0xFFFFE4E1,
 | 
			
		||||
        Moccasin = 0xFFFFE4B5,
 | 
			
		||||
        NavajoWhite = 0xFFFFDEAD,
 | 
			
		||||
        Navy = 0xFF000080,
 | 
			
		||||
        OldLace = 0xFFFDF5E6,
 | 
			
		||||
        Olive = 0xFF808000,
 | 
			
		||||
        OliveDrab = 0xFF6B8E23,
 | 
			
		||||
        Orange = 0xFFFFA500,
 | 
			
		||||
        OrangeRed = 0xFFFF4500,
 | 
			
		||||
        Orchid = 0xFFDA70D6,
 | 
			
		||||
        PaleGoldenrod = 0xFFEEE8AA,
 | 
			
		||||
        PaleGreen = 0xFF98FB98,
 | 
			
		||||
        PaleTurquoise = 0xFFAFEEEE,
 | 
			
		||||
        PaleVioletRed = 0xFFDB7093,
 | 
			
		||||
        PapayaWhip = 0xFFFFEFD5,
 | 
			
		||||
        PeachPuff = 0xFFFFDAB9,
 | 
			
		||||
        Peru = 0xFFCD853F,
 | 
			
		||||
        Pink = 0xFFFFC0CB,
 | 
			
		||||
        Plum = 0xFFDDA0DD,
 | 
			
		||||
        PowderBlue = 0xFFB0E0E6,
 | 
			
		||||
        Purple = 0xFF800080,
 | 
			
		||||
        Red = 0xFFFF0000,
 | 
			
		||||
        RosyBrown = 0xFFBC8F8F,
 | 
			
		||||
        RoyalBlue = 0xFF4169E1,
 | 
			
		||||
        SaddleBrown = 0xFF8B4513,
 | 
			
		||||
        Salmon = 0xFFFA8072,
 | 
			
		||||
        SandyBrown = 0xFFF4A460,
 | 
			
		||||
        SeaGreen = 0xFF2E8B57,
 | 
			
		||||
        SeaShell = 0xFFFFF5EE,
 | 
			
		||||
        Sienna = 0xFFA0522D,
 | 
			
		||||
        Silver = 0xFFC0C0C0,
 | 
			
		||||
        SkyBlue = 0xFF87CEEB,
 | 
			
		||||
        SlateBlue = 0xFF6A5ACD,
 | 
			
		||||
        SlateGray = 0xFF708090,
 | 
			
		||||
        Snow = 0xFFFFFAFA,
 | 
			
		||||
        SpringGreen = 0xFF00FF7F,
 | 
			
		||||
        SteelBlue = 0xFF4682B4,
 | 
			
		||||
        Tan = 0xFFD2B48C,
 | 
			
		||||
        Teal = 0xFF008080,
 | 
			
		||||
        Thistle = 0xFFD8BFD8,
 | 
			
		||||
        Tomato = 0xFFFF6347,
 | 
			
		||||
        Transparent = 0x00FFFFFF,
 | 
			
		||||
        Turquoise = 0xFF40E0D0,
 | 
			
		||||
        Violet = 0xFFEE82EE,
 | 
			
		||||
        Wheat = 0xFFF5DEB3,
 | 
			
		||||
        White = 0xFFFFFFFF,
 | 
			
		||||
        WhiteSmoke = 0xFFF5F5F5,
 | 
			
		||||
        Yellow = 0xFFFFFF00,
 | 
			
		||||
        YellowGreen = 0xFF9ACD32
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,166 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents ids for error and diagnostic messages generated by the MigraDoc DOM.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum DomMsgID
 | 
			
		||||
    {
 | 
			
		||||
        // ----- General Messages ---------------------------------------------------------------------
 | 
			
		||||
        StyleExpected,
 | 
			
		||||
        BaseStyleRequired,
 | 
			
		||||
        EmptyBaseStyle,
 | 
			
		||||
        InvalidFieldFormat,
 | 
			
		||||
        InvalidInfoFieldName,
 | 
			
		||||
        UndefinedBaseStyle,
 | 
			
		||||
        InvalidUnitValue,
 | 
			
		||||
        InvalidUnitType,
 | 
			
		||||
        InvalidEnumValue,
 | 
			
		||||
        InvalidEnumForLeftPosition,
 | 
			
		||||
        InvalidEnumForTopPosition,
 | 
			
		||||
        InvalidColorString,
 | 
			
		||||
        InvalidFontSize,
 | 
			
		||||
        InsertNullNotAllowed,
 | 
			
		||||
        ParentAlreadySet,
 | 
			
		||||
        MissingObligatoryProperty,
 | 
			
		||||
        InvalidDocumentObjectType,
 | 
			
		||||
 | 
			
		||||
        // ----- DdlReader Messages -------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
        Success = 1000,
 | 
			
		||||
 | 
			
		||||
        SymbolExpected,
 | 
			
		||||
        SymbolsExpected,
 | 
			
		||||
        OperatorExpected,
 | 
			
		||||
        KeyWordExpected,
 | 
			
		||||
        EndOfFileExpected,
 | 
			
		||||
        UnexpectedEndOfFile,
 | 
			
		||||
 | 
			
		||||
        StyleNameExpected,
 | 
			
		||||
 | 
			
		||||
        // --- old ---
 | 
			
		||||
        //    public,
 | 
			
		||||
 | 
			
		||||
        UnexpectedSymbol,
 | 
			
		||||
 | 
			
		||||
        IdentifierExpected,
 | 
			
		||||
        BoolExpected,
 | 
			
		||||
        RealExpected,
 | 
			
		||||
        IntegerExpected,
 | 
			
		||||
        //    IntegerOrIdentifierExpected,
 | 
			
		||||
        StringExpected,
 | 
			
		||||
        NullExpected,
 | 
			
		||||
        //    SymboleExpected,
 | 
			
		||||
        NumberExpected,
 | 
			
		||||
 | 
			
		||||
        InvalidEnum,
 | 
			
		||||
        //    InvalidFlag,
 | 
			
		||||
        //    InvalidStyle,
 | 
			
		||||
        //    InvalidStyleDefinition,
 | 
			
		||||
        InvalidType,
 | 
			
		||||
        InvalidAssignment,
 | 
			
		||||
        InvalidValueName,
 | 
			
		||||
        //    InvalidOperation,
 | 
			
		||||
        //    InvalidFormat,
 | 
			
		||||
        InvalidRange,
 | 
			
		||||
        InvalidColor,
 | 
			
		||||
        InvalidFieldType,
 | 
			
		||||
        InvalidValueForOperation,
 | 
			
		||||
        InvalidSymbolType,
 | 
			
		||||
 | 
			
		||||
        //    ValueOutOfRange,
 | 
			
		||||
 | 
			
		||||
        MissingBraceLeft,
 | 
			
		||||
        MissingBraceRight,
 | 
			
		||||
        MissingBracketLeft,
 | 
			
		||||
        MissingBracketRight,
 | 
			
		||||
        MissingParenLeft,
 | 
			
		||||
        MissingParenRight,
 | 
			
		||||
        //    MissingSemicolon,
 | 
			
		||||
        MissingComma,
 | 
			
		||||
 | 
			
		||||
        //    MissingDocumentPart,
 | 
			
		||||
        //    MissingEof,
 | 
			
		||||
        //    MissingIdentifier,
 | 
			
		||||
        //    MissingEndBuildingBlock,
 | 
			
		||||
        //    MissingSymbole,
 | 
			
		||||
        //    MissingParameter,
 | 
			
		||||
 | 
			
		||||
        SymbolNotAllowed,
 | 
			
		||||
        SymbolIsNotAnObject,
 | 
			
		||||
        //    BlockcommentOutsideCodeBlock,
 | 
			
		||||
        //    EOFReachedMissingSymbole,
 | 
			
		||||
        //    UnexpectedEOFReached,
 | 
			
		||||
        //    StyleAlreadyDefined,
 | 
			
		||||
        //    MultipleDefaultInSwitch,
 | 
			
		||||
        //    UnexpectedNewlineInDirective,
 | 
			
		||||
        //    UnexpectedSymboleInDirective,
 | 
			
		||||
 | 
			
		||||
        //    UnknownUnitOfMeasure,
 | 
			
		||||
        //    UnknownValueOperator,
 | 
			
		||||
        //    UnknownCodeSymbole,
 | 
			
		||||
        //    UnknownScriptSymbole,
 | 
			
		||||
        //    UnknownFieldSpecifier,
 | 
			
		||||
        //    UnknownFieldOption,
 | 
			
		||||
        //    UnknownValueType,
 | 
			
		||||
        //    UnknownEvaluationType,
 | 
			
		||||
        //    UnknownColorFunction,
 | 
			
		||||
        //    UnknownAxis,
 | 
			
		||||
        UnknownChartType,
 | 
			
		||||
 | 
			
		||||
        //    MisplacedCompilerSettings,
 | 
			
		||||
        //    MisplacedScopeType,
 | 
			
		||||
        //    TooMuchCells,
 | 
			
		||||
        NoAccess,
 | 
			
		||||
 | 
			
		||||
        //    FileNotFound,
 | 
			
		||||
        //    NotSupported,
 | 
			
		||||
 | 
			
		||||
        NewlineInString,
 | 
			
		||||
        EscapeSequenceNotAllowed,
 | 
			
		||||
        //    SymboleNotAllowedInsideText,
 | 
			
		||||
        NullAssignmentNotSupported,
 | 
			
		||||
        OutOfRange,
 | 
			
		||||
 | 
			
		||||
        //    Warning_StyleOverwrittenMoreThanOnce,
 | 
			
		||||
        //    Warning_StyleAndBaseStyleAreEqual,
 | 
			
		||||
        //    Warning_NestedParagraphInParagraphToken,
 | 
			
		||||
        UseOfUndefinedBaseStyle,
 | 
			
		||||
        UseOfUndefinedStyle,
 | 
			
		||||
 | 
			
		||||
        //    NestedFootnote,
 | 
			
		||||
        //    ImageInFootnote,
 | 
			
		||||
        //    ShapeInFootnote
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,55 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the properties for the font.
 | 
			
		||||
    /// FOR public USE ONLY.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Flags]
 | 
			
		||||
    enum FontProperties
 | 
			
		||||
    {
 | 
			
		||||
        None = 0x0000,
 | 
			
		||||
        Name = 0x0001,
 | 
			
		||||
        Size = 0x0002,
 | 
			
		||||
        Bold = 0x0004,
 | 
			
		||||
        Italic = 0x0008,
 | 
			
		||||
        Underline = 0x0010,
 | 
			
		||||
        Color = 0x0020,
 | 
			
		||||
        Border = 0x0040,
 | 
			
		||||
        Superscript = 0x0080,
 | 
			
		||||
        Subscript = 0x0100,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,50 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Determines the position of the footnote on the page.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum FootnoteLocation
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Footnote will be rendered on the bottom of the page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        BottomOfPage,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Footnote will be rendered immediately after the text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        BeneathText
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,65 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Determines the format of the footnote number.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum FootnoteNumberStyle
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Numbering like: 1, 2, 3, 4.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Arabic,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Lower case letters like: a, b, c, d.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        LowercaseLetter,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Upper case letters like: A, B, C, D.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        UppercaseLetter,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Lower case roman numbers: i, ii, iii, iv.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        LowercaseRoman,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Upper case roman numbers: I, II, III, IV.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        UppercaseRoman
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,55 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Determines the behavior of the footnote numbering.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum FootnoteNumberingRule
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Numbering of the footnote restarts on each page.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        RestartPage,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Numbering does not restart, each new footnote number will be incremented by 1.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        RestartContinuous,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Numbering of the footnote restarts on each section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        RestartSection
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,55 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Index to the three HeaderFooter objects of a HeadersFooters collection.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum HeaderFooterIndex
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Header or footer which is primarily used.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Primary = 0,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Header or footer for the first page of the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        FirstPage = 1,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Header or footer for the even pages of the section.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        EvenPage = 2
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,65 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the target of the hyperlink.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum HyperlinkType
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Targets a position in the document. Same as 'Bookmark'.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Local = 0,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Targets a position in the document. Same as 'Local'.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Bookmark = Local,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Targets a resource on the Internet or network. Same as 'Url'.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Web,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Targets a resource on the Internet or network. Same as 'Web'.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Url = Web,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Targets a physical file.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        File
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,49 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the space between lines in a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum LineSpacingRule
 | 
			
		||||
    {
 | 
			
		||||
        Single,
 | 
			
		||||
        OnePtFive,
 | 
			
		||||
        Double,
 | 
			
		||||
        AtLeast,
 | 
			
		||||
        Exactly,
 | 
			
		||||
        Multiple
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,49 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the symbol or kind of numbering of the list.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum ListType
 | 
			
		||||
    {
 | 
			
		||||
        BulletList1,
 | 
			
		||||
        BulletList2,
 | 
			
		||||
        BulletList3,
 | 
			
		||||
        NumberList1,
 | 
			
		||||
        NumberList2,
 | 
			
		||||
        NumberList3
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,50 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the page orientation.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum Orientation
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Page height is bigger than page width.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Portrait,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Page width is bigger than page height.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Landscape
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,53 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the level of a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum OutlineLevel
 | 
			
		||||
    {
 | 
			
		||||
        BodyText,
 | 
			
		||||
        Level1,
 | 
			
		||||
        Level2,
 | 
			
		||||
        Level3,
 | 
			
		||||
        Level4,
 | 
			
		||||
        Level5,
 | 
			
		||||
        Level6,
 | 
			
		||||
        Level7,
 | 
			
		||||
        Level8,
 | 
			
		||||
        Level9,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,55 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Standard page sizes.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum PageFormat
 | 
			
		||||
    {
 | 
			
		||||
        A0,
 | 
			
		||||
        A1,
 | 
			
		||||
        A2,
 | 
			
		||||
        A3,
 | 
			
		||||
        A4,
 | 
			
		||||
        A5,
 | 
			
		||||
        A6,
 | 
			
		||||
        B5,
 | 
			
		||||
        Letter,
 | 
			
		||||
        Legal,
 | 
			
		||||
        Ledger,
 | 
			
		||||
        P11x17
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,47 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the alignment of a paragraph.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum ParagraphAlignment
 | 
			
		||||
    {
 | 
			
		||||
        Left,
 | 
			
		||||
        Center,
 | 
			
		||||
        Right,
 | 
			
		||||
        Justify,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,50 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the type of a Style object.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum StyleType
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Style is a paragraph style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Paragraph,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Style is a character style. Contains font part only.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Character
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,69 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents the type of the special character.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum SymbolName : uint
 | 
			
		||||
    {
 | 
			
		||||
        // \space(...)
 | 
			
		||||
        Blank = 0xF1000001,
 | 
			
		||||
        En = 0xF1000002,
 | 
			
		||||
        Em = 0xF1000003,
 | 
			
		||||
        EmQuarter = 0xF1000004,
 | 
			
		||||
        Em4 = EmQuarter,
 | 
			
		||||
 | 
			
		||||
        // used to serialize as \tab, \linebreak
 | 
			
		||||
        Tab = 0xF2000001,
 | 
			
		||||
        LineBreak = 0xF4000001,
 | 
			
		||||
 | 
			
		||||
        // for public use only 
 | 
			
		||||
        ParaBreak = 0xF4000007,
 | 
			
		||||
        //MarginBreak       = 0xF4000002,
 | 
			
		||||
 | 
			
		||||
        // \symbol(...)
 | 
			
		||||
        Euro = 0xF8000001,
 | 
			
		||||
        Copyright = 0xF8000002,
 | 
			
		||||
        Trademark = 0xF8000003,
 | 
			
		||||
        RegisteredTrademark = 0xF8000004,
 | 
			
		||||
        Bullet = 0xF8000005,
 | 
			
		||||
        Not = 0xF8000006,
 | 
			
		||||
        EmDash = 0xF8000007,
 | 
			
		||||
        EnDash = 0xF8000008,
 | 
			
		||||
        NonBreakableBlank = 0xF8000009,
 | 
			
		||||
        HardBlank = NonBreakableBlank,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,63 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Determines the alignment of the tab.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum TabAlignment
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tab will be left aligned.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Left,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tab will be centered.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Center,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tab will be right aligned.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Right,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Positioned at the last dot or comma.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Decimal,
 | 
			
		||||
 | 
			
		||||
        //Bar     = 4,  // MigraDoc 2.0
 | 
			
		||||
        //List    = 6,  // MigraDoc 2.0
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,70 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Used to determine the leader for the tab.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum TabLeader
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Blanks are used as leader.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Spaces,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Dots at the baseline.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Dots,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Dashes are used as leader.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Dashes,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Same as Heavy.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Lines,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Leader will be underlined.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Heavy,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Dots in the middle (vertical) of the line.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        MiddleDot
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,74 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the format of a text.
 | 
			
		||||
    /// Bold, Italic, or Underline will be ignored if NotBold, NotItalic, or NoUnderline respectively are specified at the same time.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Flags]
 | 
			
		||||
    public enum TextFormat
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Specifies bold text (heavy font weight).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Bold = 0x000001,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Specifies normal font weight.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        NotBold = 0x000003,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Specifies italic text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Italic = 0x000004,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Specifies upright text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        NotItalic = 0x00000C,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Specifies underlined text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Underline = 0x000010,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Specifies text without underline.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        NoUnderline = 0x000030
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,64 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
#pragma warning disable 1591
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the underline type for the font.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum Underline
 | 
			
		||||
    {
 | 
			
		||||
        None,
 | 
			
		||||
        Single,
 | 
			
		||||
        Words,
 | 
			
		||||
        Dotted,
 | 
			
		||||
        Dash,
 | 
			
		||||
        DotDash,
 | 
			
		||||
        DotDotDash,
 | 
			
		||||
 | 
			
		||||
        /* --- unsupported ---
 | 
			
		||||
          Double          = 3,
 | 
			
		||||
          Thick           = 6,
 | 
			
		||||
          Wavy            = 11,
 | 
			
		||||
          WavyHeavy       = 27,
 | 
			
		||||
          DottedHeavy     = 20,
 | 
			
		||||
          DashHeavy       = 23,
 | 
			
		||||
          DotDashHeavy    = 25,
 | 
			
		||||
          DotDotDashHeavy = 26,
 | 
			
		||||
          DashLong        = 39,
 | 
			
		||||
          DashLongHeavy   = 55,
 | 
			
		||||
          WavyDouble      = 43
 | 
			
		||||
        */
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,66 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany)
 | 
			
		||||
//
 | 
			
		||||
// http://www.pdfsharp.com
 | 
			
		||||
// http://www.migradoc.com
 | 
			
		||||
// http://sourceforge.net/projects/pdfsharp
 | 
			
		||||
//
 | 
			
		||||
// 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.
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.DocumentObjectModel
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Specifies the measure of a Unit object.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum UnitType
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Measure is in points. A point represents 1/72 of an inch. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Point = 0,  // Default for new Unit() is Point
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Measure is in centimeter. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Centimeter = 1,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Measure is in inch. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Inch = 2,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Measure is in millimeter. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Millimeter = 3,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Measure is in picas. A pica represents 12 points, i.e. 6 pica are one inch.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Pica = 4,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user