/// <summary> /// Renders (and calculates) the \shptop and \shpbottom controls in RTF. /// </summary> private void RenderTopBottom() { Unit height = GetShapeHeight(); Unit top = 0; Unit bottom = height; if (!RenderInParagraph()) { RelativeVertical relVert = (RelativeVertical)GetValueOrDefault("RelativeVertical", RelativeVertical.Paragraph); TopPosition topPos = (TopPosition)GetValueOrDefault("Top", new TopPosition()); //REM: Will not work like this in table cells. //=>The shape would have to be put in a paragraph there. Section sec = (Section)DocumentRelations.GetParentOfType(_shape, typeof(Section)); PageSetup pgStp = sec.PageSetup; Unit topMrg = (Unit)pgStp.GetValue("TopMargin", GV.ReadOnly); Unit btmMrg = (Unit)pgStp.GetValue("BottomMargin", GV.ReadOnly); Unit pgHeight = pgStp.PageHeight; Unit pgWidth = pgStp.PageWidth; if (topPos.ShapePosition == ShapePosition.Undefined) { top = topPos.Position; bottom = top + height; } else { switch (relVert) { case RelativeVertical.Line: AlignVertically(topPos.ShapePosition, height, out top, out bottom); break; case RelativeVertical.Margin: AlignVertically(topPos.ShapePosition, pgHeight.Point - topMrg.Point - btmMrg.Point, out top, out bottom); break; case RelativeVertical.Page: AlignVertically(topPos.ShapePosition, pgHeight, out top, out bottom); break; } } } RenderUnit("shptop", top); RenderUnit("shpbottom", bottom); }
/// <summary> /// Renders (and calculates) the \shpleft and \shpright controls in RTF. /// </summary> private void RenderLeftRight() { Unit width = GetShapeWidth(); Unit left = 0; Unit right = width; if (!RenderInParagraph()) { RelativeHorizontal relHor = (RelativeHorizontal)GetValueOrDefault("RelativeHorizontal", RelativeHorizontal.Margin); LeftPosition leftPos = (LeftPosition)GetValueOrDefault("Left", new LeftPosition()); //REM: Will not work like this in table cells. //=>The shape would have to be put in a paragraph there. Section sec = (Section)DocumentRelations.GetParentOfType(_shape, typeof(Section)); PageSetup pgStp = sec.PageSetup; Unit leftMrg = (Unit)pgStp.GetValue("LeftMargin", GV.ReadOnly); Unit rgtMrg = (Unit)pgStp.GetValue("RightMargin", GV.ReadOnly); Unit pgHeight = pgStp.PageHeight; Unit pgWidth = pgStp.PageWidth; if (leftPos.ShapePosition == ShapePosition.Undefined) { left = leftPos.Position; right = left + width; } else { switch (relHor) { case RelativeHorizontal.Column: case RelativeHorizontal.Character: case RelativeHorizontal.Margin: AlignHorizontally(leftPos.ShapePosition, pgWidth.Point - leftMrg.Point - rgtMrg.Point, out left, out right); break; case RelativeHorizontal.Page: AlignHorizontally(leftPos.ShapePosition, pgWidth, out left, out right); break; } } } RenderUnit("shpleft", left); RenderUnit("shpright", right); }