Test
This commit is contained in:
		
							
								
								
									
										100
									
								
								PrintPDF/MigraDoc.Rendering/Rendering.ChartMapper/AxisMapper.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								PrintPDF/MigraDoc.Rendering/Rendering.ChartMapper/AxisMapper.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,100 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Charting;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The AxisMapper class.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class AxisMapper
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the <see cref="AxisMapper"/> class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public AxisMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        static void MapObject(Axis axis, DocumentObjectModel.Shapes.Charts.Axis domAxis)
 | 
			
		||||
        {
 | 
			
		||||
            if (!domAxis.IsNull("TickLabels.Format"))
 | 
			
		||||
                axis.TickLabels.Format = domAxis.TickLabels.Format;
 | 
			
		||||
            if (!domAxis.IsNull("TickLabels.Style"))
 | 
			
		||||
                FontMapper.Map(axis.TickLabels.Font, domAxis.TickLabels.Document, domAxis.TickLabels.Style);
 | 
			
		||||
            if (!domAxis.IsNull("TickLabels.Font"))
 | 
			
		||||
                FontMapper.Map(axis.TickLabels.Font, domAxis.TickLabels.Font);
 | 
			
		||||
 | 
			
		||||
            if (!domAxis.IsNull("MajorTickMark"))
 | 
			
		||||
                axis.MajorTickMark = (TickMarkType)domAxis.MajorTickMark;
 | 
			
		||||
            if (!domAxis.IsNull("MinorTickMark"))
 | 
			
		||||
                axis.MinorTickMark = (TickMarkType)domAxis.MinorTickMark;
 | 
			
		||||
 | 
			
		||||
            if (!domAxis.IsNull("MajorTick"))
 | 
			
		||||
                axis.MajorTick = domAxis.MajorTick;
 | 
			
		||||
            if (!domAxis.IsNull("MinorTick"))
 | 
			
		||||
                axis.MinorTick = domAxis.MinorTick;
 | 
			
		||||
 | 
			
		||||
            if (!domAxis.IsNull("Title"))
 | 
			
		||||
            {
 | 
			
		||||
                axis.Title.Caption = domAxis.Title.Caption;
 | 
			
		||||
                if (!domAxis.IsNull("Title.Style"))
 | 
			
		||||
                    FontMapper.Map(axis.Title.Font, domAxis.Title.Document, domAxis.Title.Style);
 | 
			
		||||
                if (!domAxis.IsNull("Title.Font"))
 | 
			
		||||
                    FontMapper.Map(axis.Title.Font, domAxis.Title.Font);
 | 
			
		||||
                axis.Title.Orientation = domAxis.Title.Orientation.Value;
 | 
			
		||||
                axis.Title.Alignment = (HorizontalAlignment)domAxis.Title.Alignment;
 | 
			
		||||
                axis.Title.VerticalAlignment = (VerticalAlignment)domAxis.Title.VerticalAlignment;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            axis.HasMajorGridlines = domAxis.HasMajorGridlines;
 | 
			
		||||
            axis.HasMinorGridlines = domAxis.HasMinorGridlines;
 | 
			
		||||
 | 
			
		||||
            if (!domAxis.IsNull("MajorGridlines") && !domAxis.MajorGridlines.IsNull("LineFormat"))
 | 
			
		||||
                LineFormatMapper.Map(axis.MajorGridlines.LineFormat, domAxis.MajorGridlines.LineFormat);
 | 
			
		||||
            if (!domAxis.IsNull("MinorGridlines") && !domAxis.MinorGridlines.IsNull("LineFormat"))
 | 
			
		||||
                LineFormatMapper.Map(axis.MinorGridlines.LineFormat, domAxis.MinorGridlines.LineFormat);
 | 
			
		||||
 | 
			
		||||
            if (!domAxis.IsNull("MaximumScale"))
 | 
			
		||||
                axis.MaximumScale = domAxis.MaximumScale;
 | 
			
		||||
            if (!domAxis.IsNull("MinimumScale"))
 | 
			
		||||
                axis.MinimumScale = domAxis.MinimumScale;
 | 
			
		||||
 | 
			
		||||
            if (!domAxis.IsNull("LineFormat"))
 | 
			
		||||
                LineFormatMapper.Map(axis.LineFormat, domAxis.LineFormat);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(Axis axis, DocumentObjectModel.Shapes.Charts.Axis domAxis)
 | 
			
		||||
        {
 | 
			
		||||
            AxisMapper mapper = new AxisMapper();
 | 
			
		||||
            MapObject(axis, domAxis);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,93 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Charting;
 | 
			
		||||
using PdfSharp.Drawing;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Maps charts from the MigraDoc.DocumentObjectModel to charts from Pdf.Charting.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class ChartMapper
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the chart mapper object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ChartMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        private ChartFrame MapObject(DocumentObjectModel.Shapes.Charts.Chart domChart)
 | 
			
		||||
        {
 | 
			
		||||
            ChartFrame chartFrame = new ChartFrame();
 | 
			
		||||
            chartFrame.Size = new XSize(domChart.Width.Point, domChart.Height.Point);
 | 
			
		||||
            chartFrame.Location = new XPoint(domChart.Left.Position.Point, domChart.Top.Position.Point);
 | 
			
		||||
 | 
			
		||||
            Chart chart = new Chart((ChartType)domChart.Type);
 | 
			
		||||
 | 
			
		||||
            if (!domChart.IsNull("XAxis"))
 | 
			
		||||
                AxisMapper.Map(chart.XAxis, domChart.XAxis);
 | 
			
		||||
            if (!domChart.IsNull("YAxis"))
 | 
			
		||||
                AxisMapper.Map(chart.YAxis, domChart.YAxis);
 | 
			
		||||
 | 
			
		||||
            PlotAreaMapper.Map(chart.PlotArea, domChart.PlotArea);
 | 
			
		||||
 | 
			
		||||
            SeriesCollectionMapper.Map(chart.SeriesCollection, domChart.SeriesCollection);
 | 
			
		||||
 | 
			
		||||
            LegendMapper.Map(chart, domChart);
 | 
			
		||||
 | 
			
		||||
            chart.DisplayBlanksAs = (BlankType)domChart.DisplayBlanksAs;
 | 
			
		||||
            chart.HasDataLabel = domChart.HasDataLabel;
 | 
			
		||||
            if (!domChart.IsNull("DataLabel"))
 | 
			
		||||
                DataLabelMapper.Map(chart.DataLabel, domChart.DataLabel);
 | 
			
		||||
 | 
			
		||||
            if (!domChart.IsNull("Style"))
 | 
			
		||||
                FontMapper.Map(chart.Font, domChart.Document, domChart.Style);
 | 
			
		||||
            if (!domChart.IsNull("Format.Font"))
 | 
			
		||||
                FontMapper.Map(chart.Font, domChart.Format.Font);
 | 
			
		||||
            if (!domChart.IsNull("XValues"))
 | 
			
		||||
                XValuesMapper.Map(chart.XValues, domChart.XValues);
 | 
			
		||||
 | 
			
		||||
            chartFrame.Add(chart);
 | 
			
		||||
            return chartFrame;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Maps the specified DOM chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="domChart">The DOM chart.</param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public static ChartFrame Map(DocumentObjectModel.Shapes.Charts.Chart domChart)
 | 
			
		||||
        {
 | 
			
		||||
            ChartMapper mapper = new ChartMapper();
 | 
			
		||||
            return mapper.MapObject(domChart);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,59 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Charting;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    public class DataLabelMapper
 | 
			
		||||
    {
 | 
			
		||||
        private DataLabelMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        void MapObject(DataLabel dataLabel, DocumentObjectModel.Shapes.Charts.DataLabel domDataLabel)
 | 
			
		||||
        {
 | 
			
		||||
            if (!domDataLabel.IsNull("Style"))
 | 
			
		||||
                FontMapper.Map(dataLabel.Font, domDataLabel.Document, domDataLabel.Style);
 | 
			
		||||
            if (!domDataLabel.IsNull("Font"))
 | 
			
		||||
                FontMapper.Map(dataLabel.Font, domDataLabel.Font);
 | 
			
		||||
            dataLabel.Format = domDataLabel.Format;
 | 
			
		||||
            if (!domDataLabel.IsNull("Position"))
 | 
			
		||||
                dataLabel.Position = (DataLabelPosition)domDataLabel.Position;
 | 
			
		||||
            if (!domDataLabel.IsNull("Type"))
 | 
			
		||||
                dataLabel.Type = (DataLabelType)domDataLabel.Type;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(DataLabel dataLabel, DocumentObjectModel.Shapes.Charts.DataLabel domDataLabel)
 | 
			
		||||
        {
 | 
			
		||||
            DataLabelMapper mapper = new DataLabelMapper();
 | 
			
		||||
            mapper.MapObject(dataLabel, domDataLabel);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,62 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Charting;
 | 
			
		||||
using PdfSharp.Drawing;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    public class FillFormatMapper
 | 
			
		||||
    {
 | 
			
		||||
        private FillFormatMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        void MapObject(FillFormat fillFormat, DocumentObjectModel.Shapes.FillFormat domFillFormat)
 | 
			
		||||
        {
 | 
			
		||||
            if (domFillFormat.Color.IsEmpty)
 | 
			
		||||
                fillFormat.Color = XColor.Empty;
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
#if noCMYK
 | 
			
		||||
                fillFormat.Color = XColor.FromArgb((int)domFillFormat.Color.Argb);
 | 
			
		||||
#else
 | 
			
		||||
                fillFormat.Color = ColorHelper.ToXColor(domFillFormat.Color, domFillFormat.Document.UseCmykColor);
 | 
			
		||||
#endif
 | 
			
		||||
            }
 | 
			
		||||
            fillFormat.Visible = domFillFormat.Visible;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(FillFormat fillFormat, DocumentObjectModel.Shapes.FillFormat domFillFormat)
 | 
			
		||||
        {
 | 
			
		||||
            FillFormatMapper mapper = new FillFormatMapper();
 | 
			
		||||
            mapper.MapObject(fillFormat, domFillFormat);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,80 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Charting;
 | 
			
		||||
using PdfSharp.Drawing;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    public class FontMapper
 | 
			
		||||
    {
 | 
			
		||||
        private FontMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        void MapObject(Font font, DocumentObjectModel.Font domFont)
 | 
			
		||||
        {
 | 
			
		||||
            font.Bold = domFont.Bold;
 | 
			
		||||
            if (domFont.Color.IsEmpty)
 | 
			
		||||
                font.Color = XColor.Empty;
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
#if noCMYK
 | 
			
		||||
                font.Color = XColor.FromArgb((int)domFont.Color.Argb);
 | 
			
		||||
#else
 | 
			
		||||
                font.Color = ColorHelper.ToXColor(domFont.Color, domFont.Document.UseCmykColor);
 | 
			
		||||
#endif
 | 
			
		||||
            }
 | 
			
		||||
            font.Italic = domFont.Italic;
 | 
			
		||||
            if (!domFont.IsNull("Name"))
 | 
			
		||||
                font.Name = domFont.Name;
 | 
			
		||||
            if (!domFont.IsNull("Size"))
 | 
			
		||||
                font.Size = domFont.Size.Point;
 | 
			
		||||
            font.Subscript = domFont.Subscript;
 | 
			
		||||
            font.Superscript = domFont.Superscript;
 | 
			
		||||
            font.Underline = (Underline)domFont.Underline;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(Font font, DocumentObjectModel.Document domDocument, string domStyleName)
 | 
			
		||||
        {
 | 
			
		||||
            DocumentObjectModel.Style domStyle = domDocument.Styles[domStyleName];
 | 
			
		||||
            if (domStyle != null)
 | 
			
		||||
            {
 | 
			
		||||
                FontMapper mapper = new FontMapper();
 | 
			
		||||
                mapper.MapObject(font, domStyle.Font);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(Font font, DocumentObjectModel.Font domFont)
 | 
			
		||||
        {
 | 
			
		||||
            FontMapper mapper = new FontMapper();
 | 
			
		||||
            mapper.MapObject(font, domFont);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,122 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Charting;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    public class LegendMapper
 | 
			
		||||
    {
 | 
			
		||||
        private LegendMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        void MapObject(Chart chart, DocumentObjectModel.Shapes.Charts.Chart domChart)
 | 
			
		||||
        {
 | 
			
		||||
            DocumentObjectModel.Shapes.Charts.Legend domLegend = null;
 | 
			
		||||
            DocumentObjectModel.Shapes.Charts.TextArea textArea = null;
 | 
			
		||||
 | 
			
		||||
            foreach (DocumentObjectModel.DocumentObject domObj in domChart.BottomArea.Elements)
 | 
			
		||||
            {
 | 
			
		||||
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
 | 
			
		||||
                {
 | 
			
		||||
                    chart.Legend.Docking = DockingType.Bottom;
 | 
			
		||||
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
 | 
			
		||||
                    textArea = domChart.BottomArea;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (DocumentObjectModel.DocumentObject domObj in domChart.RightArea.Elements)
 | 
			
		||||
            {
 | 
			
		||||
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
 | 
			
		||||
                {
 | 
			
		||||
                    chart.Legend.Docking = DockingType.Right;
 | 
			
		||||
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
 | 
			
		||||
                    textArea = domChart.RightArea;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (DocumentObjectModel.DocumentObject domObj in domChart.LeftArea.Elements)
 | 
			
		||||
            {
 | 
			
		||||
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
 | 
			
		||||
                {
 | 
			
		||||
                    chart.Legend.Docking = DockingType.Left;
 | 
			
		||||
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
 | 
			
		||||
                    textArea = domChart.LeftArea;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (DocumentObjectModel.DocumentObject domObj in domChart.TopArea.Elements)
 | 
			
		||||
            {
 | 
			
		||||
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
 | 
			
		||||
                {
 | 
			
		||||
                    chart.Legend.Docking = DockingType.Top;
 | 
			
		||||
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
 | 
			
		||||
                    textArea = domChart.TopArea;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (DocumentObjectModel.DocumentObject domObj in domChart.HeaderArea.Elements)
 | 
			
		||||
            {
 | 
			
		||||
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
 | 
			
		||||
                {
 | 
			
		||||
                    chart.Legend.Docking = DockingType.Top;
 | 
			
		||||
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
 | 
			
		||||
                    textArea = domChart.HeaderArea;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (DocumentObjectModel.DocumentObject domObj in domChart.FooterArea.Elements)
 | 
			
		||||
            {
 | 
			
		||||
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
 | 
			
		||||
                {
 | 
			
		||||
                    chart.Legend.Docking = DockingType.Bottom;
 | 
			
		||||
                    domLegend = domObj as DocumentObjectModel.Shapes.Charts.Legend;
 | 
			
		||||
                    textArea = domChart.FooterArea;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (domLegend != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (!domLegend.IsNull("LineFormat"))
 | 
			
		||||
                    LineFormatMapper.Map(chart.Legend.LineFormat, domLegend.LineFormat);
 | 
			
		||||
                if (!textArea.IsNull("Style"))
 | 
			
		||||
                    FontMapper.Map(chart.Legend.Font, textArea.Document, textArea.Style);
 | 
			
		||||
                if (!domLegend.IsNull("Format.Font"))
 | 
			
		||||
                    FontMapper.Map(chart.Legend.Font, domLegend.Format.Font);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(Chart chart, DocumentObjectModel.Shapes.Charts.Chart domChart)
 | 
			
		||||
        {
 | 
			
		||||
            LegendMapper mapper = new LegendMapper();
 | 
			
		||||
            mapper.MapObject(chart, domChart);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,98 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Charting;
 | 
			
		||||
using PdfSharp.Drawing;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The LineFormatMapper class.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class LineFormatMapper
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the <see cref="LineFormatMapper"/> class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public LineFormatMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        void MapObject(LineFormat lineFormat, DocumentObjectModel.Shapes.LineFormat domLineFormat)
 | 
			
		||||
        {
 | 
			
		||||
            if (domLineFormat.Color.IsEmpty)
 | 
			
		||||
                lineFormat.Color = XColor.Empty;
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
#if noCMYK
 | 
			
		||||
                lineFormat.Color = XColor.FromArgb(domLineFormat.Color.Argb);
 | 
			
		||||
#else
 | 
			
		||||
                lineFormat.Color = ColorHelper.ToXColor(domLineFormat.Color, domLineFormat.Document.UseCmykColor);
 | 
			
		||||
#endif
 | 
			
		||||
            }
 | 
			
		||||
            switch (domLineFormat.DashStyle)
 | 
			
		||||
            {
 | 
			
		||||
                case DocumentObjectModel.Shapes.DashStyle.Dash:
 | 
			
		||||
                    lineFormat.DashStyle = XDashStyle.Dash;
 | 
			
		||||
                    break;
 | 
			
		||||
                case DocumentObjectModel.Shapes.DashStyle.DashDot:
 | 
			
		||||
                    lineFormat.DashStyle = XDashStyle.DashDot;
 | 
			
		||||
                    break;
 | 
			
		||||
                case DocumentObjectModel.Shapes.DashStyle.DashDotDot:
 | 
			
		||||
                    lineFormat.DashStyle = XDashStyle.DashDotDot;
 | 
			
		||||
                    break;
 | 
			
		||||
                case DocumentObjectModel.Shapes.DashStyle.Solid:
 | 
			
		||||
                    lineFormat.DashStyle = XDashStyle.Solid;
 | 
			
		||||
                    break;
 | 
			
		||||
                case DocumentObjectModel.Shapes.DashStyle.SquareDot:
 | 
			
		||||
                    lineFormat.DashStyle = XDashStyle.Dot;
 | 
			
		||||
                    break;
 | 
			
		||||
                default:
 | 
			
		||||
                    lineFormat.DashStyle = XDashStyle.Solid;
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
            switch (domLineFormat.Style)
 | 
			
		||||
            {
 | 
			
		||||
                case DocumentObjectModel.Shapes.LineStyle.Single:
 | 
			
		||||
                    lineFormat.Style = LineStyle.Single;
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
            lineFormat.Visible = domLineFormat.Visible;
 | 
			
		||||
            if (domLineFormat.IsNull("Visible"))
 | 
			
		||||
                lineFormat.Visible = true;
 | 
			
		||||
            lineFormat.Width = domLineFormat.Width.Point;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(LineFormat lineFormat, DocumentObjectModel.Shapes.LineFormat domLineFormat)
 | 
			
		||||
        {
 | 
			
		||||
            LineFormatMapper mapper = new LineFormatMapper();
 | 
			
		||||
            mapper.MapObject(lineFormat, domLineFormat);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,65 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Charting;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The PlotAreaMapper class.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class PlotAreaMapper
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the <see cref="PlotAreaMapper"/> class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public PlotAreaMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        void MapObject(PlotArea plotArea, DocumentObjectModel.Shapes.Charts.PlotArea domPlotArea)
 | 
			
		||||
        {
 | 
			
		||||
            plotArea.BottomPadding = domPlotArea.BottomPadding.Point;
 | 
			
		||||
            plotArea.RightPadding = domPlotArea.RightPadding.Point;
 | 
			
		||||
            plotArea.LeftPadding = domPlotArea.LeftPadding.Point;
 | 
			
		||||
            plotArea.TopPadding = domPlotArea.TopPadding.Point;
 | 
			
		||||
 | 
			
		||||
            if (!domPlotArea.IsNull("LineFormat"))
 | 
			
		||||
                LineFormatMapper.Map(plotArea.LineFormat, domPlotArea.LineFormat);
 | 
			
		||||
            if (!domPlotArea.IsNull("FillFormat"))
 | 
			
		||||
                FillFormatMapper.Map(plotArea.FillFormat, domPlotArea.FillFormat);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(PlotArea plotArea, DocumentObjectModel.Shapes.Charts.PlotArea domPlotArea)
 | 
			
		||||
        {
 | 
			
		||||
            PlotAreaMapper mapper = new PlotAreaMapper();
 | 
			
		||||
            mapper.MapObject(plotArea, domPlotArea);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,116 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Drawing;
 | 
			
		||||
using PdfSharp.Charting;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The SeriesCollectionMapper class.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class SeriesCollectionMapper
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the <see cref="SeriesCollectionMapper"/> class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SeriesCollectionMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        void MapObject(SeriesCollection seriesCollection, DocumentObjectModel.Shapes.Charts.SeriesCollection domSeriesCollection)
 | 
			
		||||
        {
 | 
			
		||||
            foreach (DocumentObjectModel.Shapes.Charts.Series domSeries in domSeriesCollection)
 | 
			
		||||
            {
 | 
			
		||||
                Series series = seriesCollection.AddSeries();
 | 
			
		||||
                series.Name = domSeries.Name;
 | 
			
		||||
 | 
			
		||||
                if (domSeries.IsNull("ChartType"))
 | 
			
		||||
                {
 | 
			
		||||
                    DocumentObjectModel.Shapes.Charts.Chart chart = (DocumentObjectModel.Shapes.Charts.Chart)DocumentObjectModel.DocumentRelations.GetParentOfType(domSeries, typeof(DocumentObjectModel.Shapes.Charts.Chart));
 | 
			
		||||
                    series.ChartType = (ChartType)chart.Type;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                    series.ChartType = (ChartType)domSeries.ChartType;
 | 
			
		||||
 | 
			
		||||
                if (!domSeries.IsNull("DataLabel"))
 | 
			
		||||
                    DataLabelMapper.Map(series.DataLabel, domSeries.DataLabel);
 | 
			
		||||
                if (!domSeries.IsNull("LineFormat"))
 | 
			
		||||
                    LineFormatMapper.Map(series.LineFormat, domSeries.LineFormat);
 | 
			
		||||
                if (!domSeries.IsNull("FillFormat"))
 | 
			
		||||
                    FillFormatMapper.Map(series.FillFormat, domSeries.FillFormat);
 | 
			
		||||
 | 
			
		||||
                series.HasDataLabel = domSeries.HasDataLabel;
 | 
			
		||||
                if (domSeries.MarkerBackgroundColor.IsEmpty)
 | 
			
		||||
                    series.MarkerBackgroundColor = XColor.Empty;
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
#if noCMYK
 | 
			
		||||
          series.MarkerBackgroundColor = XColor.FromArgb(domSeries.MarkerBackgroundColor.Argb);
 | 
			
		||||
#else
 | 
			
		||||
                    series.MarkerBackgroundColor =
 | 
			
		||||
                      ColorHelper.ToXColor(domSeries.MarkerBackgroundColor, domSeries.Document.UseCmykColor);
 | 
			
		||||
#endif
 | 
			
		||||
                }
 | 
			
		||||
                if (domSeries.MarkerForegroundColor.IsEmpty)
 | 
			
		||||
                    series.MarkerForegroundColor = XColor.Empty;
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
#if noCMYK
 | 
			
		||||
          series.MarkerForegroundColor = XColor.FromArgb(domSeries.MarkerForegroundColor.Argb);
 | 
			
		||||
#else
 | 
			
		||||
                    series.MarkerForegroundColor =
 | 
			
		||||
                      ColorHelper.ToXColor(domSeries.MarkerForegroundColor, domSeries.Document.UseCmykColor);
 | 
			
		||||
#endif
 | 
			
		||||
                }
 | 
			
		||||
                series.MarkerSize = domSeries.MarkerSize.Point;
 | 
			
		||||
                if (!domSeries.IsNull("MarkerStyle"))
 | 
			
		||||
                    series.MarkerStyle = (MarkerStyle)domSeries.MarkerStyle;
 | 
			
		||||
 | 
			
		||||
                foreach (DocumentObjectModel.Shapes.Charts.Point domPoint in domSeries.Elements)
 | 
			
		||||
                {
 | 
			
		||||
                    if (domPoint != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        Point point = series.Add(domPoint.Value);
 | 
			
		||||
                        FillFormatMapper.Map(point.FillFormat, domPoint.FillFormat);
 | 
			
		||||
                        LineFormatMapper.Map(point.LineFormat, domPoint.LineFormat);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                        series.Add(double.NaN);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(SeriesCollection seriesCollection, DocumentObjectModel.Shapes.Charts.SeriesCollection domSeriesCollection)
 | 
			
		||||
        {
 | 
			
		||||
            SeriesCollectionMapper mapper = new SeriesCollectionMapper();
 | 
			
		||||
            mapper.MapObject(seriesCollection, domSeriesCollection);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,68 @@
 | 
			
		||||
#region MigraDoc - Creating Documents on the Fly
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   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 PdfSharp.Charting;
 | 
			
		||||
 | 
			
		||||
namespace MigraDoc.Rendering.ChartMapper
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The XValuesMapper class.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class XValuesMapper
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the <see cref="XValuesMapper"/> class.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public XValuesMapper()
 | 
			
		||||
        { }
 | 
			
		||||
 | 
			
		||||
        void MapObject(XValues xValues, DocumentObjectModel.Shapes.Charts.XValues domXValues)
 | 
			
		||||
        {
 | 
			
		||||
            foreach (DocumentObjectModel.Shapes.Charts.XSeries domXSeries in domXValues)
 | 
			
		||||
            {
 | 
			
		||||
                XSeries xSeries = xValues.AddXSeries();
 | 
			
		||||
                DocumentObjectModel.Shapes.Charts.XSeriesElements domXSeriesElements = domXSeries.GetValue("XSeriesElements") as DocumentObjectModel.Shapes.Charts.XSeriesElements;
 | 
			
		||||
                foreach (DocumentObjectModel.Shapes.Charts.XValue domXValue in domXSeriesElements)
 | 
			
		||||
                {
 | 
			
		||||
                    if (domXValue == null)
 | 
			
		||||
                        xSeries.AddBlank();
 | 
			
		||||
                    else
 | 
			
		||||
                        xSeries.Add(domXValue.GetValue("Value").ToString());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Map(XValues xValues, DocumentObjectModel.Shapes.Charts.XValues domXValues)
 | 
			
		||||
        {
 | 
			
		||||
            XValuesMapper mapper = new XValuesMapper();
 | 
			
		||||
            mapper.MapObject(xValues, domXValues);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user