PPTGroupShape.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using DocumentFormat.OpenXml.Packaging;
  7. namespace ClearSlideLibrary.Dom
  8. {
  9. public class PPTGroupShape : PPTShapeBase
  10. {
  11. public PPTGroupShape(SlidePart slidePart, DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
  12. {
  13. SetGroupShapeVisualProperties(slidePart, groupShape);
  14. SetGroupShapeNonVisualProperties(slidePart,groupShape);
  15. }
  16. private void SetGroupShapeNonVisualProperties(SlidePart slidePart,DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
  17. {
  18. if (groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick != null)
  19. foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
  20. if (link.Id.Equals(groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick.Id))
  21. ClickLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
  22. if (groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover != null)
  23. foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
  24. if (link.Id.Equals(groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover.Id))
  25. HoverLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
  26. var nonVisualShapeProp = new PPTNonVisualShapeProp
  27. {
  28. Id = "s1s" + //HARD CODED: we split it into separate HTML files!
  29. groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.Id,
  30. Name = groupShape.LocalName,
  31. Type = "PPTGroupShape"
  32. };
  33. base.NonVisualShapeProp = nonVisualShapeProp;
  34. }
  35. private void SetGroupShapeVisualProperties(SlidePart slidePart, DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
  36. {
  37. base.VisualShapeProp = new PPTVisualPPTShapeProp();
  38. if (groupShape.GroupShapeProperties.TransformGroup != null)
  39. {
  40. base.VisualShapeProp.Extents = groupShape.GroupShapeProperties.TransformGroup.Extents;
  41. base.VisualShapeProp.Offset = groupShape.GroupShapeProperties.TransformGroup.Offset;
  42. }
  43. else
  44. {
  45. DocumentFormat.OpenXml.Presentation.ShapeTree shapeTree =
  46. slidePart.SlideLayoutPart.SlideLayout.CommonSlideData.ShapeTree;
  47. DocumentFormat.OpenXml.Presentation.GroupShape layoutShape;
  48. if (shapeTree != null)
  49. {
  50. layoutShape = shapeTree.GetFirstChild<DocumentFormat.OpenXml.Presentation.GroupShape>();
  51. if (layoutShape.GroupShapeProperties.TransformGroup != null)
  52. {
  53. base.VisualShapeProp.Extents = layoutShape.GroupShapeProperties.TransformGroup.Extents;
  54. base.VisualShapeProp.Offset = layoutShape.GroupShapeProperties.TransformGroup.Offset;
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }