Пример #1
0
        /// <summary>
        /// parse an excel document and build a kinesis document model
        /// </summary>
        /// <param name="path">full path of the excel document</param>
        /// <returns>equivalent kinesis document model</returns>
        public Document ParseNewDocumentCharts(String path, ProcessingProgress pp, Document document)
        {
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.OverallOperationName = "All Document Charts";
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //directory where all the data will be saved
            String folderName   = document.Location;
            String documentPath = System.IO.Path.Combine(DocumentService.TEMP_DIRECTORY, folderName);

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationName          = "Opening MS Office";
            pp.CurrentOperationTotalElements = 1;
            pp.CurrentOperationElement       = 0;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //open the given excel document
            Workbook workbook = excelApplication.Workbooks.Open(path, ReadOnly: true);

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationElement       = 1;
            pp.OverallOperationTotalElements = EvaluateWorkbook(workbook, pp);
            pp.OverallOperationElement       = 0;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //for every sheet
            for (int i = 1; i <= workbook.Sheets.Count; i++)
            {
                Worksheet worksheet = workbook.Sheets[i];

                //create a new page
                KineSis.ContentManagement.Model.Page page = document.Pages[i - 1];

                //check if chart generation is wanted
                if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                {
                    //get charts
                    ChartObjects chartObjects = worksheet.ChartObjects(Type.Missing);

                    //create directory for charts
                    String chartPath = System.IO.Path.Combine(documentPath, "charts");
                    System.IO.Directory.CreateDirectory(chartPath);

                    //for every chart
                    for (int j = 1; j <= chartObjects.Count; j++)
                    {
                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                        pp.CurrentOperationName          = "Page " + i + " / Chart " + j + " of " + chartObjects.Count;
                        pp.CurrentOperationTotalElements = EvaluateChart(chartObjects.Item(j).Chart);
                        pp.CurrentOperationElement       = 0;
                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                        KineSis.ContentManagement.Model.Chart mChart = new KineSis.ContentManagement.Model.Chart();

                        //current chart
                        Microsoft.Office.Interop.Excel.Chart chart = chartObjects.Item(j).Chart;

                        mChart.SetThumbnailUrl(GenerateThumbnail(chart, chartPath + DD + i + _ + j + "_thumb"));

                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                        pp.OverallOperationElement++;
                        pp.CurrentOperationElement++;
                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                        if (DocumentService.FORCE_CHART_SIZE)
                        {
                            chart.ChartArea.Height = ((float)DocumentService.CHART_WIDTH * chart.ChartArea.Height) / chart.ChartArea.Width;
                            chart.ChartArea.Width  = DocumentService.CHART_WIDTH;
                        }

                        int chartType = GetChartType(chart);

                        //start from 0 point
                        chart.Rotation = 0;

                        int horizontalAngle = 0;

                        //depending on how many horizontal faces are required, calculate the angle between them
                        if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                        {
                            horizontalAngle = 360 / DocumentService.CHART_HORIZONTAL_FACES;
                        }

                        int verticalAngle = 0;

                        //depending on how many vertical faces are required for a horizontal face, celaculate the angle between them, excluding the vertical face at 90 degrees
                        if (DocumentService.CHART_VERTICAL_FACES > 0)
                        {
                            verticalAngle = 90 / (DocumentService.CHART_VERTICAL_FACES + 1);
                        }

                        if (chart.HasTitle)
                        {
                            mChart.Title = chart.ChartTitle.Caption;
                        }
                        else
                        {
                            mChart.Title = chart.Name;
                        }

                        //does not support rotation (it's plain)
                        if (chartType == 0)
                        {
                            //if horizontal faces number is 0, then no chart will be outputed
                            if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                            {
                                ChartHorizontalView hView = new ChartHorizontalView();

                                //draw chart face as image
                                chart.Export(chartPath + DD + i + _ + j + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FILTER, false);
                                //add to hView
                                hView.ImageUrl = chartPath + DD + i + _ + j + DocumentService.IMAGE_EXTENSION;
                                //add to views
                                mChart.Views.Add(hView);

                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                pp.OverallOperationElement++;
                                pp.CurrentOperationElement++;
                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                            }
                        }
                        else
                        {
                            //for every horizontal face
                            for (int k = 0; k < DocumentService.CHART_HORIZONTAL_FACES; k++)
                            {
                                ChartHorizontalView hView = new ChartHorizontalView();
                                //reset elevation
                                chart.Elevation = 0;
                                //export face as image

                                chart.Export(chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FILTER, false);
                                //set bitmap to view
                                hView.ImageUrl = chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION;

                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                pp.OverallOperationElement++;
                                pp.CurrentOperationElement++;
                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                                //for every vertical face
                                for (int l = 0; l < DocumentService.CHART_VERTICAL_FACES; l++)
                                {
                                    ChartVerticalView vView = new ChartVerticalView();
                                    //increse elevation
                                    chart.Elevation += verticalAngle;
                                    //export face as image
                                    chart.Export(chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FILTER, false);

                                    //set bitmap to view
                                    vView.ImageUrl = chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                    //add vertical view to horizontal UP list
                                    hView.Up.Add(vView);

                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                    pp.OverallOperationElement++;
                                    pp.CurrentOperationElement++;
                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                }

                                //some chart types, like 3D pie, does not support elevation less than 0
                                if (SupportsNegativeElevation(chart))
                                {
                                    //reset elevation
                                    chart.Elevation = 0;

                                    //for every vertical face
                                    for (int m = 0; m < DocumentService.CHART_VERTICAL_FACES; m++)
                                    {
                                        ChartVerticalView vView = new ChartVerticalView();

                                        //decrease elevation
                                        chart.Elevation -= verticalAngle;
                                        //export face as image
                                        chart.Export(chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FILTER, false);
                                        //set bitmap to vertical view
                                        vView.ImageUrl = chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                        //add vertical view to horizontal view DOWN list
                                        hView.Down.Add(vView);

                                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                        pp.OverallOperationElement++;
                                        pp.CurrentOperationElement++;
                                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                    }
                                }

                                //increase horizontal angle in order to get the next horizontal view
                                chart.Rotation += horizontalAngle;
                                //add horizontal view to the chat's views list
                                mChart.Views.Add(hView);
                            }
                        }

                        //add chart to page
                        page.Charts.Add(mChart);
                    }
                }
            }

            //close workbook without saving any possible changes (this way the "Are you sure?" or "Save changes?" dialogs will be supressed)
            workbook.Close(SaveChanges: false);

            CloseOfficeApplication();

            //return the built document
            return(document);
        }
Пример #2
0
        /// <summary>
        /// parse a word document and build a kinesis document model
        /// </summary>
        /// <param name="path">full path of the word document</param>
        /// <returns>equivalent kinesis document model</returns>
        public KineSis.ContentManagement.Model.Document ParseNewDocumentCharts(String path, ProcessingProgress pp, KineSis.ContentManagement.Model.Document document)
        {
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.OverallOperationName = "All Document Charts";
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //directory where all the data will be saved
            String folderName = document.Location;
            String documentPath = System.IO.Path.Combine(DocumentService.TEMP_DIRECTORY, folderName);

            // Make this instance of word invisible (Can still see it in the taskmgr).
            wordApplication.Visible = false;

            // Interop requires objects.
            object oMissing = System.Reflection.Missing.Value;
            object isVisible = false;
            object readOnly = false;
            object oInput = path;
            object oOutput = documentPath + DD + DOC_FILES + DD + "document.xps";
            object oFormat = WdSaveFormat.wdFormatXPS;

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationName = "Opening MS Office";
            pp.CurrentOperationTotalElements = 1;
            pp.CurrentOperationElement = 0;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            // Load a document into our instance of word.exe
            Microsoft.Office.Interop.Word._Document wdoc = wordApplication.Documents.Open(ref oInput, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref isVisible, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            // Make this document the active document.
            wdoc.Activate();

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationElement = 1;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //KineSis.ContentManagement.Model.Document document = new KineSis.ContentManagement.Model.Document();
            document.Name = wdoc.Name;
            document.Location = folderName;

            //create a new page
            KineSis.ContentManagement.Model.Page page = document.Pages[0];

            //check if chart generation is wanted
            if (DocumentService.CHART_HORIZONTAL_FACES > 0)
            {

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationName = "Transforming";
                pp.CurrentOperationTotalElements = 4;
                pp.CurrentOperationElement = 0;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                Thread thread = new Thread(new ThreadStart(ClearClipboard));
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();

                //handle the charts
                wdoc.Shapes.SelectAll();

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationElement = 1;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                wdoc.ActiveWindow.Selection.Copy(); //copy all shapes

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationElement = 2;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                //open a new powerpoint application
                Presentation presentation = powerPointApplication.Presentations.Add();

                //paste all copied shapes
                presentation.SlideMaster.Shapes.Paste();

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationElement = 3;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                //clear the clipboard
                //Clipboard.Clear();
                Thread thread1 = new Thread(new ThreadStart(ClearClipboard));
                thread1.SetApartmentState(ApartmentState.STA);
                thread1.Start();
                thread1.Join();

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationElement = 4;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                List<Microsoft.Office.Interop.PowerPoint.Shape> charts = new List<Microsoft.Office.Interop.PowerPoint.Shape>();

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.OverallOperationTotalElements = EvaluatePresentation(presentation, pp);
                pp.OverallOperationElement = 0;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                //get all charts
                for (int j = 1; j <= presentation.SlideMaster.Shapes.Count; j++)
                {
                    Microsoft.Office.Interop.PowerPoint.Shape shape = presentation.SlideMaster.Shapes[j];
                    if (shape.HasChart == Microsoft.Office.Core.MsoTriState.msoTrue)
                    {
                        charts.Add(shape);
                    }
                }

                //create directory for charts
                String chartPath = System.IO.Path.Combine(documentPath, "charts");
                System.IO.Directory.CreateDirectory(chartPath);

                //for every chart
                for (int j = 0; j < charts.Count; j++)
                {

                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                    pp.CurrentOperationName = "Chart " + (j + 1) + " of " + charts.Count;
                    pp.CurrentOperationTotalElements = EvaluateChart(charts.ElementAt(j).Chart);
                    pp.CurrentOperationElement = 0;
                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                    KineSis.ContentManagement.Model.Chart mChart = new KineSis.ContentManagement.Model.Chart();
                    Microsoft.Office.Interop.PowerPoint.Shape chart = charts.ElementAt(j);

                    mChart.SetThumbnailUrl(GenerateThumbnail(chart, chartPath + DD + j + "_thumb"));

                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                    pp.OverallOperationElement++;
                    pp.CurrentOperationElement++;
                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                    //set preferred width and height
                    chart.Height = ((float)DocumentService.CHART_WIDTH * chart.Height) / chart.Width;
                    chart.Width = DocumentService.CHART_WIDTH;

                    //get chart type
                    int chartType = GetChartType(chart.Chart);

                    //reset rotation
                    chart.Chart.Rotation = 0;

                    int horizontalAngle = 0;

                    //depending on how many horizontal faces are required, calculate the angle between them
                    if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                    {
                        horizontalAngle = 360 / DocumentService.CHART_HORIZONTAL_FACES;
                    }

                    int verticalAngle = 0;

                    //depending on how many vertical faces are required for a horizontal face, celaculate the angle between them, excluding the vertical face at 90 degrees
                    if (DocumentService.CHART_VERTICAL_FACES > 0)
                    {
                        verticalAngle = 90 / (DocumentService.CHART_VERTICAL_FACES + 1);
                    }

                    if (chart.Chart.HasTitle)
                    {
                        mChart.Title = chart.Chart.ChartTitle.Caption;
                    }
                    else
                    {
                        mChart.Title = chart.Name;
                    }

                    //does not support rotation (it's plain)
                    if (chartType == 0)
                    {

                        //if horizontal faces number is 0, then no chart will be outputed
                        if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                        {

                            ChartHorizontalView hView = new ChartHorizontalView();
                            //draw chart face as image
                            chart.Export(chartPath + DD + j + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                            //add to hView
                            hView.ImageUrl = chartPath + DD + j + DocumentService.IMAGE_EXTENSION;
                            //add to views
                            mChart.Views.Add(hView);

                            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                            pp.OverallOperationElement++;
                            pp.CurrentOperationElement++;
                            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                        }
                    }
                    else
                    {

                        //for every horizontal face
                        for (int k = 0; k < DocumentService.CHART_HORIZONTAL_FACES; k++)
                        {

                            ChartHorizontalView hView = new ChartHorizontalView();
                            //reset elevation
                            chart.Chart.Elevation = 0;
                            //export face as image
                            chart.Export(chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                            //set bitmap to view
                            hView.ImageUrl = chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION;

                            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                            pp.OverallOperationElement++;
                            pp.CurrentOperationElement++;
                            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                            //for every vertical face
                            for (int l = 0; l < DocumentService.CHART_VERTICAL_FACES; l++)
                            {
                                ChartVerticalView vView = new ChartVerticalView();

                                //increse elevation
                                chart.Chart.Elevation += verticalAngle;
                                //export face as image
                                chart.Export(chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                                //set bitmap to view
                                vView.ImageUrl = chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                //add vertical view to horizontal UP list
                                hView.Up.Add(vView);

                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                pp.OverallOperationElement++;
                                pp.CurrentOperationElement++;
                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                            }

                            //some chart types, like 3D pie, does not support elevation less than 0
                            if (SupportsNegativeElevation(chart.Chart))
                            {

                                //reset elevation
                                chart.Chart.Elevation = 0;

                                //for every vertical face
                                for (int m = 0; m < DocumentService.CHART_VERTICAL_FACES; m++)
                                {
                                    ChartVerticalView vView = new ChartVerticalView();

                                    //decrease elevation
                                    chart.Chart.Elevation -= verticalAngle;
                                    //export face as image
                                    chart.Export(chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                                    //set bitmap to vertical view
                                    vView.ImageUrl = chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                    //add vertical view to horizontal view DOWN list
                                    hView.Down.Add(vView);

                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                    pp.OverallOperationElement++;
                                    pp.CurrentOperationElement++;
                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                }
                            }
                            //increase horizontal angle in order to get the next horizontal view
                            chart.Chart.Rotation += horizontalAngle;
                            //add horizontal view to the chat's views list
                            mChart.Views.Add(hView);
                        }
                    }
                    //add chart to page
                    page.Charts.Add(mChart);
                }

                //close presentation
                presentation.Close();
            }

            wdoc.Close(SaveChanges: false);

            CloseOfficeApplication();

            //return built document
            return document;
        }
Пример #3
0
        /// <summary>
        /// parse a word document and build a kinesis document model
        /// </summary>
        /// <param name="path">full path of the word document</param>
        /// <returns>equivalent kinesis document model</returns>
        public KineSis.ContentManagement.Model.Document ParseNewDocumentCharts(String path, ProcessingProgress pp, KineSis.ContentManagement.Model.Document document)
        {
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.OverallOperationName = "All Document Charts";
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //directory where all the data will be saved
            String folderName   = document.Location;
            String documentPath = System.IO.Path.Combine(DocumentService.TEMP_DIRECTORY, folderName);

            // Make this instance of word invisible (Can still see it in the taskmgr).
            wordApplication.Visible = false;

            // Interop requires objects.
            object oMissing  = System.Reflection.Missing.Value;
            object isVisible = false;
            object readOnly  = false;
            object oInput    = path;
            object oOutput   = documentPath + DD + DOC_FILES + DD + "document.xps";
            object oFormat   = WdSaveFormat.wdFormatXPS;

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationName          = "Opening MS Office";
            pp.CurrentOperationTotalElements = 1;
            pp.CurrentOperationElement       = 0;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            // Load a document into our instance of word.exe
            Microsoft.Office.Interop.Word._Document wdoc = wordApplication.Documents.Open(ref oInput, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref isVisible, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            // Make this document the active document.
            wdoc.Activate();

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationElement = 1;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //KineSis.ContentManagement.Model.Document document = new KineSis.ContentManagement.Model.Document();
            document.Name     = wdoc.Name;
            document.Location = folderName;

            //create a new page
            KineSis.ContentManagement.Model.Page page = document.Pages[0];


            //check if chart generation is wanted
            if (DocumentService.CHART_HORIZONTAL_FACES > 0)
            {
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationName          = "Transforming";
                pp.CurrentOperationTotalElements = 4;
                pp.CurrentOperationElement       = 0;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                Thread thread = new Thread(new ThreadStart(ClearClipboard));
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();

                //handle the charts
                wdoc.Shapes.SelectAll();

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationElement = 1;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                wdoc.ActiveWindow.Selection.Copy(); //copy all shapes

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationElement = 2;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                //open a new powerpoint application
                Presentation presentation = powerPointApplication.Presentations.Add();

                //paste all copied shapes
                presentation.SlideMaster.Shapes.Paste();

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationElement = 3;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                //clear the clipboard
                //Clipboard.Clear();
                Thread thread1 = new Thread(new ThreadStart(ClearClipboard));
                thread1.SetApartmentState(ApartmentState.STA);
                thread1.Start();
                thread1.Join();

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.CurrentOperationElement = 4;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                List <Microsoft.Office.Interop.PowerPoint.Shape> charts = new List <Microsoft.Office.Interop.PowerPoint.Shape>();

                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                pp.OverallOperationTotalElements = EvaluatePresentation(presentation, pp);
                pp.OverallOperationElement       = 0;
                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                //get all charts
                for (int j = 1; j <= presentation.SlideMaster.Shapes.Count; j++)
                {
                    Microsoft.Office.Interop.PowerPoint.Shape shape = presentation.SlideMaster.Shapes[j];
                    if (shape.HasChart == Microsoft.Office.Core.MsoTriState.msoTrue)
                    {
                        charts.Add(shape);
                    }
                }

                //create directory for charts
                String chartPath = System.IO.Path.Combine(documentPath, "charts");
                System.IO.Directory.CreateDirectory(chartPath);

                //for every chart
                for (int j = 0; j < charts.Count; j++)
                {
                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                    pp.CurrentOperationName          = "Chart " + (j + 1) + " of " + charts.Count;
                    pp.CurrentOperationTotalElements = EvaluateChart(charts.ElementAt(j).Chart);
                    pp.CurrentOperationElement       = 0;
                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                    KineSis.ContentManagement.Model.Chart     mChart = new KineSis.ContentManagement.Model.Chart();
                    Microsoft.Office.Interop.PowerPoint.Shape chart  = charts.ElementAt(j);

                    mChart.SetThumbnailUrl(GenerateThumbnail(chart, chartPath + DD + j + "_thumb"));

                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                    pp.OverallOperationElement++;
                    pp.CurrentOperationElement++;
                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                    //set preferred width and height
                    chart.Height = ((float)DocumentService.CHART_WIDTH * chart.Height) / chart.Width;
                    chart.Width  = DocumentService.CHART_WIDTH;

                    //get chart type
                    int chartType = GetChartType(chart.Chart);

                    //reset rotation
                    chart.Chart.Rotation = 0;

                    int horizontalAngle = 0;

                    //depending on how many horizontal faces are required, calculate the angle between them
                    if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                    {
                        horizontalAngle = 360 / DocumentService.CHART_HORIZONTAL_FACES;
                    }

                    int verticalAngle = 0;

                    //depending on how many vertical faces are required for a horizontal face, celaculate the angle between them, excluding the vertical face at 90 degrees
                    if (DocumentService.CHART_VERTICAL_FACES > 0)
                    {
                        verticalAngle = 90 / (DocumentService.CHART_VERTICAL_FACES + 1);
                    }

                    if (chart.Chart.HasTitle)
                    {
                        mChart.Title = chart.Chart.ChartTitle.Caption;
                    }
                    else
                    {
                        mChart.Title = chart.Name;
                    }

                    //does not support rotation (it's plain)
                    if (chartType == 0)
                    {
                        //if horizontal faces number is 0, then no chart will be outputed
                        if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                        {
                            ChartHorizontalView hView = new ChartHorizontalView();
                            //draw chart face as image
                            chart.Export(chartPath + DD + j + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                            //add to hView
                            hView.ImageUrl = chartPath + DD + j + DocumentService.IMAGE_EXTENSION;
                            //add to views
                            mChart.Views.Add(hView);

                            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                            pp.OverallOperationElement++;
                            pp.CurrentOperationElement++;
                            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                        }
                    }
                    else
                    {
                        //for every horizontal face
                        for (int k = 0; k < DocumentService.CHART_HORIZONTAL_FACES; k++)
                        {
                            ChartHorizontalView hView = new ChartHorizontalView();
                            //reset elevation
                            chart.Chart.Elevation = 0;
                            //export face as image
                            chart.Export(chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                            //set bitmap to view
                            hView.ImageUrl = chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION;

                            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                            pp.OverallOperationElement++;
                            pp.CurrentOperationElement++;
                            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                            //for every vertical face
                            for (int l = 0; l < DocumentService.CHART_VERTICAL_FACES; l++)
                            {
                                ChartVerticalView vView = new ChartVerticalView();

                                //increse elevation
                                chart.Chart.Elevation += verticalAngle;
                                //export face as image
                                chart.Export(chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                                //set bitmap to view
                                vView.ImageUrl = chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                //add vertical view to horizontal UP list
                                hView.Up.Add(vView);

                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                pp.OverallOperationElement++;
                                pp.CurrentOperationElement++;
                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                            }

                            //some chart types, like 3D pie, does not support elevation less than 0
                            if (SupportsNegativeElevation(chart.Chart))
                            {
                                //reset elevation
                                chart.Chart.Elevation = 0;

                                //for every vertical face
                                for (int m = 0; m < DocumentService.CHART_VERTICAL_FACES; m++)
                                {
                                    ChartVerticalView vView = new ChartVerticalView();

                                    //decrease elevation
                                    chart.Chart.Elevation -= verticalAngle;
                                    //export face as image
                                    chart.Export(chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                                    //set bitmap to vertical view
                                    vView.ImageUrl = chartPath + DD + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                    //add vertical view to horizontal view DOWN list
                                    hView.Down.Add(vView);

                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                    pp.OverallOperationElement++;
                                    pp.CurrentOperationElement++;
                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                }
                            }
                            //increase horizontal angle in order to get the next horizontal view
                            chart.Chart.Rotation += horizontalAngle;
                            //add horizontal view to the chat's views list
                            mChart.Views.Add(hView);
                        }
                    }
                    //add chart to page
                    page.Charts.Add(mChart);
                }

                //close presentation
                presentation.Close();
            }

            wdoc.Close(SaveChanges: false);

            CloseOfficeApplication();

            //return built document
            return(document);
        }
Пример #4
0
        /// <summary>
        /// parse an excel document and build a kinesis document model
        /// </summary>
        /// <param name="path">full path of the excel document</param>
        /// <returns>equivalent kinesis document model</returns>
        public Document ParseNewDocumentCharts(String path, ProcessingProgress pp, Document document)
        {
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.OverallOperationName = "All Document Charts";
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //directory where all the data will be saved
            String folderName = document.Location;
            String documentPath = System.IO.Path.Combine(DocumentService.TEMP_DIRECTORY, folderName);

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationName = "Opening MS Office";
            pp.CurrentOperationTotalElements = 1;
            pp.CurrentOperationElement = 0;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //open the given excel document
            Workbook workbook = excelApplication.Workbooks.Open(path, ReadOnly: true);

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationElement = 1;
            pp.OverallOperationTotalElements = EvaluateWorkbook(workbook, pp);
            pp.OverallOperationElement = 0;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //for every sheet
            for (int i = 1; i <= workbook.Sheets.Count; i++)
            {
                Worksheet worksheet = workbook.Sheets[i];

                //create a new page
                KineSis.ContentManagement.Model.Page page = document.Pages[i - 1];

                //check if chart generation is wanted
                if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                {
                    //get charts
                    ChartObjects chartObjects = worksheet.ChartObjects(Type.Missing);

                    //create directory for charts
                    String chartPath = System.IO.Path.Combine(documentPath, "charts");
                    System.IO.Directory.CreateDirectory(chartPath);

                    //for every chart
                    for (int j = 1; j <= chartObjects.Count; j++)
                    {

                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                        pp.CurrentOperationName = "Page " + i + " / Chart " + j + " of " + chartObjects.Count;
                        pp.CurrentOperationTotalElements = EvaluateChart(chartObjects.Item(j).Chart);
                        pp.CurrentOperationElement = 0;
                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                        KineSis.ContentManagement.Model.Chart mChart = new KineSis.ContentManagement.Model.Chart();

                        //current chart
                        Microsoft.Office.Interop.Excel.Chart chart = chartObjects.Item(j).Chart;

                        mChart.SetThumbnailUrl(GenerateThumbnail(chart, chartPath + DD + i + _ + j + "_thumb"));

                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                        pp.OverallOperationElement++;
                        pp.CurrentOperationElement++;
                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                        if (DocumentService.FORCE_CHART_SIZE)
                        {
                            chart.ChartArea.Height = ((float)DocumentService.CHART_WIDTH * chart.ChartArea.Height) / chart.ChartArea.Width;
                            chart.ChartArea.Width = DocumentService.CHART_WIDTH;
                        }

                        int chartType = GetChartType(chart);

                        //start from 0 point
                        chart.Rotation = 0;

                        int horizontalAngle = 0;

                        //depending on how many horizontal faces are required, calculate the angle between them
                        if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                        {
                            horizontalAngle = 360 / DocumentService.CHART_HORIZONTAL_FACES;
                        }

                        int verticalAngle = 0;

                        //depending on how many vertical faces are required for a horizontal face, celaculate the angle between them, excluding the vertical face at 90 degrees
                        if (DocumentService.CHART_VERTICAL_FACES > 0)
                        {
                            verticalAngle = 90 / (DocumentService.CHART_VERTICAL_FACES + 1);
                        }

                        if (chart.HasTitle)
                        {
                            mChart.Title = chart.ChartTitle.Caption;
                        }
                        else
                        {
                            mChart.Title = chart.Name;
                        }

                        //does not support rotation (it's plain)
                        if (chartType == 0)
                        {

                            //if horizontal faces number is 0, then no chart will be outputed
                            if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                            {

                                ChartHorizontalView hView = new ChartHorizontalView();

                                //draw chart face as image
                                chart.Export(chartPath + DD + i + _ + j + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FILTER, false);
                                //add to hView
                                hView.ImageUrl = chartPath + DD + i + _ + j + DocumentService.IMAGE_EXTENSION;
                                //add to views
                                mChart.Views.Add(hView);

                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                pp.OverallOperationElement++;
                                pp.CurrentOperationElement++;
                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                            }
                        }
                        else
                        {

                            //for every horizontal face
                            for (int k = 0; k < DocumentService.CHART_HORIZONTAL_FACES; k++)
                            {

                                ChartHorizontalView hView = new ChartHorizontalView();
                                //reset elevation
                                chart.Elevation = 0;
                                //export face as image

                                chart.Export(chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FILTER, false);
                                //set bitmap to view
                                hView.ImageUrl = chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION;

                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                pp.OverallOperationElement++;
                                pp.CurrentOperationElement++;
                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                                //for every vertical face
                                for (int l = 0; l < DocumentService.CHART_VERTICAL_FACES; l++)
                                {
                                    ChartVerticalView vView = new ChartVerticalView();
                                    //increse elevation
                                    chart.Elevation += verticalAngle;
                                    //export face as image
                                    chart.Export(chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FILTER, false);

                                    //set bitmap to view
                                    vView.ImageUrl = chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                    //add vertical view to horizontal UP list
                                    hView.Up.Add(vView);

                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                    pp.OverallOperationElement++;
                                    pp.CurrentOperationElement++;
                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                }

                                //some chart types, like 3D pie, does not support elevation less than 0
                                if (SupportsNegativeElevation(chart))
                                {

                                    //reset elevation
                                    chart.Elevation = 0;

                                    //for every vertical face
                                    for (int m = 0; m < DocumentService.CHART_VERTICAL_FACES; m++)
                                    {
                                        ChartVerticalView vView = new ChartVerticalView();

                                        //decrease elevation
                                        chart.Elevation -= verticalAngle;
                                        //export face as image
                                        chart.Export(chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FILTER, false);
                                        //set bitmap to vertical view
                                        vView.ImageUrl = chartPath + DD + i + _ + j + _ + chart.Rotation + _ + chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                        //add vertical view to horizontal view DOWN list
                                        hView.Down.Add(vView);

                                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                        pp.OverallOperationElement++;
                                        pp.CurrentOperationElement++;
                                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                    }
                                }

                                //increase horizontal angle in order to get the next horizontal view
                                chart.Rotation += horizontalAngle;
                                //add horizontal view to the chat's views list
                                mChart.Views.Add(hView);
                            }
                        }

                        //add chart to page
                        page.Charts.Add(mChart);
                    }
                }
            }

            //close workbook without saving any possible changes (this way the "Are you sure?" or "Save changes?" dialogs will be supressed)
            workbook.Close(SaveChanges: false);

            CloseOfficeApplication();

            //return the built document
            return document;
        }
Пример #5
0
        /// <summary>
        /// parse a power point document and export all charts and shapes
        /// </summary>
        /// <param name="path">full path of the power point document</param>
        /// <returns>equivalent kinesis document model</returns>
        public Document ParseNewDocumentCharts(String path, ProcessingProgress pp, Document document)
        {
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.OverallOperationName = "All Document Charts and Shapes";
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //directory where all the data will be saved
            String folderName   = document.Location;
            String documentPath = System.IO.Path.Combine(DocumentService.TEMP_DIRECTORY, folderName);

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationName          = "Opening MS Office";
            pp.CurrentOperationTotalElements = 1;
            pp.CurrentOperationElement       = 0;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //open the presentation
            Presentation presentation = powerPointApplication.Presentations.Open(path, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);

            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
            pp.CurrentOperationElement       = 1;
            pp.OverallOperationTotalElements = EvaluatePresentation(presentation, pp);
            pp.OverallOperationElement       = 0;
            //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

            //for every slide
            for (int i = 1; i <= presentation.Slides.Count; i++)
            {
                //get slide
                Slide slide = presentation.Slides[i];

                //create a new page
                KineSis.ContentManagement.Model.Page page = document.Pages[i - 1];

                //check if chart generation is wanted
                if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                {
                    List <Microsoft.Office.Interop.PowerPoint.Shape> charts = new List <Microsoft.Office.Interop.PowerPoint.Shape>();

                    //get all shapes and charts
                    for (int j = 1; j <= slide.Shapes.Count; j++)
                    {
                        Microsoft.Office.Interop.PowerPoint.Shape shape = slide.Shapes[j];
                        if (shape.HasChart == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            charts.Add(shape);
                        }
                    }

                    //create directory for charts
                    String chartPath = System.IO.Path.Combine(documentPath, "charts");
                    System.IO.Directory.CreateDirectory(chartPath);

                    //for every chart
                    for (int j = 0; j < charts.Count; j++)
                    {
                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                        pp.CurrentOperationName          = "Page " + i + " / Chart " + (j + 1) + " of " + charts.Count;
                        pp.CurrentOperationTotalElements = EvaluateChart(charts.ElementAt(j).Chart);
                        pp.CurrentOperationElement       = 0;
                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                        KineSis.ContentManagement.Model.Chart     mChart = new KineSis.ContentManagement.Model.Chart();
                        Microsoft.Office.Interop.PowerPoint.Shape chart  = charts.ElementAt(j);

                        mChart.SetThumbnailUrl(GenerateThumbnail(chart, chartPath + DD + i + _ + j + "_thumb"));

                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                        pp.OverallOperationElement++;
                        pp.CurrentOperationElement++;
                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                        //set preferred width and height
                        chart.Height = ((float)DocumentService.CHART_WIDTH * chart.Height) / chart.Width;
                        chart.Width  = DocumentService.CHART_WIDTH;

                        //get chart type
                        int chartType = GetChartType(chart.Chart);

                        //reset rotation
                        chart.Chart.Rotation = 0;

                        int horizontalAngle = 0;

                        //depending on how many horizontal faces are required, calculate the angle between them
                        if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                        {
                            horizontalAngle = 360 / DocumentService.CHART_HORIZONTAL_FACES;
                        }

                        int verticalAngle = 0;

                        //depending on how many vertical faces are required for a horizontal face, celaculate the angle between them, excluding the vertical face at 90 degrees
                        if (DocumentService.CHART_VERTICAL_FACES > 0)
                        {
                            verticalAngle = 90 / (DocumentService.CHART_VERTICAL_FACES + 1);
                        }

                        if (chart.Chart.HasTitle)
                        {
                            mChart.Title = chart.Chart.ChartTitle.Caption;
                        }
                        else
                        {
                            mChart.Title = chart.Name;
                        }

                        //does not support rotation (it's plain)
                        if (chartType == 0)
                        {
                            //if horizontal faces number is 0, then no chart will be outputed
                            if (DocumentService.CHART_HORIZONTAL_FACES > 0)
                            {
                                ChartHorizontalView hView = new ChartHorizontalView();
                                //draw chart face as image
                                chart.Export(chartPath + DD + i + _ + j + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                                //add to hView
                                hView.ImageUrl = chartPath + DD + i + _ + j + DocumentService.IMAGE_EXTENSION;
                                //add to views
                                mChart.Views.Add(hView);

                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                pp.OverallOperationElement++;
                                pp.CurrentOperationElement++;
                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                            }
                        }
                        else
                        {
                            //for every horizontal face
                            for (int k = 0; k < DocumentService.CHART_HORIZONTAL_FACES; k++)
                            {
                                ChartHorizontalView hView = new ChartHorizontalView();
                                //reset elevation
                                chart.Chart.Elevation = 0;
                                //export face as image
                                chart.Export(chartPath + DD + i + _ + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                                //set bitmap to view
                                hView.ImageUrl = chartPath + DD + i + _ + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION;

                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                pp.OverallOperationElement++;
                                pp.CurrentOperationElement++;
                                //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//

                                //for every vertical face
                                for (int l = 0; l < DocumentService.CHART_VERTICAL_FACES; l++)
                                {
                                    ChartVerticalView vView = new ChartVerticalView();

                                    //increse elevation
                                    chart.Chart.Elevation += verticalAngle;
                                    //export face as image
                                    chart.Export(chartPath + DD + i + _ + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                                    //set bitmap to view
                                    vView.ImageUrl = chartPath + DD + i + _ + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                    //add vertical view to horizontal UP list
                                    hView.Up.Add(vView);

                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                    pp.OverallOperationElement++;
                                    pp.CurrentOperationElement++;
                                    //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                }

                                //some chart types, like 3D pie, does not support elevation less than 0
                                if (SupportsNegativeElevation(chart.Chart))
                                {
                                    //reset elevation
                                    chart.Chart.Elevation = 0;

                                    //for every vertical face
                                    for (int m = 0; m < DocumentService.CHART_VERTICAL_FACES; m++)
                                    {
                                        ChartVerticalView vView = new ChartVerticalView();

                                        //decrease elevation
                                        chart.Chart.Elevation -= verticalAngle;
                                        //export face as image
                                        chart.Export(chartPath + DD + i + _ + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION, DocumentService.IMAGE_FORMAT);
                                        //set bitmap to vertical view
                                        vView.ImageUrl = chartPath + DD + i + _ + j + _ + chart.Chart.Rotation + _ + chart.Chart.Elevation + DocumentService.IMAGE_EXTENSION;
                                        //add vertical view to horizontal view DOWN list
                                        hView.Down.Add(vView);

                                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                        pp.OverallOperationElement++;
                                        pp.CurrentOperationElement++;
                                        //~~~~~~~~~~~~~progress~~~~~~~~~~~~~//
                                    }
                                }

                                //increase horizontal angle in order to get the next horizontal view
                                chart.Chart.Rotation += horizontalAngle;
                                //add horizontal view to the chat's views list
                                mChart.Views.Add(hView);
                            }
                        }

                        //add chart to page
                        page.Charts.Add(mChart);
                    }
                }
            }

            //close presentation
            presentation.Close();

            CloseOfficeApplication();

            //return built document
            return(document);
        }