/// <summary> /// Generate CSS from powerpoint shape /// </summary> /// <param name="shape"></param> public ezCss(Shape shape) { //Check shape type and do action accordingly ezShapeType shapeType = Utility.GetShapeType(shape); switch (shapeType) { case ezShapeType.Group: Group grp = new Group(shape); EzCssForWeb(grp.Width, grp.Height, grp.Left, grp.Top, grp.Zindex, grp.Rotation); break; case ezShapeType.EllipseCallout: WedgeEllipseCallout ellipseCallout = new WedgeEllipseCallout(shape); EzCssForWeb(ellipseCallout.calculatedWidth, ellipseCallout.calculatedHeight, ellipseCallout.calculatedLeft, ellipseCallout.calculatedTop, ellipseCallout.Zindex, ellipseCallout.Rotation); break; case ezShapeType.TextBox: TexBox textox = new TexBox(shape); EzCssForWeb(textox.width, textox.height, textox.left, textox.top, textox.Zindex, textox.Rotation); break; default: float thickness = shape.Line.Weight; //Thickness may come incorrect if there is no thickness if (thickness < 0 || thickness > 20) { thickness = 0; } EzCssForWeb((float)(shape.Width + thickness), (float)(shape.Height + thickness), (float)(shape.Left - thickness / 2.0), (float)(shape.Top - thickness / 2.0), shape.ZOrderPosition, shape.Rotation); break; } }
} //Holds number of items in a group /// <summary> /// Extract properties from Group Type shape /// </summary> /// <param name="groupTypeShape"></param> public Group(Shape groupTypeShape) { //Assigning primitive properties first //For group type shape primitive properties we need not to consider thickness as group does not have thickness itemCount = groupTypeShape.GroupItems.Count; Rotation = groupTypeShape.Rotation; Zindex = groupTypeShape.ZOrderPosition; Width = groupTypeShape.Width; Height = groupTypeShape.Height; Top = groupTypeShape.Top; Left = groupTypeShape.Left; //For Calculation float grpMaxLeft = Left, grpMaxTop = Top, grpMaxRight = Left + Width, grpMaxBottom = Top + Height; //initialization //Now traversing though each element of the group and revising the boundaries foreach (Shape shp in groupTypeShape.GroupItems) { //Getting the type of shape ezShapeType shapeType = Utility.GetShapeType(shp); switch (shapeType) { case ezShapeType.EllipseCallout: WedgeEllipseCallout ellipseCallout = new WedgeEllipseCallout(shp); if (grpMaxLeft > ellipseCallout.calculatedLeft) { grpMaxLeft = ellipseCallout.calculatedLeft; } if (grpMaxTop > ellipseCallout.calculatedTop) { grpMaxTop = ellipseCallout.calculatedTop; } if (grpMaxRight < ellipseCallout.maxRight) { grpMaxRight = ellipseCallout.maxRight; } if (grpMaxBottom < ellipseCallout.maxBottom) { grpMaxBottom = ellipseCallout.maxBottom; } break; case ezShapeType.Group: Group group = new Group(shp); if (grpMaxLeft > group.Left) { grpMaxLeft = group.Left; } if (grpMaxTop > group.Top) { grpMaxTop = group.Top; } if (grpMaxRight < group.Left + group.Width) { grpMaxRight = group.Left + group.Width; } if (grpMaxBottom < group.Top + group.Height) { grpMaxBottom = group.Top + group.Height; } break; default: break; } } //Assigning the updated values Width = grpMaxRight - grpMaxLeft; Height = grpMaxBottom - grpMaxTop; Top = grpMaxTop; Left = grpMaxLeft; }