PPTConnectionShape.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. using DocumentFormat.OpenXml.Presentation;
  8. namespace ClearSlideLibrary.Dom
  9. {
  10. public class PPTConnectionShape : PPTShapeBase
  11. {
  12. public PPTConnectionShape(SlidePart slidePart, ConnectionShape connectionShape)
  13. {
  14. SetConnectionShapeVisualProperties(slidePart, connectionShape);
  15. SetConnectionShapeNonVisualProperties(slidePart, connectionShape);
  16. }
  17. private void SetConnectionShapeNonVisualProperties(SlidePart slidePart,
  18. ConnectionShape connectionShape)
  19. {
  20. if (connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick != null)
  21. foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
  22. if (link.Id.Equals(connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick.Id))
  23. ClickLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
  24. if (connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover != null)
  25. foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
  26. if (link.Id.Equals(connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover.Id))
  27. HoverLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
  28. var nonVisualShapeProp = new PPTNonVisualShapeProp
  29. {
  30. Id = "s1s" + //HARD CODED: we split it into separate HTML files!
  31. connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.Id,
  32. Name = connectionShape.LocalName,
  33. Type = "PPTConnectionShape"
  34. };
  35. base.NonVisualShapeProp = nonVisualShapeProp;
  36. }
  37. private void SetConnectionShapeVisualProperties(SlidePart slidePart,
  38. ConnectionShape connectionShape)
  39. {
  40. base.VisualShapeProp = new PPTVisualPPTShapeProp();
  41. if (connectionShape.ShapeProperties.Transform2D != null)
  42. {
  43. base.VisualShapeProp.Extents = connectionShape.ShapeProperties.Transform2D.Extents;
  44. base.VisualShapeProp.Offset = connectionShape.ShapeProperties.Transform2D.Offset;
  45. }
  46. else
  47. {
  48. ShapeTree shapeTree = slidePart.SlideLayoutPart.SlideLayout.CommonSlideData.ShapeTree;
  49. ConnectionShape layoutShape;
  50. if (shapeTree != null)
  51. {
  52. layoutShape = shapeTree.GetFirstChild<ConnectionShape>();
  53. if (layoutShape.ShapeProperties.Transform2D != null)
  54. {
  55. base.VisualShapeProp.Extents = layoutShape.ShapeProperties.Transform2D.Extents;
  56. base.VisualShapeProp.Offset = layoutShape.ShapeProperties.Transform2D.Offset;
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }