/// <summary> /// Creates the PresentationPart and add it to this document. /// </summary> /// <returns>The newly added PresentationPart.</returns> public PresentationPart AddPresentationPart() { PresentationPart childPart = new PresentationPart(); InitPart(childPart, MainPartContentType); return(childPart); }
private static void CreatePresentationParts(PresentationPart presentationPart) { SlideMasterIdList slideMasterIdList1 = new SlideMasterIdList(new SlideMasterId() { Id = (UInt32Value)2147483648U, RelationshipId = "rId1" }); SlideIdList slideIdList1 = new SlideIdList(new SlideId() { Id = (UInt32Value)256U, RelationshipId = "rId2" }); SlideSize slideSize1 = new SlideSize() { Cx = 9144000, Cy = 6858000, Type = SlideSizeValues.Screen4x3 }; NotesSize notesSize1 = new NotesSize() { Cx = 6858000, Cy = 9144000 }; DefaultTextStyle defaultTextStyle1 = new DefaultTextStyle(); presentationPart.Presentation.Append(slideMasterIdList1, slideIdList1, slideSize1, notesSize1, defaultTextStyle1); SlidePart slidePart1; SlideLayoutPart slideLayoutPart1; SlideMasterPart slideMasterPart1; ThemePart themePart1; slidePart1 = CreateSlidePart(presentationPart); slideLayoutPart1 = CreateSlideLayoutPart(slidePart1); slideMasterPart1 = CreateSlideMasterPart(slideLayoutPart1); themePart1 = CreateTheme(slideMasterPart1); slideMasterPart1.AddPart(slideLayoutPart1, "rId1"); presentationPart.AddPart(slideMasterPart1, "rId1"); presentationPart.AddPart(themePart1, "rId5"); }
private static SlidePart CreateSlidePart(PresentationPart presentationPart) { SlidePart slidePart1 = presentationPart.AddNewPart<SlidePart>("rId2"); slidePart1.Slide = new Slide( new CommonSlideData( new ShapeTree( new P.NonVisualGroupShapeProperties( new P.NonVisualDrawingProperties() { Id = (UInt32Value)1U, Name = "" }, new P.NonVisualGroupShapeDrawingProperties(), new ApplicationNonVisualDrawingProperties()), new GroupShapeProperties(new TransformGroup()), new P.Shape( new P.NonVisualShapeProperties( new P.NonVisualDrawingProperties() { Id = (UInt32Value)2U, Name = "Title 1" }, new P.NonVisualShapeDrawingProperties(new ShapeLocks() { NoGrouping = true }), new ApplicationNonVisualDrawingProperties(new PlaceholderShape())), new P.ShapeProperties(), new P.TextBody( new BodyProperties(), new ListStyle(), new Paragraph(new EndParagraphRunProperties() { Language = "en-US" }))))), new ColorMapOverride(new MasterColorMapping())); return slidePart1; }
private void CreateDynamicSlides(IList<TaskItemGroup> data, int[] dynamicSlideIndices, int gridSlideIndex, int completedSlideIndex, SlidePart gridSlidePart, SlidePart completedSlidePart, PresentationPart oPPart) { Repository.Utility.WriteLog("CreateDynamicSlides started", System.Diagnostics.EventLogEntryType.Information); if (data.Count < 1) { foreach (int slideIndex in dynamicSlideIndices) { if (slideIndex == gridSlideIndex) { var newGridSlidePart = gridSlidePart.CloneSlide(SlideType.Grid); oPPart.AppendSlide(newGridSlidePart); } if (slideIndex == completedSlideIndex) { var newCompletedSlidePart = completedSlidePart.CloneSlide(SlideType.Completed); oPPart.AppendSlide(newCompletedSlidePart); } } } for (int i = 0; i < data.Count; i++) { foreach (int slideIndex in dynamicSlideIndices) { if (slideIndex == gridSlideIndex) { if (gridSlidePart != null) { var newGridSlidePart = gridSlidePart.CloneSlide(SlideType.Grid); oPPart.AppendSlide(newGridSlidePart); } } if (slideIndex == completedSlideIndex) { if (data[i].CompletedTaskgroups != null) { if (completedSlidePart != null) { if (data[i].CompletedTaskgroups.Count == 0) { var newCompletedSlidePart = completedSlidePart.CloneSlide(SlideType.Completed); oPPart.AppendSlide(newCompletedSlidePart); } else { foreach (TaskItemGroup group in data[i].CompletedTaskgroups) { var newCompletedSlidePart = completedSlidePart.CloneSlide(SlideType.Completed); oPPart.AppendSlide(newCompletedSlidePart); } } } } else { var newCompletedSlidePart = completedSlidePart.CloneSlide(SlideType.Completed); oPPart.AppendSlide(newCompletedSlidePart); } } } } Repository.Utility.WriteLog("CreateDynamicSlides completed successfully", System.Diagnostics.EventLogEntryType.Information); }
private int GetSlideindexByTitle(PresentationPart oPPart, string title) { Repository.Utility.WriteLog("GetSlideindexByTitle started", System.Diagnostics.EventLogEntryType.Information); List<SlidePart> slides = oPPart.GetSlidePartsInOrder().ToList(); int count = 0; foreach (var gridSlidePart in slides) { var titleShape = gridSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.Shape>().ToList(); if (titleShape.Count > 0) { if (titleShape[0].TextBody.InnerText.Trim().ToUpper() == title.Trim().ToUpper()) { Repository.Utility.WriteLog("GetSlideindexByTitle completed successfully", System.Diagnostics.EventLogEntryType.Information); return count; } } count++; } Repository.Utility.WriteLog("GetSlideindexByTitle completed successfully", System.Diagnostics.EventLogEntryType.Information); return -1; }
private void CreateUpComingSlides(TaskGroupData taskData, int lowestSLideIndex, ref int createdCount, PresentationPart oPPart) { Repository.Utility.WriteLog("CreateupComingSlides started", System.Diagnostics.EventLogEntryType.Information); try { if (UpComingSlidePart == null) return; #region upComingSlides if (taskData.UpComingTaskGroups == null || taskData.UpComingTaskGroups.Count == 0) { createdCount++; return; } foreach (TaskItemGroup upComingTaskgroup in taskData.UpComingTaskGroups) { try { SlidePart upComingSlidePart = oPPart.GetSlidePartsInOrder().ToList()[lowestSLideIndex + createdCount]; var table = upComingSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Drawing.Table>().FirstOrDefault(); if (table != null && upComingTaskgroup.TaskItems.Count > 0) { TableUtilities.PopulateLateOrUpComingTasksTable(table, upComingTaskgroup.TaskItems, taskData.FiscalPeriod); } createdCount++; } catch { continue; } } #endregion } catch (Exception ex) { Repository.Utility.WriteLog(string.Format("CreateupComingSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information); } Repository.Utility.WriteLog("CreateupComingSlides completed", System.Diagnostics.EventLogEntryType.Information); }
private void CreateSPDLToBLSlides(TaskGroupData taskData, int lowestSLideIndex, ref int createdCount, PresentationPart oPPart, ChartType chartType) { Repository.Utility.WriteLog("CreateLateSlides started", System.Diagnostics.EventLogEntryType.Information); try { #region LateSlides if (chartType == ChartType.SPBaseLineStart && SPDSSlidePart == null) return; if (chartType == ChartType.SPBaseLineFinish && SPDFSlidePart == null) return; if (chartType == ChartType.SPBEI && SPBEISlidePart == null) return; SlidePart chartSlidePart = oPPart.GetSlidePartsInOrder().ToList()[lowestSLideIndex + createdCount]; if (chartSlidePart.ChartParts.ToList().Count > 0) { var chartPart = chartSlidePart.ChartParts.ToList()[0]; foreach (IdPartPair part in chartPart.Parts) { var spreadsheet = chartPart.GetPartById(part.RelationshipId) as EmbeddedPackagePart; if (spreadsheet != null) { using (var oSDoc = SpreadsheetDocument.Open(spreadsheet.GetStream(FileMode.OpenOrCreate, FileAccess.ReadWrite), true)) { var workSheetPart = oSDoc.WorkbookPart.GetPartsOfType<WorksheetPart>().FirstOrDefault(); var sheetData = workSheetPart.Worksheet.Elements<SheetData>().FirstOrDefault(); switch (chartType) { case ChartType.SPBaseLineStart: if (taskData.SPDLSTartToBL != null && taskData.SPDLSTartToBL.Count > 0 && taskData.SPDLSTartToBL[0].Data != null) { WorkbookUtilities.ReplicateRow(sheetData, 2, taskData.SPDLSTartToBL[0].Data.Count - 1); WorkbookUtilities.LoadGraphSheetData(sheetData, taskData.SPDLSTartToBL, 1, 0); BarChartUtilities.LoadChartData(chartPart, taskData.SPDLSTartToBL); } break; case ChartType.SPBaseLineFinish: if (taskData.SPDLFinishToBL != null && taskData.SPDLFinishToBL.Count > 0 && taskData.SPDLFinishToBL[0].Data != null) { WorkbookUtilities.ReplicateRow(sheetData, 2, taskData.SPDLFinishToBL[0].Data.Count - 1); WorkbookUtilities.LoadGraphSheetData(sheetData, taskData.SPDLFinishToBL, 1, 0); BarChartUtilities.LoadChartData(chartPart, taskData.SPDLFinishToBL); } break; case ChartType.SPBEI: if (taskData.BEIData != null && taskData.BEIData.Count > 0 && taskData.BEIData[0].Data != null) { WorkbookUtilities.ReplicateRow(sheetData, 2, taskData.BEIData[0].Data.Count - 1); WorkbookUtilities.LoadGraphSheetData(sheetData, taskData.BEIData, 1, 0); BarChartUtilities.LoadChartData(chartPart, taskData.BEIData); } break; } } break; } } } #endregion } catch (Exception ex) { Repository.Utility.WriteLog(string.Format("CreateLateSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information); } createdCount++; Repository.Utility.WriteLog("CreateLateSlides completed", System.Diagnostics.EventLogEntryType.Information); }
private void CreateGridSlide(PresentationPart oPPart, int gridSlideIndex, int i, TaskItemGroup group) { Repository.Utility.WriteLog("CreateGridSlide started", System.Diagnostics.EventLogEntryType.Information); try { if (DPSlidePart == null) return; SlidePart gridSlidePart = oPPart.GetSlidePartsInOrder().ToList()[gridSlideIndex + i]; var dataTable = group.TaskItemsDataTable; var table = gridSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Drawing.Table>().FirstOrDefault(); if (table != null && group.TaskItems != null && group.TaskItems.Count > 0) { TableUtilities.PopulateTable(table, group.TaskItems); } //else //{ // DocumentFormat.OpenXml.OpenXmlElement parent = table.Parent; // parent.ReplaceChild(new DocumentFormat.OpenXml.Presentation.Text("No Data Avialable"), table); // //table.Remove(); //} var titleShape = gridSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.Shape>().ToList(); if (titleShape.Count > 0) { titleShape[0].TextBody = new DocumentFormat.OpenXml.Presentation.TextBody( new DocumentFormat.OpenXml.Drawing.BodyProperties(), new DocumentFormat.OpenXml.Drawing.ListStyle(), new DocumentFormat.OpenXml.Drawing.Paragraph( new DocumentFormat.OpenXml.Drawing.Run( new DocumentFormat.OpenXml.Drawing.RunProperties() { FontSize = 3600 }, new DocumentFormat.OpenXml.Drawing.Text { Text = group.Title }))); } } catch (Exception ex) { Repository.Utility.WriteLog(string.Format("CreateGridSlide had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information); } Repository.Utility.WriteLog("CreateGridSlide completed", System.Diagnostics.EventLogEntryType.Information); }
private void CreateFixedSlidesData(TaskGroupData taskData, int[] fixedSlideIndices, int lateSlideIndex,int upcomingSlideIndex, int chartSlideIndex, int lowestSLideIndex, int SPDLSTartToBLSlideIndex, int SPDLFinishToBLSlideIndex,int BEISlideIndex,ref int createdCount, PresentationPart oPPart) { Repository.Utility.WriteLog("CreateFixedSlidesData started", System.Diagnostics.EventLogEntryType.Information); foreach (int slideIndex in fixedSlideIndices) { if (slideIndex == lateSlideIndex) { CreateLateSlides(taskData, lowestSLideIndex, ref createdCount, oPPart); } if (slideIndex == upcomingSlideIndex) { CreateUpComingSlides(taskData, lowestSLideIndex, ref createdCount, oPPart); } if (slideIndex == chartSlideIndex) { CreateChartSlides(taskData, lowestSLideIndex, ref createdCount, oPPart); } if (slideIndex == SPDLSTartToBLSlideIndex) { CreateSPDLToBLSlides(taskData, lowestSLideIndex, ref createdCount, oPPart,ChartType.SPBaseLineStart); } if (slideIndex == SPDLFinishToBLSlideIndex) { CreateSPDLToBLSlides(taskData, lowestSLideIndex, ref createdCount, oPPart, ChartType.SPBaseLineFinish); } if (slideIndex == BEISlideIndex) { CreateSPDLToBLSlides(taskData, lowestSLideIndex, ref createdCount, oPPart, ChartType.SPBEI); } } Repository.Utility.WriteLog("CreateFixedSlidesData completed successfully", System.Diagnostics.EventLogEntryType.Information); }
/// <summary> /// Loads the DOM from the PresentationPart. /// </summary> /// <param name="openXmlPart">Specifies the part to be loaded.</param> public void Load(PresentationPart openXmlPart) { LoadFromPart(openXmlPart); }
private void CreateCompletedSlides(TaskItemGroup group, int completedSlideIndex, PresentationPart oPPart) { Repository.Utility.WriteLog("CreateCompletedSlides started", System.Diagnostics.EventLogEntryType.Information); try { if (CPSlidePart == null) return; if (group.CompletedTaskgroups != null) { IList<TaskItemGroup> CompletedTasks = group.CompletedTaskgroups; if (CompletedTasks != null && CompletedTasks.Count() > 0) { foreach (TaskItemGroup completedTaskgroup in CompletedTasks) { SlidePart completedSlidePart = oPPart.GetSlidePartsInOrder().ToList()[completedSlideIndex]; DocumentFormat.OpenXml.Presentation.TextBody numberPart = (DocumentFormat.OpenXml.Presentation.TextBody)completedSlidePart.Slide.CommonSlideData.ShapeTree.Elements().ToList()[3].Elements().ToList()[2]; int bulletCount = numberPart.Elements<DocumentFormat.OpenXml.Drawing.Paragraph>().Count(); foreach (string task in completedTaskgroup.TaskItems.Select(t => t.Task)) { DocumentFormat.OpenXml.Drawing.Paragraph paragraph = (DocumentFormat.OpenXml.Drawing.Paragraph)numberPart.Elements().ToList()[3].Clone(); for (int i = paragraph.Elements().Count() - 1; i >=1; i--) { if (paragraph.ElementAt(i).GetType() == typeof(DocumentFormat.OpenXml.Drawing.Run)) { paragraph.ElementAt(i).Remove(); } } (paragraph.Elements().ToList()[0] as DocumentFormat.OpenXml.Drawing.Run).Text = new DocumentFormat.OpenXml.Drawing.Text(task); numberPart.Append(paragraph); } //var titleShape = completedSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.Shape>().ToList(); //if (titleShape.Count > 0) //{ // titleShape[0].TextBody = new DocumentFormat.OpenXml.Presentation.TextBody( // new DocumentFormat.OpenXml.Drawing.BodyProperties(), // new DocumentFormat.OpenXml.Drawing.ListStyle(), // new DocumentFormat.OpenXml.Drawing.Paragraph( // new DocumentFormat.OpenXml.Drawing.Run( // new DocumentFormat.OpenXml.Drawing.RunProperties() { FontSize = 3600 }, // new DocumentFormat.OpenXml.Drawing.Text { Text = group.Title }))); //} DocumentFormat.OpenXml.Presentation.TextBody numPart = (DocumentFormat.OpenXml.Presentation.TextBody)completedSlidePart.Slide.CommonSlideData.ShapeTree.Elements().ToList()[3].Elements().ToList()[2]; for (int i = bulletCount - 2; i >= 0; i--) { ((DocumentFormat.OpenXml.Drawing.Paragraph)numPart.Elements().ToList()[3]).Remove(); } } } } } catch (Exception ex) { Repository.Utility.WriteLog(string.Format("CreateCompletedSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information); } Repository.Utility.WriteLog("CreateCompletedSlides completed", System.Diagnostics.EventLogEntryType.Information); }
/// <summary> /// Create an instance of OpenXmlPart according to the given relationship type. /// </summary> /// <param name="openXmlPackage">The container OpenXmlPackage.</param> /// <param name="relationshipType">The relationship type of the target part.</param> /// <param name="openXmlPart">The created instance of OpenXmlPart.</param> /// <remarks>This partial method will be generated by code generaotr.</remarks> static partial void CreatePartCore(OpenXmlPackage openXmlPackage, string relationshipType, ref OpenXmlPart openXmlPart) { if (openXmlPackage == null) { throw new ArgumentNullException("openXmlPackage"); } if (relationshipType == null) { throw new ArgumentNullException("relationshipType"); } if (openXmlPackage is WordprocessingDocument) { switch (relationshipType) { case MainDocumentPart.RelationshipTypeConstant: openXmlPart = new MainDocumentPart(); return; case CustomXmlPart.RelationshipTypeConstant: openXmlPart = new CustomXmlPart(); return; case CustomXmlPropertiesPart.RelationshipTypeConstant: openXmlPart = new CustomXmlPropertiesPart(); return; case GlossaryDocumentPart.RelationshipTypeConstant: openXmlPart = new GlossaryDocumentPart(); return; case WordprocessingCommentsPart.RelationshipTypeConstant: openXmlPart = new WordprocessingCommentsPart(); return; case AlternativeFormatImportPart.RelationshipTypeConstant: openXmlPart = new AlternativeFormatImportPart(); return; case ChartPart.RelationshipTypeConstant: openXmlPart = new ChartPart(); return; case ChartDrawingPart.RelationshipTypeConstant: openXmlPart = new ChartDrawingPart(); return; case ImagePart.RelationshipTypeConstant: openXmlPart = new ImagePart(); return; case EmbeddedPackagePart.RelationshipTypeConstant: openXmlPart = new EmbeddedPackagePart(); return; case ThemeOverridePart.RelationshipTypeConstant: openXmlPart = new ThemeOverridePart(); return; case ChartStylePart.RelationshipTypeConstant: openXmlPart = new ChartStylePart(); return; case ChartColorStylePart.RelationshipTypeConstant: openXmlPart = new ChartColorStylePart(); return; case DiagramColorsPart.RelationshipTypeConstant: openXmlPart = new DiagramColorsPart(); return; case DiagramDataPart.RelationshipTypeConstant: openXmlPart = new DiagramDataPart(); return; case SlidePart.RelationshipTypeConstant: openXmlPart = new SlidePart(); return; case DiagramPersistLayoutPart.RelationshipTypeConstant: openXmlPart = new DiagramPersistLayoutPart(); return; case DiagramLayoutDefinitionPart.RelationshipTypeConstant: openXmlPart = new DiagramLayoutDefinitionPart(); return; case DiagramStylePart.RelationshipTypeConstant: openXmlPart = new DiagramStylePart(); return; case EmbeddedObjectPart.RelationshipTypeConstant: openXmlPart = new EmbeddedObjectPart(); return; case VmlDrawingPart.RelationshipTypeConstant: openXmlPart = new VmlDrawingPart(); return; case LegacyDiagramTextPart.RelationshipTypeConstant: openXmlPart = new LegacyDiagramTextPart(); return; case EmbeddedControlPersistenceBinaryDataPart.RelationshipTypeConstant: openXmlPart = new EmbeddedControlPersistenceBinaryDataPart(); return; case NotesSlidePart.RelationshipTypeConstant: openXmlPart = new NotesSlidePart(); return; case NotesMasterPart.RelationshipTypeConstant: openXmlPart = new NotesMasterPart(); return; case ThemePart.RelationshipTypeConstant: openXmlPart = new ThemePart(); return; case UserDefinedTagsPart.RelationshipTypeConstant: openXmlPart = new UserDefinedTagsPart(); return; case SlideLayoutPart.RelationshipTypeConstant: openXmlPart = new SlideLayoutPart(); return; case SlideMasterPart.RelationshipTypeConstant: openXmlPart = new SlideMasterPart(); return; case EmbeddedControlPersistencePart.RelationshipTypeConstant: openXmlPart = new EmbeddedControlPersistencePart(); return; case SlideSyncDataPart.RelationshipTypeConstant: openXmlPart = new SlideSyncDataPart(); return; case WorksheetPart.RelationshipTypeConstant: openXmlPart = new WorksheetPart(); return; case DrawingsPart.RelationshipTypeConstant: openXmlPart = new DrawingsPart(); return; case WebExtensionPart.RelationshipTypeConstant: openXmlPart = new WebExtensionPart(); return; case PivotTablePart.RelationshipTypeConstant: openXmlPart = new PivotTablePart(); return; case PivotTableCacheDefinitionPart.RelationshipTypeConstant: openXmlPart = new PivotTableCacheDefinitionPart(); return; case PivotTableCacheRecordsPart.RelationshipTypeConstant: openXmlPart = new PivotTableCacheRecordsPart(); return; case SingleCellTablePart.RelationshipTypeConstant: openXmlPart = new SingleCellTablePart(); return; case TableDefinitionPart.RelationshipTypeConstant: openXmlPart = new TableDefinitionPart(); return; case QueryTablePart.RelationshipTypeConstant: openXmlPart = new QueryTablePart(); return; case ControlPropertiesPart.RelationshipTypeConstant: openXmlPart = new ControlPropertiesPart(); return; case CustomPropertyPart.RelationshipTypeConstant: openXmlPart = new CustomPropertyPart(); return; case WorksheetSortMapPart.RelationshipTypeConstant: openXmlPart = new WorksheetSortMapPart(); return; case SlicersPart.RelationshipTypeConstant: openXmlPart = new SlicersPart(); return; case TimeLinePart.RelationshipTypeConstant: openXmlPart = new TimeLinePart(); return; case DocumentSettingsPart.RelationshipTypeConstant: openXmlPart = new DocumentSettingsPart(); return; case MailMergeRecipientDataPart.RelationshipTypeConstant: openXmlPart = new MailMergeRecipientDataPart(); return; case EndnotesPart.RelationshipTypeConstant: openXmlPart = new EndnotesPart(); return; case FontTablePart.RelationshipTypeConstant: openXmlPart = new FontTablePart(); return; case FontPart.RelationshipTypeConstant: openXmlPart = new FontPart(); return; case FootnotesPart.RelationshipTypeConstant: openXmlPart = new FootnotesPart(); return; case NumberingDefinitionsPart.RelationshipTypeConstant: openXmlPart = new NumberingDefinitionsPart(); return; case StyleDefinitionsPart.RelationshipTypeConstant: openXmlPart = new StyleDefinitionsPart(); return; case StylesWithEffectsPart.RelationshipTypeConstant: openXmlPart = new StylesWithEffectsPart(); return; case WebSettingsPart.RelationshipTypeConstant: openXmlPart = new WebSettingsPart(); return; case FooterPart.RelationshipTypeConstant: openXmlPart = new FooterPart(); return; case HeaderPart.RelationshipTypeConstant: openXmlPart = new HeaderPart(); return; case WordprocessingPrinterSettingsPart.RelationshipTypeConstant: openXmlPart = new WordprocessingPrinterSettingsPart(); return; case CustomizationPart.RelationshipTypeConstant: openXmlPart = new CustomizationPart(); return; case WordAttachedToolbarsPart.RelationshipTypeConstant: openXmlPart = new WordAttachedToolbarsPart(); return; case VbaProjectPart.RelationshipTypeConstant: openXmlPart = new VbaProjectPart(); return; case VbaDataPart.RelationshipTypeConstant: openXmlPart = new VbaDataPart(); return; case WordprocessingCommentsExPart.RelationshipTypeConstant: openXmlPart = new WordprocessingCommentsExPart(); return; case WordprocessingPeoplePart.RelationshipTypeConstant: openXmlPart = new WordprocessingPeoplePart(); return; case ThumbnailPart.RelationshipTypeConstant: openXmlPart = new ThumbnailPart(); return; case CoreFilePropertiesPart.RelationshipTypeConstant: openXmlPart = new CoreFilePropertiesPart(); return; case ExtendedFilePropertiesPart.RelationshipTypeConstant: openXmlPart = new ExtendedFilePropertiesPart(); return; case CustomFilePropertiesPart.RelationshipTypeConstant: openXmlPart = new CustomFilePropertiesPart(); return; case DigitalSignatureOriginPart.RelationshipTypeConstant: openXmlPart = new DigitalSignatureOriginPart(); return; case XmlSignaturePart.RelationshipTypeConstant: openXmlPart = new XmlSignaturePart(); return; case QuickAccessToolbarCustomizationsPart.RelationshipTypeConstant: openXmlPart = new QuickAccessToolbarCustomizationsPart(); return; case RibbonExtensibilityPart.RelationshipTypeConstant: openXmlPart = new RibbonExtensibilityPart(); return; case RibbonAndBackstageCustomizationsPart.RelationshipTypeConstant: openXmlPart = new RibbonAndBackstageCustomizationsPart(); return; case WebExTaskpanesPart.RelationshipTypeConstant: openXmlPart = new WebExTaskpanesPart(); return; } } else if (openXmlPackage is SpreadsheetDocument) { switch (relationshipType) { case WorkbookPart.RelationshipTypeConstant: openXmlPart = new WorkbookPart(); return; case CustomXmlPart.RelationshipTypeConstant: openXmlPart = new CustomXmlPart(); return; case CustomXmlPropertiesPart.RelationshipTypeConstant: openXmlPart = new CustomXmlPropertiesPart(); return; case CalculationChainPart.RelationshipTypeConstant: openXmlPart = new CalculationChainPart(); return; case CellMetadataPart.RelationshipTypeConstant: openXmlPart = new CellMetadataPart(); return; case ConnectionsPart.RelationshipTypeConstant: openXmlPart = new ConnectionsPart(); return; case CustomXmlMappingsPart.RelationshipTypeConstant: openXmlPart = new CustomXmlMappingsPart(); return; case SharedStringTablePart.RelationshipTypeConstant: openXmlPart = new SharedStringTablePart(); return; case WorkbookRevisionHeaderPart.RelationshipTypeConstant: openXmlPart = new WorkbookRevisionHeaderPart(); return; case WorkbookRevisionLogPart.RelationshipTypeConstant: openXmlPart = new WorkbookRevisionLogPart(); return; case WorkbookUserDataPart.RelationshipTypeConstant: openXmlPart = new WorkbookUserDataPart(); return; case WorkbookStylesPart.RelationshipTypeConstant: openXmlPart = new WorkbookStylesPart(); return; case ThemePart.RelationshipTypeConstant: openXmlPart = new ThemePart(); return; case ImagePart.RelationshipTypeConstant: openXmlPart = new ImagePart(); return; case ThumbnailPart.RelationshipTypeConstant: openXmlPart = new ThumbnailPart(); return; case VolatileDependenciesPart.RelationshipTypeConstant: openXmlPart = new VolatileDependenciesPart(); return; case ChartsheetPart.RelationshipTypeConstant: openXmlPart = new ChartsheetPart(); return; case SpreadsheetPrinterSettingsPart.RelationshipTypeConstant: openXmlPart = new SpreadsheetPrinterSettingsPart(); return; case DrawingsPart.RelationshipTypeConstant: openXmlPart = new DrawingsPart(); return; case ChartPart.RelationshipTypeConstant: openXmlPart = new ChartPart(); return; case ChartDrawingPart.RelationshipTypeConstant: openXmlPart = new ChartDrawingPart(); return; case EmbeddedPackagePart.RelationshipTypeConstant: openXmlPart = new EmbeddedPackagePart(); return; case ThemeOverridePart.RelationshipTypeConstant: openXmlPart = new ThemeOverridePart(); return; case ChartStylePart.RelationshipTypeConstant: openXmlPart = new ChartStylePart(); return; case ChartColorStylePart.RelationshipTypeConstant: openXmlPart = new ChartColorStylePart(); return; case DiagramColorsPart.RelationshipTypeConstant: openXmlPart = new DiagramColorsPart(); return; case DiagramDataPart.RelationshipTypeConstant: openXmlPart = new DiagramDataPart(); return; case SlidePart.RelationshipTypeConstant: openXmlPart = new SlidePart(); return; case DiagramPersistLayoutPart.RelationshipTypeConstant: openXmlPart = new DiagramPersistLayoutPart(); return; case DiagramLayoutDefinitionPart.RelationshipTypeConstant: openXmlPart = new DiagramLayoutDefinitionPart(); return; case DiagramStylePart.RelationshipTypeConstant: openXmlPart = new DiagramStylePart(); return; case EmbeddedObjectPart.RelationshipTypeConstant: openXmlPart = new EmbeddedObjectPart(); return; case VmlDrawingPart.RelationshipTypeConstant: openXmlPart = new VmlDrawingPart(); return; case LegacyDiagramTextPart.RelationshipTypeConstant: openXmlPart = new LegacyDiagramTextPart(); return; case EmbeddedControlPersistenceBinaryDataPart.RelationshipTypeConstant: openXmlPart = new EmbeddedControlPersistenceBinaryDataPart(); return; case NotesSlidePart.RelationshipTypeConstant: openXmlPart = new NotesSlidePart(); return; case NotesMasterPart.RelationshipTypeConstant: openXmlPart = new NotesMasterPart(); return; case UserDefinedTagsPart.RelationshipTypeConstant: openXmlPart = new UserDefinedTagsPart(); return; case SlideLayoutPart.RelationshipTypeConstant: openXmlPart = new SlideLayoutPart(); return; case SlideMasterPart.RelationshipTypeConstant: openXmlPart = new SlideMasterPart(); return; case EmbeddedControlPersistencePart.RelationshipTypeConstant: openXmlPart = new EmbeddedControlPersistencePart(); return; case SlideSyncDataPart.RelationshipTypeConstant: openXmlPart = new SlideSyncDataPart(); return; case WorksheetPart.RelationshipTypeConstant: openXmlPart = new WorksheetPart(); return; case WorksheetCommentsPart.RelationshipTypeConstant: openXmlPart = new WorksheetCommentsPart(); return; case PivotTablePart.RelationshipTypeConstant: openXmlPart = new PivotTablePart(); return; case PivotTableCacheDefinitionPart.RelationshipTypeConstant: openXmlPart = new PivotTableCacheDefinitionPart(); return; case PivotTableCacheRecordsPart.RelationshipTypeConstant: openXmlPart = new PivotTableCacheRecordsPart(); return; case SingleCellTablePart.RelationshipTypeConstant: openXmlPart = new SingleCellTablePart(); return; case TableDefinitionPart.RelationshipTypeConstant: openXmlPart = new TableDefinitionPart(); return; case QueryTablePart.RelationshipTypeConstant: openXmlPart = new QueryTablePart(); return; case ControlPropertiesPart.RelationshipTypeConstant: openXmlPart = new ControlPropertiesPart(); return; case CustomPropertyPart.RelationshipTypeConstant: openXmlPart = new CustomPropertyPart(); return; case WorksheetSortMapPart.RelationshipTypeConstant: openXmlPart = new WorksheetSortMapPart(); return; case SlicersPart.RelationshipTypeConstant: openXmlPart = new SlicersPart(); return; case TimeLinePart.RelationshipTypeConstant: openXmlPart = new TimeLinePart(); return; case WebExtensionPart.RelationshipTypeConstant: openXmlPart = new WebExtensionPart(); return; case DialogsheetPart.RelationshipTypeConstant: openXmlPart = new DialogsheetPart(); return; case ExternalWorkbookPart.RelationshipTypeConstant: openXmlPart = new ExternalWorkbookPart(); return; case ExcelAttachedToolbarsPart.RelationshipTypeConstant: openXmlPart = new ExcelAttachedToolbarsPart(); return; case VbaProjectPart.RelationshipTypeConstant: openXmlPart = new VbaProjectPart(); return; case VbaDataPart.RelationshipTypeConstant: openXmlPart = new VbaDataPart(); return; case MacroSheetPart.RelationshipTypeConstant: openXmlPart = new MacroSheetPart(); return; case InternationalMacroSheetPart.RelationshipTypeConstant: openXmlPart = new InternationalMacroSheetPart(); return; case CustomDataPropertiesPart.RelationshipTypeConstant: openXmlPart = new CustomDataPropertiesPart(); return; case CustomDataPart.RelationshipTypeConstant: openXmlPart = new CustomDataPart(); return; case SlicerCachePart.RelationshipTypeConstant: openXmlPart = new SlicerCachePart(); return; case TimeLineCachePart.RelationshipTypeConstant: openXmlPart = new TimeLineCachePart(); return; case CoreFilePropertiesPart.RelationshipTypeConstant: openXmlPart = new CoreFilePropertiesPart(); return; case ExtendedFilePropertiesPart.RelationshipTypeConstant: openXmlPart = new ExtendedFilePropertiesPart(); return; case CustomFilePropertiesPart.RelationshipTypeConstant: openXmlPart = new CustomFilePropertiesPart(); return; case DigitalSignatureOriginPart.RelationshipTypeConstant: openXmlPart = new DigitalSignatureOriginPart(); return; case XmlSignaturePart.RelationshipTypeConstant: openXmlPart = new XmlSignaturePart(); return; case QuickAccessToolbarCustomizationsPart.RelationshipTypeConstant: openXmlPart = new QuickAccessToolbarCustomizationsPart(); return; case RibbonExtensibilityPart.RelationshipTypeConstant: openXmlPart = new RibbonExtensibilityPart(); return; case RibbonAndBackstageCustomizationsPart.RelationshipTypeConstant: openXmlPart = new RibbonAndBackstageCustomizationsPart(); return; case WebExTaskpanesPart.RelationshipTypeConstant: openXmlPart = new WebExTaskpanesPart(); return; } } else if (openXmlPackage is PresentationDocument) { switch (relationshipType) { case PresentationPart.RelationshipTypeConstant: openXmlPart = new PresentationPart(); return; case CustomXmlPart.RelationshipTypeConstant: openXmlPart = new CustomXmlPart(); return; case CustomXmlPropertiesPart.RelationshipTypeConstant: openXmlPart = new CustomXmlPropertiesPart(); return; case FontPart.RelationshipTypeConstant: openXmlPart = new FontPart(); return; case PresentationPropertiesPart.RelationshipTypeConstant: openXmlPart = new PresentationPropertiesPart(); return; case TableStylesPart.RelationshipTypeConstant: openXmlPart = new TableStylesPart(); return; case ThemePart.RelationshipTypeConstant: openXmlPart = new ThemePart(); return; case ImagePart.RelationshipTypeConstant: openXmlPart = new ImagePart(); return; case ViewPropertiesPart.RelationshipTypeConstant: openXmlPart = new ViewPropertiesPart(); return; case SlidePart.RelationshipTypeConstant: openXmlPart = new SlidePart(); return; case ChartPart.RelationshipTypeConstant: openXmlPart = new ChartPart(); return; case ChartDrawingPart.RelationshipTypeConstant: openXmlPart = new ChartDrawingPart(); return; case EmbeddedPackagePart.RelationshipTypeConstant: openXmlPart = new EmbeddedPackagePart(); return; case ThemeOverridePart.RelationshipTypeConstant: openXmlPart = new ThemeOverridePart(); return; case ChartStylePart.RelationshipTypeConstant: openXmlPart = new ChartStylePart(); return; case ChartColorStylePart.RelationshipTypeConstant: openXmlPart = new ChartColorStylePart(); return; case DiagramColorsPart.RelationshipTypeConstant: openXmlPart = new DiagramColorsPart(); return; case DiagramDataPart.RelationshipTypeConstant: openXmlPart = new DiagramDataPart(); return; case WorksheetPart.RelationshipTypeConstant: openXmlPart = new WorksheetPart(); return; case DrawingsPart.RelationshipTypeConstant: openXmlPart = new DrawingsPart(); return; case DiagramPersistLayoutPart.RelationshipTypeConstant: openXmlPart = new DiagramPersistLayoutPart(); return; case DiagramLayoutDefinitionPart.RelationshipTypeConstant: openXmlPart = new DiagramLayoutDefinitionPart(); return; case DiagramStylePart.RelationshipTypeConstant: openXmlPart = new DiagramStylePart(); return; case WebExtensionPart.RelationshipTypeConstant: openXmlPart = new WebExtensionPart(); return; case VmlDrawingPart.RelationshipTypeConstant: openXmlPart = new VmlDrawingPart(); return; case LegacyDiagramTextPart.RelationshipTypeConstant: openXmlPart = new LegacyDiagramTextPart(); return; case PivotTablePart.RelationshipTypeConstant: openXmlPart = new PivotTablePart(); return; case PivotTableCacheDefinitionPart.RelationshipTypeConstant: openXmlPart = new PivotTableCacheDefinitionPart(); return; case PivotTableCacheRecordsPart.RelationshipTypeConstant: openXmlPart = new PivotTableCacheRecordsPart(); return; case SingleCellTablePart.RelationshipTypeConstant: openXmlPart = new SingleCellTablePart(); return; case TableDefinitionPart.RelationshipTypeConstant: openXmlPart = new TableDefinitionPart(); return; case QueryTablePart.RelationshipTypeConstant: openXmlPart = new QueryTablePart(); return; case EmbeddedControlPersistencePart.RelationshipTypeConstant: openXmlPart = new EmbeddedControlPersistencePart(); return; case EmbeddedControlPersistenceBinaryDataPart.RelationshipTypeConstant: openXmlPart = new EmbeddedControlPersistenceBinaryDataPart(); return; case ControlPropertiesPart.RelationshipTypeConstant: openXmlPart = new ControlPropertiesPart(); return; case EmbeddedObjectPart.RelationshipTypeConstant: openXmlPart = new EmbeddedObjectPart(); return; case CustomPropertyPart.RelationshipTypeConstant: openXmlPart = new CustomPropertyPart(); return; case WorksheetSortMapPart.RelationshipTypeConstant: openXmlPart = new WorksheetSortMapPart(); return; case SlicersPart.RelationshipTypeConstant: openXmlPart = new SlicersPart(); return; case TimeLinePart.RelationshipTypeConstant: openXmlPart = new TimeLinePart(); return; case SlideCommentsPart.RelationshipTypeConstant: openXmlPart = new SlideCommentsPart(); return; case NotesSlidePart.RelationshipTypeConstant: openXmlPart = new NotesSlidePart(); return; case NotesMasterPart.RelationshipTypeConstant: openXmlPart = new NotesMasterPart(); return; case UserDefinedTagsPart.RelationshipTypeConstant: openXmlPart = new UserDefinedTagsPart(); return; case SlideLayoutPart.RelationshipTypeConstant: openXmlPart = new SlideLayoutPart(); return; case SlideMasterPart.RelationshipTypeConstant: openXmlPart = new SlideMasterPart(); return; case SlideSyncDataPart.RelationshipTypeConstant: openXmlPart = new SlideSyncDataPart(); return; case CommentAuthorsPart.RelationshipTypeConstant: openXmlPart = new CommentAuthorsPart(); return; case HandoutMasterPart.RelationshipTypeConstant: openXmlPart = new HandoutMasterPart(); return; case LegacyDiagramTextInfoPart.RelationshipTypeConstant: openXmlPart = new LegacyDiagramTextInfoPart(); return; case VbaProjectPart.RelationshipTypeConstant: openXmlPart = new VbaProjectPart(); return; case VbaDataPart.RelationshipTypeConstant: openXmlPart = new VbaDataPart(); return; case CoreFilePropertiesPart.RelationshipTypeConstant: openXmlPart = new CoreFilePropertiesPart(); return; case ExtendedFilePropertiesPart.RelationshipTypeConstant: openXmlPart = new ExtendedFilePropertiesPart(); return; case CustomFilePropertiesPart.RelationshipTypeConstant: openXmlPart = new CustomFilePropertiesPart(); return; case ThumbnailPart.RelationshipTypeConstant: openXmlPart = new ThumbnailPart(); return; case DigitalSignatureOriginPart.RelationshipTypeConstant: openXmlPart = new DigitalSignatureOriginPart(); return; case XmlSignaturePart.RelationshipTypeConstant: openXmlPart = new XmlSignaturePart(); return; case QuickAccessToolbarCustomizationsPart.RelationshipTypeConstant: openXmlPart = new QuickAccessToolbarCustomizationsPart(); return; case RibbonExtensibilityPart.RelationshipTypeConstant: openXmlPart = new RibbonExtensibilityPart(); return; case RibbonAndBackstageCustomizationsPart.RelationshipTypeConstant: openXmlPart = new RibbonAndBackstageCustomizationsPart(); return; case WebExTaskpanesPart.RelationshipTypeConstant: openXmlPart = new WebExTaskpanesPart(); return; } } else { System.Diagnostics.Debug.Assert(false); } return; }
private void CreateChartSlides(TaskGroupData taskData, int lowestSLideIndex, ref int createdCount, PresentationPart oPPart) { Repository.Utility.WriteLog("CreateChartSlides started", System.Diagnostics.EventLogEntryType.Information); try { if (ChartSlidePart == null) return; if (taskData.ChartsData == null || taskData.ChartsData.Keys.Count == 0 || !taskData.ChartsData.Keys.Any(t=>t.StartsWith("Show On"))) { createdCount++; return; } if (taskData.ChartsData != null) { foreach (string key in taskData.ChartsData.Keys) { try { if (key.StartsWith("Show On")) { //Get all Tasks related to Driving path TaskItemGroup newGroup = new TaskItemGroup() { ChartTaskItems = taskData.ChartsData[key] }; var chartDataTable = newGroup.GetChartDataTable(key); #region Charts if (chartDataTable != null) { SlidePart chartSlidePart = oPPart.GetSlidePartsInOrder().ToList()[lowestSLideIndex + createdCount]; if (chartSlidePart.ChartParts.ToList().Count > 0) { createdCount++; var chartPart = chartSlidePart.ChartParts.ToList()[0]; foreach (IdPartPair part in chartPart.Parts) { var spreadsheet = chartPart.GetPartById(part.RelationshipId) as EmbeddedPackagePart; if (spreadsheet != null) { OpenSettings settings = new OpenSettings(); settings.AutoSave = true; using (var oSDoc = SpreadsheetDocument.Open(spreadsheet.GetStream(FileMode.OpenOrCreate, FileAccess.ReadWrite), true,settings)) { var workSheetPart = oSDoc.WorkbookPart.GetPartsOfType<WorksheetPart>().FirstOrDefault(); var sheetData = workSheetPart.Worksheet.Elements<SheetData>().FirstOrDefault(); for (int i = sheetData.Elements().Count() - 1; i >= 2; i--) { sheetData.ElementAt(i).Remove(); } string reference = workSheetPart.TableDefinitionParts.ElementAt(0).Table.Reference.Value; string length = reference.Split(":".ToCharArray())[1].Replace("I",""); WorkbookUtilities.ReplicateRow(sheetData, 2, chartDataTable.Rows.Count - 1); WorkbookUtilities.LoadSheetData(sheetData, chartDataTable, 1, 0); workSheetPart.TableDefinitionParts.ElementAt(0).Table.Reference.Value = reference.Replace(length, (chartDataTable.Rows.Count + 1).ToString()); BarChartUtilities.LoadChartData(chartPart, chartDataTable); workSheetPart.TableDefinitionParts.ElementAt(0).Table.Save(); workSheetPart.Worksheet.Save(); } break; } } var titleShape = chartSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.Shape>().ToList(); if (titleShape.Count > 0) { titleShape[0].TextBody = new DocumentFormat.OpenXml.Presentation.TextBody( new DocumentFormat.OpenXml.Drawing.BodyProperties(), new DocumentFormat.OpenXml.Drawing.ListStyle(), new DocumentFormat.OpenXml.Drawing.Paragraph( new DocumentFormat.OpenXml.Drawing.Run( new DocumentFormat.OpenXml.Drawing.RunProperties() { FontSize = 3600 }, new DocumentFormat.OpenXml.Drawing.Text { Text = key.Replace("Show On_", "") }))); } } #endregion } } } catch (Exception ex) { Repository.Utility.WriteLog(string.Format("CreateChartSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information); continue; } } } } catch (Exception ex) { Repository.Utility.WriteLog(string.Format("CreateChartSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information); } Repository.Utility.WriteLog("CreateChartSlides completed", System.Diagnostics.EventLogEntryType.Information); }
// Generates content of presentationPart1. private void GeneratePresentationPart1Content(PresentationPart presentationPart1) { P.Presentation presentation1 = new P.Presentation(){ SaveSubsetFonts = true }; presentation1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); presentation1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); presentation1.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); SlideMasterIdList slideMasterIdList1 = new SlideMasterIdList(); SlideMasterId slideMasterId1 = new SlideMasterId(){ Id = (UInt32Value)2147483648U, RelationshipId = "rId1" }; slideMasterIdList1.Append(slideMasterId1); NotesMasterIdList notesMasterIdList1 = new NotesMasterIdList(); NotesMasterId notesMasterId1 = new NotesMasterId(){ Id = "rId3" }; notesMasterIdList1.Append(notesMasterId1); SlideIdList slideIdList1 = new SlideIdList(); SlideId slideId1 = new SlideId(){ Id = (UInt32Value)256U, RelationshipId = "rId2" }; slideIdList1.Append(slideId1); SlideSize slideSize1 = new SlideSize(){ Cx = 9144000, Cy = 6858000, Type = SlideSizeValues.Screen4x3 }; NotesSize notesSize1 = new NotesSize(){ Cx = 9144000L, Cy = 6858000L }; DefaultTextStyle defaultTextStyle1 = new DefaultTextStyle(); A.DefaultParagraphProperties defaultParagraphProperties1 = new A.DefaultParagraphProperties(); A.DefaultRunProperties defaultRunProperties1 = new A.DefaultRunProperties(){ Language = "en-US" }; defaultParagraphProperties1.Append(defaultRunProperties1); A.Level1ParagraphProperties level1ParagraphProperties1 = new A.Level1ParagraphProperties(){ LeftMargin = 0, Alignment = A.TextAlignmentTypeValues.Left, DefaultTabSize = 914400, RightToLeft = false, EastAsianLineBreak = true, LatinLineBreak = false, Height = true }; A.DefaultRunProperties defaultRunProperties2 = new A.DefaultRunProperties(){ FontSize = 1800, Kerning = 1200 }; A.SolidFill solidFill1 = new A.SolidFill(); A.SchemeColor schemeColor1 = new A.SchemeColor(){ Val = A.SchemeColorValues.Text1 }; solidFill1.Append(schemeColor1); A.LatinFont latinFont1 = new A.LatinFont(){ Typeface = "+mn-lt" }; A.EastAsianFont eastAsianFont1 = new A.EastAsianFont(){ Typeface = "+mn-ea" }; A.ComplexScriptFont complexScriptFont1 = new A.ComplexScriptFont(){ Typeface = "+mn-cs" }; defaultRunProperties2.Append(solidFill1); defaultRunProperties2.Append(latinFont1); defaultRunProperties2.Append(eastAsianFont1); defaultRunProperties2.Append(complexScriptFont1); level1ParagraphProperties1.Append(defaultRunProperties2); A.Level2ParagraphProperties level2ParagraphProperties1 = new A.Level2ParagraphProperties(){ LeftMargin = 457200, Alignment = A.TextAlignmentTypeValues.Left, DefaultTabSize = 914400, RightToLeft = false, EastAsianLineBreak = true, LatinLineBreak = false, Height = true }; A.DefaultRunProperties defaultRunProperties3 = new A.DefaultRunProperties(){ FontSize = 1800, Kerning = 1200 }; A.SolidFill solidFill2 = new A.SolidFill(); A.SchemeColor schemeColor2 = new A.SchemeColor(){ Val = A.SchemeColorValues.Text1 }; solidFill2.Append(schemeColor2); A.LatinFont latinFont2 = new A.LatinFont(){ Typeface = "+mn-lt" }; A.EastAsianFont eastAsianFont2 = new A.EastAsianFont(){ Typeface = "+mn-ea" }; A.ComplexScriptFont complexScriptFont2 = new A.ComplexScriptFont(){ Typeface = "+mn-cs" }; defaultRunProperties3.Append(solidFill2); defaultRunProperties3.Append(latinFont2); defaultRunProperties3.Append(eastAsianFont2); defaultRunProperties3.Append(complexScriptFont2); level2ParagraphProperties1.Append(defaultRunProperties3); A.Level3ParagraphProperties level3ParagraphProperties1 = new A.Level3ParagraphProperties(){ LeftMargin = 914400, Alignment = A.TextAlignmentTypeValues.Left, DefaultTabSize = 914400, RightToLeft = false, EastAsianLineBreak = true, LatinLineBreak = false, Height = true }; A.DefaultRunProperties defaultRunProperties4 = new A.DefaultRunProperties(){ FontSize = 1800, Kerning = 1200 }; A.SolidFill solidFill3 = new A.SolidFill(); A.SchemeColor schemeColor3 = new A.SchemeColor(){ Val = A.SchemeColorValues.Text1 }; solidFill3.Append(schemeColor3); A.LatinFont latinFont3 = new A.LatinFont(){ Typeface = "+mn-lt" }; A.EastAsianFont eastAsianFont3 = new A.EastAsianFont(){ Typeface = "+mn-ea" }; A.ComplexScriptFont complexScriptFont3 = new A.ComplexScriptFont(){ Typeface = "+mn-cs" }; defaultRunProperties4.Append(solidFill3); defaultRunProperties4.Append(latinFont3); defaultRunProperties4.Append(eastAsianFont3); defaultRunProperties4.Append(complexScriptFont3); level3ParagraphProperties1.Append(defaultRunProperties4); A.Level4ParagraphProperties level4ParagraphProperties1 = new A.Level4ParagraphProperties(){ LeftMargin = 1371600, Alignment = A.TextAlignmentTypeValues.Left, DefaultTabSize = 914400, RightToLeft = false, EastAsianLineBreak = true, LatinLineBreak = false, Height = true }; A.DefaultRunProperties defaultRunProperties5 = new A.DefaultRunProperties(){ FontSize = 1800, Kerning = 1200 }; A.SolidFill solidFill4 = new A.SolidFill(); A.SchemeColor schemeColor4 = new A.SchemeColor(){ Val = A.SchemeColorValues.Text1 }; solidFill4.Append(schemeColor4); A.LatinFont latinFont4 = new A.LatinFont(){ Typeface = "+mn-lt" }; A.EastAsianFont eastAsianFont4 = new A.EastAsianFont(){ Typeface = "+mn-ea" }; A.ComplexScriptFont complexScriptFont4 = new A.ComplexScriptFont(){ Typeface = "+mn-cs" }; defaultRunProperties5.Append(solidFill4); defaultRunProperties5.Append(latinFont4); defaultRunProperties5.Append(eastAsianFont4); defaultRunProperties5.Append(complexScriptFont4); level4ParagraphProperties1.Append(defaultRunProperties5); A.Level5ParagraphProperties level5ParagraphProperties1 = new A.Level5ParagraphProperties(){ LeftMargin = 1828800, Alignment = A.TextAlignmentTypeValues.Left, DefaultTabSize = 914400, RightToLeft = false, EastAsianLineBreak = true, LatinLineBreak = false, Height = true }; A.DefaultRunProperties defaultRunProperties6 = new A.DefaultRunProperties(){ FontSize = 1800, Kerning = 1200 }; A.SolidFill solidFill5 = new A.SolidFill(); A.SchemeColor schemeColor5 = new A.SchemeColor(){ Val = A.SchemeColorValues.Text1 }; solidFill5.Append(schemeColor5); A.LatinFont latinFont5 = new A.LatinFont(){ Typeface = "+mn-lt" }; A.EastAsianFont eastAsianFont5 = new A.EastAsianFont(){ Typeface = "+mn-ea" }; A.ComplexScriptFont complexScriptFont5 = new A.ComplexScriptFont(){ Typeface = "+mn-cs" }; defaultRunProperties6.Append(solidFill5); defaultRunProperties6.Append(latinFont5); defaultRunProperties6.Append(eastAsianFont5); defaultRunProperties6.Append(complexScriptFont5); level5ParagraphProperties1.Append(defaultRunProperties6); A.Level6ParagraphProperties level6ParagraphProperties1 = new A.Level6ParagraphProperties(){ LeftMargin = 2286000, Alignment = A.TextAlignmentTypeValues.Left, DefaultTabSize = 914400, RightToLeft = false, EastAsianLineBreak = true, LatinLineBreak = false, Height = true }; A.DefaultRunProperties defaultRunProperties7 = new A.DefaultRunProperties(){ FontSize = 1800, Kerning = 1200 }; A.SolidFill solidFill6 = new A.SolidFill(); A.SchemeColor schemeColor6 = new A.SchemeColor(){ Val = A.SchemeColorValues.Text1 }; solidFill6.Append(schemeColor6); A.LatinFont latinFont6 = new A.LatinFont(){ Typeface = "+mn-lt" }; A.EastAsianFont eastAsianFont6 = new A.EastAsianFont(){ Typeface = "+mn-ea" }; A.ComplexScriptFont complexScriptFont6 = new A.ComplexScriptFont(){ Typeface = "+mn-cs" }; defaultRunProperties7.Append(solidFill6); defaultRunProperties7.Append(latinFont6); defaultRunProperties7.Append(eastAsianFont6); defaultRunProperties7.Append(complexScriptFont6); level6ParagraphProperties1.Append(defaultRunProperties7); A.Level7ParagraphProperties level7ParagraphProperties1 = new A.Level7ParagraphProperties(){ LeftMargin = 2743200, Alignment = A.TextAlignmentTypeValues.Left, DefaultTabSize = 914400, RightToLeft = false, EastAsianLineBreak = true, LatinLineBreak = false, Height = true }; A.DefaultRunProperties defaultRunProperties8 = new A.DefaultRunProperties(){ FontSize = 1800, Kerning = 1200 }; A.SolidFill solidFill7 = new A.SolidFill(); A.SchemeColor schemeColor7 = new A.SchemeColor(){ Val = A.SchemeColorValues.Text1 }; solidFill7.Append(schemeColor7); A.LatinFont latinFont7 = new A.LatinFont(){ Typeface = "+mn-lt" }; A.EastAsianFont eastAsianFont7 = new A.EastAsianFont(){ Typeface = "+mn-ea" }; A.ComplexScriptFont complexScriptFont7 = new A.ComplexScriptFont(){ Typeface = "+mn-cs" }; defaultRunProperties8.Append(solidFill7); defaultRunProperties8.Append(latinFont7); defaultRunProperties8.Append(eastAsianFont7); defaultRunProperties8.Append(complexScriptFont7); level7ParagraphProperties1.Append(defaultRunProperties8); A.Level8ParagraphProperties level8ParagraphProperties1 = new A.Level8ParagraphProperties(){ LeftMargin = 3200400, Alignment = A.TextAlignmentTypeValues.Left, DefaultTabSize = 914400, RightToLeft = false, EastAsianLineBreak = true, LatinLineBreak = false, Height = true }; A.DefaultRunProperties defaultRunProperties9 = new A.DefaultRunProperties(){ FontSize = 1800, Kerning = 1200 }; A.SolidFill solidFill8 = new A.SolidFill(); A.SchemeColor schemeColor8 = new A.SchemeColor(){ Val = A.SchemeColorValues.Text1 }; solidFill8.Append(schemeColor8); A.LatinFont latinFont8 = new A.LatinFont(){ Typeface = "+mn-lt" }; A.EastAsianFont eastAsianFont8 = new A.EastAsianFont(){ Typeface = "+mn-ea" }; A.ComplexScriptFont complexScriptFont8 = new A.ComplexScriptFont(){ Typeface = "+mn-cs" }; defaultRunProperties9.Append(solidFill8); defaultRunProperties9.Append(latinFont8); defaultRunProperties9.Append(eastAsianFont8); defaultRunProperties9.Append(complexScriptFont8); level8ParagraphProperties1.Append(defaultRunProperties9); A.Level9ParagraphProperties level9ParagraphProperties1 = new A.Level9ParagraphProperties(){ LeftMargin = 3657600, Alignment = A.TextAlignmentTypeValues.Left, DefaultTabSize = 914400, RightToLeft = false, EastAsianLineBreak = true, LatinLineBreak = false, Height = true }; A.DefaultRunProperties defaultRunProperties10 = new A.DefaultRunProperties(){ FontSize = 1800, Kerning = 1200 }; A.SolidFill solidFill9 = new A.SolidFill(); A.SchemeColor schemeColor9 = new A.SchemeColor(){ Val = A.SchemeColorValues.Text1 }; solidFill9.Append(schemeColor9); A.LatinFont latinFont9 = new A.LatinFont(){ Typeface = "+mn-lt" }; A.EastAsianFont eastAsianFont9 = new A.EastAsianFont(){ Typeface = "+mn-ea" }; A.ComplexScriptFont complexScriptFont9 = new A.ComplexScriptFont(){ Typeface = "+mn-cs" }; defaultRunProperties10.Append(solidFill9); defaultRunProperties10.Append(latinFont9); defaultRunProperties10.Append(eastAsianFont9); defaultRunProperties10.Append(complexScriptFont9); level9ParagraphProperties1.Append(defaultRunProperties10); defaultTextStyle1.Append(defaultParagraphProperties1); defaultTextStyle1.Append(level1ParagraphProperties1); defaultTextStyle1.Append(level2ParagraphProperties1); defaultTextStyle1.Append(level3ParagraphProperties1); defaultTextStyle1.Append(level4ParagraphProperties1); defaultTextStyle1.Append(level5ParagraphProperties1); defaultTextStyle1.Append(level6ParagraphProperties1); defaultTextStyle1.Append(level7ParagraphProperties1); defaultTextStyle1.Append(level8ParagraphProperties1); defaultTextStyle1.Append(level9ParagraphProperties1); PresentationExtensionList presentationExtensionList1 = new PresentationExtensionList(); PresentationExtension presentationExtension1 = new PresentationExtension(){ Uri = "{EFAFB233-063F-42B5-8137-9DF3F51BA10A}" }; P15.SlideGuideList slideGuideList1 = new P15.SlideGuideList(); slideGuideList1.AddNamespaceDeclaration("p15", "http://schemas.microsoft.com/office/powerpoint/2012/main"); P15.ExtendedGuide extendedGuide1 = new P15.ExtendedGuide(){ Id = (UInt32Value)1U, Orientation = DirectionValues.Horizontal, Position = 2160 }; P15.ColorType colorType1 = new P15.ColorType(); A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex(){ Val = "A4A3A4" }; colorType1.Append(rgbColorModelHex1); extendedGuide1.Append(colorType1); P15.ExtendedGuide extendedGuide2 = new P15.ExtendedGuide(){ Id = (UInt32Value)2U, Position = 2880 }; P15.ColorType colorType2 = new P15.ColorType(); A.RgbColorModelHex rgbColorModelHex2 = new A.RgbColorModelHex(){ Val = "A4A3A4" }; colorType2.Append(rgbColorModelHex2); extendedGuide2.Append(colorType2); slideGuideList1.Append(extendedGuide1); slideGuideList1.Append(extendedGuide2); presentationExtension1.Append(slideGuideList1); PresentationExtension presentationExtension2 = new PresentationExtension(){ Uri = "{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}" }; P15.NotesGuideList notesGuideList1 = new P15.NotesGuideList(); notesGuideList1.AddNamespaceDeclaration("p15", "http://schemas.microsoft.com/office/powerpoint/2012/main"); P15.ExtendedGuide extendedGuide3 = new P15.ExtendedGuide(){ Id = (UInt32Value)1U, Orientation = DirectionValues.Horizontal, Position = 2160 }; P15.ColorType colorType3 = new P15.ColorType(); A.RgbColorModelHex rgbColorModelHex3 = new A.RgbColorModelHex(){ Val = "A4A3A4" }; colorType3.Append(rgbColorModelHex3); extendedGuide3.Append(colorType3); P15.ExtendedGuide extendedGuide4 = new P15.ExtendedGuide(){ Id = (UInt32Value)2U, Position = 2880 }; P15.ColorType colorType4 = new P15.ColorType(); A.RgbColorModelHex rgbColorModelHex4 = new A.RgbColorModelHex(){ Val = "A4A3A4" }; colorType4.Append(rgbColorModelHex4); extendedGuide4.Append(colorType4); notesGuideList1.Append(extendedGuide3); notesGuideList1.Append(extendedGuide4); presentationExtension2.Append(notesGuideList1); presentationExtensionList1.Append(presentationExtension1); presentationExtensionList1.Append(presentationExtension2); presentation1.Append(slideMasterIdList1); presentation1.Append(notesMasterIdList1); presentation1.Append(slideIdList1); presentation1.Append(slideSize1); presentation1.Append(notesSize1); presentation1.Append(defaultTextStyle1); presentation1.Append(presentationExtensionList1); presentationPart1.Presentation = presentation1; }
//http://stackoverflow.com/questions/32076114/c-sharp-openxml-sdk-2-5-insert-new-slide-from-slide-masters-with-the-layout public static SlidePart AppendNewSlide(PresentationPart presentationPart, SlideLayoutPart masterLayoutPart, out IEnumerable<Shape> placeholderShapes) { Slide clonedSlide = new Slide() { ColorMapOverride = new ColorMapOverride { MasterColorMapping = new Draw.MasterColorMapping() } }; SlidePart clonedSlidePart = presentationPart.AddNewPart<SlidePart>(); clonedSlidePart.Slide = clonedSlide; clonedSlidePart.AddPart(masterLayoutPart); clonedSlide.Save(clonedSlidePart); var masterShapeTree = masterLayoutPart.SlideLayout.CommonSlideData.ShapeTree; placeholderShapes = (from s in masterShapeTree.ChildElements<Shape>() where s.NonVisualShapeProperties.OfType<ApplicationNonVisualDrawingProperties>().Any(anvdp=>anvdp.PlaceholderShape != null) select new Shape() { NonVisualShapeProperties = (NonVisualShapeProperties)s.NonVisualShapeProperties.CloneNode(true), TextBody = new TextBody(s.TextBody.ChildElements<Draw.Paragraph>().Select(p => p.CloneNode(true))) { BodyProperties = new Draw.BodyProperties(), ListStyle = new Draw.ListStyle() }, ShapeProperties = new ShapeProperties() }).ToList(); clonedSlide.CommonSlideData = new CommonSlideData { ShapeTree = new ShapeTree(placeholderShapes) { GroupShapeProperties = (GroupShapeProperties)masterShapeTree.GroupShapeProperties.CloneNode(true), NonVisualGroupShapeProperties = (NonVisualGroupShapeProperties)masterShapeTree.NonVisualGroupShapeProperties.CloneNode(true) } }; SlideIdList slideIdList = presentationPart.Presentation.SlideIdList; // Find the highest slide ID in the current list. uint maxSlideId = slideIdList.Max(c=>(uint?)((SlideId)c).Id) ?? 256; // Insert the new slide into the slide list after the previous slide. slideIdList.Append(new SlideId() { Id = ++maxSlideId, RelationshipId = presentationPart.GetIdOfPart(clonedSlidePart) }); //presentationPart.Presentation.Save(); return clonedSlidePart; }
/// <summary> /// Initializes a new instance of the <see cref="PptxSlide"/> class. /// </summary> /// <param name="presentationPart">The presentation part.</param> /// <param name="slidePart">The slide part.</param> internal PptxSlide(PresentationPart presentationPart, SlidePart slidePart) { this.presentationPart = presentationPart; this.slidePart = slidePart; }
static uint GetMaxUniqueId(PresentationPart presentationPart) { // Slide master identifiers have a minimum value of greater than or equal to 2147483648. uint max = 2147483648; var slideMasterIdList = presentationPart.Presentation.SlideMasterIdList; if (slideMasterIdList != null) // Get the maximum id value from the current set of children. foreach (SlideMasterId child in slideMasterIdList.Elements<SlideMasterId>()) { uint id = child.Id; if (id > max) max = id; } foreach (var slideMasterPart in presentationPart.SlideMasterParts) { var slideLayoutIdList = slideMasterPart.SlideMaster.SlideLayoutIdList; if (slideLayoutIdList != null) // Get the maximum id value from the current set of children. foreach (var child in slideLayoutIdList.Elements<SlideLayoutId>()) { uint id = child.Id; if (id > max) max = id; } } return max; }
/// <summary> /// Presentation constructor. /// </summary> /// <param name="ownerPart">The owner part of the Presentation.</param> internal Presentation(PresentationPart ownerPart) : base (ownerPart ) { }
private void CreateDynamicSlidesData(IList<TaskItemGroup> data, int[] dynamicSlideIndices, int gridSlideIndex, int lowestSLideIndex, ref int createdCount, int completedSlideIndex, PresentationPart oPPart) { Repository.Utility.WriteLog("CreateDynamicSlidesData started", System.Diagnostics.EventLogEntryType.Information); if (data.Count == 0) { createdCount += 2; return; } for (int i = 0; i < data.Count; i++) { var group = data[i]; foreach (int slideIndex in dynamicSlideIndices) { if (slideIndex == gridSlideIndex) { CreateGridSlide(oPPart, lowestSLideIndex, createdCount, group); createdCount++; } if (slideIndex == completedSlideIndex) { CreateCompletedSlides(group, lowestSLideIndex + createdCount, oPPart); createdCount++; } } } Repository.Utility.WriteLog("CreateDynamicSlidesData completed successfully", System.Diagnostics.EventLogEntryType.Information); }
/// <summary> /// Saves the DOM into the PresentationPart. /// </summary> /// <param name="openXmlPart">Specifies the part to save to.</param> public void Save(PresentationPart openXmlPart) { base.SaveToPart(openXmlPart); }
private void CreateFixedSlides(TaskGroupData taskData, int[] dynamicSlideIndices, int lateSlideIndex,int upComingSlideIndex, int chartSlideIndex, int SPDLSTartToBLSlideIndex, int SPDLFinishToBLSlideIndex,int BEISlideIndex, SlidePart lateSlidePart,SlidePart upComingSlidePart, SlidePart chartSlidePart, SlidePart SPDLSTartToBLSlidePart, SlidePart SPDLFinishToBLSlidePart,SlidePart BEISlidePart, PresentationPart oPPart) { Repository.Utility.WriteLog("CreateFixedSlides started", System.Diagnostics.EventLogEntryType.Information); foreach (int slideIndex in dynamicSlideIndices) { if (lateSlideIndex == slideIndex) { if (taskData.LateTaskGroups != null && taskData.LateTaskGroups.Count > 0) { if (lateSlidePart != null) { foreach (TaskItemGroup group in taskData.LateTaskGroups) { var newLateSlidePart = lateSlidePart.CloneSlide(SlideType.Late); oPPart.AppendSlide(newLateSlidePart); } } } else { if (lateSlidePart != null) { var newLateSlidePart = lateSlidePart.CloneSlide(SlideType.Late); oPPart.AppendSlide(newLateSlidePart); } } } if (upComingSlideIndex == slideIndex) { if (taskData.UpComingTaskGroups != null && taskData.UpComingTaskGroups.Count > 0) { if (upComingSlidePart != null) { foreach (TaskItemGroup group in taskData.UpComingTaskGroups) { var newupComingSlidePart = upComingSlidePart.CloneSlide(SlideType.Late); oPPart.AppendSlide(newupComingSlidePart); } } } else { if (upComingSlidePart != null) { var newupComingSlidePart = upComingSlidePart.CloneSlide(SlideType.Late); oPPart.AppendSlide(newupComingSlidePart); } } } if (SPDLSTartToBLSlideIndex == slideIndex) { if (SPDLSTartToBLSlidePart != null) { var newSPDLStartToBLSlidePart = SPDLSTartToBLSlidePart.CloneSlide(SlideType.Chart); oPPart.AppendSlide(newSPDLStartToBLSlidePart); } } if (SPDLFinishToBLSlideIndex == slideIndex) { if (SPDLFinishToBLSlidePart != null) { var newSPDLFinishToBLSlidePart = SPDLFinishToBLSlidePart.CloneSlide(SlideType.Chart); oPPart.AppendSlide(newSPDLFinishToBLSlidePart); } } if (BEISlideIndex == slideIndex) { if (BEISlidePart != null) { var newBEISlidePart = BEISlidePart.CloneSlide(SlideType.Chart); oPPart.AppendSlide(newBEISlidePart); } } if (chartSlideIndex == slideIndex) { if (taskData.ChartsData != null && taskData.ChartsData.Count > 0) { if (chartSlidePart != null && taskData.ChartsData.Keys.Any(t => t.StartsWith("Show On") == true)) { foreach (string chartType in taskData.ChartsData.Keys) { if (chartType.StartsWith("Show On")) { var newChartSlidePart = chartSlidePart.CloneSlide(SlideType.Chart); oPPart.AppendSlide(newChartSlidePart); } } } else { var newChartSlidePart = chartSlidePart.CloneSlide(SlideType.Chart); oPPart.AppendSlide(newChartSlidePart); } } } } Repository.Utility.WriteLog("CreateFixedSlides completed successfully", System.Diagnostics.EventLogEntryType.Information); }