This commit is contained in:
2021-05-25 17:00:45 +05:00
parent e2fcfed44c
commit ec2dac13d8
1172 changed files with 5636 additions and 5839 deletions

View File

@@ -0,0 +1,117 @@
#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.Fields
{
/// <summary>
/// BookmarkField is used as target for Hyperlinks or PageRefs.
/// </summary>
public class BookmarkField : DocumentObject
{
/// <summary>
/// Initializes a new instance of the BookmarkField class.
/// </summary>
public BookmarkField()
{ }
/// <summary>
/// Initializes a new instance of the BookmarkField class with the specified parent.
/// </summary>
public BookmarkField(DocumentObject parent) : base(parent) { }
/// <summary>
/// Initializes a new instance of the BookmarkField class with the necessary bookmark name.
/// </summary>
public BookmarkField(string name)
: this()
{
Name = name;
}
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new BookmarkField Clone()
{
return (BookmarkField)DeepCopy();
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the name of the bookmark.
/// Used to reference the bookmark from a Hyperlink or PageRef.
/// </summary>
public string Name
{
get { return _name.Value; }
set { _name.Value = value; }
}
[DV]
public NString _name = NString.NullValue;
#endregion
#region public
/// <summary>
/// Converts BookmarkField into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
if (_name.Value == string.Empty)
throw new InvalidOperationException(DomSR.MissingObligatoryProperty("Name", "BookmarkField"));
serializer.Write("\\field(Bookmark)[Name = \"" + Name.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"]");
}
/// <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(BookmarkField))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,109 @@
#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.Fields
{
/// <summary>
/// DateField is used to reference the date and time the printing starts.
/// </summary>
public class DateField : DocumentObject
{
/// <summary>
/// Initializes a new instance of the DateField class.
/// </summary>
public DateField()
{ }
/// <summary>
/// Initializes a new instance of the DateField class with the specified parent.
/// </summary>
public DateField(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new DateField Clone()
{
return (DateField)DeepCopy();
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the format of the date.
/// </summary>
public string Format
{
get { return _format.Value; }
set { _format.Value = value; }
}
[DV]
public NString _format = NString.NullValue;
#endregion
#region public
/// <summary>
/// Converts DateField into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
string str = "\\field(Date)";
if (_format.Value != string.Empty)
str += "[Format = \"" + Format + "\"]";
else
str += "[]"; //Has to be appended to avoid confusion with '[' in immediatly following text.
serializer.Write(str);
}
/// <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(DateField))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,145 @@
#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.Fields
{
/// <summary>
/// InfoField is used to reference one of the DocumentInfo fields in the document.
/// </summary>
public class InfoField : DocumentObject
{
/// <summary>
/// Initializes a new instance of the InfoField class.
/// </summary>
public InfoField()
{ }
/// <summary>
/// Initializes a new instance of the InfoField class with the specified parent.
/// </summary>
public InfoField(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new InfoField Clone()
{
return (InfoField)DeepCopy();
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the name of the information to be shown in the field.
/// </summary>
public string Name
{
get { return _name.Value; }
set
{
if (IsValidName(value))
_name.Value = value;
else
throw new ArgumentException(DomSR.InvalidInfoFieldName(value));
}
}
[DV]
public NString _name = NString.NullValue;
#endregion
/// <summary>
/// Determines whether the name is a valid InfoFieldType.
/// </summary>
private bool IsValidName(string name)
{
// Check using a way that never throws an exception
#if SILVERLIGHT
if (validNames == null)
{
validNames = new string[4];
validNames[0] = "Title";
validNames[1] = "Author";
validNames[2] = "Keywords";
validNames[3] = "Subject";
}
#endif
foreach (string validName in validNames)
{
if (String.Compare(validName, name, StringComparison.OrdinalIgnoreCase) == 0)
return true;
}
return false;
}
#if SILVERLIGHT
private static string[] validNames;
#else
private static string[] validNames = Enum.GetNames(typeof(InfoFieldType));
#endif
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
public override bool IsNull()
{
return false;
}
#region public
/// <summary>
/// Converts InfoField into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
string str = "\\field(Info)";
if (Name == "")
throw new InvalidOperationException(DomSR.MissingObligatoryProperty("Name", "InfoField"));
str += "[Name = \"" + Name + "\"]";
serializer.Write(str);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(InfoField))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,89 @@
#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.Fields
{
/// <summary>
/// NumPagesField is used to reference the number of all pages in the document.
/// </summary>
public class NumPagesField : NumericFieldBase
{
/// <summary>
/// Initializes a new instance of the NumPagesField class.
/// </summary>
public NumPagesField()
{ }
/// <summary>
/// Initializes a new instance of the NumPagesField class with the specified parent.
/// </summary>
public NumPagesField(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new NumPagesField Clone()
{
return (NumPagesField)DeepCopy();
}
#endregion
#region public
/// <summary>
/// Converts NumPagesField into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
string str = "\\field(NumPages)";
if (_format.Value != "")
str += "[Format = \"" + Format + "\"]";
else
str += "[]"; // Has to be appended to avoid confusion with '[' in directly following text.
serializer.Write(str);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(NumPagesField))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,126 @@
#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.Fields
{
/// <summary>
/// NumericFieldBase serves as a base for Numeric fields, which are:
/// NumPagesField, PageField, PageRefField, SectionField, SectionPagesField
/// </summary>
public abstract class NumericFieldBase : DocumentObject
{
/// <summary>
/// The valid format strings for the supported numeric types.
/// </summary>
protected static string[] ValidFormatStrings =
{
"",
"ROMAN",
"roman",
"ALPHABETIC",
"alphabetic"
};
/// <summary>
/// Initializes a new instance of the NumericFieldBase class.
/// </summary>
public NumericFieldBase()
{ }
/// <summary>
/// Initializes a new instance of the NumericFieldBase class with the specified parent.
/// </summary>
public NumericFieldBase(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new NumericFieldBase Clone()
{
return (NumericFieldBase)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
NumericFieldBase numericFieldBase = (NumericFieldBase)base.DeepCopy();
return numericFieldBase;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the format of the number.
/// </summary>
public string Format
{
get { return _format.Value; }
set
{
if (IsValidFormat(value))
_format.Value = value;
else
throw new ArgumentException(DomSR.InvalidFieldFormat(value));
}
}
[DV]
public NString _format = NString.NullValue;
#endregion
/// <summary>
/// Determines whether the format is valid for numeric fields.
/// </summary>
protected bool IsValidFormat(string format)
{
foreach (string name in ValidFormatStrings)
{
if (name == Format)
return true;
}
return false;
}
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
public override bool IsNull()
{
return false;
}
}
}

View File

@@ -0,0 +1,89 @@
#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.Fields
{
/// <summary>
/// PageField is used to reference the number of the current page.
/// </summary>
public class PageField : NumericFieldBase
{
/// <summary>
/// Initializes a new instance of the PageField class.
/// </summary>
public PageField()
{ }
/// <summary>
/// Initializes a new instance of the PageField class with the specified parent.
/// </summary>
public PageField(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new PageField Clone()
{
return (PageField)DeepCopy();
}
#endregion
#region public
/// <summary>
/// Converts PageField into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
string str = "\\field(Page)";
if (_format.Value != "")
str += "[Format = \"" + Format + "\"]";
else
str += "[]"; //Has to be appended to avoid confusion with '[' in immediatly following text.
serializer.Write(str);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(PageField))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,111 @@
#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.Fields
{
/// <summary>
/// PageRefField is used to reference the page number of a bookmark in the document.
/// </summary>
public class PageRefField : NumericFieldBase
{
/// <summary>
/// Initializes a new instance of the PageRefField class.
/// </summary>
public PageRefField()
{ }
/// <summary>
/// Initializes a new instance of the PageRefField class with the necessary bookmark name.
/// </summary>
public PageRefField(string name)
: this()
{
Name = name;
}
/// <summary>
/// Initializes a new instance of the PageRefField class with the specified parent.
/// </summary>
public PageRefField(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new PageRefField Clone()
{
return (PageRefField)DeepCopy();
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the bookmark name whose page is to be shown.
/// </summary>
public string Name
{
get { return _name.Value; }
set { _name.Value = value; }
}
[DV]
public NString _name = NString.NullValue;
#endregion
#region public
/// <summary>
/// Converts PageRefField into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
string str = "\\field(PageRef)";
str += "[Name = \"" + Name + "\"";
if (_format.Value != "")
str += " Format = \"" + Format + "\"";
str += "]";
serializer.Write(str);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(PageRefField))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,89 @@
#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.Fields
{
/// <summary>
/// SectionField is used to reference the number of the current section.
/// </summary>
public class SectionField : NumericFieldBase
{
/// <summary>
/// Initializes a new instance of the SectionField class.
/// </summary>
public SectionField()
{ }
/// <summary>
/// Initializes a new instance of the SectionField class with the specified parent.
/// </summary>
public SectionField(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new SectionField Clone()
{
return (SectionField)DeepCopy();
}
#endregion
#region public
/// <summary>
/// Converts SectionField into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
string str = "\\field(Section)";
if (_format.Value != "")
str += "[Format = \"" + Format + "\"]";
else
str += "[]"; //Has to be appended to avoid confusion with '[' in directly following text.
serializer.Write(str);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(SectionField))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,89 @@
#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.Fields
{
/// <summary>
/// SectionPagesField is used to reference the number of all pages of the current section.
/// </summary>
public class SectionPagesField : NumericFieldBase
{
/// <summary>
/// Initializes a new instance of the SectionPagesField class.
/// </summary>
public SectionPagesField()
{ }
/// <summary>
/// Initializes a new instance of the SectionPagesField class with the specified parent.
/// </summary>
public SectionPagesField(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new SectionPagesField Clone()
{
return (SectionPagesField)DeepCopy();
}
#endregion
#region public
/// <summary>
/// Converts SectionPagesField into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
string str = "\\field(SectionPages)";
if (_format.Value != "")
str += "[Format = \"" + Format + "\"]";
else
str += "[]"; //Has to be appended to avoid confusion with '[' in directly following text.
serializer.Write(str);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(SectionPagesField))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,60 @@
#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.Fields
{
/// <summary>
/// Specifies the information to be shown in the field.
/// </summary>
public enum InfoFieldType
{
/// <summary>
/// Specifies the title for the document.
/// </summary>
Title,
/// <summary>
/// Specifies the author for the document.
/// </summary>
Author,
/// <summary>
/// Specifies the keywords for the document.
/// </summary>
Keywords,
/// <summary>
/// Specifies the subject for the document.
/// </summary>
Subject
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,91 @@
#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.IO
{
/// <summary>
/// Represents an exception used by the DDL parser. This exception will always be caught inside
/// the DDL parser.
/// </summary>
public class DdlParserException : Exception
{
/// <summary>
/// Initializes a new instance of the DdlParserException class with the specified message.
/// </summary>
public DdlParserException(string message)
: base(message)
{
_error = new DdlReaderError(DdlErrorLevel.Error, message, 0);
}
/// <summary>
/// Initializes a new instance of the DdlParserException class with the specified message and the
/// inner exception.
/// </summary>
public DdlParserException(string message, Exception innerException)
: base(message, innerException)
{
_error = new DdlReaderError(DdlErrorLevel.Error, message, 0);
}
/// <summary>
/// Initializes a new instance of the DdlParserException class with the specified error level, name,
/// error code and message.
/// </summary>
public DdlParserException(DdlErrorLevel level, string message, DomMsgID errorCode)
: base(message)
{
_error = new DdlReaderError(level, message, (int)errorCode);
}
/// <summary>
/// Initializes a new instance of the DdlParserException class with the DdlReaderError.
/// </summary>
public DdlParserException(DdlReaderError error)
: base(error.ErrorMessage)
{
_error = error;
}
/// <summary>
/// Gets the DdlReaderError.
/// </summary>
public DdlReaderError Error
{
get { return _error; }
}
readonly DdlReaderError _error;
}
}

View File

@@ -0,0 +1,278 @@
#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.IO;
using System.Text;
namespace MigraDoc.DocumentObjectModel.IO
{
/// <summary>
/// Represents a reader that provides access to DDL data.
/// </summary>
public class DdlReader
{
/// <summary>
/// Initializes a new instance of the DdlReader class with the specified Stream.
/// </summary>
public DdlReader(Stream stream)
: this(stream, null)
{ }
/// <summary>
/// Initializes a new instance of the DdlReader class with the specified Stream and ErrorManager2.
/// </summary>
public DdlReader(Stream stream, DdlReaderErrors errors)
{
_errorManager = errors;
_reader = new StreamReader(stream);
}
/// <summary>
/// Initializes a new instance of the DdlReader class with the specified filename.
/// </summary>
public DdlReader(string filename)
: this(filename, null)
{ }
/// <summary>
/// Initializes a new instance of the DdlReader class with the specified filename and ErrorManager2.
/// </summary>
public DdlReader(string filename, DdlReaderErrors errors)
{
_fileName = filename;
_errorManager = errors;
#if !NETFX_CORE
_reader = new StreamReader(filename, Encoding.UTF8);
#else
_reader = new StreamReader(null, Encoding.UTF8);
#endif
//#if SILVERLIGHT
// _reader = new StreamReader(filename, Encoding.UTF8);
//#else
// _reader = new StreamReader(filename, Encoding.Default);
//#endif
}
/// <summary>
/// Initializes a new instance of the DdlReader class with the specified TextReader.
/// </summary>
public DdlReader(TextReader reader)
: this(reader, null)
{ }
/// <summary>
/// Initializes a new instance of the DdlReader class with the specified TextReader and ErrorManager2.
/// </summary>
public DdlReader(TextReader reader, DdlReaderErrors errors)
{
_doClose = false;
_errorManager = errors;
_reader = reader;
}
/// <summary>
/// Closes the underlying stream or text writer.
/// </summary>
public void Close()
{
if (_doClose && _reader != null)
{
#if !NETFX_CORE
_reader.Close();
#else
_reader.Dispose();
#endif
_reader = null;
}
}
/// <summary>
/// Reads and returns a Document from a file or a DDL string.
/// </summary>
public Document ReadDocument()
{
string ddl = _reader.ReadToEnd();
Document document;
if (!String.IsNullOrEmpty(_fileName))
{
DdlParser parser = new DdlParser(_fileName, ddl, _errorManager);
document = parser.ParseDocument(null);
document._ddlFile = _fileName;
}
else
{
DdlParser parser = new DdlParser(ddl, _errorManager);
document = parser.ParseDocument(null);
}
return document;
}
/// <summary>
/// Reads and returns a DocumentObject from a file or a DDL string.
/// </summary>
public DocumentObject ReadObject()
{
string ddl = _reader.ReadToEnd();
DdlParser parser = !String.IsNullOrEmpty(_fileName) ?
new DdlParser(_fileName, ddl, _errorManager) :
new DdlParser(ddl, _errorManager);
return parser.ParseDocumentObject();
}
/// <summary>
/// Reads and returns a Document from the specified file.
/// </summary>
public static Document DocumentFromFile(string documentFileName) //, ErrorManager2 _errorManager)
{
Document document;
DdlReader reader = null;
try
{
reader = new DdlReader(documentFileName); //, _errorManager);
document = reader.ReadDocument();
}
finally
{
if (reader != null)
reader.Close();
}
return document;
}
/// <summary>
/// Reads and returns a Document from the specified DDL string.
/// </summary>
public static Document DocumentFromString(string ddl)
{
StringReader stringReader = null;
Document document;
DdlReader reader = null;
try
{
stringReader = new StringReader(ddl);
reader = new DdlReader(stringReader);
document = reader.ReadDocument();
}
finally
{
if (stringReader != null)
{
#if !NETFX_CORE
stringReader.Close();
#else
stringReader.Dispose();
#endif
}
if (reader != null)
reader.Close();
}
return document;
}
/// <summary>
/// Reads and returns a domain object from the specified file.
/// </summary>
public static DocumentObject ObjectFromFile(string documentFileName, DdlReaderErrors errors)
{
DdlReader reader = null;
DocumentObject domObj;
try
{
reader = new DdlReader(documentFileName, errors);
domObj = reader.ReadObject();
}
finally
{
if (reader != null)
reader.Close();
}
return domObj;
}
/// <summary>
/// Reads and returns a domain object from the specified file.
/// </summary>
public static DocumentObject ObjectFromFile(string documentFileName)
{
return ObjectFromFile(documentFileName, null);
}
/// <summary>
/// Reads and returns a domain object from the specified DDL string.
/// </summary>
public static DocumentObject ObjectFromString(string ddl, DdlReaderErrors errors)
{
StringReader stringReader = null;
DocumentObject domObj;
DdlReader reader = null;
try
{
stringReader = new StringReader(ddl);
reader = new DdlReader(stringReader);
domObj = reader.ReadObject();
}
finally
{
if (stringReader != null)
{
#if !NETFX_CORE
stringReader.Close();
#else
stringReader.Dispose();
#endif
}
if (reader != null)
reader.Close();
}
return domObj;
}
/// <summary>
/// Reads and returns a domain object from the specified DDL string.
/// </summary>
public static DocumentObject ObjectFromString(string ddl)
{
return ObjectFromString(ddl, null);
}
readonly bool _doClose = true;
TextReader _reader;
readonly DdlReaderErrors _errorManager;
readonly string _fileName;
}
}

View File

@@ -0,0 +1,130 @@
#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.IO
{
/// <summary>
/// Represents an error or diagnostic message reported by the DDL reader.
/// </summary>
public class DdlReaderError
{
/// <summary>
/// Initializes a new instance of the DdlReaderError class.
/// </summary>
public DdlReaderError(DdlErrorLevel errorLevel, string errorMessage, int errorNumber,
string sourceFile, int sourceLine, int sourceColumn)
{
ErrorLevel = errorLevel;
ErrorMessage = errorMessage;
ErrorNumber = errorNumber;
SourceFile = sourceFile;
SourceLine = sourceLine;
SourceColumn = sourceColumn;
}
/// <summary>
/// Initializes a new instance of the <see cref="DdlReaderError"/> class.
/// </summary>
public DdlReaderError(DdlErrorLevel errorLevel, string errorMessage, int errorNumber)
{
ErrorLevel = errorLevel;
ErrorMessage = errorMessage;
ErrorNumber = errorNumber;
}
// public DdlReaderError(string errorName, DdlReaderError _level, DomMsgID _error, string message, string msg2,
// string DocumentFileName, int CurrentLine, int CurrentLinePos)
// {
// }
//
// public DdlReaderError(string errorName, int _level, string _error, string message, string adf,
// string DocumentFileName, int CurrentLine, int CurrentLinePos)
// {
// }
//
// public DdlReaderError(string errorName, DdlErrorLevel errorInfo , string _error, string message, string adf,
// string DocumentFileName, int CurrentLine, int CurrentLinePos)
// {
// }
//
// public DdlReaderError(string errorName, DdlErrorLevel errorInfo , DomMsgID _error, string message, string adf,
// string DocumentFileName, int CurrentLine, int CurrentLinePos)
// {
// }
//public const int NoErrorNumber = -1;
/// <summary>
/// Returns a String that represents the current DdlReaderError.
/// </summary>
public override string ToString()
{
return String.Format("[{0}({1},{2}):] {3} DDL{4}: {5}",
SourceFile, SourceLine, SourceColumn, "xxx", ErrorNumber, ErrorMessage);
}
/// <summary>
/// Specifies the severity of this diagnostic.
/// </summary>
public readonly DdlErrorLevel ErrorLevel;
/// <summary>
/// Specifies the diagnostic message text.
/// </summary>
public readonly string ErrorMessage;
/// <summary>
/// Specifies the diagnostic number.
/// </summary>
public readonly int ErrorNumber;
/// <summary>
/// Specifies the filename of the DDL text that caused the diagnostic,
/// or an empty string ("").
/// </summary>
public readonly string SourceFile;
/// <summary>
/// Specifies the line of the DDL text that caused the diagnostic (1 based),
/// or 0 if there is no line information.
/// </summary>
public readonly int SourceLine;
/// <summary>
/// Specifies the column of the source text that caused the diagnostic (1 based),
/// or 0 if there is no column information.
/// </summary>
public readonly int SourceColumn;
}
}

View File

@@ -0,0 +1,84 @@
#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.Collections.Generic;
using System.Collections;
namespace MigraDoc.DocumentObjectModel.IO
{
/// <summary>
/// Used to collect errors reported by the DDL parser.
/// </summary>
public class DdlReaderErrors : IEnumerable
{
/// <summary>
/// Adds the specified DdlReaderError at the end of the error list.
/// </summary>
public void AddError(DdlReaderError error)
{
_errors.Add(error);
}
/// <summary>
/// Gets the DdlReaderError at the specified position.
/// </summary>
public DdlReaderError this[int index]
{
get { return _errors[index]; }
}
/// <summary>
/// Gets the number of messages that are errors.
/// </summary>
public int ErrorCount
{
get
{
int count = 0;
for (int idx = 0; idx < _errors.Count; idx++)
if (_errors[idx].ErrorLevel == DdlErrorLevel.Error)
count++;
return count;
}
}
private readonly List<DdlReaderError> _errors = new List<DdlReaderError>();
/// <summary>
/// Returns an enumerator that iterates through the error collection.
/// </summary>
public IEnumerator GetEnumerator()
{
return _errors.GetEnumerator();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,311 @@
#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.IO;
using System.Text;
namespace MigraDoc.DocumentObjectModel.IO
{
/// <summary>
/// Represents the MigraDoc DDL writer.
/// </summary>
public class DdlWriter
{
/// <summary>
/// Initializes a new instance of the DdlWriter class with the specified Stream.
/// </summary>
public DdlWriter(Stream stream)
{
_writer = new StreamWriter(stream);
_serializer = new Serializer(_writer);
}
#if !NETFX_CORE
/// <summary>
/// Initializes a new instance of the DdlWriter class with the specified filename.
/// </summary>
public DdlWriter(string filename)
{
_writer = new StreamWriter(filename, false, Encoding.UTF8);
_serializer = new Serializer(_writer);
}
#endif
/// <summary>
/// Initializes a new instance of the DdlWriter class with the specified TextWriter.
/// </summary>
public DdlWriter(TextWriter writer)
{
_serializer = new Serializer(writer);
}
/// <summary>
/// Closes the underlying serializer and text writer.
/// </summary>
public void Close()
{
_serializer = null;
if (_writer != null)
{
_writer.Close();
_writer = null;
}
}
/// <summary>
/// Flushes the underlying TextWriter.
/// </summary>
public void Flush()
{
_serializer.Flush();
}
/// <summary>
/// Gets or sets the indentation for the DDL file.
/// </summary>
public int Indent
{
get { return _serializer.Indent; }
set { _serializer.Indent = value; }
}
/// <summary>
/// Gets or sets the initial indentation for the DDL file.
/// </summary>
public int InitialIndent
{
get { return _serializer.InitialIndent; }
set { _serializer.InitialIndent = value; }
}
/// <summary>
/// Writes the specified DocumentObject to DDL.
/// </summary>
public void WriteDocument(DocumentObject documentObject)
{
documentObject.Serialize(_serializer);
_serializer.Flush();
}
/// <summary>
/// Writes the specified DocumentObjectCollection to DDL.
/// </summary>
public void WriteDocument(DocumentObjectCollection documentObjectContainer)
{
documentObjectContainer.Serialize(_serializer);
_serializer.Flush();
}
/// <summary>
/// Writes a DocumentObject type object to string.
/// </summary>
public static string WriteToString(DocumentObject docObject)
{
return WriteToString(docObject, 2, 0);
}
/// <summary>
/// Writes a DocumentObject type object to string. Indent a new block by indent characters.
/// </summary>
public static string WriteToString(DocumentObject docObject, int indent)
{
return WriteToString(docObject, indent, 0);
}
/// <summary>
/// Writes a DocumentObject type object to string. Indent a new block by indent + initialIndent characters.
/// </summary>
public static string WriteToString(DocumentObject docObject, int indent, int initialIndent)
{
StringBuilder strBuilder = new StringBuilder();
StringWriter writer = null;
DdlWriter wrt = null;
try
{
writer = new StringWriter(strBuilder);
wrt = new DdlWriter(writer);
wrt.Indent = indent;
wrt.InitialIndent = initialIndent;
wrt.WriteDocument(docObject);
wrt.Close();
}
finally
{
if (wrt != null)
wrt.Close();
if (writer != null)
{
#if !NETFX_CORE
writer.Close();
#else
writer.Dispose();
#endif
}
}
return strBuilder.ToString();
}
/// <summary>
/// Writes a DocumentObjectCollection type object to string.
/// </summary>
public static string WriteToString(DocumentObjectCollection docObjectContainer)
{
return WriteToString(docObjectContainer, 2, 0);
}
/// <summary>
/// Writes a DocumentObjectCollection type object to string. Indent a new block by _indent characters.
/// </summary>
public static string WriteToString(DocumentObjectCollection docObjectContainer, int indent)
{
return WriteToString(docObjectContainer, indent, 0);
}
/// <summary>
/// Writes a DocumentObjectCollection type object to string. Indent a new block by
/// indent + initialIndent characters.
/// </summary>
public static string WriteToString(DocumentObjectCollection docObjectContainer, int indent, int initialIndent)
{
StringBuilder strBuilder = new StringBuilder();
StringWriter writer = null;
DdlWriter wrt = null;
try
{
writer = new StringWriter(strBuilder);
wrt = new DdlWriter(writer);
wrt.Indent = indent;
wrt.InitialIndent = initialIndent;
wrt.WriteDocument(docObjectContainer);
wrt.Close();
}
finally
{
if (wrt != null)
wrt.Close();
if (writer != null)
{
#if !NETFX_CORE
writer.Close();
#else
writer.Dispose();
#endif
}
}
return strBuilder.ToString();
}
/// <summary>
/// Writes a document object to a DDL file.
/// </summary>
public static void WriteToFile(DocumentObject docObject, string filename)
{
WriteToFile(docObject, filename, 2, 0);
}
/// <summary>
/// Writes a document object to a DDL file. Indent a new block by the specified number of characters.
/// </summary>
public static void WriteToFile(DocumentObject docObject, string filename, int indent)
{
WriteToFile(docObject, filename, indent, 0);
}
/// <summary>
/// Writes a DocumentObject type object to a DDL file. Indent a new block by indent + initialIndent characters.
/// </summary>
public static void WriteToFile(DocumentObject docObject, string filename, int indent, int initialIndent)
{
DdlWriter wrt = null;
try
{
wrt = new DdlWriter(filename);
wrt.Indent = indent;
wrt.InitialIndent = initialIndent;
wrt.WriteDocument(docObject);
}
finally
{
if (wrt != null)
wrt.Close();
}
}
/// <summary>
/// Writes a DocumentObjectCollection type object to a DDL file.
/// </summary>
public static void WriteToFile(DocumentObjectCollection docObjectContainer, string filename)
{
WriteToFile(docObjectContainer, filename, 2, 0);
}
/// <summary>
/// Writes a DocumentObjectCollection type object to a DDL file. Indent a new block by
/// indent + initialIndent characters.
/// </summary>
public static void WriteToFile(DocumentObjectCollection docObjectContainer, string filename, int indent)
{
WriteToFile(docObjectContainer, filename, indent, 0);
}
/// <summary>
/// Writes a DocumentObjectCollection type object to a DDL file. Indent a new block by
/// indent + initialIndent characters.
/// </summary>
public static void WriteToFile(DocumentObjectCollection docObjectContainer, string filename, int indent, int initialIndent)
{
DdlWriter wrt = null;
try
{
wrt = new DdlWriter(filename);
wrt.Indent = indent;
wrt.InitialIndent = initialIndent;
wrt.WriteDocument(docObjectContainer);
}
finally
{
if (wrt != null)
wrt.Close();
}
}
StreamWriter _writer;
Serializer _serializer;
}
}

View File

@@ -0,0 +1,229 @@
#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.IO
{
public class KeyWords
{
static KeyWords()
{
EnumToName.Add(Symbol.True, "true");
EnumToName.Add(Symbol.False, "false");
EnumToName.Add(Symbol.Null, "null");
EnumToName.Add(Symbol.Styles, @"\styles");
EnumToName.Add(Symbol.Document, @"\document");
EnumToName.Add(Symbol.Section, @"\section");
EnumToName.Add(Symbol.Paragraph, @"\paragraph");
EnumToName.Add(Symbol.Header, @"\header");
EnumToName.Add(Symbol.Footer, @"\footer");
EnumToName.Add(Symbol.PrimaryHeader, @"\primaryheader");
EnumToName.Add(Symbol.PrimaryFooter, @"\primaryfooter");
EnumToName.Add(Symbol.FirstPageHeader, @"\firstpageheader");
EnumToName.Add(Symbol.FirstPageFooter, @"\firstpagefooter");
EnumToName.Add(Symbol.EvenPageHeader, @"\evenpageheader");
EnumToName.Add(Symbol.EvenPageFooter, @"\evenpagefooter");
EnumToName.Add(Symbol.Table, @"\table");
EnumToName.Add(Symbol.Columns, @"\columns");
EnumToName.Add(Symbol.Column, @"\column");
EnumToName.Add(Symbol.Rows, @"\rows");
EnumToName.Add(Symbol.Row, @"\row");
EnumToName.Add(Symbol.Cell, @"\cell");
EnumToName.Add(Symbol.Image, @"\image");
EnumToName.Add(Symbol.TextFrame, @"\textframe");
EnumToName.Add(Symbol.PageBreak, @"\pagebreak");
EnumToName.Add(Symbol.Barcode, @"\barcode");
EnumToName.Add(Symbol.Chart, @"\chart");
EnumToName.Add(Symbol.HeaderArea, @"\headerarea");
EnumToName.Add(Symbol.FooterArea, @"\footerarea");
EnumToName.Add(Symbol.TopArea, @"\toparea");
EnumToName.Add(Symbol.BottomArea, @"\bottomarea");
EnumToName.Add(Symbol.LeftArea, @"\leftarea");
EnumToName.Add(Symbol.RightArea, @"\rightarea");
EnumToName.Add(Symbol.PlotArea, @"\plotarea");
EnumToName.Add(Symbol.Legend, @"\legend");
EnumToName.Add(Symbol.XAxis, @"\xaxis");
EnumToName.Add(Symbol.YAxis, @"\yaxis");
EnumToName.Add(Symbol.ZAxis, @"\zaxis");
EnumToName.Add(Symbol.Series, @"\series");
EnumToName.Add(Symbol.XValues, @"\xvalues");
EnumToName.Add(Symbol.Point, @"\point");
EnumToName.Add(Symbol.Bold, @"\bold");
EnumToName.Add(Symbol.Italic, @"\italic");
EnumToName.Add(Symbol.Underline, @"\underline");
EnumToName.Add(Symbol.FontSize, @"\fontsize");
EnumToName.Add(Symbol.FontColor, @"\fontcolor");
EnumToName.Add(Symbol.Font, @"\font");
//
EnumToName.Add(Symbol.Field, @"\field");
EnumToName.Add(Symbol.Symbol, @"\symbol");
EnumToName.Add(Symbol.Chr, @"\chr");
//
EnumToName.Add(Symbol.Footnote, @"\footnote");
EnumToName.Add(Symbol.Hyperlink, @"\hyperlink");
//
EnumToName.Add(Symbol.SoftHyphen, @"\-");
EnumToName.Add(Symbol.Tab, @"\tab");
EnumToName.Add(Symbol.LineBreak, @"\linebreak");
EnumToName.Add(Symbol.Space, @"\space");
EnumToName.Add(Symbol.NoSpace, @"\nospace");
//
//
EnumToName.Add(Symbol.BraceLeft, "{");
EnumToName.Add(Symbol.BraceRight, "}");
EnumToName.Add(Symbol.BracketLeft, "[");
EnumToName.Add(Symbol.BracketRight, "]");
EnumToName.Add(Symbol.ParenLeft, "(");
EnumToName.Add(Symbol.ParenRight, ")");
EnumToName.Add(Symbol.Colon, ":");
EnumToName.Add(Symbol.Semicolon, ";"); //??? id DDL?
EnumToName.Add(Symbol.Dot, ".");
EnumToName.Add(Symbol.Comma, ",");
EnumToName.Add(Symbol.Percent, "%"); //??? id DDL?
EnumToName.Add(Symbol.Dollar, "$"); //??? id DDL?
//enumToName.Add(Symbol.At, "@");
EnumToName.Add(Symbol.Hash, "#"); //??? id DDL?
//enumToName.Add(Symbol.Question, "?"); //??? id DDL?
//enumToName.Add(Symbol.Bar, "|"); //??? id DDL?
EnumToName.Add(Symbol.Assign, "=");
EnumToName.Add(Symbol.Slash, "/"); //??? id DDL?
EnumToName.Add(Symbol.BackSlash, "\\");
EnumToName.Add(Symbol.Plus, "+"); //??? id DDL?
EnumToName.Add(Symbol.PlusAssign, "+=");
EnumToName.Add(Symbol.Minus, "-"); //??? id DDL?
EnumToName.Add(Symbol.MinusAssign, "-=");
EnumToName.Add(Symbol.Blank, " ");
//---------------------------------------------------------------
//---------------------------------------------------------------
//---------------------------------------------------------------
NameToEnum.Add("true", Symbol.True);
NameToEnum.Add("false", Symbol.False);
NameToEnum.Add("null", Symbol.Null);
//
NameToEnum.Add(@"\styles", Symbol.Styles);
NameToEnum.Add(@"\document", Symbol.Document);
NameToEnum.Add(@"\section", Symbol.Section);
NameToEnum.Add(@"\paragraph", Symbol.Paragraph);
NameToEnum.Add(@"\header", Symbol.Header);
NameToEnum.Add(@"\footer", Symbol.Footer);
NameToEnum.Add(@"\primaryheader", Symbol.PrimaryHeader);
NameToEnum.Add(@"\primaryfooter", Symbol.PrimaryFooter);
NameToEnum.Add(@"\firstpageheader", Symbol.FirstPageHeader);
NameToEnum.Add(@"\firstpagefooter", Symbol.FirstPageFooter);
NameToEnum.Add(@"\evenpageheader", Symbol.EvenPageHeader);
NameToEnum.Add(@"\evenpagefooter", Symbol.EvenPageFooter);
NameToEnum.Add(@"\table", Symbol.Table);
NameToEnum.Add(@"\columns", Symbol.Columns);
NameToEnum.Add(@"\column", Symbol.Column);
NameToEnum.Add(@"\rows", Symbol.Rows);
NameToEnum.Add(@"\row", Symbol.Row);
NameToEnum.Add(@"\cell", Symbol.Cell);
NameToEnum.Add(@"\image", Symbol.Image);
NameToEnum.Add(@"\textframe", Symbol.TextFrame);
NameToEnum.Add(@"\pagebreak", Symbol.PageBreak);
NameToEnum.Add(@"\barcode", Symbol.Barcode);
NameToEnum.Add(@"\chart", Symbol.Chart);
NameToEnum.Add(@"\headerarea", Symbol.HeaderArea);
NameToEnum.Add(@"\footerarea", Symbol.FooterArea);
NameToEnum.Add(@"\toparea", Symbol.TopArea);
NameToEnum.Add(@"\bottomarea", Symbol.BottomArea);
NameToEnum.Add(@"\leftarea", Symbol.LeftArea);
NameToEnum.Add(@"\rightarea", Symbol.RightArea);
NameToEnum.Add(@"\plotarea", Symbol.PlotArea);
NameToEnum.Add(@"\legend", Symbol.Legend);
NameToEnum.Add(@"\xaxis", Symbol.XAxis);
NameToEnum.Add(@"\yaxis", Symbol.YAxis);
NameToEnum.Add(@"\zaxis", Symbol.ZAxis);
NameToEnum.Add(@"\series", Symbol.Series);
NameToEnum.Add(@"\xvalues", Symbol.XValues);
NameToEnum.Add(@"\point", Symbol.Point);
NameToEnum.Add(@"\bold", Symbol.Bold);
NameToEnum.Add(@"\italic", Symbol.Italic);
NameToEnum.Add(@"\underline", Symbol.Underline);
NameToEnum.Add(@"\fontsize", Symbol.FontSize);
NameToEnum.Add(@"\fontcolor", Symbol.FontColor);
NameToEnum.Add(@"\font", Symbol.Font);
//
NameToEnum.Add(@"\field", Symbol.Field);
NameToEnum.Add(@"\symbol", Symbol.Symbol);
NameToEnum.Add(@"\chr", Symbol.Chr);
//
NameToEnum.Add(@"\footnote", Symbol.Footnote);
NameToEnum.Add(@"\hyperlink", Symbol.Hyperlink);
//
NameToEnum.Add(@"\-", Symbol.SoftHyphen); //??? \( is another special case.
NameToEnum.Add(@"\tab", Symbol.Tab);
NameToEnum.Add(@"\linebreak", Symbol.LineBreak);
NameToEnum.Add(@"\space", Symbol.Space);
NameToEnum.Add(@"\nospace", Symbol.NoSpace);
}
/// <summary>
/// Returns Symbol value from name, or Symbol.None if no such Symbol exists.
/// </summary>
public static Symbol SymbolFromName(string name)
{
Symbol symbol;
if (!NameToEnum.TryGetValue(name, out symbol))
{
// Check for case sensitive keywords. Allow first character upper case only.
if (string.Compare(name, "True", StringComparison.OrdinalIgnoreCase) == 0)
symbol = Symbol.True;
else if (string.Compare(name, "False", StringComparison.OrdinalIgnoreCase) == 0)
symbol = Symbol.False;
else if (string.Compare(name, "Null", StringComparison.OrdinalIgnoreCase) == 0)
symbol = Symbol.Null;
else
symbol = Symbol.None;
}
return symbol;
}
/// <summary>
/// Returns string from Symbol value.
/// </summary>
public static string NameFromSymbol(Symbol symbol)
{
return EnumToName[symbol];
}
static readonly Dictionary<Symbol, string> EnumToName = new Dictionary<Symbol, string>();
static readonly Dictionary<string, Symbol> NameToEnum = new Dictionary<string, Symbol>();
}
}

View File

@@ -0,0 +1,60 @@
#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.IO
{
/// <summary>
/// Specifies the severity of a DDL reader diagnostic.
/// </summary>
public enum DdlErrorLevel
{
/// <summary>
/// An unknown severity.
/// </summary>
None,
/// <summary>
/// An information diagnostic.
/// </summary>
Info,
/// <summary>
/// A warning or suggestive diagnostic.
/// </summary>
Warning,
/// <summary>
/// An error diagnostic.
/// </summary>
Error,
}
}

View File

@@ -0,0 +1,177 @@
#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.IO
{
/// <summary>
/// The symbols used by DdlScanner/DdlParser.
/// </summary>
public enum Symbol
{
// TokenType.None
None,
Eof,
Eol, // End of line
// TokenType.Keyword
True,
False,
Null,
// TokenType.Identifier
Identifier,
Comment,
// TokenType.IntegerLiteral
IntegerLiteral,
HexIntegerLiteral,
OctIntegerLiteral,
// TokenType.StringLiteral
StringLiteral,
// TokenType.RealLiteral
RealLiteral,
// TokenType.OperatorOrPunctuator
Slash, // /
BackSlash, // \
ParenLeft, // (
ParenRight, // )
BraceLeft, // {
BraceRight, // }
BracketLeft, // [
BracketRight, // ]
EmptyLine, //CR LF CR LF
Colon, // :
Semicolon, // ;
Assign, // =
Plus, // +
Minus, // -
Dot, // .
Comma, // ,
Percent, // %
Dollar, // $
Hash, // #
Currency, // <20>
//Questionmark, // ?
Quotationmark, // "
At, // @
//Bar, // |
PlusAssign, // +=
MinusAssign, // -=
CR, // 0x0D
LF, // 0x0A
// TokenType.Keyword
Styles,
Document,
Section,
TableTemplates,
TableTemplate,
Paragraph,
HeaderOrFooter, // Only used as context in ParseDocumentElements
Header,
PrimaryHeader,
FirstPageHeader,
EvenPageHeader,
Footer,
PrimaryFooter,
FirstPageFooter,
EvenPageFooter,
Table,
Columns,
Column,
Rows,
Row,
Cell,
Image,
TextFrame,
Chart,
Footnote,
PageBreak,
Barcode,
// Diagramms
HeaderArea,
FooterArea,
TopArea,
BottomArea,
LeftArea,
RightArea,
PlotArea,
Legend,
XAxis,
YAxis,
ZAxis,
Series,
XValues,
Point,
// paragraph formats
Bold,
Italic,
Underline,
FontSize,
FontColor,
Font,
// Hyperlink used by ParagraphParser
Hyperlink,
// Token used by ParagraphParser
Text, // Plain text in a paragraph.
Blank,
Tab,
NonBreakeableBlank,
SoftHyphen,
LineBreak,
Space,
NoSpace,
// Field used by ParagraphParser
Field,
// Field types used by ParagraphParser
DateField,
PageField,
NumPagesField,
InfoField,
SectionField,
SectionPagesField,
BookmarkField,
PageRefField,
Character, //???
Symbol,
Chr
}
}

View File

@@ -0,0 +1,85 @@
#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.IO
{
/// <summary>
/// The tokens used by DdlScanner/DdlParser.
/// </summary>
public enum TokenType
{
/// <summary>
/// White space or comment.
/// </summary>
None,
/// <summary>
/// Same as identifiers in C#, but not case sensitive.
/// </summary>
Identifier,
/// <summary>
/// Both <20>true<75> and <20>\bold<6C> are keywords, case sensitive.
/// </summary>
KeyWord,
/// <summary>
/// Sample: <20>42<34>
/// </summary>
IntegerLiteral,
/// <summary>
/// Samples: <20>42.0<EFBFBD>, <20>42.<2E>, <20>.42<EFBFBD>,...
/// </summary>
RealLiteral,
/// <summary>
/// Not used.
/// </summary>
CharacterLiteral,
/// <summary>
/// Both <20>"text"<22> and <20>@"text with ""quotes"""<22>.
/// </summary>
StringLiteral,
/// <summary>
/// Samples: <20>.<2E>, <20>{<7B>, <20>+=<3D>,...
/// </summary>
OperatorOrPunctuator,
/// <summary>
/// Plain text. Possible after ReadText.
/// </summary>
Text,
}
}

View File

@@ -0,0 +1,75 @@
#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;
// ReSharper disable InconsistentNaming
namespace MigraDoc.DocumentObjectModel.publics
{
/// <summary>
/// Indicates that this field can be accessed via SetValue and GetValue.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class DVAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the DVAttribute class.
/// </summary>
public DVAttribute()
{
RefOnly = false;
ItemType = null;
}
/// <summary>
/// Gets or sets the type of the reflected value. Must be specified by NEnum.
/// </summary>
public Type Type
{
get { return _type; }
set { _type = value; }
}
Type _type;
/// <summary>
/// Determines whether the field is RefOnly and should be excluded from recursive operations.
/// </summary>
public bool RefOnly;
// TODO: Check type in value descriptor
/// <summary>
/// Describes the type of the elements a collection contains.
/// </summary>
public Type ItemType;
}
}

View File

@@ -0,0 +1,91 @@
#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;
namespace MigraDoc.DocumentObjectModel.publics
{
/// <summary>
/// A collection that manages ValueDescriptors.
/// </summary>
public class ValueDescriptorCollection : IEnumerable
{
/// <summary>
/// Gets the count of ValueDescriptors.
/// </summary>
public int Count
{
get { return _list.Count; }
}
/// <summary>
/// Adds the specified ValueDescriptor.
/// </summary>
public void Add(ValueDescriptor vd)
{
_dictionary.Add(vd.ValueName, vd);
_list.Add(vd);
}
/// <summary>
/// Gets the <see cref="MigraDoc.DocumentObjectModel.publics.ValueDescriptor"/> at the specified index.
/// </summary>
public ValueDescriptor this[int index]
{
get { return _list[index]; }
}
/// <summary>
/// Gets the <see cref="MigraDoc.DocumentObjectModel.publics.ValueDescriptor"/> with the specified name.
/// </summary>
public ValueDescriptor this[string name]
{
get { return _dictionary[name]; }
}
/// <summary>
/// Returns an enumerator that iterates through a collection.
/// </summary>
/// <returns>
/// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
/// </returns>
public IEnumerator GetEnumerator()
{
return _list.GetEnumerator();
}
readonly List<ValueDescriptor> _list = new List<ValueDescriptor>();
readonly Dictionary<string, ValueDescriptor> _dictionary = new Dictionary<string, ValueDescriptor>(StringComparer.OrdinalIgnoreCase);
}
}

View File

@@ -0,0 +1,45 @@
#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.publics
{
/// <summary>
/// Interface for simple nullable values like NInt, NString etc.
/// </summary>
public interface INullableValue
{
object GetValue();
void SetValue(object value);
void SetNull();
bool IsNull { get; }
}
}

View File

@@ -0,0 +1,282 @@
#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.Reflection;
namespace MigraDoc.DocumentObjectModel.publics
{
/// <summary>
/// Meta class for document objects.
/// </summary>
public sealed class Meta
{
/// <summary>
/// Initializes a new instance of the DomMeta class.
/// </summary>
public Meta(Type documentObjectType)
{
AddValueDescriptors(this, documentObjectType);
}
/// <summary>
/// Gets the meta object of the specified document object.
/// </summary>
/// <param name="documentObject">The document object the meta is returned for.</param>
public static Meta GetMeta(DocumentObject documentObject)
{
return documentObject.Meta;
}
/// <summary>
/// Gets the object specified by name from dom.
/// </summary>
public object GetValue(DocumentObject dom, string name, GV flags)
{
int dot = name.IndexOf('.');
if (dot == 0)
throw new ArgumentException(DomSR.InvalidValueName(name));
string trail = null;
if (dot > 0)
{
trail = name.Substring(dot + 1);
name = name.Substring(0, dot);
}
ValueDescriptor vd = _vds[name];
if (vd == null)
throw new ArgumentException(DomSR.InvalidValueName(name));
object value = vd.GetValue(dom, flags);
if (value == null && flags == GV.GetNull) //??? also for GV.ReadOnly?
return null;
//REVIEW DaSt: Create object in case of GV.ReadWrite?
if (trail != null)
{
if (value == null || trail == "")
throw new ArgumentException(DomSR.InvalidValueName(name));
DocumentObject doc = value as DocumentObject;
if (doc == null)
throw new ArgumentException(DomSR.InvalidValueName(name));
value = doc.GetValue(trail, flags);
}
return value;
}
/// <summary>
/// Sets the member of dom specified by name to val.
/// If a member with the specified name does not exist an ArgumentException will be thrown.
/// </summary>
public void SetValue(DocumentObject dom, string name, object val)
{
int dot = name.IndexOf('.');
if (dot == 0)
throw new ArgumentException(DomSR.InvalidValueName(name));
string trail = null;
if (dot > 0)
{
trail = name.Substring(dot + 1);
name = name.Substring(0, dot);
}
ValueDescriptor vd = _vds[name];
if (vd == null)
throw new ArgumentException(DomSR.InvalidValueName(name));
if (trail != null)
{
//REVIEW DaSt: dom.GetValue(name) and call SetValue recursively,
// or dom.GetValue(name.BisVorletzteElement) and then call SetValue?
DocumentObject doc = (DocumentObject)dom.GetValue(name);
doc.SetValue(trail, val);
}
else
vd.SetValue(dom, val);
}
/// <summary>
/// Determines whether this meta contains a value with the specified name.
/// </summary>
public bool HasValue(string name)
{
ValueDescriptor vd = _vds[name];
return vd != null;
}
/// <summary>
/// Sets the member of dom specified by name to null.
/// If a member with the specified name does not exist an ArgumentException will be thrown.
/// </summary>
public void SetNull(DocumentObject dom, string name)
{
ValueDescriptor vd = _vds[name];
if (vd == null)
throw new ArgumentException(DomSR.InvalidValueName(name));
vd.SetNull(dom);
}
/// <summary>
/// Determines whether the member of dom specified by name is null.
/// If a member with the specified name does not exist an ArgumentException will be thrown.
/// </summary>
public /* not virtual */ bool IsNull(DocumentObject dom, string name)
{
//bool isNull = false;
int dot = name.IndexOf('.');
if (dot == 0)
throw new ArgumentException(DomSR.InvalidValueName(name));
string trail = null;
if (dot > 0)
{
trail = name.Substring(dot + 1);
name = name.Substring(0, dot);
}
ValueDescriptor vd = _vds[name];
if (vd == null)
throw new ArgumentException(DomSR.InvalidValueName(name));
if (vd is NullableDescriptor || vd is ValueTypeDescriptor)
{
if (trail != null)
throw new ArgumentException(DomSR.InvalidValueName(name));
return vd.IsNull(dom);
}
DocumentObject docObj = (DocumentObject)vd.GetValue(dom, GV.ReadOnly);
if (docObj == null)
return true;
if (trail != null)
return docObj.IsNull(trail);
return docObj.IsNull();
// DomValueDescriptor vd = vds[name];
// if (vd == null)
// throw new ArgumentException(DomSR.InvalidValueName(name));
//
// return vd.IsNull(dom);
}
/// <summary>
/// Sets all members of the specified dom to null.
/// </summary>
public /*virtual*/ void SetNull(DocumentObject dom)
{
int count = _vds.Count;
for (int index = 0; index < count; index++)
{
if (!_vds[index].IsRefOnly)
_vds[index].SetNull(dom);
}
}
/// <summary>
/// Determines whether all members of the specified dom are null. If dom contains no members IsNull
/// returns true.
/// </summary>
public bool IsNull(DocumentObject dom)
{
int count = _vds.Count;
for (int index = 0; index < count; index++)
{
ValueDescriptor vd = _vds[index];
if (vd.IsRefOnly)
continue;
if (!vd.IsNull(dom))
return false;
}
return true;
}
/// <summary>
/// Gets the DomValueDescriptor of the member specified by name from the DocumentObject.
/// </summary>
public ValueDescriptor this[string name]
{
get { return _vds[name]; }
}
/// <summary>
/// Gets the DomValueDescriptorCollection of the DocumentObject.
/// </summary>
public ValueDescriptorCollection ValueDescriptors
{
get { return _vds; }
}
readonly ValueDescriptorCollection _vds = new ValueDescriptorCollection();
/// <summary>
/// Adds a value descriptor for each field and property found in type to meta.
/// </summary>
static void AddValueDescriptors(Meta meta, Type type)
{
#if !NETFX_CORE
FieldInfo[] fieldInfos = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
#else
var fieldInfos = type.GetTypeInfo().DeclaredFields;
#endif
foreach (FieldInfo fieldInfo in fieldInfos)
{
#if DEBUG_
string name = fieldInfo.Name;
if (name == "parent")
name.GetType();
#endif
DVAttribute[] dvs = (DVAttribute[])fieldInfo.GetCustomAttributes(typeof(DVAttribute), false);
if (dvs.Length == 1)
{
ValueDescriptor vd = ValueDescriptor.CreateValueDescriptor(fieldInfo, dvs[0]);
meta.ValueDescriptors.Add(vd);
}
}
#if !NETFX_CORE
PropertyInfo[] propInfos = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
#else
var propInfos = type.GetTypeInfo().DeclaredProperties;
#endif
foreach (PropertyInfo propInfo in propInfos)
{
#if DEBUG_
string name = propInfo.Name;
if (name == "Font")
name.GetType();
#endif
DVAttribute[] dvs = (DVAttribute[])propInfo.GetCustomAttributes(typeof(DVAttribute), false);
if (dvs.Length == 1)
{
ValueDescriptor vd = ValueDescriptor.CreateValueDescriptor(propInfo, dvs[0]);
meta.ValueDescriptors.Add(vd);
}
}
}
}
}

View 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
namespace MigraDoc.DocumentObjectModel.publics
{
/// <summary>
/// Represents a nullable boolean value.
/// </summary>
public struct NBool : INullableValue
{
public NBool(bool value)
{
_value = value ? (sbyte)1 : (sbyte)0;
}
NBool(sbyte value)
{
_value = value;
}
/// <summary>
/// Gets or sets the value of the instance.
/// </summary>
public bool Value
{
get { return _value == 1; }
set { _value = value ? (sbyte)1 : (sbyte)0; }
}
/// <summary>
/// Gets the value of the instance.
/// </summary>
object INullableValue.GetValue()
{
return Value;
}
/// <summary>
/// Sets the value of the instance.
/// </summary>
void INullableValue.SetValue(object value)
{
_value = (bool)value ? (sbyte)1 : (sbyte)0;
}
/// <summary>
/// Resets this instance,
/// i.e. IsNull() will return true afterwards.
/// </summary>
public void SetNull()
{
_value = -1;
}
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
public bool IsNull
{
get { return _value == -1; }
}
/// <summary>
/// Returns a value indicating whether this instance is equal to the specified object.
/// </summary>
public override bool Equals(object value)
{
if (value is NBool)
return this == (NBool)value;
return false;
}
public override int GetHashCode()
{
return _value.GetHashCode();
}
public static bool operator ==(NBool l, NBool r)
{
if (l.IsNull)
return r.IsNull;
if (r.IsNull)
return false;
return l.Value == r.Value;
}
public static bool operator !=(NBool l, NBool r)
{
return !(l == r);
}
public static readonly NBool NullValue = new NBool(-1);
/// <summary>
/// -1 (undefined), 0 (false), or 1 (true).
/// </summary>
sbyte _value;
}
}

View File

@@ -0,0 +1,120 @@
#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.publics
{
/// <summary>
/// Represents a nullable double value.
/// </summary>
public struct NDouble : INullableValue
{
public NDouble(double value)
{
_value = value;
}
/// <summary>
/// Gets or sets the value of the instance.
/// </summary>
public double Value
{
get { return double.IsNaN(_value) ? 0 : _value; }
set { _value = value; }
}
/// <summary>
/// Gets the value of the instance.
/// </summary>
object INullableValue.GetValue()
{
return Value;
}
/// <summary>
/// Sets the value of the instance.
/// </summary>
void INullableValue.SetValue(object value)
{
_value = (double)value;
}
/// <summary>
/// Resets this instance,
/// i.e. IsNull() will return true afterwards.
/// </summary>
public void SetNull()
{
_value = double.NaN;
}
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
public bool IsNull
{
get { return double.IsNaN(_value); }
}
/// <summary>
/// Returns a value indicating whether this instance is equal to the specified object.
/// </summary>
public override bool Equals(object value)
{
if (value is NDouble)
return this == (NDouble)value;
return false;
}
public override int GetHashCode()
{
return _value.GetHashCode();
}
public static bool operator ==(NDouble l, NDouble r)
{
if (l.IsNull)
return r.IsNull;
if (r.IsNull)
return false;
return l.Value == r.Value;
}
public static bool operator !=(NDouble l, NDouble r)
{
return !(l == r);
}
public static readonly NDouble NullValue = new NDouble(double.NaN);
double _value;
}
}

View File

@@ -0,0 +1,158 @@
#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.publics
{
/// <summary>
/// Represents a nullable Enum value.
/// </summary>
public struct NEnum : INullableValue
{
public NEnum(int val, Type type)
{
_type = type;
_value = val;
}
NEnum(int value)
{
_type = null;
_value = value;
}
public Type Type
{
get { return _type; }
set { _type = value; }
}
Type _type;
public int Value
{
get { return _value != int.MinValue ? _value : 0; }
set
{
// TODO Remove German remarks!
//TODO: Klasse Character so <20>ndern, dass symbolName und char in unterschiedlichen Feldern gespeichert werden.
//Diese Spezialbehandlung entf<74>llt dann.
if (_type == typeof(SymbolName))
{
// if (Enum.IsDefined(this .type, (uint)value))
_value = value;
// else
// throw new ArgumentOutOfRangeException("value");
}
else
{
if (Enum.IsDefined(_type, value))
_value = value;
else
throw new /*InvalidEnum*/ArgumentException(DomSR.InvalidEnumValue(value), "value");
}
}
}
object INullableValue.GetValue()
{
return ToObject();
}
void INullableValue.SetValue(object value)
{
_value = (int)value;
}
public void SetNull()
{
_value = int.MinValue;
}
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
public bool IsNull
{
get { return _value == int.MinValue; }
}
public object ToObject()
{
if (_value != int.MinValue)
return Enum.ToObject(_type, _value);
// BUG Have all enum 0 as valid value?
return Enum.ToObject(_type, 0);
}
//public static readonly NEnum NullValue = new NEnum(int.MinValue);
/// <summary>
/// Returns a value indicating whether this instance is equal to the specified object.
/// </summary>
public override bool Equals(object value)
{
if (value is NEnum)
return this == (NEnum)value;
return false;
}
public override int GetHashCode()
{
return _value.GetHashCode();
}
public static bool operator ==(NEnum l, NEnum r)
{
if (l.IsNull)
return r.IsNull;
if (r.IsNull)
return false;
if (l._type == r._type)
return l.Value == r.Value;
return false;
}
public static bool operator !=(NEnum l, NEnum r)
{
return !(l == r);
}
public static NEnum NullValue(Type fieldType)
{
return new NEnum(int.MinValue, fieldType);
}
int _value;
}
}

View File

@@ -0,0 +1,130 @@
#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.publics
{
/// <summary>
/// Represents a nullable integer value.
/// </summary>
public struct NInt : INullableValue
{
public NInt(int val)
{
_value = val;
}
/// <summary>
/// Gets or sets the value of the instance.
/// </summary>
public int Value
{
get { return _value != int.MinValue ? _value : 0; }
set { _value = value; }
}
/// <summary>
/// Gets the value of the instance.
/// </summary>
object INullableValue.GetValue()
{
return Value;
}
/// <summary>
/// Sets the value of the instance.
/// </summary>
void INullableValue.SetValue(object value)
{
_value = (int)value;
}
/// <summary>
/// Resets this instance,
/// i.e. IsNull() will return true afterwards.
/// </summary>
public void SetNull()
{
_value = int.MinValue;
}
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
public bool IsNull
{
get { return _value == int.MinValue; }
}
public static implicit operator NInt(int val)
{
return new NInt(val);
}
public static implicit operator int(NInt val)
{
return val.Value;
}
/// <summary>
/// Returns a value indicating whether this instance is equal to the specified object.
/// </summary>
public override bool Equals(object value)
{
if (value is NInt)
return this == (NInt)value;
return false;
}
public override int GetHashCode()
{
return _value.GetHashCode();
}
public static bool operator ==(NInt l, NInt r)
{
if (l.IsNull)
return r.IsNull;
if (r.IsNull)
return false;
return l.Value == r.Value;
}
public static bool operator !=(NInt l, NInt r)
{
return !(l == r);
}
public static readonly NInt NullValue = new NInt(int.MinValue);
int _value;
}
}

View File

@@ -0,0 +1,117 @@
#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.publics
{
/// <summary>
/// Represents a nullable string value.
/// </summary>
public struct NString : INullableValue
{
/// <summary>
/// Gets or sets the value of the instance.
/// </summary>
public string Value
{
get { return _value ?? String.Empty; }
set { _value = value; }
}
/// <summary>
/// Returns the value of the instance.
/// </summary>
object INullableValue.GetValue()
{
return Value;
}
/// <summary>
/// Sets the value of the instance.
/// </summary>
void INullableValue.SetValue(object value)
{
_value = (String)value;
}
/// <summary>
/// Resets this instance,
/// i.e. IsNull() will return true afterwards.
/// </summary>
public void SetNull()
{
_value = null;
}
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
public bool IsNull
{
get { return _value == null; }
}
/// <summary>
/// Returns a value indicating whether this instance is equal to the specified object.
/// </summary>
public override bool Equals(object value)
{
if (value is NString)
return this == (NString)value;
return false;
}
public override int GetHashCode()
{
return _value == null ? 0 : _value.GetHashCode();
}
public static bool operator ==(NString l, NString r)
{
if (l.IsNull)
return r.IsNull;
if (r.IsNull)
return false;
return l.Value == r.Value;
}
public static bool operator !=(NString l, NString r)
{
return !(l == r);
}
public static readonly NString NullValue = new NString();
string _value;
}
}

View File

@@ -0,0 +1,521 @@
#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;
#pragma warning disable 1591
namespace MigraDoc.DocumentObjectModel.publics
{
/// <summary>
/// Base class of all value descriptor classes.
/// </summary>
public abstract class ValueDescriptor
{
public ValueDescriptor(string valueName, Type valueType, Type memberType, MemberInfo memberInfo, VDFlags flags)
{
// Take new naming convention into account.
if (valueName.StartsWith("_"))
valueName = valueName.Substring(1);
ValueName = valueName;
ValueType = valueType;
MemberType = memberType;
MemberInfo = memberInfo;
_flags = flags;
}
public object CreateValue()
{
#if !NETFX_CORE
ConstructorInfo constructorInfo = ValueType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
#else
var constructorInfos = ValueType.GetTypeInfo().DeclaredConstructors;
ConstructorInfo constructorInfo = null;
foreach (var info in constructorInfos)
{
if (info.GetParameters().Length == 0)
constructorInfo = info;
}
#endif
Debug.Assert(constructorInfo != null);
return constructorInfo.Invoke(null);
}
public abstract object GetValue(DocumentObject dom, GV flags);
public abstract void SetValue(DocumentObject dom, object val);
public abstract void SetNull(DocumentObject dom);
public abstract bool IsNull(DocumentObject dom);
public static ValueDescriptor CreateValueDescriptor(MemberInfo memberInfo, DVAttribute attr)
{
VDFlags flags = VDFlags.None;
if (attr.RefOnly)
flags |= VDFlags.RefOnly;
string name = memberInfo.Name;
FieldInfo fieldInfo = memberInfo as FieldInfo;
Type type = fieldInfo != null ? fieldInfo.FieldType : ((PropertyInfo)memberInfo).PropertyType;
if (type == typeof(NBool))
return new NullableDescriptor(name, typeof(Boolean), type, memberInfo, flags);
if (type == typeof(NInt))
return new NullableDescriptor(name, typeof(Int32), type, memberInfo, flags);
if (type == typeof(NDouble))
return new NullableDescriptor(name, typeof(Double), type, memberInfo, flags);
if (type == typeof(NString))
return new NullableDescriptor(name, typeof(String), type, memberInfo, flags);
if (type == typeof(String))
return new ValueTypeDescriptor(name, typeof(String), type, memberInfo, flags);
if (type == typeof(NEnum))
{
Type valueType = attr.Type;
#if !NETFX_CORE
Debug.Assert(valueType.IsSubclassOf(typeof(Enum)), "NEnum must have 'Type' attribute with the underlying type");
#else
Debug.Assert(valueType.GetTypeInfo().IsSubclassOf(typeof(Enum)), "NEnum must have 'Type' attribute with the underlying type");
#endif
return new NullableDescriptor(name, valueType, type, memberInfo, flags);
}
#if !NETFX_CORE
if (type.IsSubclassOf(typeof(ValueType)))
#else
if (type.GetTypeInfo().IsSubclassOf(typeof(ValueType)))
#endif
return new ValueTypeDescriptor(name, type, type, memberInfo, flags);
#if !NETFX_CORE
if (typeof(DocumentObjectCollection).IsAssignableFrom(type))
#else
if (typeof(DocumentObjectCollection).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()))
#endif
return new DocumentObjectCollectionDescriptor(name, type, type, memberInfo, flags);
#if !NETFX_CORE
if (typeof(DocumentObject).IsAssignableFrom(type))
#else
if (typeof(DocumentObject).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()))
#endif
return new DocumentObjectDescriptor(name, type, type, memberInfo, flags);
Debug.Assert(false, type.FullName);
return null;
}
public bool IsRefOnly
{
get { return (_flags & VDFlags.RefOnly) == VDFlags.RefOnly; }
}
public FieldInfo FieldInfo
{
get { return MemberInfo as FieldInfo; }
}
public PropertyInfo PropertyInfo
{
get { return MemberInfo as PropertyInfo; }
}
/// <summary>
/// Name of the value.
/// </summary>
public readonly string ValueName;
/// <summary>
/// Type of the described value, e.g. typeof(Int32) for an NInt.
/// </summary>
public readonly Type ValueType;
/// <summary>
/// Type of the described field or property, e.g. typeof(NInt) for an NInt.
/// </summary>
public readonly Type MemberType;
/// <summary>
/// FieldInfo of the described field.
/// </summary>
public readonly MemberInfo MemberInfo;
/// <summary>
/// Flags of the described field, e.g. RefOnly.
/// </summary>
readonly VDFlags _flags;
}
/// <summary>
/// Value descriptor of all nullable types.
/// </summary>
public class NullableDescriptor : ValueDescriptor
{
public NullableDescriptor(string valueName, Type valueType, Type fieldType, MemberInfo memberInfo, VDFlags flags)
: base(valueName, valueType, fieldType, memberInfo, flags)
{ }
public override object GetValue(DocumentObject dom, GV flags)
{
if (!Enum.IsDefined(typeof(GV), flags))
throw new /*InvalidEnum*/ArgumentException(DomSR.InvalidEnumValue(flags), "flags");
#if !NETFX_CORE
object val = FieldInfo != null ? FieldInfo.GetValue(dom) : PropertyInfo.GetGetMethod(true).Invoke(dom, null);
#else
object val = FieldInfo != null ? FieldInfo.GetValue(dom) : PropertyInfo.GetValue(dom);
#endif
INullableValue ival = (INullableValue)val;
if (ival.IsNull && flags == GV.GetNull)
return null;
return ival.GetValue();
}
public override void SetValue(DocumentObject dom, object value)
{
object val;
INullableValue ival;
if (FieldInfo != null)
{
val = FieldInfo.GetValue(dom);
ival = (INullableValue)val;
ival.SetValue(value);
FieldInfo.SetValue(dom, ival);
}
else
{
#if !NETFX_CORE
val = PropertyInfo.GetGetMethod(true).Invoke(dom, null);
#else
val = PropertyInfo.GetValue(dom);
#endif
ival = (INullableValue)val;
ival.SetValue(value);
#if !NETFX_CORE
PropertyInfo.GetSetMethod(true).Invoke(dom, new object[] { ival });
#else
PropertyInfo.SetValue(dom, ival);
#endif
}
}
public override void SetNull(DocumentObject dom)
{
object val;
INullableValue ival;
if (FieldInfo != null)
{
val = FieldInfo.GetValue(dom);
ival = (INullableValue)val;
ival.SetNull();
FieldInfo.SetValue(dom, ival);
}
else
{
#if !NETFX_CORE
val = PropertyInfo.GetGetMethod(true).Invoke(dom, null);
#else
val = PropertyInfo.GetValue(dom);
#endif
ival = (INullableValue)val;
ival.SetNull();
#if !NETFX_CORE
PropertyInfo.GetSetMethod(true).Invoke(dom, new object[] { ival });
#else
PropertyInfo.SetValue(dom, ival);
#endif
}
}
/// <summary>
/// Determines whether the given DocumentObject is null (not set).
/// </summary>
public override bool IsNull(DocumentObject dom)
{
#if !NETFX_CORE
object val = FieldInfo != null ? FieldInfo.GetValue(dom) : PropertyInfo.GetGetMethod(true).Invoke(dom, null);
#else
object val = FieldInfo != null ? FieldInfo.GetValue(dom) : PropertyInfo.GetValue(dom);
#endif
return ((INullableValue)val).IsNull;
}
}
/// <summary>
/// Value descriptor of value types.
/// </summary>
public class ValueTypeDescriptor : ValueDescriptor
{
public ValueTypeDescriptor(string valueName, Type valueType, Type fieldType, MemberInfo memberInfo, VDFlags flags)
: base(valueName, valueType, fieldType, memberInfo, flags)
{ }
public override object GetValue(DocumentObject dom, GV flags)
{
if (!Enum.IsDefined(typeof(GV), flags))
throw new /*InvalidEnum*/ArgumentException(DomSR.InvalidEnumValue(flags), "flags");
#if !NETFX_CORE
object val = FieldInfo != null ? FieldInfo.GetValue(dom) : PropertyInfo.GetGetMethod(true).Invoke(dom, null);
#else
object val = FieldInfo != null ? FieldInfo.GetValue(dom) : PropertyInfo.GetValue(dom);
#endif
INullableValue ival = val as INullableValue;
if (ival != null && ival.IsNull && flags == GV.GetNull)
return null;
return val;
}
public override void SetValue(DocumentObject dom, object value)
{
if (FieldInfo != null)
FieldInfo.SetValue(dom, value);
else
#if !NETFX_CORE
PropertyInfo.GetSetMethod(true).Invoke(dom, new object[] { value });
#else
PropertyInfo.SetValue(dom, value);
#endif
}
public override void SetNull(DocumentObject dom)
{
object val;
INullableValue ival;
if (FieldInfo != null)
{
val = FieldInfo.GetValue(dom);
ival = (INullableValue)val;
ival.SetNull();
FieldInfo.SetValue(dom, ival);
}
else
{
#if !NETFX_CORE
val = PropertyInfo.GetGetMethod(true).Invoke(dom, null);
#else
val = PropertyInfo.GetValue(dom);
#endif
ival = (INullableValue)val;
ival.SetNull();
#if !NETFX_CORE
PropertyInfo.GetSetMethod(true).Invoke(dom, new object[] { ival });
#else
PropertyInfo.SetValue(dom, ival);
#endif
}
}
/// <summary>
/// Determines whether the given DocumentObject is null (not set).
/// </summary>
public override bool IsNull(DocumentObject dom)
{
#if !NETFX_CORE
object val = FieldInfo != null ? FieldInfo.GetValue(dom) : PropertyInfo.GetGetMethod(true).Invoke(dom, null);
#else
object val = FieldInfo != null ? FieldInfo.GetValue(dom) : PropertyInfo.GetValue(dom);
#endif
INullableValue ival = val as INullableValue;
if (ival != null)
return ival.IsNull;
return false;
}
}
/// <summary>
/// Value descriptor of DocumentObject.
/// </summary>
public class DocumentObjectDescriptor : ValueDescriptor
{
public DocumentObjectDescriptor(string valueName, Type valueType, Type fieldType, MemberInfo memberInfo, VDFlags flags)
: base(valueName, valueType, fieldType, memberInfo, flags)
{ }
public override object GetValue(DocumentObject dom, GV flags)
{
if (!Enum.IsDefined(typeof(GV), flags))
throw new /*InvalidEnum*/ArgumentException(DomSR.InvalidEnumValue(flags), "flags");
FieldInfo fieldInfo = FieldInfo;
DocumentObject val;
if (fieldInfo != null)
{
// Member is a field
val = FieldInfo.GetValue(dom) as DocumentObject;
if (val == null && flags == GV.ReadWrite)
{
val = (DocumentObject)CreateValue();
val._parent = dom;
FieldInfo.SetValue(dom, val);
return val;
}
}
else
{
// Member is a property
#if !NETFX_CORE
val = PropertyInfo.GetGetMethod(true).Invoke(dom, null) as DocumentObject;
#else
val = PropertyInfo.GetValue(dom) as DocumentObject;
#endif
}
if (val != null && (val.IsNull() && flags == GV.GetNull))
return null;
return val;
}
public override void SetValue(DocumentObject dom, object val)
{
FieldInfo fieldInfo = FieldInfo;
// Member is a field
if (fieldInfo != null)
{
fieldInfo.SetValue(dom, val);
return;
}
throw new InvalidOperationException("This value cannot be set.");
}
public override void SetNull(DocumentObject dom)
{
FieldInfo fieldInfo = FieldInfo;
DocumentObject val;
// Member is a field.
if (fieldInfo != null)
{
val = FieldInfo.GetValue(dom) as DocumentObject;
if (val != null)
val.SetNull();
}
// Member is a property.
if (PropertyInfo != null)
{
PropertyInfo propInfo = PropertyInfo;
#if !NETFX_CORE
val = propInfo.GetGetMethod(true).Invoke(dom, null) as DocumentObject;
#else
val = propInfo.GetValue(dom) as DocumentObject;
#endif
if (val != null)
val.SetNull();
}
}
/// <summary>
/// Determines whether the given DocumentObject is null (not set).
/// </summary>
public override bool IsNull(DocumentObject dom)
{
FieldInfo fieldInfo = FieldInfo;
DocumentObject val;
// Member is a field
if (fieldInfo != null)
{
val = FieldInfo.GetValue(dom) as DocumentObject;
if (val == null)
return true;
return val.IsNull();
}
// Member is a property
PropertyInfo propInfo = PropertyInfo;
#if !NETFX_CORE
val = propInfo.GetGetMethod(true).Invoke(dom, null) as DocumentObject;
#else
val = propInfo.GetValue(dom) as DocumentObject;
#endif
if (val != null)
val.IsNull();
return true;
}
}
/// <summary>
/// Value descriptor of DocumentObjectCollection.
/// </summary>
public class DocumentObjectCollectionDescriptor : ValueDescriptor
{
public DocumentObjectCollectionDescriptor(string valueName, Type valueType, Type fieldType, MemberInfo memberInfo, VDFlags flags)
: base(valueName, valueType, fieldType, memberInfo, flags)
{ }
public override object GetValue(DocumentObject dom, GV flags)
{
if (!Enum.IsDefined(typeof(GV), flags))
throw new /*InvalidEnum*/ArgumentException(DomSR.InvalidEnumValue(flags), "flags");
Debug.Assert(MemberInfo is FieldInfo, "Properties of DocumentObjectCollection not allowed.");
DocumentObjectCollection val = FieldInfo.GetValue(dom) as DocumentObjectCollection;
if (val == null && flags == GV.ReadWrite)
{
val = (DocumentObjectCollection)CreateValue();
val._parent = dom;
FieldInfo.SetValue(dom, val);
return val;
}
if (val != null && val.IsNull() && flags == GV.GetNull)
return null;
return val;
}
public override void SetValue(DocumentObject dom, object val)
{
FieldInfo.SetValue(dom, val);
}
public override void SetNull(DocumentObject dom)
{
DocumentObjectCollection val = FieldInfo.GetValue(dom) as DocumentObjectCollection;
if (val != null)
val.SetNull();
}
/// <summary>
/// Determines whether the given DocumentObject is null (not set).
/// </summary>
public override bool IsNull(DocumentObject dom)
{
DocumentObjectCollection val = FieldInfo.GetValue(dom) as DocumentObjectCollection;
if (val == null)
return true;
return val.IsNull();
}
}
}

View File

@@ -0,0 +1,57 @@
#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
// ReSharper disable InconsistentNaming
namespace MigraDoc.DocumentObjectModel.publics
{
/// <summary>
/// Indicates how to retrieve a value from a DocumentObject.
/// </summary>
public enum GV
{
/// <summary>
/// Gets the value for reading and writing. If the value does not exist, it is created.
/// </summary>
ReadWrite = 0,
/// <summary>
/// Gets the value for reading. If the value does not exist, it is not created.
/// </summary>
ReadOnly = 1,
/// <summary>
/// Returns null if value is Null or does not exist.
/// </summary>
GetNull = 2,
}
}

View File

@@ -0,0 +1,45 @@
#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;
// ReSharper disable InconsistentNaming
namespace MigraDoc.DocumentObjectModel.publics
{
[Flags]
public enum VDFlags
{
None = 0,
RefOnly = 0x0001
}
}

View File

@@ -0,0 +1,71 @@
; ----- German (de) Messages ---------------------------------------------------
; Messages for German language
; that differ from the default messages.
;
; Must be saved with encoding UTF8. Otherwise German umlauts get not processed correctly.
;
; ------------------------------------------------------------------------------
StyleExpected = Der übergebene Wert muss vom Typ MigraDoc.DocumentObjectModel.Style sein.
BaseStyleRequired = Es muss eine Basis-Formatvorlage definiert werden.
EmptyBaseStyle = Die Basis-Formatvorlage darf nicht leer sein.
InvalidFieldFormat = '{0}' ist kein gültiges Format für ein numerisches Feld.
InvalidInfoFieldName = Die Eigenschaft 'Name' an 'InfoField' hat den ungültigen Wert '{0}'.
UndefinedBaseStyle = Die Basis-Formatvorlage '{0}' ist nicht definiert.
InvalidUnitValue = '{0}' ist keine gültige Zeichenkette für ein 'Unit'-Objekt.
InvalidUnitType = '{0}' ist ein unbekannter Maß für ein 'Unit'-Objekt.
InvalidEnumValue = Der Wert '{0:X}' ist für den enum-Type '{1}' nicht gültig.
InvalidEnumForLeftPosition = ShapePosition muss einer der Werte 'Left', 'Center', oder 'Right' sein.
InvalidEnumForTopPosition = ShapePosition einer der Werte 'Top', 'Center', oder 'Bottom' sein.
InvalidColorString = Aus der Zeichenkette '{0}' konnte keine Farbe eingelesen werden.
InvalidFontSize = Die Fontgröße '{0}' is ausserhalb des erlaubten Bereichs.
InsertNullNotAllowed = In ein Collection-Objekt darf keine null eingefügt werden.
ParentAlreadySet = Wert vom Typ '{0}' muss geklont werden, bevor we an '{1}' gesetzt werden kann.
MissingObligatoryProperty = Obigatorische Eigenschaft '{0}' wurde an '{1}' nicht gesetzt.
InvalidDocumentObjectType = Das übergebene Dokumentobjekt ist in diesem Zusammenhang nicht gültig.
; ----- DdlReader Messages ------------------------------------------------------------------------
;DomMsgID
SymbolExpected = Symbol '{0}' erwartet, '{1}' vorgefunden.
SymbolsExpected = Eines der folgenden Symbole {0} erwartet.
OperatorExpected = Syntaxfehler: Operator '{0}' erwartet.
KeyWordExpected = Schlüsselwort '{1}' - '{0}' erwartet.
EndOfFileExpected = Ende der Datei erwartet.
UnexpectedEndOfFile = Unerwartetes Dateiende.
StyleNameExpected = '{0}' ist kein gültiger Name für eine Formatvorlage.
UnexpectedSymbol = Unerwartetes Symbol '{0}'.
IdentifierExpected = Bezeichner erwartet: '{0}'.
BoolExpected = Boolescher Wert erwartet: '{0}'.
RealExpected = Fließkomma-Wert erwartet: '{0}'.
IntegerExpected = Ganze Zahl erwartet: '{0}'.
StringExpected = Zeichenkette erwartet: '{0}'.
NullExpected = Null erwartet: '{0}'.
NumberExpected = Zahl erwartet: '{0}'.
InvalidEnum = '{0}' '{1}'.
InvalidType = Variablentyp '{0}' wird von '{1}' nicht unterstützt.
InvalidAssignment = Ungültige Zuweisung an '{0}'.
InvalidValueName = '{0}' ist ein ungültiger Wertname.
InvalidRange = Ungültiger Bereich: '{0}'.
InvalidColor = Ungültiger Farbwert: '{0}'.
InvalidFieldType = Ungültiger Feldtyp: '{0}'.
InvalidValueForOperation = Operation '{1}' ist für den Wert '{0}' nicht gültig.
InvalidSymbolType = Ungültiges Symbol '{0}'.
MissingBraceLeft = Öffnende geschweifte Klammer nach '{0}' fehlt.
MissingBraceRight = Schließende geschweifte Klammer nach '{0}' fehlt.
MissingBracketLeft = Öffnende eckige Klammer nach '{0}' fehlt.
MissingBracketRight = Schließende eckige Klammer nach '{0}' fehlt.
MissingParenLeft = Öffnende runde Klammer nach '{0}' fehlt.
MissingParenRight = Schließende runde Klammer nach '{0}' fehlt.
MissingComma = Komma fehlt.
SymbolNotAllowed = Symbol '{0}' ist in diesem Zusammenhang nichterlaubt.
SymbolIsNotAnObject = Symbol '{0}' ist kein Objekt.
UnknownChartType = Unbekannter Diagrammtyp: '{0}'
NoAccess = Zugriff verweigert: '{0}' existiert nur für den internen Gebrauch.
NewlineInString = Zeilenumbruch in Zeichenkette nicht erlaubt.
EscapeSequenceNotAllowed = Ungültige Escapesequenz.
NullAssignmentNotSupported = Zuweisung von 'null' an '{0}' ist nicht erlaubt.
OutOfRange = Der gültige Bereich liegt innerhalb von '{0}'.
UseOfUndefinedBaseStyle = Die unbekannte Basis-Formatvorlage '{0}' wurde verwendet.
UseOfUndefinedStyle = Die unbekannte Formatvorlage '{0}' wurde verwendet.

View File

@@ -0,0 +1,70 @@
; ----- Default Messages -------------------------------------------------------
; Each Message will be shown for any language
; that does not override it in its specific .txt-file.
; ------------------------------------------------------------------------------
; ----- General Messages --------------------------------------------------------------------------
StyleExpected = The value must be of type MigraDoc.DocumentObjectModel.Style.
BaseStyleRequired = Base style name must be defined.
EmptyBaseStyle = Attempt to set empty base style is invalid.
InvalidFieldFormat = '{0}' is not a valid numeric field format.
InvalidInfoFieldName = Property 'Name' of 'InfoField' has invalid value '{0}'.
UndefinedBaseStyle = Base style name '{0}' is undefined.
InvalidUnitValue = String '{0}' is not a valid value for structure 'Unit'.
InvalidUnitType = '{0}' is an unknown unit type.
InvalidEnumValue = The value '{0:X}' is not valid for enum type '{1}'.
InvalidEnumForLeftPosition = ShapePosition must be Left, Center, or Right.
InvalidEnumForTopPosition = ShapePosition must be Top, Center, or Bottom.
InvalidColorString = Color could not be parsed from string '{0}'.
InvalidFontSize = The font size '{0}' is out of range.
InsertNullNotAllowed = Inserting null into a collection is not allowed.
ParentAlreadySet = Value of type '{0}' must be cloned before set into '{1}'.
MissingObligatoryProperty = Obigatory property '{0}' not set in '{1}'.
InvalidDocumentObjectType = The given document object is not valid in this context.
; ----- DdlReader Messages ------------------------------------------------------------------------
;DomMsgID
SymbolExpected = '{0}' expected, found '{1}'.
SymbolsExpected = One of the following symbols {0} is expected.
OperatorExpected = Syntax error: Operator '{0}' is expected.
KeyWordExpected = '{1}' - '{0}' expected.
EndOfFileExpected = End of file expected.
UnexpectedEndOfFile = Unexpected end of file.
StyleNameExpected = Invalid style name '{0}'.
UnexpectedSymbol = Unexpected symbol '{0}'.
IdentifierExpected = Identifier expected: '{0}'.
BoolExpected = Bool expected: '{0}'.
RealExpected = Real expected: '{0}'.
IntegerExpected = Integer expected: '{0}'.
StringExpected = String expected: '{0}'.
NullExpected = Null expected: '{0}'.
NumberExpected = Number expected: '{0}'.
InvalidEnum = '{0}' '{1}'.
InvalidType = Variable type '{0}' not supported by '{1}'.
InvalidAssignment = Invalid assignment to '{0}'.
InvalidValueName = Invalid value name: '{0}'.
InvalidRange = Invalid range: '{0}'.
InvalidColor = Invalid color: '{0}'.
InvalidFieldType = Invalid field type: '{0}'.
InvalidValueForOperation = Operation '{1}' not valid for Value '{0}'.
InvalidSymbolType = Symbol not valid '{0}'.
MissingBraceLeft = Missing left brace after '{0}'.
MissingBraceRight = Missing right brace after '{0}'.
MissingBracketLeft = Missing left bracket after '{0}'.
MissingBracketRight = Missing right bracket after '{0}'.
MissingParenLeft = Missing left parenthesis after '{0}'.
MissingParenRight = Missing right parenthesis after '{0}'.
MissingComma = Missing comma.
SymbolNotAllowed = Symbol '{0}' in this context not allowed.
SymbolIsNotAnObject = Symbol '{0}' is not an object.
UnknownChartType = Unknown chart type: '{0}'
NoAccess = Access denied: '{0}' for public use only.
NewlineInString = Newline in string not allowed.
EscapeSequenceNotAllowed = Invalid escape sequence.
NullAssignmentNotSupported = Assign 'null' to '{0}' not allowed.
OutOfRange = Valid range only within '{0}'.
UseOfUndefinedBaseStyle = Use of undefined base style '{0}'.
UseOfUndefinedStyle = Use of undefined style '{0}'.

View File

@@ -0,0 +1,331 @@
#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.Shapes.Charts
{
/// <summary>
/// This class represents an axis in a chart.
/// </summary>
public class Axis : ChartObject
{
/// <summary>
/// Initializes a new instance of the Axis class.
/// </summary>
public Axis()
{ }
/// <summary>
/// Initializes a new instance of the Axis class with the specified parent.
/// </summary>
public Axis(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Axis Clone()
{
return (Axis)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Axis axis = (Axis)base.DeepCopy();
if (axis._title != null)
{
axis._title = axis._title.Clone();
axis._title._parent = axis;
}
if (axis._tickLabels != null)
{
axis._tickLabels = axis._tickLabels.Clone();
axis._tickLabels._parent = axis;
}
if (axis._lineFormat != null)
{
axis._lineFormat = axis._lineFormat.Clone();
axis._lineFormat._parent = axis;
}
if (axis._majorGridlines != null)
{
axis._majorGridlines = axis._majorGridlines.Clone();
axis._majorGridlines._parent = axis;
}
if (axis._minorGridlines != null)
{
axis._minorGridlines = axis._minorGridlines.Clone();
axis._minorGridlines._parent = axis;
}
return axis;
}
#endregion
#region Properties
/// <summary>
/// Gets the title of the axis.
/// </summary>
public AxisTitle Title
{
get { return _title ?? (_title = new AxisTitle(this)); }
set
{
SetParent(value);
_title = value;
}
}
[DV]
public AxisTitle _title;
/// <summary>
/// Gets or sets the minimum value of the axis.
/// </summary>
public double MinimumScale
{
get { return _minimumScale.Value; }
set { _minimumScale.Value = value; }
}
[DV]
public NDouble _minimumScale = NDouble.NullValue;
/// <summary>
/// Gets or sets the maximum value of the axis.
/// </summary>
public double MaximumScale
{
get { return _maximumScale.Value; }
set { _maximumScale.Value = value; }
}
[DV]
public NDouble _maximumScale = NDouble.NullValue;
/// <summary>
/// Gets or sets the interval of the primary tick.
/// </summary>
public double MajorTick
{
get { return _majorTick.Value; }
set { _majorTick.Value = value; }
}
[DV]
public NDouble _majorTick = NDouble.NullValue;
/// <summary>
/// Gets or sets the interval of the secondary tick.
/// </summary>
public double MinorTick
{
get { return _minorTick.Value; }
set { _minorTick.Value = value; }
}
[DV]
public NDouble _minorTick = NDouble.NullValue;
/// <summary>
/// Gets or sets the type of the primary tick mark.
/// </summary>
public TickMarkType MajorTickMark
{
get { return (TickMarkType)_majorTickMark.Value; }
set { _majorTickMark.Value = (int)value; }
}
[DV(Type = typeof(TickMarkType))]
public NEnum _majorTickMark = NEnum.NullValue(typeof(TickMarkType));
/// <summary>
/// Gets or sets the type of the secondary tick mark.
/// </summary>
public TickMarkType MinorTickMark
{
get { return (TickMarkType)_minorTickMark.Value; }
set { _minorTickMark.Value = (int)value; }
}
[DV(Type = typeof(TickMarkType))]
public NEnum _minorTickMark = NEnum.NullValue(typeof(TickMarkType));
/// <summary>
/// Gets the label of the primary tick.
/// </summary>
public TickLabels TickLabels
{
get { return _tickLabels ?? (_tickLabels = new TickLabels(this)); }
set
{
SetParent(value);
_tickLabels = value;
}
}
[DV]
public TickLabels _tickLabels;
/// <summary>
/// Gets the format of the axis line.
/// </summary>
public LineFormat LineFormat
{
get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); }
set
{
SetParent(value);
_lineFormat = value;
}
}
[DV]
public LineFormat _lineFormat;
/// <summary>
/// Gets the primary gridline object.
/// </summary>
public Gridlines MajorGridlines
{
get { return _majorGridlines ?? (_majorGridlines = new Gridlines(this)); }
set
{
SetParent(value);
_majorGridlines = value;
}
}
[DV]
public Gridlines _majorGridlines;
/// <summary>
/// Gets the secondary gridline object.
/// </summary>
public Gridlines MinorGridlines
{
get { return _minorGridlines ?? (_minorGridlines = new Gridlines(this)); }
set
{
SetParent(value);
_minorGridlines = value;
}
}
[DV]
public Gridlines _minorGridlines;
/// <summary>
/// Gets or sets, whether the axis has a primary gridline object.
/// </summary>
public bool HasMajorGridlines
{
get { return _hasMajorGridlines.Value; }
set { _hasMajorGridlines.Value = value; }
}
[DV]
public NBool _hasMajorGridlines = NBool.NullValue;
/// <summary>
/// Gets or sets, whether the axis has a secondary gridline object.
/// </summary>
public bool HasMinorGridlines
{
get { return _hasMinorGridlines.Value; }
set { _hasMinorGridlines.Value = value; }
}
[DV]
public NBool _hasMinorGridlines = NBool.NullValue;
#endregion
/// <summary>
/// Determines whether the specified gridlines object is a MajorGridlines or an MinorGridlines.
/// </summary>
public string CheckGridlines(Gridlines gridlines)
{
if ((_majorGridlines != null) && (gridlines == _majorGridlines))
return "MajorGridlines";
if ((_minorGridlines != null) && (gridlines == _minorGridlines))
return "MinorGridlines";
return "";
}
#region public
/// <summary>
/// Converts Axis into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
Chart chartObject = _parent as Chart;
serializer.WriteLine("\\" + chartObject.CheckAxis(this));
int pos = serializer.BeginAttributes();
if (!_minimumScale.IsNull)
serializer.WriteSimpleAttribute("MinimumScale", MinimumScale);
if (!_maximumScale.IsNull)
serializer.WriteSimpleAttribute("MaximumScale", MaximumScale);
if (!_majorTick.IsNull)
serializer.WriteSimpleAttribute("MajorTick", MajorTick);
if (!_minorTick.IsNull)
serializer.WriteSimpleAttribute("MinorTick", MinorTick);
if (!_hasMajorGridlines.IsNull)
serializer.WriteSimpleAttribute("HasMajorGridLines", HasMajorGridlines);
if (!_hasMinorGridlines.IsNull)
serializer.WriteSimpleAttribute("HasMinorGridLines", HasMinorGridlines);
if (!_majorTickMark.IsNull)
serializer.WriteSimpleAttribute("MajorTickMark", MajorTickMark);
if (!_minorTickMark.IsNull)
serializer.WriteSimpleAttribute("MinorTickMark", MinorTickMark);
if (!IsNull("Title"))
_title.Serialize(serializer);
if (!IsNull("LineFormat"))
_lineFormat.Serialize(serializer);
if (!IsNull("MajorGridlines"))
_majorGridlines.Serialize(serializer);
if (!IsNull("MinorGridlines"))
_minorGridlines.Serialize(serializer);
if (!IsNull("TickLabels"))
_tickLabels.Serialize(serializer);
serializer.EndAttributes(pos);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Axis))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,190 @@
#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.Tables;
namespace MigraDoc.DocumentObjectModel.Shapes.Charts
{
/// <summary>
/// Represents the title of an axis.
/// </summary>
public class AxisTitle : ChartObject
{
/// <summary>
/// Initializes a new instance of the AxisTitle class.
/// </summary>
public AxisTitle()
{
}
/// <summary>
/// Initializes a new instance of the AxisTitle class with the specified parent.
/// </summary>
public AxisTitle(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new AxisTitle Clone()
{
return (AxisTitle)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
AxisTitle axisTitle = (AxisTitle)base.DeepCopy();
if (axisTitle._font != null)
{
axisTitle._font = axisTitle._font.Clone();
axisTitle._font._parent = axisTitle;
}
return axisTitle;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the style name of the axis.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets or sets the caption of the title.
/// </summary>
public string Caption
{
get { return _caption.Value; }
set { _caption.Value = value; }
}
[DV]
public NString _caption = NString.NullValue;
/// <summary>
/// Gets the font object of the title.
/// </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 orientation of the caption.
/// </summary>
public Unit Orientation
{
get { return _orientation; }
set { _orientation = value; }
}
[DV]
public Unit _orientation = Unit.NullValue;
/// <summary>
/// Gets or sets the alignment of the caption.
/// </summary>
public HorizontalAlignment Alignment
{
get { return (HorizontalAlignment)_alignment.Value; }
set { _alignment.Value = (int)value; }
}
[DV(Type = typeof(HorizontalAlignment))]
public NEnum _alignment = NEnum.NullValue(typeof(HorizontalAlignment));
/// <summary>
/// Gets or sets the alignment of the caption.
/// </summary>
public VerticalAlignment VerticalAlignment
{
get { return (VerticalAlignment)_verticalAlignment.Value; }
set { _verticalAlignment.Value = (int)value; }
}
[DV(Type = typeof(VerticalAlignment))]
public NEnum _verticalAlignment = NEnum.NullValue(typeof(VerticalAlignment));
#endregion
#region public
/// <summary>
/// Converts AxisTitle into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int pos = serializer.BeginContent("Title");
if (!_style.IsNull)
serializer.WriteSimpleAttribute("Style", Style);
if (!IsNull("Font"))
_font.Serialize(serializer);
if (!_orientation.IsNull)
serializer.WriteSimpleAttribute("Orientation", Orientation);
if (!_alignment.IsNull)
serializer.WriteSimpleAttribute("Alignment", Alignment);
if (!_verticalAlignment.IsNull)
serializer.WriteSimpleAttribute("VerticalAlignment", VerticalAlignment);
if (!_caption.IsNull)
serializer.WriteSimpleAttribute("Caption", Caption);
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(AxisTitle))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,552 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents charts with different types.
/// </summary>
public class Chart : Shape, IVisitable
{
/// <summary>
/// Initializes a new instance of the Chart class.
/// </summary>
public Chart()
{
}
/// <summary>
/// Initializes a new instance of the Chart class with the specified parent.
/// </summary>
public Chart(DocumentObject parent) : base(parent) { }
/// <summary>
/// Initializes a new instance of the Chart class with the specified chart type.
/// </summary>
public Chart(ChartType type)
: this()
{
Type = type;
}
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Chart Clone()
{
return (Chart)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Chart chart = (Chart)base.DeepCopy();
if (chart._format != null)
{
chart._format = chart._format.Clone();
chart._format._parent = chart;
}
if (chart._xAxis != null)
{
chart._xAxis = chart._xAxis.Clone();
chart._xAxis._parent = chart;
}
if (chart._yAxis != null)
{
chart._yAxis = chart._yAxis.Clone();
chart._yAxis._parent = chart;
}
if (chart._zAxis != null)
{
chart._zAxis = chart._zAxis.Clone();
chart._zAxis._parent = chart;
}
if (chart._seriesCollection != null)
{
chart._seriesCollection = chart._seriesCollection.Clone();
chart._seriesCollection._parent = chart;
}
if (chart._xValues != null)
{
chart._xValues = chart._xValues.Clone();
chart._xValues._parent = chart;
}
if (chart._headerArea != null)
{
chart._headerArea = chart._headerArea.Clone();
chart._headerArea._parent = chart;
}
if (chart._bottomArea != null)
{
chart._bottomArea = chart._bottomArea.Clone();
chart._bottomArea._parent = chart;
}
if (chart._topArea != null)
{
chart._topArea = chart._topArea.Clone();
chart._topArea._parent = chart;
}
if (chart._footerArea != null)
{
chart._footerArea = chart._footerArea.Clone();
chart._footerArea._parent = chart;
}
if (chart._leftArea != null)
{
chart._leftArea = chart._leftArea.Clone();
chart._leftArea._parent = chart;
}
if (chart._rightArea != null)
{
chart._rightArea = chart._rightArea.Clone();
chart._rightArea._parent = chart;
}
if (chart._plotArea != null)
{
chart._plotArea = chart._plotArea.Clone();
chart._plotArea._parent = chart;
}
if (chart._dataLabel != null)
{
chart._dataLabel = chart._dataLabel.Clone();
chart._dataLabel._parent = chart;
}
return chart;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the base type of the chart.
/// ChartType of the series can be overwritten.
/// </summary>
public ChartType Type
{
get { return (ChartType)_type.Value; }
set { _type.Value = (int)value; }
}
[DV(Type = typeof(ChartType))]
public NEnum _type = NEnum.NullValue(typeof(ChartType));
/// <summary>
/// Gets or sets the default style name of the whole chart.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets the default paragraph format of the whole chart.
/// </summary>
public ParagraphFormat Format
{
get { return _format ?? (_format = new ParagraphFormat(this)); }
set
{
SetParent(value);
_format = value;
}
}
[DV]
public ParagraphFormat _format;
/// <summary>
/// Gets the X-Axis of the Chart.
/// </summary>
public Axis XAxis
{
get { return _xAxis ?? (_xAxis = new Axis(this)); }
set
{
SetParent(value);
_xAxis = value;
}
}
[DV]
public Axis _xAxis;
/// <summary>
/// Gets the Y-Axis of the Chart.
/// </summary>
public Axis YAxis
{
get { return _yAxis ?? (_yAxis = new Axis(this)); }
set
{
SetParent(value);
_yAxis = value;
}
}
[DV]
public Axis _yAxis;
/// <summary>
/// Gets the Z-Axis of the Chart.
/// </summary>
public Axis ZAxis
{
get { return _zAxis ?? (_zAxis = new Axis(this)); }
set
{
SetParent(value);
_zAxis = value;
}
}
[DV]
public Axis _zAxis;
/// <summary>
/// Gets the collection of the data series.
/// </summary>
public SeriesCollection SeriesCollection
{
get { return _seriesCollection ?? (_seriesCollection = new SeriesCollection(this)); }
set
{
SetParent(value);
_seriesCollection = value;
}
}
[DV(ItemType = typeof(Series))]
public SeriesCollection _seriesCollection;
/// <summary>
/// Gets the collection of the values written on the X-Axis.
/// </summary>
public XValues XValues
{
get { return _xValues ?? (_xValues = new XValues(this)); }
set
{
SetParent(value);
_xValues = value;
}
}
[DV(ItemType = typeof(Series))]
public XValues _xValues;
/// <summary>
/// Gets the header area of the chart.
/// </summary>
public TextArea HeaderArea
{
get { return _headerArea ?? (_headerArea = new TextArea(this)); }
set
{
SetParent(value);
_headerArea = value;
}
}
[DV]
public TextArea _headerArea;
/// <summary>
/// Gets the bottom area of the chart.
/// </summary>
public TextArea BottomArea
{
get { return _bottomArea ?? (_bottomArea = new TextArea(this)); }
set
{
SetParent(value);
_bottomArea = value;
}
}
[DV]
public TextArea _bottomArea;
/// <summary>
/// Gets the top area of the chart.
/// </summary>
public TextArea TopArea
{
get { return _topArea ?? (_topArea = new TextArea(this)); }
set
{
SetParent(value);
_topArea = value;
}
}
[DV]
public TextArea _topArea;
/// <summary>
/// Gets the footer area of the chart.
/// </summary>
public TextArea FooterArea
{
get { return _footerArea ?? (_footerArea = new TextArea(this)); }
set
{
SetParent(value);
_footerArea = value;
}
}
[DV]
public TextArea _footerArea;
/// <summary>
/// Gets the left area of the chart.
/// </summary>
public TextArea LeftArea
{
get { return _leftArea ?? (_leftArea = new TextArea(this)); }
set
{
SetParent(value);
_leftArea = value;
}
}
[DV]
public TextArea _leftArea;
/// <summary>
/// Gets the right area of the chart.
/// </summary>
public TextArea RightArea
{
get { return _rightArea ?? (_rightArea = new TextArea(this)); }
set
{
SetParent(value);
_rightArea = value;
}
}
[DV]
public TextArea _rightArea;
/// <summary>
/// Gets the plot (drawing) area of the chart.
/// </summary>
public PlotArea PlotArea
{
get { return _plotArea ?? (_plotArea = new PlotArea(this)); }
set
{
SetParent(value);
_plotArea = value;
}
}
[DV]
public PlotArea _plotArea;
/// <summary>
/// Gets or sets a value defining how blanks in the data series should be shown.
/// </summary>
public BlankType DisplayBlanksAs
{
get { return (BlankType)_displayBlanksAs.Value; }
set { _displayBlanksAs.Value = (int)value; }
}
[DV(Type = typeof(BlankType))]
public NEnum _displayBlanksAs = NEnum.NullValue(typeof(BlankType));
/// <summary>
/// Gets or sets whether XAxis Labels should be merged.
/// </summary>
public bool PivotChart
{
get { return _pivotChart.Value; }
set { _pivotChart.Value = value; }
}
[DV]
public NBool _pivotChart = NBool.NullValue;
/// <summary>
/// Gets the DataLabel of the chart.
/// </summary>
public DataLabel DataLabel
{
get { return _dataLabel ?? (_dataLabel = new DataLabel(this)); }
set
{
SetParent(value);
_dataLabel = value;
}
}
[DV]
public DataLabel _dataLabel;
/// <summary>
/// Gets or sets whether the chart has a DataLabel.
/// </summary>
public bool HasDataLabel
{
get { return _hasDataLabel.Value; }
set { _hasDataLabel.Value = value; }
}
[DV]
public NBool _hasDataLabel = NBool.NullValue;
#endregion
/// <summary>
/// Determines the type of the given axis.
/// </summary>
public string CheckAxis(Axis axis)
{
if ((_xAxis != null) && (axis == _xAxis))
return "xaxis";
if ((_yAxis != null) && (axis == _yAxis))
return "yaxis";
if ((_zAxis != null) && (axis == _zAxis))
return "zaxis";
return "";
}
/// <summary>
/// Determines the type of the given textarea.
/// </summary>
public string CheckTextArea(TextArea textArea)
{
if ((_headerArea != null) && (textArea == _headerArea))
return "headerarea";
if ((_footerArea != null) && (textArea == _footerArea))
return "footerarea";
if ((_leftArea != null) && (textArea == _leftArea))
return "leftarea";
if ((_rightArea != null) && (textArea == _rightArea))
return "rightarea";
if ((_topArea != null) && (textArea == _topArea))
return "toparea";
if ((_bottomArea != null) && (textArea == _bottomArea))
return "bottomarea";
return "";
}
#region public
/// <summary>
/// Converts Chart into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteLine("\\chart(" + Type + ")");
int pos = serializer.BeginAttributes();
base.Serialize(serializer);
if (!_displayBlanksAs.IsNull)
serializer.WriteSimpleAttribute("DisplayBlanksAs", DisplayBlanksAs);
if (!_pivotChart.IsNull)
serializer.WriteSimpleAttribute("PivotChart", PivotChart);
if (!_hasDataLabel.IsNull)
serializer.WriteSimpleAttribute("HasDataLabel", HasDataLabel);
if (!_style.IsNull)
serializer.WriteSimpleAttribute("Style", Style);
if (!IsNull("Format"))
_format.Serialize(serializer, "Format", null);
if (!IsNull("DataLabel"))
_dataLabel.Serialize(serializer);
serializer.EndAttributes(pos);
serializer.BeginContent();
if (!IsNull("PlotArea"))
_plotArea.Serialize(serializer);
if (!IsNull("HeaderArea"))
_headerArea.Serialize(serializer);
if (!IsNull("FooterArea"))
_footerArea.Serialize(serializer);
if (!IsNull("TopArea"))
_topArea.Serialize(serializer);
if (!IsNull("BottomArea"))
_bottomArea.Serialize(serializer);
if (!IsNull("LeftArea"))
_leftArea.Serialize(serializer);
if (!IsNull("RightArea"))
_rightArea.Serialize(serializer);
if (!IsNull("XAxis"))
_xAxis.Serialize(serializer);
if (!IsNull("YAxis"))
_yAxis.Serialize(serializer);
if (!IsNull("ZAxis"))
_zAxis.Serialize(serializer);
if (!IsNull("SeriesCollection"))
_seriesCollection.Serialize(serializer);
if (!IsNull("XValues"))
_xValues.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.VisitChart(this);
if (visitChildren)
{
if (_bottomArea != null)
((IVisitable)_bottomArea).AcceptVisitor(visitor, true);
if (_footerArea != null)
((IVisitable)_footerArea).AcceptVisitor(visitor, true);
if (_headerArea != null)
((IVisitable)_headerArea).AcceptVisitor(visitor, true);
if (_leftArea != null)
((IVisitable)_leftArea).AcceptVisitor(visitor, true);
if (_rightArea != null)
((IVisitable)_rightArea).AcceptVisitor(visitor, true);
if (_topArea != null)
((IVisitable)_topArea).AcceptVisitor(visitor, true);
}
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Chart))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,73 @@
#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.Shapes.Charts
{
/// <summary>
/// Base class for all chart classes.
/// </summary>
public class ChartObject : DocumentObject
{
/// <summary>
/// Initializes a new instance of the ChartObject class.
/// </summary>
public ChartObject()
{
}
/// <summary>
/// Initializes a new instance of the ChartObject class with the specified parent.
/// </summary>
public ChartObject(DocumentObject parent) : base(parent) { }
#region public
/// <summary>
/// Converts ChartObject into DDL.
/// </summary>
public override void Serialize(Serializer _serializer)
{
// Nothing to do
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(ChartObject))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,172 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents a DataLabel of a Series
/// </summary>
public class DataLabel : DocumentObject
{
/// <summary>
/// Initializes a new instance of the DataLabel class.
/// </summary>
public DataLabel()
{
}
/// <summary>
/// Initializes a new instance of the DataLabel class with the specified parent.
/// </summary>
public DataLabel(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new DataLabel Clone()
{
return (DataLabel)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
DataLabel dataLabel = (DataLabel)base.DeepCopy();
if (dataLabel._font != null)
{
dataLabel._font = dataLabel._font.Clone();
dataLabel._font._parent = dataLabel;
}
return dataLabel;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets a numeric format string for the DataLabel.
/// </summary>
public string Format
{
get { return _format.Value; }
set { _format.Value = value; }
}
[DV]
public NString _format = NString.NullValue;
/// <summary>
/// Gets the Font for the DataLabel.
/// </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 for the DataLabel.
/// Only the Font-associated part of the Style's ParagraphFormat is used.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets or sets the position of the DataLabel.
/// </summary>
public DataLabelPosition Position
{
get { return (DataLabelPosition)_position.Value; }
set { _position.Value = (int)value; }
}
[DV(Type = typeof(DataLabelPosition))]
public NEnum _position = NEnum.NullValue(typeof(DataLabelPosition));
/// <summary>
/// Gets or sets the type of the DataLabel.
/// </summary>
public DataLabelType Type
{
get { return (DataLabelType)_type.Value; }
set { _type.Value = (int)value; }
}
[DV(Type = typeof(DataLabelType))]
public NEnum _type = NEnum.NullValue(typeof(DataLabelType));
#endregion
#region public
/// <summary>
/// Converts DataLabel into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int pos = serializer.BeginContent("DataLabel");
if (Style != string.Empty)
serializer.WriteSimpleAttribute("Style", Style);
if (Format != string.Empty)
serializer.WriteSimpleAttribute("Format", Format);
if (!_position.IsNull)
serializer.WriteSimpleAttribute("Position", Position);
if (!_type.IsNull)
serializer.WriteSimpleAttribute("Type", Type);
if (!IsNull("Font"))
_font.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(DataLabel))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,121 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents the gridlines on the axes.
/// </summary>
public class Gridlines : ChartObject
{
/// <summary>
/// Initializes a new instance of the Gridlines class.
/// </summary>
public Gridlines()
{
}
/// <summary>
/// Initializes a new instance of the Gridlines class with the specified parent.
/// </summary>
public Gridlines(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Gridlines Clone()
{
return (Gridlines)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Gridlines gridlines = (Gridlines)base.DeepCopy();
if (gridlines._lineFormat != null)
{
gridlines._lineFormat = gridlines._lineFormat.Clone();
gridlines._lineFormat._parent = gridlines;
}
return gridlines;
}
#endregion
#region Properties
/// <summary>
/// Gets the line format of the grid.
/// </summary>
public LineFormat LineFormat
{
get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); }
set
{
SetParent(value);
_lineFormat = value;
}
}
[DV]
public LineFormat _lineFormat;
#endregion
#region public
/// <summary>
/// Converts Gridlines into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
Axis axisObject = _parent as Axis;
int pos = serializer.BeginContent(axisObject.CheckGridlines(this));
if (!IsNull("LineFormat"))
_lineFormat.Serialize(serializer);
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Gridlines))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,171 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents a legend of a chart.
/// </summary>
public class Legend : ChartObject, IVisitable
{
/// <summary>
/// Initializes a new instance of the Legend class.
/// </summary>
public Legend()
{ }
/// <summary>
/// Initializes a new instance of the Legend class with the specified parent.
/// </summary>
public Legend(DocumentObject parent) : base(parent) { }
#region Serialization
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Legend Clone()
{
return (Legend)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Legend legend = (Legend)base.DeepCopy();
if (legend._format != null)
{
legend._format = legend._format.Clone();
legend._format._parent = legend;
}
if (legend._lineFormat != null)
{
legend._lineFormat = legend._lineFormat.Clone();
legend._lineFormat._parent = legend;
}
return legend;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the style name of the legend's text.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets the paragraph format of the legend's text.
/// </summary>
public ParagraphFormat Format
{
get { return _format ?? (_format = new ParagraphFormat(this)); }
set
{
SetParent(value);
_format = value;
}
}
[DV]
public ParagraphFormat _format;
/// <summary>
/// Gets the line format of the legend's border.
/// </summary>
public LineFormat LineFormat
{
get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); }
set
{
SetParent(value);
_lineFormat = value;
}
}
[DV]
public LineFormat _lineFormat;
#endregion
#region public
/// <summary>
/// Converts Legend into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteLine("\\legend");
int pos = serializer.BeginAttributes();
if (!_style.IsNull)
serializer.WriteSimpleAttribute("Style", Style);
if (!IsNull("Format"))
_format.Serialize(serializer, "Format", null);
if (!IsNull("LineFormat"))
_lineFormat.Serialize(serializer);
serializer.EndAttributes(pos);
}
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
public override bool IsNull()
{
// legend objects are never null, i.e. the presence of this object is meaningful.
return false;
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Legend))); }
}
static Meta _meta;
#endregion
void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
{
visitor.VisitLegend(this);
}
}
}

View File

@@ -0,0 +1,198 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents the area where the actual chart is drawn.
/// </summary>
public class PlotArea : ChartObject
{
/// <summary>
/// Initializes a new instance of the PlotArea class.
/// </summary>
public PlotArea()
{
}
/// <summary>
/// Initializes a new instance of the PlotArea class with the specified parent.
/// </summary>
public PlotArea(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new PlotArea Clone()
{
return (PlotArea)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
PlotArea plotArea = (PlotArea)base.DeepCopy();
if (plotArea._lineFormat != null)
{
plotArea._lineFormat = plotArea._lineFormat.Clone();
plotArea._lineFormat._parent = plotArea;
}
if (plotArea._fillFormat != null)
{
plotArea._fillFormat = plotArea._fillFormat.Clone();
plotArea._fillFormat._parent = plotArea;
}
return plotArea;
}
#endregion
#region Properties
/// <summary>
/// Gets the line format of the plot area's border.
/// </summary>
public LineFormat LineFormat
{
get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); }
set
{
SetParent(value);
_lineFormat = value;
}
}
[DV]
public LineFormat _lineFormat;
/// <summary>
/// Gets the background filling of the plot area.
/// </summary>
public FillFormat FillFormat
{
get { return _fillFormat ?? (_fillFormat = new FillFormat(this)); }
set
{
SetParent(value);
_fillFormat = value;
}
}
[DV]
public FillFormat _fillFormat;
/// <summary>
/// Gets or sets the left padding of the area.
/// </summary>
public Unit LeftPadding
{
get { return _leftPadding; }
set { _leftPadding = value; }
}
[DV]
public Unit _leftPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the right padding of the area.
/// </summary>
public Unit RightPadding
{
get { return _rightPadding; }
set { _rightPadding = value; }
}
[DV]
public Unit _rightPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the top padding of the area.
/// </summary>
public Unit TopPadding
{
get { return _topPadding; }
set { _topPadding = value; }
}
[DV]
public Unit _topPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the bottom padding of the area.
/// </summary>
public Unit BottomPadding
{
get { return _bottomPadding; }
set { _bottomPadding = value; }
}
[DV]
public Unit _bottomPadding = Unit.NullValue;
#endregion
#region public
/// <summary>
/// Converts PlotArea into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteLine("\\plotarea");
int pos = serializer.BeginAttributes();
if (!_topPadding.IsNull)
serializer.WriteSimpleAttribute("TopPadding", TopPadding);
if (!_leftPadding.IsNull)
serializer.WriteSimpleAttribute("LeftPadding", LeftPadding);
if (!_rightPadding.IsNull)
serializer.WriteSimpleAttribute("RightPadding", RightPadding);
if (!_bottomPadding.IsNull)
serializer.WriteSimpleAttribute("BottomPadding", BottomPadding);
if (!IsNull("LineFormat"))
_lineFormat.Serialize(serializer);
if (!IsNull("FillFormat"))
_fillFormat.Serialize(serializer);
serializer.EndAttributes(pos);
serializer.BeginContent();
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(PlotArea))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,167 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents a formatted value on the data series.
/// </summary>
public class Point : ChartObject
{
/// <summary>
/// Initializes a new instance of the Point class.
/// </summary>
public Point()
{ }
/// <summary>
/// Initializes a new instance of the Point class with a real value.
/// </summary>
public Point(double value)
: this()
{
Value = value;
}
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Point Clone()
{
return (Point)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Point point = (Point)base.DeepCopy();
if (point._lineFormat != null)
{
point._lineFormat = point._lineFormat.Clone();
point._lineFormat._parent = point;
}
if (point._fillFormat != null)
{
point._fillFormat = point._fillFormat.Clone();
point._fillFormat._parent = point;
}
return point;
}
#endregion
#region Properties
/// <summary>
/// Gets the line format of the data point's border.
/// </summary>
public LineFormat LineFormat
{
get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); }
set
{
SetParent(value);
_lineFormat = value;
}
}
[DV]
public LineFormat _lineFormat;
/// <summary>
/// Gets the filling format of the data point.
/// </summary>
public FillFormat FillFormat
{
get { return _fillFormat ?? (_fillFormat = new FillFormat(this)); }
set
{
SetParent(value);
_fillFormat = value;
}
}
[DV]
public FillFormat _fillFormat;
/// <summary>
/// The actual value of the data point.
/// </summary>
public double Value
{
get { return _value.Value; }
set { _value.Value = value; }
}
[DV]
public NDouble _value = NDouble.NullValue;
#endregion
#region public
/// <summary>
/// Converts Point into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
if (!IsNull("LineFormat") || !IsNull("FillFormat"))
{
serializer.WriteLine("");
serializer.WriteLine("\\point");
int pos = serializer.BeginAttributes();
if (!IsNull("LineFormat"))
_lineFormat.Serialize(serializer);
if (!IsNull("FillFormat"))
_fillFormat.Serialize(serializer);
serializer.EndAttributes(pos);
serializer.BeginContent();
serializer.WriteLine(Value.ToString(System.Globalization.CultureInfo.InvariantCulture));
serializer.EndContent();
}
else
serializer.Write(Value.ToString(System.Globalization.CultureInfo.InvariantCulture));
serializer.Write(", ");
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Point))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,318 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents a series of data on the chart.
/// </summary>
public class Series : ChartObject
{
/// <summary>
/// Initializes a new instance of the Series class.
/// </summary>
public Series()
{ }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Series Clone()
{
return (Series)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Series series = (Series)base.DeepCopy();
if (series._seriesElements != null)
{
series._seriesElements = series._seriesElements.Clone();
series._seriesElements._parent = series;
}
if (series._lineFormat != null)
{
series._lineFormat = series._lineFormat.Clone();
series._lineFormat._parent = series;
}
if (series._fillFormat != null)
{
series._fillFormat = series._fillFormat.Clone();
series._fillFormat._parent = series;
}
if (series._dataLabel != null)
{
series._dataLabel = series._dataLabel.Clone();
series._dataLabel._parent = series;
}
return series;
}
/// <summary>
/// Adds a blank to the series.
/// </summary>
public void AddBlank()
{
Elements.AddBlank();
}
/// <summary>
/// Adds a real value to the series.
/// </summary>
public Point Add(double value)
{
return Elements.Add(value);
}
/// <summary>
/// Adds an array of real values to the series.
/// </summary>
public void Add(params double[] values)
{
Elements.Add(values);
}
#endregion
#region Properties
/// <summary>
/// The actual value container of the series.
/// </summary>
public SeriesElements Elements
{
get { return _seriesElements ?? (_seriesElements = new SeriesElements(this)); }
set
{
SetParent(value);
_seriesElements = value;
}
}
[DV]
public SeriesElements _seriesElements;
/// <summary>
/// Gets or sets the name of the series which will be used in the legend.
/// </summary>
public string Name
{
get { return _name.Value; }
set { _name.Value = value; }
}
[DV]
public NString _name = NString.NullValue;
/// <summary>
/// Gets the line format of the border of each data.
/// </summary>
public LineFormat LineFormat
{
get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); }
set
{
SetParent(value);
_lineFormat = value;
}
}
[DV]
public LineFormat _lineFormat;
/// <summary>
/// Gets the background filling of the data.
/// </summary>
public FillFormat FillFormat
{
get { return _fillFormat ?? (_fillFormat = new FillFormat(this)); }
set
{
SetParent(value);
_fillFormat = value;
}
}
[DV]
public FillFormat _fillFormat;
/// <summary>
/// Gets or sets the size of the marker in a line chart.
/// </summary>
public Unit MarkerSize
{
get { return _markerSize; }
set { _markerSize = value; }
}
[DV]
public Unit _markerSize = Unit.NullValue;
/// <summary>
/// Gets or sets the style of the marker in a line chart.
/// </summary>
public MarkerStyle MarkerStyle
{
get { return (MarkerStyle)_markerStyle.Value; }
set { _markerStyle.Value = (int)value; }
}
[DV(Type = typeof(MarkerStyle))]
public NEnum _markerStyle = NEnum.NullValue(typeof(MarkerStyle));
/// <summary>
/// Gets or sets the foreground color of the marker in a line chart.
/// </summary>
public Color MarkerForegroundColor
{
get { return _markerForegroundColor; }
set { _markerForegroundColor = value; }
}
[DV]
public Color _markerForegroundColor = Color.Empty;
/// <summary>
/// Gets or sets the background color of the marker in a line chart.
/// </summary>
public Color MarkerBackgroundColor
{
get { return _markerBackgroundColor; }
set { _markerBackgroundColor = value; }
}
[DV]
public Color _markerBackgroundColor = Color.Empty;
/// <summary>
/// Gets or sets the chart type of the series if it's intended to be different than the global chart type.
/// </summary>
public ChartType ChartType
{
get { return (ChartType)_chartType.Value; }
set { _chartType.Value = (int)value; }
}
[DV(Type = typeof(ChartType))]
public NEnum _chartType = NEnum.NullValue(typeof(ChartType));
/// <summary>
/// Gets the DataLabel of the series.
/// </summary>
public DataLabel DataLabel
{
get { return _dataLabel ?? (_dataLabel = new DataLabel(this)); }
set
{
SetParent(value);
_dataLabel = value;
}
}
[DV]
public DataLabel _dataLabel;
/// <summary>
/// Gets or sets whether the series has a DataLabel.
/// </summary>
public bool HasDataLabel
{
get { return _hasDataLabel.Value; }
set { _hasDataLabel.Value = value; }
}
[DV]
public NBool _hasDataLabel = NBool.NullValue;
/// <summary>
/// Gets the elementcount of the series.
/// </summary>
public int Count
{
get
{
if (_seriesElements != null)
return _seriesElements.Count;
return 0;
}
}
#endregion
#region public
/// <summary>
/// Converts Series into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteLine("\\series");
int pos = serializer.BeginAttributes();
if (!_name.IsNull)
serializer.WriteSimpleAttribute("Name", Name);
if (!_markerSize.IsNull)
serializer.WriteSimpleAttribute("MarkerSize", MarkerSize);
if (!_markerStyle.IsNull)
serializer.WriteSimpleAttribute("MarkerStyle", MarkerStyle);
if (!_markerBackgroundColor.IsNull)
serializer.WriteSimpleAttribute("MarkerBackgroundColor", MarkerBackgroundColor);
if (!_markerForegroundColor.IsNull)
serializer.WriteSimpleAttribute("MarkerForegroundColor", MarkerForegroundColor);
if (!_chartType.IsNull)
serializer.WriteSimpleAttribute("ChartType", ChartType);
if (!_hasDataLabel.IsNull)
serializer.WriteSimpleAttribute("HasDataLabel", HasDataLabel);
if (!IsNull("LineFormat"))
_lineFormat.Serialize(serializer);
if (!IsNull("FillFormat"))
_fillFormat.Serialize(serializer);
if (!IsNull("DataLabel"))
_dataLabel.Serialize(serializer);
serializer.EndAttributes(pos);
serializer.BeginContent();
_seriesElements.Serialize(serializer);
serializer.WriteLine("");
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Series))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,106 @@
#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.Shapes.Charts
{
/// <summary>
/// The collection of data series.
/// </summary>
public class SeriesCollection : DocumentObjectCollection
{
/// <summary>
/// Initializes a new instance of the SeriesCollection class.
/// </summary>
public SeriesCollection()
{
}
/// <summary>
/// Initializes a new instance of the SeriesCollection class with the specified parent.
/// </summary>
public SeriesCollection(DocumentObject parent) : base(parent) { }
/// <summary>
/// Gets a series by its index.
/// </summary>
public new Series this[int index]
{
get { return base[index] as Series; }
}
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new SeriesCollection Clone()
{
return (SeriesCollection)DeepCopy();
}
/// <summary>
/// Adds a new series to the collection.
/// </summary>
public Series AddSeries()
{
Series series = new Series();
Add(series);
return series;
}
#endregion
#region public
/// <summary>
/// Converts SeriesCollection into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int count = Count;
for (int index = 0; index < count; ++index)
{
Series series = this[index];
series.Serialize(serializer);
}
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(SeriesCollection))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,117 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents the collection of the values in a data series.
/// </summary>
public class SeriesElements : DocumentObjectCollection
{
/// <summary>
/// Initializes a new instance of the SeriesElements class.
/// </summary>
public SeriesElements()
{ }
/// <summary>
/// Initializes a new instance of the SeriesElements class with the specified parent.
/// </summary>
public SeriesElements(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new SeriesElements Clone()
{
return (SeriesElements)DeepCopy();
}
/// <summary>
/// Adds a blank to the series.
/// </summary>
public void AddBlank()
{
base.Add(null);
}
/// <summary>
/// Adds a new point with a real value to the series.
/// </summary>
public Point Add(double value)
{
Point point = new Point(value);
Add(point);
return point;
}
/// <summary>
/// Adds an array of new points with real values to the series.
/// </summary>
public void Add(params double[] values)
{
foreach (double val in values)
Add(val);
}
#endregion
#region public
/// <summary>
/// Converts SeriesElements into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int count = Count;
for (int index = 0; index < count; ++index)
{
Point point = this[index] as Point;
if (point == null)
serializer.Write("null, ");
else
point.Serialize(serializer);
}
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(SeriesElements))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,379 @@
#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.Tables;
using MigraDoc.DocumentObjectModel.Visitors;
namespace MigraDoc.DocumentObjectModel.Shapes.Charts
{
/// <summary>
/// An area object in the chart which contain text or legend.
/// </summary>
public class TextArea : ChartObject, IVisitable
{
/// <summary>
/// Initializes a new instance of the TextArea class.
/// </summary>
public TextArea()
{ }
/// <summary>
/// Initializes a new instance of the TextArea class with the specified parent.
/// </summary>
public TextArea(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new TextArea Clone()
{
return (TextArea)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
TextArea textArea = (TextArea)base.DeepCopy();
if (textArea._format != null)
{
textArea._format = textArea._format.Clone();
textArea._format._parent = textArea;
}
if (textArea._lineFormat != null)
{
textArea._lineFormat = textArea._lineFormat.Clone();
textArea._lineFormat._parent = textArea;
}
if (textArea._fillFormat != null)
{
textArea._fillFormat = textArea._fillFormat.Clone();
textArea._fillFormat._parent = textArea;
}
if (textArea._elements != null)
{
textArea._elements = textArea._elements.Clone();
textArea._elements._parent = textArea;
}
return textArea;
}
/// <summary>
/// Adds a new paragraph to the text area.
/// </summary>
public Paragraph AddParagraph()
{
return Elements.AddParagraph();
}
/// <summary>
/// Adds a new paragraph with the specified text to the text area.
/// </summary>
public Paragraph AddParagraph(string paragraphText)
{
return Elements.AddParagraph(paragraphText);
}
/// <summary>
/// Adds a new table to the text area.
/// </summary>
public Table AddTable()
{
return Elements.AddTable();
}
/// <summary>
/// Adds a new Image to the text area.
/// </summary>
public Image AddImage(string fileName)
{
return Elements.AddImage(fileName);
}
/// <summary>
/// Adds a new legend to the text area.
/// </summary>
public Legend AddLegend()
{
return Elements.AddLegend();
}
/// <summary>
/// Adds a new paragraph to the text area.
/// </summary>
public void Add(Paragraph paragraph)
{
Elements.Add(paragraph);
}
/// <summary>
/// Adds a new table to the text area.
/// </summary>
public void Add(Table table)
{
Elements.Add(table);
}
/// <summary>
/// Adds a new image to the text area.
/// </summary>
public void Add(Image image)
{
Elements.Add(image);
}
/// <summary>
/// Adds a new legend to the text area.
/// </summary>
public void Add(Legend legend)
{
Elements.Add(legend);
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the height of the area.
/// </summary>
public Unit Height
{
get { return _height; }
set { _height = value; }
}
[DV]
public Unit _height = Unit.NullValue;
/// <summary>
/// Gets or sets the width of the area.
/// </summary>
public Unit Width
{
get { return _width; }
set { _width = value; }
}
[DV]
public Unit _width = Unit.NullValue;
/// <summary>
/// Gets or sets the default style name of the area.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets or sets the default paragraph format of the area.
/// </summary>
public ParagraphFormat Format
{
get { return _format ?? (_format = new ParagraphFormat(this)); }
set
{
SetParent(value);
_format = value;
}
}
[DV]
public ParagraphFormat _format;
/// <summary>
/// Gets the line format of the area's border.
/// </summary>
public LineFormat LineFormat
{
get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); }
set
{
SetParent(value);
_lineFormat = value;
}
}
[DV]
public LineFormat _lineFormat;
/// <summary>
/// Gets the background filling of the area.
/// </summary>
public FillFormat FillFormat
{
get { return _fillFormat ?? (_fillFormat = new FillFormat(this)); }
set
{
SetParent(value);
_fillFormat = value;
}
}
[DV]
public FillFormat _fillFormat;
/// <summary>
/// Gets or sets the left padding of the area.
/// </summary>
public Unit LeftPadding
{
get { return _leftPadding; }
set { _leftPadding = value; }
}
[DV]
public Unit _leftPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the right padding of the area.
/// </summary>
public Unit RightPadding
{
get { return _rightPadding; }
set { _rightPadding = value; }
}
[DV]
public Unit _rightPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the top padding of the area.
/// </summary>
public Unit TopPadding
{
get { return _topPadding; }
set { _topPadding = value; }
}
[DV]
public Unit _topPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the bottom padding of the area.
/// </summary>
public Unit BottomPadding
{
get { return _bottomPadding; }
set { _bottomPadding = value; }
}
[DV]
public Unit _bottomPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the Vertical alignment of the area.
/// </summary>
public VerticalAlignment VerticalAlignment
{
get { return (VerticalAlignment)_verticalAlignment.Value; }
set { _verticalAlignment.Value = (int)value; }
}
[DV(Type = typeof(VerticalAlignment))]
public NEnum _verticalAlignment = NEnum.NullValue(typeof(VerticalAlignment));
/// <summary>
/// Gets the document objects that creates the text area.
/// </summary>
public DocumentElements Elements
{
get { return _elements ?? (_elements = new DocumentElements(this)); }
set
{
SetParent(value);
_elements = value;
}
}
[DV(ItemType = typeof(DocumentObject))]
public DocumentElements _elements;
#endregion
#region public
/// <summary>
/// Converts TextArea into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
Chart chartObject = _parent as Chart;
serializer.WriteLine("\\" + chartObject.CheckTextArea(this));
int pos = serializer.BeginAttributes();
if (!_style.IsNull)
serializer.WriteSimpleAttribute("Style", Style);
if (!IsNull("Format"))
_format.Serialize(serializer, "Format", null);
if (!_topPadding.IsNull)
serializer.WriteSimpleAttribute("TopPadding", TopPadding);
if (!_leftPadding.IsNull)
serializer.WriteSimpleAttribute("LeftPadding", LeftPadding);
if (!_rightPadding.IsNull)
serializer.WriteSimpleAttribute("RightPadding", RightPadding);
if (!_bottomPadding.IsNull)
serializer.WriteSimpleAttribute("BottomPadding", BottomPadding);
if (!_width.IsNull)
serializer.WriteSimpleAttribute("Width", Width);
if (!_height.IsNull)
serializer.WriteSimpleAttribute("Height", Height);
if (!_verticalAlignment.IsNull)
serializer.WriteSimpleAttribute("VerticalAlignment", VerticalAlignment);
if (!IsNull("LineFormat"))
_lineFormat.Serialize(serializer);
if (!IsNull("FillFormat"))
_fillFormat.Serialize(serializer);
serializer.EndAttributes(pos);
serializer.BeginContent();
if (_elements != null)
_elements.Serialize(serializer);
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(TextArea))); }
}
static Meta _meta;
#endregion
void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
{
visitor.VisitTextArea(this);
if (_elements != null && visitChildren)
((IVisitable)_elements).AcceptVisitor(visitor, visitChildren);
}
}
}

View File

@@ -0,0 +1,146 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents the format of the label of each value on the axis.
/// </summary>
public class TickLabels : ChartObject
{
/// <summary>
/// Initializes a new instance of the TickLabels class.
/// </summary>
public TickLabels()
{ }
/// <summary>
/// Initializes a new instance of the TickLabels class with the specified parent.
/// </summary>
public TickLabels(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new TickLabels Clone()
{
return (TickLabels)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
TickLabels tickLabels = (TickLabels)base.DeepCopy();
if (tickLabels._font != null)
{
tickLabels._font = tickLabels._font.Clone();
tickLabels._font._parent = tickLabels;
}
return tickLabels;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the style name of the label.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets or sets the label's number format.
/// </summary>
public string Format
{
get { return _format.Value; }
set { _format.Value = value; }
}
[DV]
public NString _format = NString.NullValue;
/// <summary>
/// Gets the font of the label.
/// </summary>
public Font Font
{
get { return _font ?? (_font = new Font(this)); }
set
{
SetParent(value);
_font = value;
}
}
[DV]
public Font _font;
#endregion
#region public
/// <summary>
/// Converts TickLabels into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int pos = serializer.BeginContent("TickLabels");
if (!_style.IsNull)
serializer.WriteSimpleAttribute("Style", Style);
if (_font != null)
_font.Serialize(serializer);
if (!_format.IsNull)
serializer.WriteSimpleAttribute("Format", Format);
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(TickLabels))); }
}
static Meta _meta;
#endregion
}
}

View 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 MigraDoc.DocumentObjectModel.publics;
namespace MigraDoc.DocumentObjectModel.Shapes.Charts
{
/// <summary>
/// Represents a series of data on the X-Axis.
/// </summary>
public class XSeries : ChartObject
{
/// <summary>
/// Initializes a new instance of the XSeries class.
/// </summary>
public XSeries()
{
_xSeriesElements = new XSeriesElements();
}
/// <summary>
/// The actual value container of the XSeries.
/// </summary>
[DV]
public XSeriesElements _xSeriesElements;
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new XSeries Clone()
{
return (XSeries)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
XSeries xSeries = (XSeries)base.DeepCopy();
if (xSeries._xSeriesElements != null)
{
xSeries._xSeriesElements = xSeries._xSeriesElements.Clone();
xSeries._xSeriesElements._parent = xSeries;
}
return xSeries;
}
/// <summary>
/// Adds a blank to the XSeries.
/// </summary>
public void AddBlank()
{
_xSeriesElements.AddBlank();
}
/// <summary>
/// Adds a value to the XSeries.
/// </summary>
public XValue Add(string value)
{
return _xSeriesElements.Add(value);
}
/// <summary>
/// Adds an array of values to the XSeries.
/// </summary>
public void Add(params string[] values)
{
_xSeriesElements.Add(values);
}
#endregion
#region public
/// <summary>
/// Converts XSeries into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteLine("\\xvalues");
serializer.BeginContent();
_xSeriesElements.Serialize(serializer);
serializer.WriteLine("");
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(XSeries))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,112 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents the collection of the value in an XSeries.
/// </summary>
public class XSeriesElements : DocumentObjectCollection
{
/// <summary>
/// Initializes a new instance of the XSeriesElements class.
/// </summary>
public XSeriesElements()
{ }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new XSeriesElements Clone()
{
return (XSeriesElements)base.DeepCopy();
}
/// <summary>
/// Adds a blank to the XSeries.
/// </summary>
public void AddBlank()
{
base.Add(null);
}
/// <summary>
/// Adds a value to the XSeries.
/// </summary>
public XValue Add(string value)
{
XValue xValue = new XValue(value);
Add(xValue);
return xValue;
}
/// <summary>
/// Adds an array of values to the XSeries.
/// </summary>
public void Add(params string[] values)
{
foreach (string val in values)
Add(val);
}
#endregion
#region public
/// <summary>
/// Converts XSeriesElements into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int count = Count;
for (int index = 0; index < count; index++)
{
XValue xValue = this[index] as XValue;
if (xValue == null)
serializer.Write("null, ");
else
xValue.Serialize(serializer);
}
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(XSeriesElements))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -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
using System;
using MigraDoc.DocumentObjectModel.publics;
namespace MigraDoc.DocumentObjectModel.Shapes.Charts
{
/// <summary>
/// Represents the actual value on the XSeries.
/// </summary>
public class XValue : ChartObject
{
/// <summary>
/// Initializes a new instance of the XValue class.
/// </summary>
public XValue()
{ }
/// <summary>
/// Initializes a new instance of the XValue class with the specified value.
/// </summary>
public XValue(string value)
: this()
{
if (value == null)
throw new ArgumentNullException("value");
Value = value;
}
/// <summary>
/// The actual value of the XValue.
/// </summary>
[DV] // No Get- and Set -Property.
public string Value;
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new XValue Clone()
{
return (XValue)DeepCopy();
}
#endregion
#region public
/// <summary>
/// Converts XValue into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.Write("\"" + Value + "\", ");
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(XValue))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,106 @@
#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.Shapes.Charts
{
/// <summary>
/// Represents the collection of values on the X-Axis.
/// </summary>
public class XValues : DocumentObjectCollection
{
/// <summary>
/// Initializes a new instance of the XValues class.
/// </summary>
public XValues()
{
}
/// <summary>
/// Initializes a new instance of the XValues class with the specified parent.
/// </summary>
public XValues(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new XValues Clone()
{
return (XValues)DeepCopy();
}
/// <summary>
/// Gets an XSeries by its index.
/// </summary>
public new XSeries this[int index]
{
get { return base[index] as XSeries; }
}
/// <summary>
/// Adds a new XSeries to the collection.
/// </summary>
public XSeries AddXSeries()
{
XSeries xSeries = new XSeries();
Add(xSeries);
return xSeries;
}
#endregion
#region public
/// <summary>
/// Converts XValues into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int count = Count;
for (int index = 0; index < count; ++index)
{
XSeries xSeries = this[index] as XSeries;
xSeries.Serialize(serializer);
}
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(XValues))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -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.Shapes.Charts
{
/// <summary>
/// Determines how null values will be handled in a chart.
/// </summary>
public enum BlankType
{
/// <summary>
/// Null value is not plotted.
/// </summary>
NotPlotted,
/// <summary>
/// Null value will be interpolated.
/// </summary>
Interpolated,
/// <summary>
/// Null value will be handled as zero.
/// </summary>
Zero
}
}

View File

@@ -0,0 +1,80 @@
#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.Shapes.Charts
{
/// <summary>
/// Specifies with type of chart will be drawn.
/// </summary>
public enum ChartType
{
/// <summary>
/// A line chart.
/// </summary>
Line,
/// <summary>
/// A clustered 2d column chart.
/// </summary>
Column2D,
/// <summary>
/// A stacked 2d column chart.
/// </summary>
ColumnStacked2D,
/// <summary>
/// A 2d area chart.
/// </summary>
Area2D,
/// <summary>
/// A clustered 2d bar chart.
/// </summary>
Bar2D,
/// <summary>
/// A stacked 2d bar chart.
/// </summary>
BarStacked2D,
/// <summary>
/// A 2d pie chart.
/// </summary>
Pie2D,
/// <summary>
/// An exploded 2d pie chart.
/// </summary>
PieExploded2D,
}
}

View File

@@ -0,0 +1,60 @@
#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.Shapes.Charts
{
/// <summary>
/// Determines where the data label will be positioned.
/// </summary>
public enum DataLabelPosition
{
/// <summary>
/// DataLabel will be centered inside the bar or pie.
/// </summary>
Center,
/// <summary>
/// Inside the bar or pie at the origin.
/// </summary>
InsideBase,
/// <summary>
/// Inside the bar or pie at the edge.
/// </summary>
InsideEnd,
/// <summary>
/// Outside the bar or pie.
/// </summary>
OutsideEnd
}
}

View File

@@ -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.Shapes.Charts
{
/// <summary>
/// Determines the type of the data label.
/// </summary>
public enum DataLabelType
{
/// <summary>
/// No DataLabel.
/// </summary>
None,
/// <summary>
/// Percentage of the data. For pie charts only.
/// </summary>
Percent,
/// <summary>
/// Value of the data.
/// </summary>
Value
}
}

View File

@@ -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
namespace MigraDoc.DocumentObjectModel.Shapes.Charts
{
/// <summary>
/// Used to determine the horizontal alignment of the axis title.
/// </summary>
public enum HorizontalAlignment
{
/// <summary>
/// Axis title will be left aligned.
/// </summary>
Left,
/// <summary>
/// Axis title will be right aligned.
/// </summary>
Right,
/// <summary>
/// Axis title will be centered.
/// </summary>
Center
}
}

View File

@@ -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.Shapes.Charts
{
/// <summary>
/// Symbols of a data point in a line chart.
/// </summary>
public enum MarkerStyle
{
None,
Circle,
Dash,
Diamond,
Dot,
Plus,
Square,
Star,
Triangle,
X
}
}

View File

@@ -0,0 +1,60 @@
#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.Shapes.Charts
{
/// <summary>
/// Determines the position where the Tickmarks will be rendered.
/// </summary>
public enum TickMarkType
{
/// <summary>
/// Tickmarks are not rendered.
/// </summary>
None,
/// <summary>
/// Tickmarks are rendered inside the plot area.
/// </summary>
Inside,
/// <summary>
/// Tickmarks are rendered outside the plot area.
/// </summary>
Outside,
/// <summary>
/// Tickmarks are rendered inside and outside the plot area.
/// </summary>
Cross
}
}

View File

@@ -0,0 +1,197 @@
#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.Shapes
{
/// <summary>
/// Represents a barcode in the document or paragraph. !!!Still under Construction!!!
/// </summary>
public class Barcode : Shape
{
/// <summary>
/// Initializes a new instance of the Barcode class.
/// </summary>
public Barcode()
{ }
/// <summary>
/// Initializes a new instance of the Barcode class with the specified parent.
/// </summary>
public Barcode(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Barcode Clone()
{
return (Barcode)DeepCopy();
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the text orientation for the barcode content.
/// </summary>
public TextOrientation Orientation
{
get { return (TextOrientation)_orientation.Value; }
set { _orientation.Value = (int)value; }
}
[DV(Type = typeof(TextOrientation))]
public NEnum _orientation = NEnum.NullValue(typeof(TextOrientation));
/// <summary>
/// Gets or sets the type of the barcode.
/// </summary>
public BarcodeType Type
{
get { return (BarcodeType)_type.Value; }
set { _type.Value = (int)value; }
}
[DV(Type = typeof(BarcodeType))]
public NEnum _type = NEnum.NullValue(typeof(BarcodeType));
/// <summary>
/// Gets or sets a value indicating whether bars shall appear beside the barcode
/// </summary>
public bool BearerBars
{
get { return _bearerBars.Value; }
set { _bearerBars.Value = value; }
}
[DV]
public NBool _bearerBars = NBool.NullValue;
/// <summary>
/// Gets or sets the a value indicating whether the barcode's code is rendered.
/// </summary>
public bool Text
{
get { return _text.Value; }
set { _text.Value = value; }
}
[DV]
public NBool _text = NBool.NullValue;
/// <summary>
/// Gets or sets code the barcode represents.
/// </summary>
public string Code
{
get { return _code.Value; }
set { _code.Value = value; }
}
[DV]
public NString _code = NString.NullValue;
/// <summary>
/// ???
/// </summary>
public double LineRatio
{
get { return _lineRatio.Value; }
set { _lineRatio.Value = value; }
}
[DV]
public NDouble _lineRatio = NDouble.NullValue;
/// <summary>
/// ???
/// </summary>
public double LineHeight
{
get { return _lineHeight.Value; }
set { _lineHeight.Value = value; }
}
[DV]
public NDouble _lineHeight = NDouble.NullValue;
/// <summary>
/// ???
/// </summary>
public double NarrowLineWidth
{
get { return _narrowLineWidth.Value; }
set { _narrowLineWidth.Value = value; }
}
[DV]
public NDouble _narrowLineWidth = NDouble.NullValue;
#endregion
#region public
/// <summary>
/// Converts Barcode into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
if (_code.Value == "")
throw new InvalidOperationException(DomSR.MissingObligatoryProperty("Name", "BookmarkField"));
serializer.WriteLine("\\barcode(\"" + Code + "\")");
int pos = serializer.BeginAttributes();
base.Serialize(serializer);
if (!_orientation.IsNull)
serializer.WriteSimpleAttribute("Orientation", Orientation);
if (!_bearerBars.IsNull)
serializer.WriteSimpleAttribute("BearerBars", BearerBars);
if (!_text.IsNull)
serializer.WriteSimpleAttribute("Text", Text);
if (!_type.IsNull)
serializer.WriteSimpleAttribute("Type", Type);
if (!_lineRatio.IsNull)
serializer.WriteSimpleAttribute("LineRatio", LineRatio);
if (!_lineHeight.IsNull)
serializer.WriteSimpleAttribute("LineHeight", LineHeight);
if (!_narrowLineWidth.IsNull)
serializer.WriteSimpleAttribute("NarrowLineWidth", NarrowLineWidth);
serializer.EndAttributes(pos);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Barcode))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,111 @@
#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.Shapes
{
/// <summary>
/// Defines the background filling of the shape.
/// </summary>
public class FillFormat : DocumentObject
{
/// <summary>
/// Initializes a new instance of the FillFormat class.
/// </summary>
public FillFormat()
{ }
/// <summary>
/// Initializes a new instance of the FillFormat class with the specified parent.
/// </summary>
public FillFormat(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new FillFormat Clone()
{
return (FillFormat)DeepCopy();
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the color of the filling.
/// </summary>
public Color Color
{
get { return _color; }
set { _color = value; }
}
[DV]
public Color _color = Color.Empty;
/// <summary>
/// Gets or sets a value indicating whether the background color should be visible.
/// </summary>
public bool Visible
{
get { return _visible.Value; }
set { _visible.Value = value; }
}
[DV]
public NBool _visible = NBool.NullValue;
#endregion
#region public
/// <summary>
/// Converts FillFormat into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.BeginContent("FillFormat");
if (!_visible.IsNull)
serializer.WriteSimpleAttribute("Visible", Visible);
if (!_color.IsNull)
serializer.WriteSimpleAttribute("Color", Color);
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(FillFormat))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,236 @@
#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.IO;
using MigraDoc.DocumentObjectModel.publics;
namespace MigraDoc.DocumentObjectModel.Shapes
{
/// <summary>
/// Represents an image in the document or paragraph.
/// </summary>
public class Image : Shape
{
/// <summary>
/// Initializes a new instance of the Image class.
/// </summary>
public Image()
{ }
/// <summary>
/// Initializes a new instance of the Image class with the specified parent.
/// </summary>
public Image(DocumentObject parent) : base(parent) { }
/// <summary>
/// Initializes a new instance of the Image class from the specified (file) name.
/// </summary>
public Image(string name)
: this()
{
Name = name;
}
//#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Image Clone()
{
return (Image)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Image image = (Image)base.DeepCopy();
if (image._pictureFormat != null)
{
image._pictureFormat = image._pictureFormat.Clone();
image._pictureFormat._parent = image;
}
return image;
}
//#endregion
//#region Properties
/// <summary>
/// Gets or sets the name of the image.
/// </summary>
public string Name
{
get { return _name.Value; }
set { _name.Value = value; }
}
[DV]
public NString _name = NString.NullValue;
/// <summary>
/// Gets or sets the ScaleWidth of the image.
/// If the Width is set to, the resulting image width is ScaleWidth * Width.
/// </summary>
public double ScaleWidth
{
get { return _scaleWidth.Value; }
set { _scaleWidth.Value = value; }
}
[DV]
public NDouble _scaleWidth = NDouble.NullValue;
/// <summary>
/// Gets or sets the ScaleHeight of the image.
/// If the Height is set too, the resulting image height is ScaleHeight * Height.
/// </summary>
public double ScaleHeight
{
get { return _scaleHeight.Value; }
set { _scaleHeight.Value = value; }
}
[DV]
public NDouble _scaleHeight = NDouble.NullValue;
/// <summary>
/// Gets or sets whether the AspectRatio of the image is kept unchanged.
/// If both Width and Height are set, this property is ignored.
/// </summary>
public bool LockAspectRatio
{
get { return _lockAspectRatio.Value; }
set { _lockAspectRatio.Value = value; }
}
[DV]
public NBool _lockAspectRatio = NBool.NullValue;
/// <summary>
/// Gets or sets the PictureFormat for the image
/// </summary>
public PictureFormat PictureFormat
{
get { return _pictureFormat ?? (_pictureFormat = new PictureFormat(this)); }
set
{
SetParent(value);
_pictureFormat = value;
}
}
[DV]
public PictureFormat _pictureFormat;
/// <summary>
/// Gets or sets a user defined resolution for the image in dots per inch.
/// </summary>
public double Resolution
{
get { return _resolution.Value; }
set { _resolution.Value = value; }
}
[DV]
public NDouble _resolution = NDouble.NullValue;
//#endregion
#region public
/// <summary>
/// Converts Image into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteLine("\\image(\"" + _name.Value.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\")");
int pos = serializer.BeginAttributes();
base.Serialize(serializer);
if (!_scaleWidth.IsNull)
serializer.WriteSimpleAttribute("ScaleWidth", ScaleWidth);
if (!_scaleHeight.IsNull)
serializer.WriteSimpleAttribute("ScaleHeight", ScaleHeight);
if (!_lockAspectRatio.IsNull)
serializer.WriteSimpleAttribute("LockAspectRatio", LockAspectRatio);
if (!_resolution.IsNull)
serializer.WriteSimpleAttribute("Resolution", Resolution);
if (!IsNull("PictureFormat"))
_pictureFormat.Serialize(serializer);
serializer.EndAttributes(pos);
}
/// <summary>
/// Gets the concrete image path, taking into account the DOM document's DdlFile and
/// ImagePath properties as well as the given working directory (which can be null).
/// </summary>
public string GetFilePath(string workingDir)
{
if (Name.StartsWith("base64:")) // The file is stored in the string here, so we don't have to add a path.
return Name;
string filePath;
#if !NETFX_CORE
if (!String.IsNullOrEmpty(workingDir))
filePath = workingDir;
else
filePath = Directory.GetCurrentDirectory() + "\\";
#else
throw new NotImplementedException();
//if (!String.IsNullOrEmpty(workingDir))
// filePath = workingDir;
//else
// filePath = Directory.GetCurrentDirectory() + "\\";
#endif
if (!Document.IsNull("ImagePath"))
{
string foundfile = ImageHelper.GetImageName(filePath, Name, Document.ImagePath);
if (foundfile != null)
filePath = foundfile;
else
filePath = Path.Combine(filePath, Name);
}
else
filePath = Path.Combine(filePath, Name);
return filePath;
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Image))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,244 @@
#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.Shapes
{
/// <summary>
/// Represents the left position in a shape.
/// </summary>
public struct LeftPosition : INullableValue
{
/// <summary>
/// Initializes a new instance of the LeftPosition class from Unit.
/// </summary>
private LeftPosition(Unit value)
{
_shapePosition = ShapePosition.Undefined;
_position = value;
_notNull = !value.IsNull;
}
/// <summary>
/// Initializes a new instance of the LeftPosition class from ShapePosition.
/// </summary>
private LeftPosition(ShapePosition value)
{
if (!(value == ShapePosition.Undefined || IsValid(value)))
throw new ArgumentException(DomSR.InvalidEnumForLeftPosition);
_shapePosition = value;
_position = Unit.NullValue;
_notNull = (value != ShapePosition.Undefined);
}
/// <summary>
/// Sets shapeposition enum and resets position.
/// </summary>
private void SetFromEnum(ShapePosition shapePosition)
{
if (!IsValid(shapePosition))
throw new ArgumentException(DomSR.InvalidEnumForLeftPosition);
_shapePosition = shapePosition;
_position = Unit.NullValue;
}
/// <summary>
/// Sets the Position from a Unit.
/// </summary>
private void SetFromUnit(Unit unit)
{
_shapePosition = ShapePosition.Undefined;
_position = unit;
}
/// <summary>
/// Sets the Position from an object.
/// </summary>
void INullableValue.SetValue(object value)
{
//REVIEW: Same code in TopPosition/LeftPosition.
if (value == null)
throw new ArgumentNullException("value");
if (value is ShapePosition)
SetFromEnum((ShapePosition)value);
else if (value is string && Enum.IsDefined(typeof(ShapePosition), value))
SetFromEnum((ShapePosition)Enum.Parse(typeof(ShapePosition), (string)value, true));
else
SetFromUnit(value.ToString());
_notNull = true;
}
/// <summary>
/// Gets the value of the position.
/// </summary>
object INullableValue.GetValue()
{
if (_shapePosition == ShapePosition.Undefined)
return _position;
return _shapePosition;
}
/// <summary>
/// Resets this instance, i.e. IsNull() will return true afterwards.
/// </summary>
void INullableValue.SetNull()
{
this = new LeftPosition();
}
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
bool INullableValue.IsNull
{
get { return !_notNull; }
}
private bool _notNull;
/// <summary>
/// Gets the value of the position in unit.
/// </summary>
public Unit Position
{
get { return _position; }
}
public Unit _position;
/// <summary>
/// Gets the value of the position.
/// </summary>
public ShapePosition ShapePosition
{
get { return _shapePosition; }
}
public ShapePosition _shapePosition;
/// <summary>
/// Indicates the given shapePosition is valid for LeftPosition.
/// </summary>
private static bool IsValid(ShapePosition shapePosition)
{
return shapePosition == ShapePosition.Left ||
shapePosition == ShapePosition.Center ||
shapePosition == ShapePosition.Right ||
shapePosition == ShapePosition.Inside ||
shapePosition == ShapePosition.Outside;
}
/// <summary>
/// Converts a ShapePosition to a LeftPosition.
/// </summary>
public static implicit operator LeftPosition(ShapePosition value)
{
return new LeftPosition(value);
}
/// <summary>
/// Converts a Unit to a LeftPosition.
/// </summary>
public static implicit operator LeftPosition(Unit value)
{
return new LeftPosition(value);
}
/// <summary>
/// Converts a string to a LeftPosition.
/// The string is interpreted as a Unit.
/// </summary>
public static implicit operator LeftPosition(string value)
{
Unit unit = value;
return new LeftPosition(unit);
}
/// <summary>
/// Converts a double to a LeftPosition.
/// The double is interpreted as a Unit in Point.
/// </summary>
public static implicit operator LeftPosition(double value)
{
Unit unit = value;
return new LeftPosition(unit);
}
/// <summary>
/// Converts an integer to a LeftPosition.
/// The integer is interpreted as a Unit in Point.
/// </summary>
public static implicit operator LeftPosition(int value)
{
Unit unit = value;
return new LeftPosition(unit);
}
/// <summary>
/// Parses the specified value.
/// </summary>
public static LeftPosition Parse(string value)
{
if (String.IsNullOrEmpty(value))
throw new ArgumentNullException("value");
value = value.Trim();
char ch = value[0];
if (ch == '+' || ch == '-' || Char.IsNumber(ch))
return Unit.Parse(value);
return (ShapePosition)Enum.Parse(typeof(ShapePosition), value, true);
}
#region public
/// <summary>
/// Converts LeftPosition into DDL.
/// </summary>
public void Serialize(Serializer serializer)
{
if (_shapePosition == ShapePosition.Undefined)
serializer.WriteSimpleAttribute("Left", Position);
else
serializer.WriteSimpleAttribute("Left", ShapePosition);
}
#endregion
/// <summary>
/// Returns the uninitialized LeftPosition object.
/// </summary>
public static readonly LeftPosition NullValue = new LeftPosition();
}
}

View File

@@ -0,0 +1,150 @@
#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.Shapes
{
/// <summary>
/// Defines the format of a line in a shape object.
/// </summary>
public class LineFormat : DocumentObject
{
/// <summary>
/// Initializes a new instance of the LineFormat class.
/// </summary>
public LineFormat()
{ }
/// <summary>
/// Initializes a new instance of the Lineformat class with the specified parent.
/// </summary>
public LineFormat(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new LineFormat Clone()
{
return (LineFormat)DeepCopy();
}
#endregion
#region Properties
/// <summary>
/// Gets or sets a value indicating whether the line should be visible.
/// </summary>
public bool Visible
{
get { return _visible.Value; }
set { _visible.Value = value; }
}
[DV]
public NBool _visible = NBool.NullValue;
/// <summary>
/// Gets or sets the width of the line in Unit.
/// </summary>
public Unit Width
{
get { return _width; }
set { _width = value; }
}
[DV]
public Unit _width = Unit.NullValue;
/// <summary>
/// Gets or sets the color of the line.
/// </summary>
public Color Color
{
get { return _color; }
set { _color = value; }
}
[DV]
public Color _color = Color.Empty;
/// <summary>
/// Gets or sets the dash style of the line.
/// </summary>
public DashStyle DashStyle
{
get { return (DashStyle)_dashStyle.Value; }
set { _dashStyle.Value = (int)value; }
}
[DV(Type = typeof(DashStyle))]
public NEnum _dashStyle = NEnum.NullValue(typeof(DashStyle));
/// <summary>
/// Gets or sets the style of the line.
/// </summary>
public LineStyle Style
{
get { return (LineStyle)_style.Value; }
set { _style.Value = (int)value; }
}
[DV(Type = typeof(LineStyle))]
public NEnum _style = NEnum.NullValue(typeof(LineStyle));
#endregion
#region public
/// <summary>
/// Converts LineFormat into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int pos = serializer.BeginContent("LineFormat");
if (!_visible.IsNull)
serializer.WriteSimpleAttribute("Visible", Visible);
if (!_style.IsNull)
serializer.WriteSimpleAttribute("Style", Style);
if (!_dashStyle.IsNull)
serializer.WriteSimpleAttribute("DashStyle", DashStyle);
if (!_width.IsNull)
serializer.WriteSimpleAttribute("Width", Width);
if (!_color.IsNull)
serializer.WriteSimpleAttribute("Color", Color);
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(LineFormat))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,140 @@
#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;
#pragma warning disable 1591
namespace MigraDoc.DocumentObjectModel.Shapes
{
/// <summary>
/// A PictureFormat object.
/// Used to set more detailed image attributes
/// </summary>
public class PictureFormat : DocumentObject
{
/// <summary>
/// Initializes a new instance of the PictureFormat class.
/// </summary>
public PictureFormat()
{ }
/// <summary>
/// Initializes a new instance of the PictureFormat class with the specified parent.
/// </summary>
public PictureFormat(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new PictureFormat Clone()
{
return (PictureFormat)DeepCopy();
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the part cropped from the left of the image.
/// </summary>
public Unit CropLeft
{
get { return _cropLeft; }
set { _cropLeft = value; }
}
[DV]
protected Unit _cropLeft = Unit.NullValue;
/// <summary>
/// Gets or sets the part cropped from the right of the image.
/// </summary>
public Unit CropRight
{
get { return _cropRight; }
set { _cropRight = value; }
}
[DV]
protected Unit _cropRight = Unit.NullValue;
/// <summary>
/// Gets or sets the part cropped from the top of the image.
/// </summary>
public Unit CropTop
{
get { return _cropTop; }
set { _cropTop = value; }
}
[DV]
protected Unit _cropTop = Unit.NullValue;
/// <summary>
/// Gets or sets the part cropped from the bottom of the image.
/// </summary>
public Unit CropBottom
{
get { return _cropBottom; }
set { _cropBottom = value; }
}
[DV]
protected Unit _cropBottom = Unit.NullValue;
#endregion
#region public
/// <summary>
/// Converts PictureFormat into DDL
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.BeginContent("PictureFormat");
if (!_cropLeft.IsNull)
serializer.WriteSimpleAttribute("CropLeft", CropLeft);
if (!_cropRight.IsNull)
serializer.WriteSimpleAttribute("CropRight", CropRight);
if (!_cropTop.IsNull)
serializer.WriteSimpleAttribute("CropTop", CropTop);
if (!_cropBottom.IsNull)
serializer.WriteSimpleAttribute("CropBottom", CropBottom);
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(PictureFormat))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,236 @@
#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.Shapes
{
/// <summary>
/// Base Class for all positionable Classes.
/// </summary>
public class Shape : DocumentObject
{
/// <summary>
/// Initializes a new instance of the Shape class.
/// </summary>
public Shape()
{ }
/// <summary>
/// Initializes a new instance of the Shape class with the specified parent.
/// </summary>
public Shape(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Shape Clone()
{
return (Shape)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Shape shape = (Shape)base.DeepCopy();
if (shape._wrapFormat != null)
{
shape._wrapFormat = shape._wrapFormat.Clone();
shape._wrapFormat._parent = shape;
}
if (shape._lineFormat != null)
{
shape._lineFormat = shape._lineFormat.Clone();
shape._lineFormat._parent = shape;
}
if (shape._fillFormat != null)
{
shape._fillFormat = shape._fillFormat.Clone();
shape._fillFormat._parent = shape;
}
return shape;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the wrapping format of the shape.
/// </summary>
public WrapFormat WrapFormat
{
get { return _wrapFormat ?? (_wrapFormat = new WrapFormat(this)); }
set
{
SetParent(value);
_wrapFormat = value;
}
}
[DV]
public WrapFormat _wrapFormat;
/// <summary>
/// Gets or sets the reference point of the Top property.
/// </summary>
public RelativeVertical RelativeVertical
{
get { return (RelativeVertical)_relativeVertical.Value; }
set { _relativeVertical.Value = (int)value; }
}
[DV(Type = typeof(RelativeVertical))]
public NEnum _relativeVertical = NEnum.NullValue(typeof(RelativeVertical));
/// <summary>
/// Gets or sets the reference point of the Left property.
/// </summary>
public RelativeHorizontal RelativeHorizontal
{
get { return (RelativeHorizontal)_relativeHorizontal.Value; }
set { _relativeHorizontal.Value = (int)value; }
}
[DV(Type = typeof(RelativeHorizontal))]
public NEnum _relativeHorizontal = NEnum.NullValue(typeof(RelativeHorizontal));
/// <summary>
/// Gets or sets the position of the top side of the shape.
/// </summary>
public TopPosition Top
{
get { return _top; }
set { _top = value; }
}
[DV]
public TopPosition _top = TopPosition.NullValue;
/// <summary>
/// Gets or sets the position of the left side of the shape.
/// </summary>
public LeftPosition Left
{
get { return _left; }
set { _left = value; }
}
[DV]
public LeftPosition _left = LeftPosition.NullValue;
/// <summary>
/// Gets the line format of the shape's border.
/// </summary>
public LineFormat LineFormat
{
get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); }
set
{
SetParent(value);
_lineFormat = value;
}
}
[DV]
public LineFormat _lineFormat;
/// <summary>
/// Gets the background filling format of the shape.
/// </summary>
public FillFormat FillFormat
{
get { return _fillFormat ?? (_fillFormat = new FillFormat(this)); }
set
{
SetParent(value);
_fillFormat = value;
}
}
[DV]
public FillFormat _fillFormat;
/// <summary>
/// Gets or sets the height of the shape.
/// </summary>
public Unit Height
{
get { return _height; }
set { _height = value; }
}
[DV]
public Unit _height = Unit.NullValue;
/// <summary>
/// Gets or sets the width of the shape.
/// </summary>
public Unit Width
{
get { return _width; }
set { _width = value; }
}
[DV]
public Unit _width = Unit.NullValue;
#endregion
#region public
/// <summary>
/// Converts Shape into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
if (!_height.IsNull)
serializer.WriteSimpleAttribute("Height", Height);
if (!_width.IsNull)
serializer.WriteSimpleAttribute("Width", Width);
if (!_relativeHorizontal.IsNull)
serializer.WriteSimpleAttribute("RelativeHorizontal", RelativeHorizontal);
if (!_relativeVertical.IsNull)
serializer.WriteSimpleAttribute("RelativeVertical", RelativeVertical);
if (!IsNull("Left"))
_left.Serialize(serializer);
if (!IsNull("Top"))
_top.Serialize(serializer);
if (!IsNull("WrapFormat"))
_wrapFormat.Serialize(serializer);
if (!IsNull("LineFormat"))
_lineFormat.Serialize(serializer);
if (!IsNull("FillFormat"))
_fillFormat.Serialize(serializer);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Shape))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,294 @@
#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;
namespace MigraDoc.DocumentObjectModel.Shapes
{
/// <summary>
/// Represents a text frame that can be freely placed.
/// </summary>
public class TextFrame : Shape, IVisitable
{
/// <summary>
/// Initializes a new instance of the TextFrame class.
/// </summary>
public TextFrame()
{ }
/// <summary>
/// Initializes a new instance of the TextFrame class with the specified parent.
/// </summary>
public TextFrame(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new TextFrame Clone()
{
return (TextFrame)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
TextFrame textFrame = (TextFrame)base.DeepCopy();
if (textFrame._elements != null)
{
textFrame._elements = textFrame._elements.Clone();
textFrame._elements._parent = textFrame;
}
return textFrame;
}
/// <summary>
/// Adds a new paragraph to the text frame.
/// </summary>
public Paragraph AddParagraph()
{
return Elements.AddParagraph();
}
/// <summary>
/// Adds a new paragraph with the specified text to the text frame.
/// </summary>
public Paragraph AddParagraph(string _paragraphText)
{
return Elements.AddParagraph(_paragraphText);
}
/// <summary>
/// Adds a new chart with the specified type to the text frame.
/// </summary>
public Chart AddChart(ChartType _type)
{
return Elements.AddChart(_type);
}
/// <summary>
/// Adds a new chart to the text frame.
/// </summary>
public Chart AddChart()
{
return Elements.AddChart();
}
/// <summary>
/// Adds a new table to the text frame.
/// </summary>
public Table AddTable()
{
return Elements.AddTable();
}
/// <summary>
/// Adds a new Image to the text frame.
/// </summary>
public Image AddImage(string _fileName)
{
return Elements.AddImage(_fileName);
}
/// <summary>
/// Adds a new paragraph to the text frame.
/// </summary>
public void Add(Paragraph paragraph)
{
Elements.Add(paragraph);
}
/// <summary>
/// Adds a new chart to the text frame.
/// </summary>
public void Add(Chart chart)
{
Elements.Add(chart);
}
/// <summary>
/// Adds a new table to the text frame.
/// </summary>
public void Add(Table table)
{
Elements.Add(table);
}
/// <summary>
/// Adds a new image to the text frame.
/// </summary>
public void Add(Image image)
{
Elements.Add(image);
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the Margin between the textframes content and its left edge.
/// </summary>
public Unit MarginLeft
{
get { return _marginLeft; }
set { _marginLeft = value; }
}
[DV]
public Unit _marginLeft = Unit.NullValue;
/// <summary>
/// Gets or sets the Margin between the textframes content and its right edge.
/// </summary>
public Unit MarginRight
{
get { return _marginRight; }
set { _marginRight = value; }
}
[DV]
public Unit _marginRight = Unit.NullValue;
/// <summary>
/// Gets or sets the Margin between the textframes content and its top edge.
/// </summary>
public Unit MarginTop
{
get { return _marginTop; }
set { _marginTop = value; }
}
[DV]
public Unit _marginTop = Unit.NullValue;
/// <summary>
/// Gets or sets the Margin between the textframes content and its bottom edge.
/// </summary>
public Unit MarginBottom
{
get { return _marginBottom; }
set { _marginBottom = value; }
}
[DV]
public Unit _marginBottom = Unit.NullValue;
/// <summary>
/// Sets all margins in one step with the same value.
/// </summary>
public Unit Margin
{
set
{
_marginLeft = value;
_marginRight = value;
_marginTop = value;
_marginBottom = value;
}
}
/// <summary>
/// Gets or sets the text orientation for the texframe content.
/// </summary>
public TextOrientation Orientation
{
get { return (TextOrientation)_orientation.Value; }
set { _orientation.Value = (int)value; }
}
[DV(Type = typeof(TextOrientation))]
public NEnum _orientation = NEnum.NullValue(typeof(TextOrientation));
/// <summary>
/// The document elements that build the textframe's content.
/// </summary>
public DocumentElements Elements
{
get { return _elements ?? (_elements = new DocumentElements(this)); }
set
{
SetParent(value);
_elements = value;
}
}
[DV(ItemType = typeof(DocumentObject))]
private DocumentElements _elements;
#endregion
/// <summary>
/// Allows the visitor object to visit the document object and its child objects.
/// </summary>
void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren)
{
visitor.VisitTextFrame(this);
if (visitChildren && _elements != null)
((IVisitable)_elements).AcceptVisitor(visitor, true);
}
#region public
/// <summary>
/// Converts TextFrame into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteLine("\\textframe");
int pos = serializer.BeginAttributes();
base.Serialize(serializer);
if (!_marginLeft.IsNull)
serializer.WriteSimpleAttribute("MarginLeft", MarginLeft);
if (!_marginRight.IsNull)
serializer.WriteSimpleAttribute("MarginRight", MarginRight);
if (!_marginTop.IsNull)
serializer.WriteSimpleAttribute("MarginTop", MarginTop);
if (!_marginBottom.IsNull)
serializer.WriteSimpleAttribute("MarginBottom", MarginBottom);
if (!_orientation.IsNull)
serializer.WriteSimpleAttribute("Orientation", Orientation);
serializer.EndAttributes(pos);
serializer.BeginContent();
if (_elements != null)
_elements.Serialize(serializer);
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(TextFrame))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,240 @@
#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.Shapes
{
/// <summary>
/// Represents the top position in a shape.
/// </summary>
public struct TopPosition : INullableValue
{
/// <summary>
/// Initializes a new instance of TopPosition from Unit.
/// </summary>
private TopPosition(Unit value)
{
_shapePosition = ShapePosition.Undefined;
_position = value;
_notNull = !value.IsNull;
}
/// <summary>
/// Initializes a new instance of TopPosition from ShapePosition.
/// </summary>
private TopPosition(ShapePosition value)
{
if (!(IsValid(value) || value == ShapePosition.Undefined))
throw new ArgumentException(DomSR.InvalidEnumForTopPosition);
_shapePosition = value;
_position = Unit.NullValue;
_notNull = (value != ShapePosition.Undefined);
}
/// <summary>
/// Indicates the given shapePosition is valid for TopPosition.
/// </summary>
private static bool IsValid(ShapePosition shapePosition)
{
return shapePosition == ShapePosition.Bottom ||
shapePosition == ShapePosition.Top ||
shapePosition == ShapePosition.Center;
}
/// <summary>
/// Converts a ShapePosition to a TopPosition.
/// </summary>
public static implicit operator TopPosition(ShapePosition value)
{
return new TopPosition(value);
}
/// <summary>
/// Converts a Unit to a TopPosition.
/// </summary>
public static implicit operator TopPosition(Unit val)
{
return new TopPosition(val);
}
/// <summary>
/// Converts a string to a TopPosition.
/// The string is interpreted as a Unit.
/// </summary>
public static implicit operator TopPosition(string value)
{
Unit unit = value;
return new TopPosition(unit);
}
/// <summary>
/// Converts a double to a TopPosition.
/// The double is interpreted as a Unit in Point.
/// </summary>
public static implicit operator TopPosition(double value)
{
Unit unit = value;
return new TopPosition(unit);
}
/// <summary>
/// Converts an integer to a TopPosition.
/// The integer is interpreted as a Unit in Point.
/// </summary>
public static implicit operator TopPosition(int value)
{
Unit unit = value;
return new TopPosition(unit);
}
/// <summary>
/// Sets shapeposition enum and resets position.
/// </summary>
private void SetFromEnum(ShapePosition shapePosition)
{
if (!IsValid(shapePosition))
throw new ArgumentException(DomSR.InvalidEnumForTopPosition);
_shapePosition = shapePosition;
_position = Unit.NullValue;
}
/// <summary>
/// Sets the Position from a Unit.
/// </summary>
private void SetFromUnit(Unit unit)
{
_shapePosition = ShapePosition.Undefined;
_position = unit;
}
/// <summary>
/// Sets the Position from an object.
/// </summary>
void INullableValue.SetValue(object value)
{
if (value == null)
throw new ArgumentNullException("value");
if (value is ShapePosition)
SetFromEnum((ShapePosition)value);
else if (value is string && Enum.IsDefined(typeof(ShapePosition), value))
SetFromEnum((ShapePosition)Enum.Parse(typeof(ShapePosition), (string)value, true));
else
SetFromUnit(value.ToString());
_notNull = true;
}
/// <summary>
/// Gets the Position as Unit or ShapePosition.
/// </summary>
object INullableValue.GetValue()
{
if (_shapePosition == ShapePosition.Undefined)
return _position;
return _shapePosition;
}
/// <summary>
/// Resets this instance, i.e. IsNull() will return true afterwards.
/// </summary>
void INullableValue.SetNull()
{
this = new TopPosition();
}
/// <summary>
/// Determines whether this instance is null (not set).
/// </summary>
bool INullableValue.IsNull
{
get { return !_notNull; }
}
bool _notNull;
/// <summary>
/// Gets the value of the position in unit.
/// </summary>
public Unit Position
{
get { return _position; }
}
public Unit _position;
/// <summary>
/// Gets the value of the position.
/// </summary>
public ShapePosition ShapePosition
{
get { return _shapePosition; }
}
public ShapePosition _shapePosition;
/// <summary>
/// Parses the specified value.
/// </summary>
public static TopPosition Parse(string value)
{
if (String.IsNullOrEmpty(value))
throw new ArgumentNullException("value");
value = value.Trim();
char ch = value[0];
if (ch == '+' || ch == '-' || Char.IsNumber(ch))
return Unit.Parse(value);
return (ShapePosition)Enum.Parse(typeof(ShapePosition), value, true);
}
#region public
/// <summary>
/// Converts TopPosition into DDL.
/// </summary>
public void Serialize(Serializer serializer)
{
if (_shapePosition == ShapePosition.Undefined)
serializer.WriteSimpleAttribute("Top", Position);
else
serializer.WriteSimpleAttribute("Top", ShapePosition);
}
#endregion
/// <summary>
/// Represents the unitialized TopPosition object.
/// </summary>
public static readonly TopPosition NullValue = new TopPosition();
}
}

View File

@@ -0,0 +1,150 @@
#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.Shapes
{
/// <summary>
/// Define how the shape should be wrapped between the texts.
/// </summary>
public class WrapFormat : DocumentObject
{
/// <summary>
/// Initializes a new instance of the WrapFormat class.
/// </summary>
public WrapFormat()
{ }
/// <summary>
/// Initializes a new instance of the WrapFormat class with the specified parent.
/// </summary>
public WrapFormat(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new WrapFormat Clone()
{
return (WrapFormat)DeepCopy();
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the wrapping style.
/// </summary>
public WrapStyle Style
{
get { return (WrapStyle)_style.Value; }
set { _style.Value = (int)value; }
}
[DV(Type = typeof(WrapStyle))]
public NEnum _style = NEnum.NullValue(typeof(WrapStyle));
/// <summary>
/// Gets or sets the distance between the top side of the shape with the adjacent text.
/// </summary>
public Unit DistanceTop
{
get { return _distanceTop; }
set { _distanceTop = value; }
}
[DV]
Unit _distanceTop = Unit.NullValue;
/// <summary>
/// Gets or sets the distance between the bottom side of the shape with the adjacent text.
/// </summary>
public Unit DistanceBottom
{
get { return _distanceBottom; }
set { _distanceBottom = value; }
}
[DV]
Unit _distanceBottom = Unit.NullValue;
/// <summary>
/// Gets or sets the distance between the left side of the shape with the adjacent text.
/// </summary>
public Unit DistanceLeft
{
get { return _distanceLeft; }
set { _distanceLeft = value; }
}
[DV]
Unit _distanceLeft = Unit.NullValue;
/// <summary>
/// Gets or sets the distance between the right side of the shape with the adjacent text.
/// </summary>
public Unit DistanceRight
{
get { return _distanceRight; }
set { _distanceRight = value; }
}
[DV]
Unit _distanceRight = Unit.NullValue;
#endregion
#region public
/// <summary>
/// Converts WrapFormat into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int pos = serializer.BeginContent("WrapFormat");
if (!_style.IsNull)
serializer.WriteSimpleAttribute("Style", Style);
if (!_distanceTop.IsNull)
serializer.WriteSimpleAttribute("DistanceTop", DistanceTop);
if (!_distanceLeft.IsNull)
serializer.WriteSimpleAttribute("DistanceLeft", DistanceLeft);
if (!_distanceRight.IsNull)
serializer.WriteSimpleAttribute("DistanceRight", DistanceRight);
if (!_distanceBottom.IsNull)
serializer.WriteSimpleAttribute("DistanceBottom", DistanceBottom);
serializer.EndContent();
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(WrapFormat))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,57 @@
#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
// ReSharper disable InconsistentNaming
namespace MigraDoc.DocumentObjectModel.Shapes
{
/// <summary>
/// Specifies the type of the barcode.
/// </summary>
public enum BarcodeType
{
/// <summary>
/// Barcode "Interleaved 2 of 5"
/// </summary>
Barcode25i,
/// <summary>
/// Barcode "3 of 9"
/// </summary>
Barcode39,
/// <summary>
/// Barcode "Code 128"
/// </summary>
Barcode128
}
}

View File

@@ -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.Shapes
{
/// <summary>
/// Specifies the dash style of the LineFormat object.
/// </summary>
public enum DashStyle
{
/// <summary>
/// A solid line.
/// </summary>
Solid,
/// <summary>
/// A dashed line.
/// </summary>
Dash,
/// <summary>
/// Alternating dashes and dots.
/// </summary>
DashDot,
/// <summary>
/// A dash followed by two dots.
/// </summary>
DashDotDot,
/// <summary>
/// Square dots.
/// </summary>
SquareDot
}
}

View File

@@ -0,0 +1,45 @@
#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.Shapes
{
/// <summary>
/// Specifies the line style of the LineFormat object.
/// </summary>
public enum LineStyle
{
/// <summary>
/// A solid line.
/// </summary>
Single
}
}

View File

@@ -0,0 +1,60 @@
#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.Shapes
{
/// <summary>
/// Reference point of the Left attribute.
/// </summary>
public enum RelativeHorizontal
{
/// <summary>
/// Alignment relative to the right side of the previous element.
/// </summary>
Character,
/// <summary>
/// Alignment relative to the right side of the previous element.
/// </summary>
Column,
/// <summary>
/// Alignment relative to page margin.
/// </summary>
Margin,
/// <summary>
/// Alignment relative to page edge.
/// </summary>
Page
}
}

View File

@@ -0,0 +1,60 @@
#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.Shapes
{
/// <summary>
/// Reference point of the Top attribute.
/// </summary>
public enum RelativeVertical
{
/// <summary>
/// Alignment relative to the bottom side of the previous element.
/// </summary>
Line,
/// <summary>
/// Alignment relative to page margin.
/// </summary>
Margin,
/// <summary>
/// Alignment relative to page edge.
/// </summary>
Page,
/// <summary>
/// Alignment relative to the bottom line of the previous element.
/// </summary>
Paragraph
}
}

View File

@@ -0,0 +1,80 @@
#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.Shapes
{
/// <summary>
/// Specifies the position of a shape. Values are used for both LeftPositon and TopPosition.
/// </summary>
public enum ShapePosition
{
/// <summary>
/// Undefined position.
/// </summary>
Undefined,
/// <summary>
/// Left-aligned position.
/// </summary>
Left,
/// <summary>
/// Right-aligned position.
/// </summary>
Right,
/// <summary>
/// Centered position.
/// </summary>
Center,
/// <summary>
/// Top-aligned position.
/// </summary>
Top,
/// <summary>
/// Bottom-aligned position.
/// </summary>
Bottom,
/// <summary>
/// Used with mirrored margins: left-aligned on right page and right-aligned on left page.
/// </summary>
Inside,
/// <summary>
/// Used with mirrored margins: left-aligned on left page and right-aligned on right page.
/// </summary>
Outside
}
}

View File

@@ -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.Shapes
{
/// <summary>
/// Specifies the orientation of the text in the TextFrame.
/// </summary>
public enum TextOrientation
{
/// <summary>
/// Horizontal orientation.
/// </summary>
Horizontal,
/// <summary>
/// Horizontal orientation.
/// </summary>
HorizontalRotatedFarEast,
/// <summary>
/// Vertical orientation (upward).
/// </summary>
Upward,
/// <summary>
/// Vertical orientation (downward).
/// </summary>
Vertical,
/// <summary>
/// Vertical orientation (downward).
/// </summary>
VerticalFarEast,
/// <summary>
/// Vertical orientation (downward).
/// </summary>
Downward
}
}

View File

@@ -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.Shapes
{
/// <summary>
/// Specifies how the shape object should be placed between the other elements.
/// </summary>
public enum WrapStyle
{
/// <summary>
/// The object will be placed between its predecessor and its successor.
/// </summary>
TopBottom,
/// <summary>
/// The object will be ignored when the other elements are placed.
/// </summary>
None,
/// <summary>
/// The object will be ignored when the other elements are placed.
/// </summary>
Through,
}
}

View File

@@ -0,0 +1,450 @@
#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;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
namespace MigraDoc.DocumentObjectModel.Tables
{
/// <summary>
/// Represents a cell of a table.
/// </summary>
public class Cell : DocumentObject, IVisitable
{
/// <summary>
/// Initializes a new instance of the Cell class.
/// </summary>
public Cell()
{ }
/// <summary>
/// Initializes a new instance of the Cell class with the specified parent.
/// </summary>
public Cell(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Cell Clone()
{
return (Cell)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Cell cell = (Cell)base.DeepCopy();
// Remove all references to the original object hierarchy.
cell.ResetCachedValues();
// TODO Call ResetCachedValues() for all classes where this is needed!
if (cell._format != null)
{
cell._format = cell._format.Clone();
cell._format._parent = cell;
}
if (cell._borders != null)
{
cell._borders = cell._borders.Clone();
cell._borders._parent = cell;
}
if (cell._shading != null)
{
cell._shading = cell._shading.Clone();
cell._shading._parent = cell;
}
if (cell._elements != null)
{
cell._elements = cell._elements.Clone();
cell._elements._parent = cell;
}
return cell;
}
/// <summary>
/// Resets the cached values.
/// </summary>
public override void ResetCachedValues()
{
base.ResetCachedValues();
_row = null;
_clm = null;
_table = null;
}
/// <summary>
/// Adds a new paragraph to the cell.
/// </summary>
public Paragraph AddParagraph()
{
return Elements.AddParagraph();
}
/// <summary>
/// Adds a new paragraph with the specified text to the cell.
/// </summary>
public Paragraph AddParagraph(string paragraphText)
{
return Elements.AddParagraph(paragraphText);
}
/// <summary>
/// Adds a new chart with the specified type to the cell.
/// </summary>
public Chart AddChart(ChartType type)
{
return Elements.AddChart(type);
}
/// <summary>
/// Adds a new chart to the cell.
/// </summary>
public Chart AddChart()
{
return Elements.AddChart();
}
/// <summary>
/// Adds a new Image to the cell.
/// </summary>
public Image AddImage(string fileName)
{
return Elements.AddImage(fileName);
}
/// <summary>
/// Adds a new textframe to the cell.
/// </summary>
public TextFrame AddTextFrame()
{
return Elements.AddTextFrame();
}
/// <summary>
/// Adds a new paragraph to the cell.
/// </summary>
public void Add(Paragraph paragraph)
{
Elements.Add(paragraph);
}
/// <summary>
/// Adds a new chart to the cell.
/// </summary>
public void Add(Chart chart)
{
Elements.Add(chart);
}
/// <summary>
/// Adds a new image to the cell.
/// </summary>
public void Add(Image image)
{
Elements.Add(image);
}
/// <summary>
/// Adds a new text frame to the cell.
/// </summary>
public void Add(TextFrame textFrame)
{
Elements.Add(textFrame);
}
#endregion
#region Properties
/// <summary>
/// Gets the table the cell belongs to.
/// </summary>
public Table Table
{
get
{
if (_table == null)
{
Cells cls = Parent as Cells;
if (cls != null)
_table = cls.Table;
}
return _table;
}
}
Table _table;
/// <summary>
/// Gets the column the cell belongs to.
/// </summary>
public Column Column
{
get
{
if (_clm == null)
{
Cells cells = Parent as Cells;
for (int index = 0; index < cells.Count; ++index)
{
if (cells[index] == this)
_clm = Table.Columns[index];
}
}
return _clm;
}
}
Column _clm;
/// <summary>
/// Gets the row the cell belongs to.
/// </summary>
public Row Row
{
get
{
if (_row == null)
{
Cells cells = Parent as Cells;
_row = cells.Row;
}
return _row;
}
}
Row _row;
/// <summary>
/// Sets or gets the style name.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets 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 or sets the vertical alignment of the cell.
/// </summary>
public VerticalAlignment VerticalAlignment
{
get { return (VerticalAlignment)_verticalAlignment.Value; }
set { _verticalAlignment.Value = (int)value; }
}
[DV(Type = typeof(VerticalAlignment))]
public NEnum _verticalAlignment = NEnum.NullValue(typeof(VerticalAlignment));
/// <summary>
/// Gets the Borders object.
/// </summary>
public Borders Borders
{
get
{
if (_borders == null)
{
if (Document == null) // BUG CMYK
GetType();
_borders = new Borders(this);
}
return _borders;
}
set
{
SetParent(value);
_borders = value;
}
}
[DV]
public Borders _borders;
/// <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>
/// Specifies if the Cell should be rendered as a rounded corner.
/// </summary>
public RoundedCorner RoundedCorner
{
get { return _roundedCorner; }
set
{
_roundedCorner = value;
}
}
[DV]
public RoundedCorner _roundedCorner;
/// <summary>
/// Gets or sets the number of cells to be merged right.
/// </summary>
public int MergeRight
{
get { return _mergeRight.Value; }
set { _mergeRight.Value = value; }
}
[DV]
public NInt _mergeRight = NInt.NullValue;
/// <summary>
/// Gets or sets the number of cells to be merged down.
/// </summary>
public int MergeDown
{
get { return _mergeDown.Value; }
set { _mergeDown.Value = value; }
}
[DV]
public NInt _mergeDown = NInt.NullValue;
/// <summary>
/// Gets the collection of document objects that defines the cell.
/// </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 Cell into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteComment(_comment.Value);
serializer.WriteLine("\\cell");
int pos = serializer.BeginAttributes();
if (_style.Value != String.Empty)
serializer.WriteSimpleAttribute("Style", Style);
if (!IsNull("Format"))
_format.Serialize(serializer, "Format", null);
if (!_mergeDown.IsNull)
serializer.WriteSimpleAttribute("MergeDown", MergeDown);
if (!_mergeRight.IsNull)
serializer.WriteSimpleAttribute("MergeRight", MergeRight);
if (!_verticalAlignment.IsNull)
serializer.WriteSimpleAttribute("VerticalAlignment", VerticalAlignment);
if (!IsNull("Borders"))
_borders.Serialize(serializer, null);
if (!IsNull("Shading"))
_shading.Serialize(serializer);
if (_roundedCorner != RoundedCorner.None)
serializer.WriteSimpleAttribute("RoundedCorner", RoundedCorner);
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.VisitCell(this);
if (visitChildren && _elements != null)
((IVisitable)_elements).AcceptVisitor(visitor, visitChildren);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Cell))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,150 @@
#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.Tables
{
/// <summary>
/// Represents the collection of all cells of a row.
/// </summary>
public class Cells : DocumentObjectCollection
{
/// <summary>
/// Initializes a new instance of the Cells class.
/// </summary>
public Cells()
{ }
/// <summary>
/// Initializes a new instance of the Cells class with the specified parent.
/// </summary>
public Cells(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Cells Clone()
{
Cells cells = (Cells)base.DeepCopy();
cells.ResetCachedValues();
return cells;
}
/// <summary>
/// Resets the cached values.
/// </summary>
public override void ResetCachedValues()
{
base.ResetCachedValues();
_row = null;
_table = null;
}
#endregion
#region Properties
/// <summary>
/// Gets the table the cells collection belongs to.
/// </summary>
public Table Table
{
get
{
if (_table == null)
{
Row rw = Parent as Row;
if (rw != null)
_table = rw.Table;
}
return _table;
}
}
Table _table;
/// <summary>
/// Gets the row the cells collection belongs to.
/// </summary>
public Row Row
{
get { return _row ?? (_row = Parent as Row); }
}
Row _row;
/// <summary>
/// Gets a cell by its index. The first cell has the index 0.
/// </summary>
public new Cell this[int index]
{
get
{
if (index < 0 || (Table != null && index >= Table.Columns.Count))
throw new ArgumentOutOfRangeException("index");
Resize(index);
return base[index] as Cell;
}
}
#endregion
/// <summary>
/// Resizes this cells' list if necessary.
/// </summary>
private void Resize(int index)
{
for (int currentIndex = Count; currentIndex <= index; currentIndex++)
Add(new Cell());
}
#region public
/// <summary>
/// Converts Cells into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
int cells = Count;
for (int cell = 0; cell < cells; cell++)
this[cell].Serialize(serializer);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Cells))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,329 @@
#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.Tables
{
/// <summary>
/// Represents a column of a table.
/// </summary>
public class Column : DocumentObject
{
/// <summary>
/// Initializes a new instance of the Column class.
/// </summary>
public Column()
{ }
/// <summary>
/// Initializes a new instance of the Column class with the specified parent.
/// </summary>
public Column(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Column Clone()
{
return (Column)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Column column = (Column)base.DeepCopy();
column.ResetCachedValues();
if (column._format != null)
{
column._format = column._format.Clone();
column._format._parent = column;
}
if (column._borders != null)
{
column._borders = column._borders.Clone();
column._borders._parent = column;
}
if (column._shading != null)
{
column._shading = column._shading.Clone();
column._shading._parent = column;
}
return column;
}
/// <summary>
/// Resets the cached values.
/// </summary>
public override void ResetCachedValues()
{
base.ResetCachedValues();
_table = null;
_index = NInt.NullValue;
}
#endregion
#region Properties
/// <summary>
/// Gets the table the Column belongs to.
/// </summary>
public Table Table
{
get
{
if (_table == null)
{
Columns clms = Parent as Columns;
if (clms != null)
_table = clms.Parent as Table;
}
return _table;
}
}
Table _table;
/// <summary>
/// Gets the index of the column. First column has index 0.
/// </summary>
public int Index
{
get
{
if (_index == NInt.NullValue /*IsNull("Index")*/)
{
Columns clms = (Columns)Parent;
// One for all and all for one.
for (int i = 0; i < clms.Count; ++i)
{
clms[i]._index = i;
}
}
return _index;
}
}
[DV]
public NInt _index = NInt.NullValue;
/// <summary>
/// Gets a cell by its row index. The first cell has index 0.
/// </summary>
public Cell this[int index]
{
get
{
//Check.ArgumentOutOfRange(index >= 0 && index < table.Rows.Count, "index");
return Table.Rows[index][_index];
}
}
/// <summary>
/// Sets or gets the default style name for all cells of the column.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets the default ParagraphFormat for all cells of the column.
/// </summary>
public ParagraphFormat Format
{
get { return _format ?? (_format = new ParagraphFormat(this)); }
set
{
SetParent(value);
_format = value;
}
}
[DV]
public ParagraphFormat _format;
/// <summary>
/// Gets or sets the width of a column.
/// </summary>
public Unit Width
{
get { return _width; }
set { _width = value; }
}
[DV]
public Unit _width = Unit.NullValue;
/// <summary>
/// Gets or sets the default left padding for all cells of the column.
/// </summary>
public Unit LeftPadding
{
get { return _leftPadding; }
set { _leftPadding = value; }
}
[DV]
public Unit _leftPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the default right padding for all cells of the column.
/// </summary>
public Unit RightPadding
{
get { return _rightPadding; }
set { _rightPadding = value; }
}
[DV]
public Unit _rightPadding = Unit.NullValue;
/// <summary>
/// Gets the default Borders object for all cells of the column.
/// </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 number of columns that should be kept together with
/// current column in case of a page break.
/// </summary>
public int KeepWith
{
get { return _keepWith.Value; }
set { _keepWith.Value = value; }
}
[DV]
public NInt _keepWith = NInt.NullValue;
/// <summary>
/// Gets or sets a value which define whether the column is a header.
/// </summary>
public bool HeadingFormat
{
get { return _headingFormat.Value; }
set { _headingFormat.Value = value; }
}
[DV]
public NBool _headingFormat = NBool.NullValue;
/// <summary>
/// Gets the default Shading object for all cells of the column.
/// </summary>
public Shading Shading
{
get { return _shading ?? (_shading = new Shading(this)); }
set
{
SetParent(value);
_shading = value;
}
}
[DV]
public Shading _shading;
/// <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 Column into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteComment(_comment.Value);
serializer.WriteLine("\\column");
int pos = serializer.BeginAttributes();
if (_style.Value != String.Empty)
serializer.WriteSimpleAttribute("Style", Style);
if (!IsNull("Format"))
_format.Serialize(serializer, "Format", null);
if (!_headingFormat.IsNull)
serializer.WriteSimpleAttribute("HeadingFormat", HeadingFormat);
if (!_leftPadding.IsNull)
serializer.WriteSimpleAttribute("LeftPadding", LeftPadding);
if (!_rightPadding.IsNull)
serializer.WriteSimpleAttribute("RightPadding", RightPadding);
if (!_width.IsNull)
serializer.WriteSimpleAttribute("Width", Width);
if (!_keepWith.IsNull)
serializer.WriteSimpleAttribute("KeepWith", KeepWith);
if (!IsNull("Borders"))
_borders.Serialize(serializer, null);
if (!IsNull("Shading"))
_shading.Serialize(serializer);
serializer.EndAttributes(pos);
// columns has no content
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Column))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,177 @@
#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.Tables
{
/// <summary>
/// Represents the columns of a table.
/// </summary>
public class Columns : DocumentObjectCollection, IVisitable
{
/// <summary>
/// Initializes a new instance of the Columns class.
/// </summary>
public Columns()
{ }
/// <summary>
/// Initializes a new instance of the Columns class containing columns of the specified widths.
/// </summary>
public Columns(params Unit[] widths)
{
foreach (Unit width in widths)
{
Column clm = new Column();
clm.Width = width;
Add(clm);
}
}
/// <summary>
/// Initializes a new instance of the Columns class with the specified parent.
/// </summary>
public Columns(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Columns Clone()
{
return (Columns)base.DeepCopy();
}
/// <summary>
/// Adds a new column to the columns collection. Allowed only before any row was added.
/// </summary>
public Column AddColumn()
{
if (Table.Rows.Count > 0)
throw new InvalidOperationException("Cannot add column because rows collection is not empty.");
Column column = new Column();
Add(column);
return column;
}
#endregion
#region Properties
/// <summary>
/// Gets the table the columns collection belongs to.
/// </summary>
public Table Table
{
get { return _parent as Table; }
}
/// <summary>
/// Gets a column by its index.
/// </summary>
public new Column this[int index]
{
get { return base[index] as Column; }
}
/// <summary>
/// Gets or sets the default width of all columns.
/// </summary>
public Unit Width
{
get { return _width; }
set { _width = value; }
}
[DV]
public Unit _width = Unit.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 Columns into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteComment(_comment.Value);
serializer.WriteLine("\\columns");
int pos = serializer.BeginAttributes();
if (!_width.IsNull)
serializer.WriteSimpleAttribute("Width", Width);
serializer.EndAttributes(pos);
serializer.BeginContent();
int clms = Count;
if (clms > 0)
{
for (int clm = 0; clm < clms; clm++)
this[clm].Serialize(serializer);
}
else
serializer.WriteComment("Invalid - no columns defined. Table will not render.");
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.VisitColumns(this);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Columns))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,389 @@
#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.Tables
{
/// <summary>
/// Represents a row of a table.
/// </summary>
public class Row : DocumentObject, IVisitable
{
/// <summary>
/// Initializes a new instance of the Row class.
/// </summary>
public Row()
{ }
/// <summary>
/// Initializes a new instance of the Row class with the specified parent.
/// </summary>
public Row(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Row Clone()
{
return (Row)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Row row = (Row)base.DeepCopy();
row.ResetCachedValues();
if (row._format != null)
{
row._format = row._format.Clone();
row._format._parent = row;
}
if (row._borders != null)
{
row._borders = row._borders.Clone();
row._borders._parent = row;
}
if (row._shading != null)
{
row._shading = row._shading.Clone();
row._shading._parent = row;
}
if (row._cells != null)
{
row._cells = row._cells.Clone();
row._cells._parent = row;
}
return row;
}
/// <summary>
/// Resets the cached values.
/// </summary>
public override void ResetCachedValues()
{
base.ResetCachedValues();
_table = null;
index = NInt.NullValue;
}
#endregion
#region Properties
/// <summary>
/// Gets the table the row belongs to.
/// </summary>
public Table Table
{
get
{
if (_table == null)
{
Rows rws = Parent as Rows;
if (rws != null)
_table = rws.Table;
}
return _table;
}
}
Table _table;
/// <summary>
/// Gets the index of the row. First row has index 0.
/// </summary>
public int Index
{
get
{
if (index == NInt.NullValue /*IsNull("index")*/)
{
Rows rws = (Rows)_parent;
// One for all and all for one.
for (int i = 0; i < rws.Count; ++i)
{
rws[i].index = i;
}
}
return index;
}
}
[DV]
public NInt index = NInt.NullValue;
/// <summary>
/// Gets a cell by its column index. The first cell has index 0.
/// </summary>
public Cell this[int index]
{
get { return Cells[index]; }
}
/// <summary>
/// Gets or sets the default style name for all cells of the row.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets the default ParagraphFormat for all cells of the row.
/// </summary>
public ParagraphFormat Format
{
get { return _format ?? (_format = new ParagraphFormat(this)); }
set
{
SetParent(value);
_format = value;
}
}
[DV]
public ParagraphFormat _format;
/// <summary>
/// Gets or sets the default vertical alignment for all cells of the row.
/// </summary>
public VerticalAlignment VerticalAlignment
{
get { return (VerticalAlignment)_verticalAlignment.Value; }
set { _verticalAlignment.Value = (int)value; }
}
[DV(Type = typeof(VerticalAlignment))]
public NEnum _verticalAlignment = NEnum.NullValue(typeof(VerticalAlignment));
/// <summary>
/// Gets or sets the height of the row.
/// </summary>
public Unit Height
{
get { return _height; }
set { _height = value; }
}
[DV]
public Unit _height = Unit.NullValue;
/// <summary>
/// Gets or sets the rule which is used to determine the height of the row.
/// </summary>
public RowHeightRule HeightRule
{
get { return (RowHeightRule)_heightRule.Value; }
set { _heightRule.Value = (int)value; }
}
[DV(Type = typeof(RowHeightRule))]
public NEnum _heightRule = NEnum.NullValue(typeof(RowHeightRule));
/// <summary>
/// Gets or sets the default value for all cells of the row.
/// </summary>
public Unit TopPadding
{
get { return _topPadding; }
set { _topPadding = value; }
}
[DV]
public Unit _topPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the default value for all cells of the row.
/// </summary>
public Unit BottomPadding
{
get { return _bottomPadding; }
set { _bottomPadding = value; }
}
[DV]
public Unit _bottomPadding = Unit.NullValue;
/// <summary>
/// Gets or sets a value which define whether the row is a header.
/// </summary>
public bool HeadingFormat
{
get { return _headingFormat.Value; }
set { _headingFormat.Value = value; }
}
[DV]
public NBool _headingFormat = NBool.NullValue;
/// <summary>
/// Gets the default Borders object for all cells of the row.
/// </summary>
public Borders Borders
{
get { return _borders ?? (_borders = new Borders(this)); }
set
{
SetParent(value);
_borders = value;
}
}
[DV]
public Borders _borders;
/// <summary>
/// Gets the default Shading object for all cells of the row.
/// </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 number of rows that should be
/// kept together with the current row in case of a page break.
/// </summary>
public int KeepWith
{
get { return _keepWith.Value; }
set { _keepWith.Value = value; }
}
[DV]
public NInt _keepWith = NInt.NullValue;
/// <summary>
/// Gets the Cells collection of the table.
/// </summary>
public Cells Cells
{
get { return _cells ?? (_cells = new Cells(this)); }
set
{
SetParent(value);
_cells = value;
}
}
[DV]
public Cells _cells;
/// <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 Row into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteComment(_comment.Value);
serializer.WriteLine("\\row");
int pos = serializer.BeginAttributes();
if (_style.Value != String.Empty)
serializer.WriteSimpleAttribute("Style", Style);
if (!IsNull("Format"))
_format.Serialize(serializer, "Format", null);
if (!_height.IsNull)
serializer.WriteSimpleAttribute("Height", Height);
if (!_heightRule.IsNull)
serializer.WriteSimpleAttribute("HeightRule", HeightRule);
if (!_topPadding.IsNull)
serializer.WriteSimpleAttribute("TopPadding", TopPadding);
if (!_bottomPadding.IsNull)
serializer.WriteSimpleAttribute("BottomPadding", BottomPadding);
if (!_headingFormat.IsNull)
serializer.WriteSimpleAttribute("HeadingFormat", HeadingFormat);
if (!_verticalAlignment.IsNull)
serializer.WriteSimpleAttribute("VerticalAlignment", VerticalAlignment);
if (!_keepWith.IsNull)
serializer.WriteSimpleAttribute("KeepWith", KeepWith);
//Borders & Shading
if (!IsNull("Borders"))
_borders.Serialize(serializer, null);
if (!IsNull("Shading"))
_shading.Serialize(serializer);
serializer.EndAttributes(pos);
serializer.BeginContent();
if (!IsNull("Cells"))
_cells.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.VisitRow(this);
foreach (Cell cell in _cells)
((IVisitable)cell).AcceptVisitor(visitor, visitChildren);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Row))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,224 @@
#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.Tables
{
/// <summary>
/// Represents the collection of all rows of a table.
/// </summary>
public class Rows : DocumentObjectCollection, IVisitable
{
/// <summary>
/// Initializes a new instance of the Rows class.
/// </summary>
public Rows()
{ }
/// <summary>
/// Initializes a new instance of the Rows class with the specified parent.
/// </summary>
public Rows(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Rows Clone()
{
return (Rows)base.DeepCopy();
}
/// <summary>
/// Adds a new row to the rows collection. Allowed only if at least one column exists.
/// </summary>
public Row AddRow()
{
if (Table.Columns.Count == 0)
throw new InvalidOperationException("Cannot add row, because no columns exists.");
Row row = new Row();
Add(row);
return row;
}
#endregion
#region Properties
/// <summary>
/// Gets the table the rows collection belongs to.
/// </summary>
public Table Table
{
get { return _parent as Table; }
}
/// <summary>
/// Gets a row by its index.
/// </summary>
public new Row this[int index]
{
get { return base[index] as Row; }
}
/// <summary>
/// Gets or sets the row alignment of the table.
/// </summary>
public RowAlignment Alignment
{
get { return (RowAlignment)_alignment.Value; }
set { _alignment.Value = (int)value; }
}
[DV(Type = typeof(RowAlignment))]
public NEnum _alignment = NEnum.NullValue(typeof(RowAlignment));
/// <summary>
/// Gets or sets the left indent of the table. If row alignment is not Left,
/// the value is ignored.
/// </summary>
public Unit LeftIndent
{
get { return _leftIndent; }
set { _leftIndent = value; }
}
[DV]
public Unit _leftIndent = Unit.NullValue;
/// <summary>
/// Gets or sets the default vertical alignment for all rows.
/// </summary>
public VerticalAlignment VerticalAlignment
{
get { return (VerticalAlignment)_verticalAlignment.Value; }
set { _verticalAlignment.Value = (int)value; }
}
[DV(Type = typeof(VerticalAlignment))]
public NEnum _verticalAlignment = NEnum.NullValue(typeof(VerticalAlignment));
/// <summary>
/// Gets or sets the height of the rows.
/// </summary>
public Unit Height
{
get { return _height; }
set { _height = value; }
}
[DV]
public Unit _height = Unit.NullValue;
/// <summary>
/// Gets or sets the rule which is used to determine the height of the rows.
/// </summary>
public RowHeightRule HeightRule
{
get { return (RowHeightRule)_heightRule.Value; }
set { _heightRule.Value = (int)value; }
}
[DV(Type = typeof(RowHeightRule))]
public NEnum _heightRule = NEnum.NullValue(typeof(RowHeightRule));
/// <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 Rows into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteComment(_comment.Value);
serializer.WriteLine("\\rows");
int pos = serializer.BeginAttributes();
if (!_alignment.IsNull)
serializer.WriteSimpleAttribute("Alignment", Alignment);
if (!_height.IsNull)
serializer.WriteSimpleAttribute("Height", Height);
if (!_heightRule.IsNull)
serializer.WriteSimpleAttribute("HeightRule", HeightRule);
if (!_leftIndent.IsNull)
serializer.WriteSimpleAttribute("LeftIndent", LeftIndent);
if (!_verticalAlignment.IsNull)
serializer.WriteSimpleAttribute("VerticalAlignment", VerticalAlignment);
serializer.EndAttributes(pos);
serializer.BeginContent();
int rows = Count;
if (rows > 0)
{
for (int row = 0; row < rows; row++)
this[row].Serialize(serializer);
}
else
serializer.WriteComment("Invalid - no rows defined. Table will not render.");
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.VisitRows(this);
foreach (Row row in this)
((IVisitable)row).AcceptVisitor(visitor, visitChildren);
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Rows))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,483 @@
#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.Tables
{
/// <summary>
/// Represents a table in a document.
/// </summary>
public class Table : DocumentObject, IVisitable
{
/// <summary>
/// Initializes a new instance of the Table class.
/// </summary>
public Table()
{ }
/// <summary>
/// Initializes a new instance of the Table class with the specified parent.
/// </summary>
public Table(DocumentObject parent) : base(parent) { }
#region Methods
/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new Table Clone()
{
return (Table)DeepCopy();
}
/// <summary>
/// Implements the deep copy of the object.
/// </summary>
protected override object DeepCopy()
{
Table table = (Table)base.DeepCopy();
if (table._columns != null)
{
table._columns = table._columns.Clone();
table._columns._parent = table;
}
if (table._rows != null)
{
table._rows = table._rows.Clone();
table._rows._parent = table;
}
if (table._format != null)
{
table._format = table._format.Clone();
table._format._parent = table;
}
if (table._borders != null)
{
table._borders = table._borders.Clone();
table._borders._parent = table;
}
if (table._shading != null)
{
table._shading = table._shading.Clone();
table._shading._parent = table;
}
return table;
}
/// <summary>
/// Adds a new column to the table. Allowed only before any row was added.
/// </summary>
public Column AddColumn()
{
return Columns.AddColumn();
}
/// <summary>
/// Adds a new column of the specified width to the table. Allowed only before any row was added.
/// </summary>
public Column AddColumn(Unit width)
{
Column clm = Columns.AddColumn();
clm.Width = width;
return clm;
}
/// <summary>
/// Adds a new row to the table. Allowed only if at least one column was added.
/// </summary>
public Row AddRow()
{
return _rows.AddRow();
}
/// <summary>
/// Returns true if no cell exists in the table.
/// </summary>
public bool IsEmpty
{
get { return Rows.Count == 0 || Columns.Count == 0; }
}
/// <summary>
/// Sets a shading of the specified Color in the specified Tablerange.
/// </summary>
public void SetShading(int clm, int row, int clms, int rows, Color clr)
{
int rowsCount = _rows.Count;
int clmsCount = _columns.Count;
if (row < 0 || row >= rowsCount)
throw new ArgumentOutOfRangeException("row", "Invalid row index.");
if (clm < 0 || clm >= clmsCount)
throw new ArgumentOutOfRangeException("clm", "Invalid column index.");
if (rows <= 0 || row + rows > rowsCount)
throw new ArgumentOutOfRangeException("rows", "Invalid row count.");
if (clms <= 0 || clm + clms > clmsCount)
throw new ArgumentOutOfRangeException("clms", "Invalid column count.");
int maxRow = row + rows - 1;
int maxClm = clm + clms - 1;
for (int r = row; r <= maxRow; r++)
{
Row currentRow = _rows[r];
for (int c = clm; c <= maxClm; c++)
currentRow[c].Shading.Color = clr;
}
}
/// <summary>
/// Sets the borders surrounding the specified range of the table.
/// </summary>
public void SetEdge(int clm, int row, int clms, int rows,
Edge edge, BorderStyle style, Unit width, Color clr)
{
Border border;
int maxRow = row + rows - 1;
int maxClm = clm + clms - 1;
for (int r = row; r <= maxRow; r++)
{
Row currentRow = _rows[r];
for (int c = clm; c <= maxClm; c++)
{
Cell currentCell = currentRow[c];
if ((edge & Edge.Top) == Edge.Top && r == row)
{
border = currentCell.Borders.Top;
border.Style = style;
border.Width = width;
if (clr != Color.Empty)
border.Color = clr;
}
if ((edge & Edge.Left) == Edge.Left && c == clm)
{
border = currentCell.Borders.Left;
border.Style = style;
border.Width = width;
if (clr != Color.Empty)
border.Color = clr;
}
if ((edge & Edge.Bottom) == Edge.Bottom && r == maxRow)
{
border = currentCell.Borders.Bottom;
border.Style = style;
border.Width = width;
if (clr != Color.Empty)
border.Color = clr;
}
if ((edge & Edge.Right) == Edge.Right && c == maxClm)
{
border = currentCell.Borders.Right;
border.Style = style;
border.Width = width;
if (clr != Color.Empty)
border.Color = clr;
}
if ((edge & Edge.Horizontal) == Edge.Horizontal && r < maxRow)
{
border = currentCell.Borders.Bottom;
border.Style = style;
border.Width = width;
if (clr != Color.Empty)
border.Color = clr;
}
if ((edge & Edge.Vertical) == Edge.Vertical && c < maxClm)
{
border = currentCell.Borders.Right;
border.Style = style;
border.Width = width;
if (clr != Color.Empty)
border.Color = clr;
}
if ((edge & Edge.DiagonalDown) == Edge.DiagonalDown)
{
border = currentCell.Borders.DiagonalDown;
border.Style = style;
border.Width = width;
if (clr != Color.Empty)
border.Color = clr;
}
if ((edge & Edge.DiagonalUp) == Edge.DiagonalUp)
{
border = currentCell.Borders.DiagonalUp;
border.Style = style;
border.Width = width;
if (clr != Color.Empty)
border.Color = clr;
}
}
}
}
/// <summary>
/// Sets the borders surrounding the specified range of the table.
/// </summary>
public void SetEdge(int clm, int row, int clms, int rows, Edge edge, BorderStyle style, Unit width)
{
SetEdge(clm, row, clms, rows, edge, style, width, Color.Empty);
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the Columns collection of the table.
/// </summary>
public Columns Columns
{
get { return _columns ?? (_columns = new Columns(this)); }
set
{
SetParent(value);
_columns = value;
}
}
[DV]
public Columns _columns;
/// <summary>
/// Gets the Rows collection of the table.
/// </summary>
public Rows Rows
{
get { return _rows ?? (_rows = new Rows(this)); }
set
{
SetParent(value);
_rows = value;
}
}
[DV]
public Rows _rows;
/// <summary>
/// Sets or gets the default style name for all rows and columns of the table.
/// </summary>
public string Style
{
get { return _style.Value; }
set { _style.Value = value; }
}
[DV]
public NString _style = NString.NullValue;
/// <summary>
/// Gets the default ParagraphFormat for all rows and columns of the table.
/// </summary>
public ParagraphFormat Format
{
get { return _format ?? (_format = new ParagraphFormat(this)); }
set
{
SetParent(value);
_format = value;
}
}
[DV]
public ParagraphFormat _format;
/// <summary>
/// Gets or sets the default top padding for all cells of the table.
/// </summary>
public Unit TopPadding
{
get { return _topPadding; }
set { _topPadding = value; }
}
[DV]
public Unit _topPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the default bottom padding for all cells of the table.
/// </summary>
public Unit BottomPadding
{
get { return _bottomPadding; }
set { _bottomPadding = value; }
}
[DV]
public Unit _bottomPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the default left padding for all cells of the table.
/// </summary>
public Unit LeftPadding
{
get { return _leftPadding; }
set { _leftPadding = value; }
}
[DV]
public Unit _leftPadding = Unit.NullValue;
/// <summary>
/// Gets or sets the default right padding for all cells of the table.
/// </summary>
public Unit RightPadding
{
get { return _rightPadding; }
set { _rightPadding = value; }
}
[DV]
public Unit _rightPadding = Unit.NullValue;
/// <summary>
/// Gets the default Borders object for all cells of the column.
/// </summary>
public Borders Borders
{
get { return _borders ?? (_borders = new Borders(this)); }
set
{
SetParent(value);
_borders = value;
}
}
[DV]
public Borders _borders;
/// <summary>
/// Gets the default Shading object for all cells of the column.
/// </summary>
public Shading Shading
{
get { return _shading ?? (_shading = new Shading(this)); }
set
{
SetParent(value);
_shading = value;
}
}
[DV]
public Shading _shading;
/// <summary>
/// Gets or sets a value indicating whether
/// to keep all the table rows 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 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 Table into DDL.
/// </summary>
public override void Serialize(Serializer serializer)
{
serializer.WriteComment(_comment.Value);
serializer.WriteLine("\\table");
int pos = serializer.BeginAttributes();
if (_style.Value != String.Empty)
serializer.WriteSimpleAttribute("Style", Style);
if (!IsNull("Format"))
_format.Serialize(serializer, "Format", null);
if (!_topPadding.IsNull)
serializer.WriteSimpleAttribute("TopPadding", TopPadding);
if (!_leftPadding.IsNull)
serializer.WriteSimpleAttribute("LeftPadding", LeftPadding);
if (!_rightPadding.IsNull)
serializer.WriteSimpleAttribute("RightPadding", RightPadding);
if (!_bottomPadding.IsNull)
serializer.WriteSimpleAttribute("BottomPadding", BottomPadding);
if (!IsNull("Borders"))
_borders.Serialize(serializer, null);
if (!IsNull("Shading"))
_shading.Serialize(serializer);
serializer.EndAttributes(pos);
serializer.BeginContent();
Columns.Serialize(serializer);
Rows.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.VisitTable(this);
((IVisitable)_columns).AcceptVisitor(visitor, visitChildren);
((IVisitable)_rows).AcceptVisitor(visitor, visitChildren);
}
/// <summary>
/// Gets the cell with the given row and column indices.
/// </summary>
public Cell this[int rwIdx, int clmIdx]
{
get { return Rows[rwIdx].Cells[clmIdx]; }
}
/// <summary>
/// Returns the meta object of this instance.
/// </summary>
public override Meta Meta
{
get { return _meta ?? (_meta = new Meta(typeof(Table))); }
}
static Meta _meta;
#endregion
}
}

View File

@@ -0,0 +1,248 @@
using System.Diagnostics;
namespace MigraDoc.DocumentObjectModel.Tables
{
/// <summary>
/// Contains methods to simplify table formatting.
/// </summary>
public static class TableFormatter
{
/// <summary>
/// Adds one variable count of rows and columns to the top, right, bottom and left of the table.
/// </summary>
/// <param name="table"></param>
/// <param name="newSurroundingCells"></param>
public static void ExpandTable(Table table, int newSurroundingCells)
{
ExpandTable(table, newSurroundingCells, newSurroundingCells, newSurroundingCells, newSurroundingCells);
}
/// <summary>
/// Adds one variable count of rows and one of columns to the right and the bottom of the table.
/// </summary>
/// <param name="table"></param>
/// <param name="newColsRight"></param>
/// <param name="newRowsBottom"></param>
public static void ExpandTable(Table table, int newColsRight, int newRowsBottom)
{
ExpandTable(table, 0, newColsRight, newRowsBottom, 0);
}
/// <summary>
/// Adds variable counts of rows and columns to the top, right, bottom and of left of the table.
/// </summary>
/// <param name="table"></param>
/// <param name="newRowsTop"></param>
/// <param name="newColsRight"></param>
/// <param name="newRowsBottom"></param>
/// <param name="newColsLeft"></param>
public static void ExpandTable(Table table, int newRowsTop, int newColsRight, int newRowsBottom, int newColsLeft)
{
for (int i = 0; i < newRowsTop; i++)
table.Rows.InsertObject(0, new Row());
for (int i = 0; i < newColsLeft; i++)
{
table.Columns.InsertObject(0, new Column());
foreach (Row row in table.Rows)
row.Cells.InsertObject(0, new Cell());
}
for (int i = 0; i < newRowsBottom; i++)
table.Rows.Add(new Row());
for (int i = 0; i < newColsRight; i++)
table.Columns.Add(new Column());
}
/// <summary>
/// Sets the corner cells of the table to rounded corners.
/// </summary>
/// <param name="table"></param>
public static void SetRoundedCorners(Table table)
{
int rowCount = table.Rows.Count;
int colCount = table.Columns.Count;
if (rowCount < 2 || colCount < 2)
return;
table.Rows[0].Cells[0].RoundedCorner = RoundedCorner.TopLeft;
table.Rows[0].Cells[colCount - 1].RoundedCorner = RoundedCorner.TopRight;
table.Rows[rowCount - 1].Cells[colCount - 1].RoundedCorner = RoundedCorner.BottomRight;
table.Rows[rowCount - 1].Cells[0].RoundedCorner = RoundedCorner.BottomLeft;
}
/// <summary>
/// Sets the width/height of the outer columns/rows to one value.
/// </summary>
/// <param name="table"></param>
/// <param name="width"></param>
public static void SetOuterCellsWidth(Table table, Unit width)
{
SetOuterCellsWidth(table, width, width);
}
/// <summary>
/// Sets each the width of the outer columns and the height of the outer rows to a value.
/// </summary>
/// <param name="table"></param>
/// <param name="width"></param>
/// <param name="height"></param>
public static void SetOuterCellsWidth(Table table, Unit width, Unit height)
{
int rowCount = table.Rows.Count;
int colCount = table.Columns.Count;
if (rowCount < 2 || colCount < 2)
return;
table.Columns[0].Width = width;
table.Columns[colCount - 1].Width = width;
table.Rows[0].Height = height;
table.Rows[0].HeightRule = RowHeightRule.Exactly;
table.Rows[rowCount - 1].Height = height;
table.Rows[rowCount - 1].HeightRule = RowHeightRule.Exactly;
}
/// <summary>
/// Get the Shading of the first "targetRowCount" Rows from the Row below.
/// </summary>
/// <param name="table"></param>
/// <param name="targetRowCount"></param>
public static void CopyNeighbouringRowShadingToTop(Table table, int targetRowCount)
{
if (table.Rows.Count <= targetRowCount)
return;
Row source = table.Rows[targetRowCount];
for (int i = 0; i < targetRowCount; i++)
table.Rows[i].Shading = source.Shading.Clone();
}
/// <summary>
/// Get the Shading of the last "targetRowCount" Rows from the Row above.
/// </summary>
/// <param name="table"></param>
/// <param name="targetRowCount"></param>
public static void CopyNeighbouringRowShadingToBottom(Table table, int targetRowCount)
{
int lastIndex = table.Rows.Count - 1;
if (lastIndex - targetRowCount < 0)
return;
Row source = table.Rows[lastIndex - targetRowCount];
for (int i = 0; i < targetRowCount; i++)
table.Rows[lastIndex - i].Shading = source.Shading.Clone();
}
/// <summary>
/// Removes all inner horizontal Borders between "start" index and the next "count" Rows.
/// </summary>
/// <param name="table"></param>
/// <param name="start"></param>
/// <param name="count"></param>
public static void RemoveInnerHorizontalBorders(Table table, int start, int count)
{
int end = start + count;
for (int i = start; i < end - 1; i++)
{
if (i + 1 >= table.Rows.Count)
break;
table.Rows[i].Borders.Bottom.Visible = false;
table.Rows[i + 1].Borders.Top.Visible = false;
}
}
/// <summary>
/// Removes all inner vertical Borders between "start" index and the next "count" Columns.
/// </summary>
/// <param name="table"></param>
/// <param name="start"></param>
/// <param name="count"></param>
public static void RemoveInnerVerticalBorders(Table table, int start, int count)
{
int end = start + count;
for (int i = start; i < end - 1; i++)
{
if (i + 1 >= table.Columns.Count)
break;
table.Columns[i].Borders.Right.Visible = false;
table.Columns[i + 1].Borders.Left.Visible = false;
}
}
/// <summary>
/// Inserts a magic glue column to avoid PageBreaks at the first "rowCountTop" and the last "rowCountBottom" of a Table.
/// </summary>
/// <param name="table"></param>
/// <param name="insertAtIndex"></param>
/// <param name="rowCountTop">For example 3 for rounded corners Row, Header Row and first content Row.</param>
/// <param name="rowCountBottom">For example 2 for last content Row and rounded corners Row.</param>
public static void InsertGlueColumn(Table table, int insertAtIndex, int rowCountTop, int rowCountBottom)
{
if (table.Columns.Count == 0)
return;
int glueColumnIndex = insertAtIndex + 1;
Unit glueColumnWidth = Unit.FromPoint(0.1);
Column glueColumn = new Column();
glueColumn.Width = glueColumnWidth;
if (table.Columns[insertAtIndex].Width > glueColumnWidth)
table.Columns[insertAtIndex].Width -= glueColumnWidth;
table.Columns.InsertObject(glueColumnIndex, glueColumn);
foreach (Row row in table.Rows)
{
if (row.Cells.Count > glueColumnIndex)
row.Cells.InsertObject(glueColumnIndex, new Cell());
}
int mergeTop = rowCountTop - 1;
if (mergeTop < table.Rows.Count)
table.Rows[0].Cells[glueColumnIndex].MergeDown = mergeTop;
int mergeBottom = rowCountBottom - 1;
if (table.Rows.Count - 1 - mergeBottom >= 0)
table.Rows[table.Rows.Count - 1 - mergeBottom].Cells[glueColumnIndex].MergeDown = mergeBottom;
}
/// <summary>
/// Surrounds "count" Elements beginning with index "start" with a one-Column Table of the specified width, where each row contains one of the paragraphs.
/// </summary>
/// <param name="section"></param>
/// <param name="start"></param>
/// <param name="count"></param>
/// <param name="columnWidth"></param>
public static Table SurroundContentWithTable(Section section, int start, int count, Unit columnWidth)
{
Table table = new Table();
table.Columns.AddColumn();
table.Borders.Width = 0;
table.Columns[0].Width = columnWidth;
while (count-- > 0)
{
Row row = table.AddRow();
row.Cells.Add(new Cell());
Paragraph paragraph = section.Elements[start].Clone() as Paragraph;
if (paragraph != null)
{
row.Cells[0].Add(paragraph);
section.Elements.RemoveObjectAt(start);
}
else
Debug.Assert(false);
}
section.Elements.InsertObject(start, table);
return table;
}
}
}

View File

@@ -0,0 +1,57 @@
#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;
#pragma warning disable 1591
namespace MigraDoc.DocumentObjectModel.Tables
{
/// <summary>
/// Combinable flags to set Borders using the SetEdge function.
/// </summary>
[Flags]
public enum Edge
{
Top = 0x0001,
Left = 0x0002,
Bottom = 0x0004,
Right = 0x0008,
Horizontal = 0x0010,
Vertical = 0x0020,
DiagonalDown = 0x0040,
DiagonalUp = 0x0080,
Box = Top | Left | Bottom | Right,
Interior = Horizontal | Vertical,
Cross = DiagonalDown | DiagonalUp,
}
}

View File

@@ -0,0 +1,48 @@
#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.Tables
{
/// <summary>
/// Specifies if the Cell should be rendered as a rounded corner.
/// </summary>
public enum RoundedCorner
{
None,
TopLeft,
TopRight,
BottomLeft,
BottomRight
}
}

View File

@@ -0,0 +1,46 @@
#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.Tables
{
/// <summary>
/// Specifies the horizontal alignment of the table.
/// </summary>
public enum RowAlignment
{
Left,
Center,
Right
}
}

View File

@@ -0,0 +1,46 @@
#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.Tables
{
/// <summary>
/// Specifies the calculation rule of the row height.
/// </summary>
public enum RowHeightRule
{
AtLeast,
Auto,
Exactly
}
}

View File

@@ -0,0 +1,46 @@
#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.Tables
{
/// <summary>
/// Specifies the vertical alignment of the cell's content.
/// </summary>
public enum VerticalAlignment
{
Top,
Center,
Bottom
}
}

View File

@@ -0,0 +1,93 @@
#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.Collections.Generic;
using MigraDoc.DocumentObjectModel.Tables;
namespace MigraDoc.DocumentObjectModel.Visitors
{
/// <summary>
/// Comparer for the cell positions within a table.
/// It compares the cell positions from top to bottom and left to right.
/// </summary>
public class CellComparer : IComparer<Cell>
{
// AG_HACK
//public int Compare(object lhs, object rhs)
//{
// if (!(lhs is Cell))
// throw new ArgumentException(DomSR.CompareJustCells, "lhs");
// if (!(rhs is Cell))
// throw new ArgumentException(DomSR.CompareJustCells, "rhs");
// Cell cellLhs = lhs as Cell;
// Cell cellRhs = rhs as Cell;
// int rowCmpr = cellLhs.Row.Index - cellRhs.Row.Index;
// if (rowCmpr != 0)
// return rowCmpr;
// return cellLhs.Column.Index - cellRhs.Column.Index;
//}
//int IComparer<object>.Compare(object lhs, object rhs)
//{
// if (!(lhs is Cell))
// throw new ArgumentException(DomSR.CompareJustCells, "lhs");
// if (!(rhs is Cell))
// throw new ArgumentException(DomSR.CompareJustCells, "rhs");
// Cell cellLhs = lhs as Cell;
// Cell cellRhs = rhs as Cell;
// int rowCmpr = cellLhs.Row.Index - cellRhs.Row.Index;
// if (rowCmpr != 0)
// return rowCmpr;
// return cellLhs.Column.Index - cellRhs.Column.Index;
//}
/// <summary>
/// Compares the specified cells.
/// </summary>
/// <returns></returns>
public int Compare(Cell cellLhs, Cell cellRhs)
{
int rowCmpr = cellLhs.Row.Index - cellRhs.Row.Index;
if (rowCmpr != 0)
return rowCmpr;
return cellLhs.Column.Index - cellRhs.Column.Index;
}
}
}

View File

@@ -0,0 +1,91 @@
#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.Shapes;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MigraDoc.DocumentObjectModel.Tables;
namespace MigraDoc.DocumentObjectModel.Visitors
{
/// <summary>
/// Represents the base visitor for the DocumentObject.
/// </summary>
public abstract class DocumentObjectVisitor
{
/// <summary>
/// Visits the specified document object.
/// </summary>
public abstract void Visit(DocumentObject documentObject);
// Chart
public virtual void VisitChart(Chart chart) { }
public virtual void VisitTextArea(TextArea textArea) { }
public virtual void VisitLegend(Legend legend) { }
// Document
public virtual void VisitDocument(Document document) { }
public virtual void VisitDocumentElements(DocumentElements elements) { }
public virtual void VisitDocumentObjectCollection(DocumentObjectCollection elements) { }
// Fields
// Format
public virtual void VisitFont(Font font) { }
public virtual void VisitParagraphFormat(ParagraphFormat paragraphFormat) { }
public virtual void VisitShading(Shading shading) { }
public virtual void VisitStyle(Style style) { }
public virtual void VisitStyles(Styles styles) { }
// Paragraph
public virtual void VisitFootnote(Footnote footnote) { }
public virtual void VisitHyperlink(Hyperlink hyperlink) { }
public virtual void VisitFormattedText(FormattedText formattedText) { }
public virtual void VisitParagraph(Paragraph paragraph) { }
// Section
public virtual void VisitHeaderFooter(HeaderFooter headerFooter) { }
public virtual void VisitHeadersFooters(HeadersFooters headersFooters) { }
public virtual void VisitSection(Section section) { }
public virtual void VisitSections(Sections sections) { }
// Shape
public virtual void VisitImage(Image image) { }
public virtual void VisitTextFrame(TextFrame textFrame) { }
// Table
public virtual void VisitCell(Cell cell) { }
public virtual void VisitColumns(Columns columns) { }
public virtual void VisitRow(Row row) { }
public virtual void VisitRows(Rows rows) { }
public virtual void VisitTable(Table table) { }
}
}

View File

@@ -0,0 +1,42 @@
#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.Visitors
{
public interface IVisitable
{
/// <summary>
/// Allows the visitor object to visit the document object and its child objects.
/// </summary>
void AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren);
}
}

View File

@@ -0,0 +1,357 @@
#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.Tables;
using MigraDoc.DocumentObjectModel.publics;
namespace MigraDoc.DocumentObjectModel.Visitors
{
/// <summary>
/// Represents a merged list of cells of a table.
/// </summary>
public class MergedCellList : List<Cell>
{
/// <summary>
/// Enumeration of neighbor positions of cells in a table.
/// </summary>
enum NeighborPosition
{
Top,
Left,
Right,
Bottom
}
/// <summary>
/// Initializes a new instance of the MergedCellList class.
/// </summary>
public MergedCellList(Table table)
{
Init(table);
}
/// <summary>
/// Initializes this instance from a table.
/// </summary>
private void Init(Table table)
{
for (int rwIdx = 0; rwIdx < table.Rows.Count; ++rwIdx)
{
for (int clmIdx = 0; clmIdx < table.Columns.Count; ++clmIdx)
{
Cell cell = table[rwIdx, clmIdx];
if (!IsAlreadyCovered(cell))
Add(cell);
}
}
}
/// <summary>
/// Returns whether the given cell is already covered by a preceding cell in this instance.
/// </summary>
/// <remarks>
/// Help function for Init().
/// </remarks>
private bool IsAlreadyCovered(Cell cell)
{
for (int index = Count - 1; index >= 0; --index)
{
Cell currentCell = this[index];
if (currentCell.Column.Index <= cell.Column.Index && currentCell.Column.Index + currentCell.MergeRight >= cell.Column.Index)
{
if (currentCell.Row.Index <= cell.Row.Index && currentCell.Row.Index + currentCell.MergeDown >= cell.Row.Index)
return true;
if (currentCell.Row.Index + currentCell.MergeDown == cell.Row.Index - 1)
return false;
}
}
return false;
}
/// <summary>
/// Gets the cell at the specified position.
/// </summary>
public new Cell this[int index]
{
get { return base[index]; }
}
/// <summary>
/// Gets a borders object that should be used for rendering.
/// </summary>
/// <exception cref="System.ArgumentException">
/// Thrown when the cell is not in this list.
/// This situation occurs if the given cell is merged "away" by a previous one.
/// </exception>
public Borders GetEffectiveBorders(Cell cell)
{
//Borders borders = cell.GetValue("Borders", GV.ReadOnly) as Borders;
Borders borders = cell._borders;
if (borders != null)
{
//Document doc = borders.Document;
borders = borders.Clone();
borders._parent = cell;
//doc = borders.Document;
}
else
borders = new Borders(cell._parent);
int cellIdx = BinarySearch(cell, new CellComparer());
if (!(cellIdx >= 0 && cellIdx < Count))
throw new ArgumentException("cell is not a relevant cell", "cell");
if (cell._mergeRight > 0)
{
Cell rightBorderCell = cell.Table[cell.Row.Index, cell.Column.Index + cell._mergeRight];
if (rightBorderCell._borders != null && rightBorderCell._borders._right != null)
borders.Right = rightBorderCell._borders._right.Clone();
else
borders._right = null;
}
if (cell._mergeDown > 0)
{
Cell bottomBorderCell = cell.Table[cell.Row.Index + cell._mergeDown, cell.Column.Index];
if (bottomBorderCell._borders != null && bottomBorderCell._borders._bottom != null)
borders.Bottom = bottomBorderCell._borders._bottom.Clone();
else
borders._bottom = null;
}
// For BorderTypes Top, Right, Bottom and Left update the width with the neighbours touching border where required.
// In case of rounded corners this should not be done.
Cell leftNeighbor = GetNeighbor(cellIdx, NeighborPosition.Left);
if (leftNeighbor != null && leftNeighbor.RoundedCorner != RoundedCorner.TopRight && leftNeighbor.RoundedCorner != RoundedCorner.BottomRight)
{
Borders nbrBrdrs = leftNeighbor.GetValue("Borders", GV.ReadWrite) as Borders;
if (nbrBrdrs != null && GetEffectiveBorderWidth(nbrBrdrs, BorderType.Right) >= GetEffectiveBorderWidth(borders, BorderType.Left))
borders.SetValue("Left", GetBorderFromBorders(nbrBrdrs, BorderType.Right));
}
Cell rightNeighbor = GetNeighbor(cellIdx, NeighborPosition.Right);
if (rightNeighbor != null && rightNeighbor.RoundedCorner != RoundedCorner.TopLeft && rightNeighbor.RoundedCorner != RoundedCorner.BottomLeft)
{
Borders nbrBrdrs = rightNeighbor.GetValue("Borders", GV.ReadWrite) as Borders;
if (nbrBrdrs != null && GetEffectiveBorderWidth(nbrBrdrs, BorderType.Left) > GetEffectiveBorderWidth(borders, BorderType.Right))
borders.SetValue("Right", GetBorderFromBorders(nbrBrdrs, BorderType.Left));
}
Cell topNeighbor = GetNeighbor(cellIdx, NeighborPosition.Top);
if (topNeighbor != null && topNeighbor.RoundedCorner != RoundedCorner.BottomLeft && topNeighbor.RoundedCorner != RoundedCorner.BottomRight)
{
Borders nbrBrdrs = topNeighbor.GetValue("Borders", GV.ReadWrite) as Borders;
if (nbrBrdrs != null && GetEffectiveBorderWidth(nbrBrdrs, BorderType.Bottom) >= GetEffectiveBorderWidth(borders, BorderType.Top))
borders.SetValue("Top", GetBorderFromBorders(nbrBrdrs, BorderType.Bottom));
}
Cell bottomNeighbor = GetNeighbor(cellIdx, NeighborPosition.Bottom);
if (bottomNeighbor != null && bottomNeighbor.RoundedCorner != RoundedCorner.TopLeft && bottomNeighbor.RoundedCorner != RoundedCorner.TopRight)
{
Borders nbrBrdrs = bottomNeighbor.GetValue("Borders", GV.ReadWrite) as Borders;
if (nbrBrdrs != null && GetEffectiveBorderWidth(nbrBrdrs, BorderType.Top) > GetEffectiveBorderWidth(borders, BorderType.Bottom))
borders.SetValue("Bottom", GetBorderFromBorders(nbrBrdrs, BorderType.Top));
}
return borders;
}
/// <summary>
/// Gets the cell that covers the given cell by merging. Usually the cell itself if not merged.
/// </summary>
public Cell GetCoveringCell(Cell cell)
{
int cellIdx = BinarySearch(cell, new CellComparer());
if (cellIdx >= 0 && cellIdx < Count)
return this[cellIdx];
// Binary Search returns the complement of the next value, therefore, "~cellIdx - 1" is the previous cell.
cellIdx = ~cellIdx - 1;
for (int index = cellIdx; index >= 0; --index)
{
Cell currCell = this[index];
if (currCell.Column.Index <= cell.Column.Index &&
currCell.Column.Index + currCell.MergeRight >= cell.Column.Index &&
currCell.Row.Index <= cell.Row.Index &&
currCell.Row.Index + currCell.MergeDown >= cell.Row.Index)
return currCell;
}
return null;
}
/// <summary>
/// Returns the border of the given borders-object of the specified type (top, bottom, ...).
/// If that border doesn't exist, it returns a new border object that inherits all properties from the given borders object
/// </summary>
private static Border GetBorderFromBorders(Borders borders, BorderType type)
{
Border returnBorder = borders.GetBorderReadOnly(type);
if (returnBorder == null)
{
returnBorder = new Border();
returnBorder._style = borders._style;
returnBorder._width = borders._width;
returnBorder._color = borders._color;
returnBorder._visible = borders._visible;
}
return returnBorder;
}
/// <summary>
/// Returns the width of the border at the specified position.
/// </summary>
private static Unit GetEffectiveBorderWidth(Borders borders, BorderType type)
{
if (borders == null)
return 0;
Border border = borders.GetBorderReadOnly(type);
DocumentObject relevantDocObj = border;
if (relevantDocObj == null || relevantDocObj.IsNull("Width"))
relevantDocObj = borders;
// Avoid unnecessary GetValue calls.
object visible = relevantDocObj.GetValue("visible", GV.GetNull);
if (visible != null && !(bool)visible)
return 0;
object width = relevantDocObj.GetValue("width", GV.GetNull);
if (width != null)
return (Unit)width;
object color = relevantDocObj.GetValue("color", GV.GetNull);
if (color != null)
return 0.5;
object style = relevantDocObj.GetValue("style", GV.GetNull);
if (style != null)
return 0.5;
return 0;
}
/// <summary>
/// Gets the specified cell's uppermost neighbor at the specified position.
/// </summary>
private Cell GetNeighbor(int cellIdx, NeighborPosition position)
{
Cell cell = this[cellIdx];
if (cell.Column.Index == 0 && position == NeighborPosition.Left ||
cell.Row.Index == 0 && position == NeighborPosition.Top ||
cell.Row.Index + cell.MergeDown == cell.Table.Rows.Count - 1 && position == NeighborPosition.Bottom ||
cell.Column.Index + cell.MergeRight == cell.Table.Columns.Count - 1 && position == NeighborPosition.Right)
return null;
switch (position)
{
case NeighborPosition.Top:
case NeighborPosition.Left:
for (int index = cellIdx - 1; index >= 0; --index)
{
Cell currCell = this[index];
if (IsNeighbor(cell, currCell, position))
return currCell;
}
break;
case NeighborPosition.Right:
if (cellIdx + 1 < Count)
{
Cell cell2 = this[cellIdx + 1];
if (cell2.Row.Index == cell.Row.Index)
return cell2;
}
for (int index = cellIdx - 1; index >= 0; --index)
{
Cell currCell = this[index];
if (IsNeighbor(cell, currCell, position))
return currCell;
}
break;
case NeighborPosition.Bottom:
for (int index = cellIdx + 1; index < Count; ++index)
{
Cell currCell = this[index];
if (IsNeighbor(cell, currCell, position))
return currCell;
}
break;
}
return null;
}
/// <summary>
/// Returns whether cell2 is a neighbor of cell1 at the specified position.
/// </summary>
private bool IsNeighbor(Cell cell1, Cell cell2, NeighborPosition position)
{
bool isNeighbor = false;
switch (position)
{
case NeighborPosition.Bottom:
int bottomRowIdx = cell1.Row.Index + cell1.MergeDown + 1;
isNeighbor = cell2.Row.Index == bottomRowIdx &&
cell2.Column.Index <= cell1.Column.Index &&
cell2.Column.Index + cell2.MergeRight >= cell1.Column.Index;
break;
case NeighborPosition.Left:
int leftClmIdx = cell1.Column.Index - 1;
isNeighbor = cell2.Row.Index <= cell1.Row.Index &&
cell2.Row.Index + cell2.MergeDown >= cell1.Row.Index &&
cell2.Column.Index + cell2.MergeRight == leftClmIdx;
break;
case NeighborPosition.Right:
int rightClmIdx = cell1.Column.Index + cell1.MergeRight + 1;
isNeighbor = cell2.Row.Index <= cell1.Row.Index &&
cell2.Row.Index + cell2.MergeDown >= cell1.Row.Index &&
cell2.Column.Index == rightClmIdx;
break;
case NeighborPosition.Top:
int topRowIdx = cell1.Row.Index - 1;
isNeighbor = cell2.Row.Index + cell2.MergeDown == topRowIdx &&
cell2.Column.Index + cell2.MergeRight >= cell1.Column.Index &&
cell2.Column.Index <= cell1.Column.Index;
break;
}
return isNeighbor;
}
}
}

View File

@@ -0,0 +1,243 @@
#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.Collections.Generic;
namespace MigraDoc.DocumentObjectModel.Visitors
{
/// <summary>
/// Flattens a document for PDF rendering.
/// </summary>
public class PdfFlattenVisitor : VisitorBase
{
/// <summary>
/// Initializes a new instance of the PdfFlattenVisitor class.
/// </summary>
public PdfFlattenVisitor()
{
//this .docObject = documentObject;
}
public override void VisitDocumentElements(DocumentElements elements)
{
#if true
// New version without sorted list
int count = elements.Count;
for (int idx = 0; idx < count; ++idx)
{
Paragraph paragraph = elements[idx] as Paragraph;
if (paragraph != null)
{
Paragraph[] paragraphs = paragraph.SplitOnParaBreak();
if (paragraphs != null)
{
foreach (Paragraph para in paragraphs)
{
elements.InsertObject(idx++, para);
++count;
}
elements.RemoveObjectAt(idx--);
--count;
}
}
}
#else
SortedList splitParaList = new SortedList();
for (int idx = 0; idx < elements.Count; ++idx)
{
Paragraph paragraph = elements[idx] as Paragraph;
if (paragraph != null)
{
Paragraph[] paragraphs = paragraph.SplitOnParaBreak();
if (paragraphs != null)
splitParaList.Add(idx, paragraphs);
}
}
int insertedObjects = 0;
for (int idx = 0; idx < splitParaList.Count; ++idx)
{
int insertPosition = (int)splitParaList.GetKey(idx);
Paragraph[] paragraphs = (Paragraph[])splitParaList.GetByIndex(idx);
foreach (Paragraph paragraph in paragraphs)
{
elements.InsertObject(insertPosition + insertedObjects, paragraph);
++insertedObjects;
}
elements.RemoveObjectAt(insertPosition + insertedObjects);
--insertedObjects;
}
#endif
}
public override void VisitDocumentObjectCollection(DocumentObjectCollection elements)
{
List<int> textIndices = new List<int>();
if (elements is ParagraphElements)
{
for (int idx = 0; idx < elements.Count; ++idx)
{
if (elements[idx] is Text)
textIndices.Add(idx);
}
}
int[] indices = (int[])textIndices.ToArray();
if (indices != null)
{
int insertedObjects = 0;
foreach (int idx in indices)
{
Text text = (Text)elements[idx + insertedObjects];
string currentString = "";
foreach (char ch in text.Content)
{
// TODO Add support for other breaking spaces (en space, em space, &c.).
switch (ch)
{
case ' ':
case '\r':
case '\n':
case '\t':
if (currentString != "")
{
elements.InsertObject(idx + insertedObjects, new Text(currentString));
++insertedObjects;
currentString = "";
}
elements.InsertObject(idx + insertedObjects, new Text(" "));
++insertedObjects;
break;
case '-': // minus.
elements.InsertObject(idx + insertedObjects, new Text(currentString + ch));
++insertedObjects;
currentString = "";
break;
// Characters that allow line breaks without indication.
case '\u200B': // zero width space.
case '\u200C': // zero width non-joiner.
if (currentString != "")
{
elements.InsertObject(idx + insertedObjects, new Text(currentString));
++insertedObjects;
currentString = "";
}
break;
case '<27>': // soft hyphen.
if (currentString != "")
{
elements.InsertObject(idx + insertedObjects, new Text(currentString));
++insertedObjects;
currentString = "";
}
elements.InsertObject(idx + insertedObjects, new Text("<22>"));
++insertedObjects;
//currentString = "";
break;
default:
currentString += ch;
break;
}
}
if (currentString != "")
{
elements.InsertObject(idx + insertedObjects, new Text(currentString));
++insertedObjects;
}
elements.RemoveObjectAt(idx + insertedObjects);
--insertedObjects;
}
}
}
public override void VisitFormattedText(FormattedText formattedText)
{
Document document = formattedText.Document;
ParagraphFormat format = null;
Style style = document._styles[formattedText._style.Value];
if (style != null)
format = style._paragraphFormat;
else if (formattedText._style.Value != "")
format = document._styles[StyleNames.InvalidStyleName]._paragraphFormat;
if (format != null)
{
if (formattedText._font == null)
formattedText.Font = format._font.Clone();
else if (format._font != null)
FlattenFont(formattedText._font, format._font);
}
Font parentFont = GetParentFont(formattedText);
if (formattedText._font == null)
formattedText.Font = parentFont.Clone();
else if (parentFont != null)
FlattenFont(formattedText._font, parentFont);
}
public override void VisitHyperlink(Hyperlink hyperlink)
{
Font styleFont = hyperlink.Document.Styles[StyleNames.Hyperlink].Font;
if (hyperlink._font == null)
hyperlink.Font = styleFont.Clone();
else
FlattenFont(hyperlink._font, styleFont);
FlattenFont(hyperlink._font, GetParentFont(hyperlink));
}
protected Font GetParentFont(DocumentObject obj)
{
DocumentObject parentElements = DocumentRelations.GetParent(obj);
DocumentObject parentObject = DocumentRelations.GetParent(parentElements);
Font parentFont;
Paragraph paragraph = parentObject as Paragraph;
if (paragraph != null)
{
ParagraphFormat format = paragraph.Format;
parentFont = format._font;
}
else // Hyperlink or FormattedText
{
parentFont = parentObject.GetValue("Font") as Font;
}
return parentFont;
}
}
}

View File

@@ -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
namespace MigraDoc.DocumentObjectModel.Visitors
{
/// <summary>
/// Represents the visitor for flattening the DocumentObject to be used in the RtfRenderer.
/// </summary>
public class RtfFlattenVisitor : VisitorBase
{
public override void VisitFormattedText(FormattedText formattedText)
{
Document document = formattedText.Document;
ParagraphFormat format = null;
Style style = document._styles[formattedText._style.Value];
if (style != null)
format = style._paragraphFormat;
else if (formattedText._style.Value != "")
format = document._styles[StyleNames.InvalidStyleName]._paragraphFormat;
if (format != null)
{
if (formattedText._font == null)
formattedText.Font = format._font.Clone();
else if (format._font != null)
FlattenFont(formattedText._font, format._font);
}
}
public override void VisitHyperlink(Hyperlink hyperlink)
{
Font styleFont = hyperlink.Document.Styles[StyleNames.Hyperlink].Font;
if (hyperlink._font == null)
hyperlink.Font = styleFont.Clone();
else
FlattenFont(hyperlink._font, styleFont);
}
}
}

View File

@@ -0,0 +1,897 @@
#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.Tables;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
namespace MigraDoc.DocumentObjectModel.Visitors
{
/// <summary>
/// Summary description for VisitorBase.
/// </summary>
public abstract class VisitorBase : DocumentObjectVisitor
{
public override void Visit(DocumentObject documentObject)
{
IVisitable visitable = documentObject as IVisitable;
if (visitable != null)
visitable.AcceptVisitor(this, true);
}
protected void FlattenParagraphFormat(ParagraphFormat format, ParagraphFormat refFormat)
{
if (format._alignment.IsNull)
format._alignment = refFormat._alignment;
if (format._firstLineIndent.IsNull)
format._firstLineIndent = refFormat._firstLineIndent;
if (format._leftIndent.IsNull)
format._leftIndent = refFormat._leftIndent;
if (format._rightIndent.IsNull)
format._rightIndent = refFormat._rightIndent;
if (format._spaceBefore.IsNull)
format._spaceBefore = refFormat._spaceBefore;
if (format._spaceAfter.IsNull)
format._spaceAfter = refFormat._spaceAfter;
if (format._lineSpacingRule.IsNull)
format._lineSpacingRule = refFormat._lineSpacingRule;
if (format._lineSpacing.IsNull)
format._lineSpacing = refFormat._lineSpacing;
if (format._widowControl.IsNull)
format._widowControl = refFormat._widowControl;
if (format._keepTogether.IsNull)
format._keepTogether = refFormat._keepTogether;
if (format._keepWithNext.IsNull)
format._keepWithNext = refFormat._keepWithNext;
if (format._pageBreakBefore.IsNull)
format._pageBreakBefore = refFormat._pageBreakBefore;
if (format._outlineLevel.IsNull)
format._outlineLevel = refFormat._outlineLevel;
if (format._font == null)
{
if (refFormat._font != null)
{
//The font is cloned here to avoid parent problems
format._font = refFormat._font.Clone();
format._font._parent = format;
}
}
else if (refFormat._font != null)
FlattenFont(format._font, refFormat._font);
if (format._shading == null)
{
if (refFormat._shading != null)
{
format._shading = refFormat._shading.Clone();
format._shading._parent = format;
}
//format.shading = refFormat.shading;
}
else if (refFormat._shading != null)
FlattenShading(format._shading, refFormat._shading);
if (format._borders == null)
format._borders = refFormat._borders;
else if (refFormat._borders != null)
FlattenBorders(format._borders, refFormat._borders);
//if (format.tabStops == null)
// format.tabStops = refFormat.tabStops;
if (refFormat._tabStops != null)
FlattenTabStops(format.TabStops, refFormat._tabStops);
if (refFormat._listInfo != null)
FlattenListInfo(format.ListInfo, refFormat._listInfo);
}
protected void FlattenListInfo(ListInfo listInfo, ListInfo refListInfo)
{
if (listInfo._continuePreviousList.IsNull)
listInfo._continuePreviousList = refListInfo._continuePreviousList;
if (listInfo._listType.IsNull)
listInfo._listType = refListInfo._listType;
if (listInfo._numberPosition.IsNull)
listInfo._numberPosition = refListInfo._numberPosition;
}
protected void FlattenFont(Font font, Font refFont)
{
if (font._name.IsNull)
font._name = refFont._name;
if (font._size.IsNull)
font._size = refFont._size;
if (font._color.IsNull)
font._color = refFont._color;
if (font._underline.IsNull)
font._underline = refFont._underline;
if (font._bold.IsNull)
font._bold = refFont._bold;
if (font._italic.IsNull)
font._italic = refFont._italic;
if (font._superscript.IsNull)
font._superscript = refFont._superscript;
if (font._subscript.IsNull)
font._subscript = refFont._subscript;
}
protected void FlattenShading(Shading shading, Shading refShading)
{
//fClear?
if (shading._visible.IsNull)
shading._visible = refShading._visible;
if (shading._color.IsNull)
shading._color = refShading._color;
}
protected Border FlattenedBorderFromBorders(Border border, Borders parentBorders)
{
if (border == null)
border = new Border(parentBorders);
if (border._visible.IsNull)
border._visible = parentBorders._visible;
if (border._style.IsNull)
border._style = parentBorders._style;
if (border._width.IsNull)
border._width = parentBorders._width;
if (border._color.IsNull)
border._color = parentBorders._color;
return border;
}
protected void FlattenBorders(Borders borders, Borders refBorders)
{
if (borders._visible.IsNull)
borders._visible = refBorders._visible;
if (borders._width.IsNull)
borders._width = refBorders._width;
if (borders._style.IsNull)
borders._style = refBorders._style;
if (borders._color.IsNull)
borders._color = refBorders._color;
if (borders._distanceFromBottom.IsNull)
borders._distanceFromBottom = refBorders._distanceFromBottom;
if (borders._distanceFromRight.IsNull)
borders._distanceFromRight = refBorders._distanceFromRight;
if (borders._distanceFromLeft.IsNull)
borders._distanceFromLeft = refBorders._distanceFromLeft;
if (borders._distanceFromTop.IsNull)
borders._distanceFromTop = refBorders._distanceFromTop;
if (refBorders._left != null)
{
FlattenBorder(borders.Left, refBorders._left);
FlattenedBorderFromBorders(borders._left, borders);
}
if (refBorders._right != null)
{
FlattenBorder(borders.Right, refBorders._right);
FlattenedBorderFromBorders(borders._right, borders);
}
if (refBorders._top != null)
{
FlattenBorder(borders.Top, refBorders._top);
FlattenedBorderFromBorders(borders._top, borders);
}
if (refBorders._bottom != null)
{
FlattenBorder(borders.Bottom, refBorders._bottom);
FlattenedBorderFromBorders(borders._bottom, borders);
}
}
protected void FlattenBorder(Border border, Border refBorder)
{
if (border._visible.IsNull)
border._visible = refBorder._visible;
if (border._width.IsNull)
border._width = refBorder._width;
if (border._style.IsNull)
border._style = refBorder._style;
if (border._color.IsNull)
border._color = refBorder._color;
}
protected void FlattenTabStops(TabStops tabStops, TabStops refTabStops)
{
if (!tabStops._fClearAll)
{
foreach (TabStop refTabStop in refTabStops)
{
if (tabStops.GetTabStopAt(refTabStop.Position) == null && refTabStop.AddTab)
tabStops.AddTabStop(refTabStop.Position, refTabStop.Alignment, refTabStop.Leader);
}
}
for (int i = 0; i < tabStops.Count; i++)
{
TabStop tabStop = tabStops[i];
if (!tabStop.AddTab)
tabStops.RemoveObjectAt(i);
}
// The TabStopCollection is complete now.
// Prevent inheritence of tab stops.
tabStops._fClearAll = true;
}
protected void FlattenPageSetup(PageSetup pageSetup, PageSetup refPageSetup)
{
if (pageSetup._pageWidth.IsNull && pageSetup._pageHeight.IsNull)
{
if (pageSetup._pageFormat.IsNull)
{
pageSetup._pageWidth = refPageSetup._pageWidth;
pageSetup._pageHeight = refPageSetup._pageHeight;
pageSetup._pageFormat = refPageSetup._pageFormat;
}
else
PageSetup.GetPageSize(pageSetup.PageFormat, out pageSetup._pageWidth, out pageSetup._pageHeight);
}
else
{
Unit dummyUnit;
if (pageSetup._pageWidth.IsNull)
{
if (pageSetup._pageFormat.IsNull)
pageSetup._pageHeight = refPageSetup._pageHeight;
else
PageSetup.GetPageSize(pageSetup.PageFormat, out dummyUnit, out pageSetup._pageHeight);
}
else if (pageSetup._pageHeight.IsNull)
{
if (pageSetup._pageFormat.IsNull)
pageSetup._pageWidth = refPageSetup._pageWidth;
else
PageSetup.GetPageSize(pageSetup.PageFormat, out pageSetup._pageWidth, out dummyUnit);
}
}
// if (pageSetup.pageWidth.IsNull)
// pageSetup.pageWidth = refPageSetup.pageWidth;
// if (pageSetup.pageHeight.IsNull)
// pageSetup.pageHeight = refPageSetup.pageHeight;
// if (pageSetup.pageFormat.IsNull)
// pageSetup.pageFormat = refPageSetup.pageFormat;
if (pageSetup._sectionStart.IsNull)
pageSetup._sectionStart = refPageSetup._sectionStart;
if (pageSetup._orientation.IsNull)
pageSetup._orientation = refPageSetup._orientation;
if (pageSetup._topMargin.IsNull)
pageSetup._topMargin = refPageSetup._topMargin;
if (pageSetup._bottomMargin.IsNull)
pageSetup._bottomMargin = refPageSetup._bottomMargin;
if (pageSetup._leftMargin.IsNull)
pageSetup._leftMargin = refPageSetup._leftMargin;
if (pageSetup._rightMargin.IsNull)
pageSetup._rightMargin = refPageSetup._rightMargin;
if (pageSetup._headerDistance.IsNull)
pageSetup._headerDistance = refPageSetup._headerDistance;
if (pageSetup._footerDistance.IsNull)
pageSetup._footerDistance = refPageSetup._footerDistance;
if (pageSetup._oddAndEvenPagesHeaderFooter.IsNull)
pageSetup._oddAndEvenPagesHeaderFooter = refPageSetup._oddAndEvenPagesHeaderFooter;
if (pageSetup._differentFirstPageHeaderFooter.IsNull)
pageSetup._differentFirstPageHeaderFooter = refPageSetup._differentFirstPageHeaderFooter;
if (pageSetup._mirrorMargins.IsNull)
pageSetup._mirrorMargins = refPageSetup._mirrorMargins;
if (pageSetup._horizontalPageBreak.IsNull)
pageSetup._horizontalPageBreak = refPageSetup._horizontalPageBreak;
}
protected void FlattenHeaderFooter(HeaderFooter headerFooter, bool isHeader)
{ }
protected void FlattenFillFormat(FillFormat fillFormat)
{ }
protected void FlattenLineFormat(LineFormat lineFormat, LineFormat refLineFormat)
{
if (refLineFormat != null)
{
if (lineFormat._width.IsNull)
lineFormat._width = refLineFormat._width;
}
}
protected void FlattenAxis(Axis axis)
{
if (axis == null)
return;
LineFormat refLineFormat = new LineFormat();
refLineFormat._width = 0.15;
if (axis._hasMajorGridlines.Value && axis._majorGridlines != null)
FlattenLineFormat(axis._majorGridlines._lineFormat, refLineFormat);
if (axis._hasMinorGridlines.Value && axis._minorGridlines != null)
FlattenLineFormat(axis._minorGridlines._lineFormat, refLineFormat);
refLineFormat._width = 0.4;
if (axis._lineFormat != null)
FlattenLineFormat(axis._lineFormat, refLineFormat);
// axis.majorTick;
// axis.majorTickMark;
// axis.minorTick;
// axis.minorTickMark;
// axis.maximumScale;
// axis.minimumScale;
// axis.tickLabels;
// axis.title;
}
protected void FlattenPlotArea(PlotArea plotArea)
{ }
protected void FlattenDataLabel(DataLabel dataLabel)
{ }
#region Chart
public override void VisitChart(Chart chart)
{
Document document = chart.Document;
if (chart._style.IsNull)
chart._style.Value = Style.DefaultParagraphName;
Style style = document.Styles[chart._style.Value];
if (chart._format == null)
{
chart._format = style._paragraphFormat.Clone();
chart._format._parent = chart;
}
else
FlattenParagraphFormat(chart._format, style._paragraphFormat);
FlattenLineFormat(chart._lineFormat, null);
FlattenFillFormat(chart._fillFormat);
FlattenAxis(chart._xAxis);
FlattenAxis(chart._yAxis);
FlattenAxis(chart._zAxis);
FlattenPlotArea(chart._plotArea);
// if (this .hasDataLabel.Value)
FlattenDataLabel(chart._dataLabel);
}
#endregion
#region Document
public override void VisitDocument(Document document)
{
}
public override void VisitDocumentElements(DocumentElements elements)
{
}
#endregion
#region Format
public override void VisitStyle(Style style)
{
Style baseStyle = style.GetBaseStyle();
if (baseStyle != null && baseStyle._paragraphFormat != null)
{
if (style._paragraphFormat == null)
style._paragraphFormat = baseStyle._paragraphFormat;
else
FlattenParagraphFormat(style._paragraphFormat, baseStyle._paragraphFormat);
}
}
public override void VisitStyles(Styles styles)
{
}
#endregion
#region Paragraph
public override void VisitFootnote(Footnote footnote)
{
Document document = footnote.Document;
ParagraphFormat format = null;
Style style = document._styles[footnote._style.Value];
if (style != null)
format = ParagraphFormatFromStyle(style);
else
{
footnote.Style = StyleNames.Footnote;
format = document._styles[StyleNames.Footnote]._paragraphFormat;
}
if (footnote._format == null)
{
footnote._format = format.Clone();
footnote._format._parent = footnote;
}
else
FlattenParagraphFormat(footnote._format, format);
}
public override void VisitParagraph(Paragraph paragraph)
{
Document document = paragraph.Document;
ParagraphFormat format;
DocumentObject currentElementHolder = GetDocumentElementHolder(paragraph);
Style style = document._styles[paragraph._style.Value];
if (style != null)
format = ParagraphFormatFromStyle(style);
else if (currentElementHolder is Cell)
{
paragraph._style = ((Cell)currentElementHolder)._style;
format = ((Cell)currentElementHolder)._format;
}
else if (currentElementHolder is HeaderFooter)
{
HeaderFooter currHeaderFooter = ((HeaderFooter)currentElementHolder);
if (currHeaderFooter.IsHeader)
{
paragraph.Style = StyleNames.Header;
format = document._styles[StyleNames.Header]._paragraphFormat;
}
else
{
paragraph.Style = StyleNames.Footer;
format = document._styles[StyleNames.Footer]._paragraphFormat;
}
if (currHeaderFooter._format != null)
FlattenParagraphFormat(paragraph.Format, currHeaderFooter._format);
}
else if (currentElementHolder is Footnote)
{
paragraph.Style = StyleNames.Footnote;
format = document._styles[StyleNames.Footnote]._paragraphFormat;
}
else if (currentElementHolder is TextArea)
{
paragraph._style = ((TextArea)currentElementHolder)._style;
format = ((TextArea)currentElementHolder)._format;
}
else
{
if (paragraph._style.Value != "")
paragraph.Style = StyleNames.InvalidStyleName;
else
paragraph.Style = StyleNames.Normal;
format = document._styles[paragraph.Style]._paragraphFormat;
}
if (paragraph._format == null)
{
paragraph._format = format.Clone();
paragraph._format._parent = paragraph;
}
else
FlattenParagraphFormat(paragraph._format, format);
}
#endregion
#region Section
public override void VisitHeaderFooter(HeaderFooter headerFooter)
{
Document document = headerFooter.Document;
string styleString;
if (headerFooter.IsHeader)
styleString = StyleNames.Header;
else
styleString = StyleNames.Footer;
ParagraphFormat format;
Style style = document._styles[headerFooter._style.Value];
if (style != null)
format = ParagraphFormatFromStyle(style);
else
{
format = document._styles[styleString]._paragraphFormat;
headerFooter.Style = styleString;
}
if (headerFooter._format == null)
{
headerFooter._format = format.Clone();
headerFooter._format._parent = headerFooter;
}
else
FlattenParagraphFormat(headerFooter._format, format);
}
public override void VisitHeadersFooters(HeadersFooters headersFooters)
{
}
public override void VisitSection(Section section)
{
Section prevSec = section.PreviousSection();
PageSetup prevPageSetup = PageSetup.DefaultPageSetup;
if (prevSec != null)
{
prevPageSetup = prevSec._pageSetup;
if (!section.Headers.HasHeaderFooter(HeaderFooterIndex.Primary))
section.Headers._primary = prevSec.Headers._primary;
if (!section.Headers.HasHeaderFooter(HeaderFooterIndex.EvenPage))
section.Headers._evenPage = prevSec.Headers._evenPage;
if (!section.Headers.HasHeaderFooter(HeaderFooterIndex.FirstPage))
section.Headers._firstPage = prevSec.Headers._firstPage;
if (!section.Footers.HasHeaderFooter(HeaderFooterIndex.Primary))
section.Footers._primary = prevSec.Footers._primary;
if (!section.Footers.HasHeaderFooter(HeaderFooterIndex.EvenPage))
section.Footers._evenPage = prevSec.Footers._evenPage;
if (!section.Footers.HasHeaderFooter(HeaderFooterIndex.FirstPage))
section.Footers._firstPage = prevSec.Footers._firstPage;
}
if (section._pageSetup == null)
section._pageSetup = prevPageSetup;
else
FlattenPageSetup(section._pageSetup, prevPageSetup);
}
public override void VisitSections(Sections sections)
{
}
#endregion
#region Shape
public override void VisitTextFrame(TextFrame textFrame)
{
if (textFrame._height.IsNull)
textFrame._height = Unit.FromInch(1);
if (textFrame._width.IsNull)
textFrame._width = Unit.FromInch(1);
}
#endregion
#region Table
public override void VisitCell(Cell cell)
{
// format, shading and borders are already processed.
}
public override void VisitColumns(Columns columns)
{
foreach (Column col in columns)
{
if (col._width.IsNull)
col._width = columns._width;
if (col._width.IsNull)
col._width = "2.5cm";
}
}
public override void VisitRow(Row row)
{
foreach (Cell cell in row.Cells)
{
if (cell._verticalAlignment.IsNull)
cell._verticalAlignment = row._verticalAlignment;
}
}
public override void VisitRows(Rows rows)
{
foreach (Row row in rows)
{
if (row._height.IsNull)
row._height = rows._height;
if (row._heightRule.IsNull)
row._heightRule = rows._heightRule;
if (row._verticalAlignment.IsNull)
row._verticalAlignment = rows._verticalAlignment;
}
}
/// <summary>
/// Returns a paragraph format object initialized by the given style.
/// It differs from style.ParagraphFormat if style is a character style.
/// </summary>
ParagraphFormat ParagraphFormatFromStyle(Style style)
{
if (style.Type == StyleType.Character)
{
Document doc = style.Document;
ParagraphFormat format = style._paragraphFormat.Clone();
FlattenParagraphFormat(format, doc.Styles.Normal.ParagraphFormat);
return format;
}
else
return style._paragraphFormat;
}
public override void VisitTable(Table table)
{
Document document = table.Document;
if (table._leftPadding.IsNull)
table._leftPadding = Unit.FromMillimeter(1.2);
if (table._rightPadding.IsNull)
table._rightPadding = Unit.FromMillimeter(1.2);
ParagraphFormat format;
Style style = document._styles[table._style.Value];
if (style != null)
format = ParagraphFormatFromStyle(style);
else
{
table.Style = "Normal";
format = document._styles.Normal._paragraphFormat;
}
if (table._format == null)
{
table._format = format.Clone();
table._format._parent = table;
}
else
FlattenParagraphFormat(table._format, format);
int rows = table.Rows.Count;
int clms = table.Columns.Count;
for (int idxclm = 0; idxclm < clms; idxclm++)
{
Column column = table.Columns[idxclm];
ParagraphFormat colFormat;
style = document._styles[column._style.Value];
if (style != null)
colFormat = ParagraphFormatFromStyle(style);
else
{
column._style = table._style;
colFormat = table.Format;
}
if (column._format == null)
{
column._format = colFormat.Clone();
column._format._parent = column;
if (column._format._shading == null && table._format._shading != null)
column._format._shading = table._format._shading;
}
else
FlattenParagraphFormat(column._format, colFormat);
if (column._leftPadding.IsNull)
column._leftPadding = table._leftPadding;
if (column._rightPadding.IsNull)
column._rightPadding = table._rightPadding;
if (column._shading == null)
column._shading = table._shading;
else if (table._shading != null)
FlattenShading(column._shading, table._shading);
if (column._borders == null)
column._borders = table._borders;
else if (table._borders != null)
FlattenBorders(column._borders, table._borders);
}
for (int idxrow = 0; idxrow < rows; idxrow++)
{
Row row = table.Rows[idxrow];
ParagraphFormat rowFormat;
style = document._styles[row._style.Value];
if (style != null)
{
rowFormat = ParagraphFormatFromStyle(style);
}
else
{
row._style = table._style;
rowFormat = table.Format;
}
for (int idxclm = 0; idxclm < clms; idxclm++)
{
Column column = table.Columns[idxclm];
Cell cell = row[idxclm];
ParagraphFormat cellFormat;
Style cellStyle = document._styles[cell._style.Value];
if (cellStyle != null)
{
cellFormat = ParagraphFormatFromStyle(cellStyle);
if (cell._format == null)
cell._format = cellFormat;
else
FlattenParagraphFormat(cell._format, cellFormat);
}
else
{
if (row._format != null)
FlattenParagraphFormat(cell.Format, row._format);
if (style != null)
{
cell._style = row._style;
FlattenParagraphFormat(cell.Format, rowFormat);
}
else
{
cell._style = column._style;
FlattenParagraphFormat(cell.Format, column._format);
}
}
if (cell._format._shading == null && table._format._shading != null)
cell._format._shading = table._format._shading;
if (cell._shading == null)
cell._shading = row._shading;
else if (row._shading != null)
FlattenShading(cell._shading, row._shading);
if (cell._shading == null)
cell._shading = column._shading;
else if (column._shading != null)
FlattenShading(cell._shading, column._shading);
if (cell._borders == null)
CloneHelper(ref cell._borders, row._borders);
else if (row._borders != null)
FlattenBorders(cell._borders, row._borders);
if (cell._borders == null)
cell._borders = column._borders;
else if (column._borders != null)
FlattenBorders(cell._borders, column._borders);
}
if (row._format == null)
{
row._format = rowFormat.Clone();
row._format._parent = row;
if (row._format._shading == null && table._format._shading != null)
row._format._shading = table._format._shading;
}
else
FlattenParagraphFormat(row._format, rowFormat);
if (row._topPadding.IsNull)
row._topPadding = table._topPadding;
if (row._bottomPadding.IsNull)
row._bottomPadding = table._bottomPadding;
if (row._shading == null)
row._shading = table._shading;
else if (table._shading != null)
FlattenShading(row._shading, table._shading);
if (row._borders == null)
row._borders = table._borders;
else if (table._borders != null)
FlattenBorders(row._borders, table._borders);
}
}
private void CloneHelper(ref Borders borders, Borders source)
{
if (source != null)
{
borders = source.Clone();
borders._parent = source._parent;
}
}
#endregion
public override void VisitLegend(Legend legend)
{
ParagraphFormat parentFormat;
if (!legend._style.IsNull)
{
Style style = legend.Document.Styles[legend.Style];
if (style == null)
style = legend.Document.Styles[StyleNames.InvalidStyleName];
parentFormat = style._paragraphFormat;
}
else
{
TextArea textArea = (TextArea)GetDocumentElementHolder(legend);
legend._style = textArea._style;
parentFormat = textArea._format;
}
if (legend._format == null)
legend.Format = parentFormat.Clone();
else
FlattenParagraphFormat(legend._format, parentFormat);
}
public override void VisitTextArea(TextArea textArea)
{
if (textArea == null || textArea._elements == null)
return;
Document document = textArea.Document;
ParagraphFormat parentFormat;
if (!textArea._style.IsNull)
{
Style style = textArea.Document.Styles[textArea.Style];
if (style == null)
style = textArea.Document.Styles[StyleNames.InvalidStyleName];
parentFormat = style._paragraphFormat;
}
else
{
Chart chart = (Chart)textArea._parent;
parentFormat = chart._format;
textArea._style = chart._style;
}
if (textArea._format == null)
textArea.Format = parentFormat.Clone();
else
FlattenParagraphFormat(textArea._format, parentFormat);
FlattenFillFormat(textArea._fillFormat);
FlattenLineFormat(textArea._lineFormat, null);
}
private DocumentObject GetDocumentElementHolder(DocumentObject docObj)
{
DocumentElements docEls = (DocumentElements)docObj._parent;
return docEls._parent;
}
}
}

View 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
}
}

View 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
}
}

Some files were not shown because too many files have changed in this diff Show More