private ParagraphIterator GetParentIterator()
        {
            if (_positionIndices.Count == 0)
            {
                return(null);
            }

            List <int> indices = new List <int>(_positionIndices);

            indices.RemoveAt(indices.Count - 1);
            DocumentObject parent = DocumentRelations.GetParentOfType(_current, typeof(ParagraphElements));

            return(new ParagraphIterator(_rootNode, parent, indices));
        }
Ejemplo n.º 2
0
        private ParagraphIterator GetParentIterator()
        {
            if (this.positionIndices.Count == 0)
            {
                return(null);
            }

            ArrayList indices = (ArrayList)this.positionIndices.Clone();

            indices.RemoveAt(indices.Count - 1);
            DocumentObject parent = DocumentRelations.GetParentOfType(this.current, typeof(ParagraphElements));

            return(new ParagraphIterator(this.rootNode, parent, indices));
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Renders the dummy paragraph's left indent.
        /// </summary>
        void RenderParagraphIndents()
        {
            object relHor   = GetValueAsIntended("RelativeHorizontal");
            double leftInd  = 0;
            double rightInd = 0;

            if (relHor != null && (RelativeHorizontal)relHor == RelativeHorizontal.Page)
            {
                Section parentSec = (Section)DocumentRelations.GetParentOfType(_shape, typeof(Section));
                Unit    leftPgMrg = (Unit)parentSec.PageSetup.GetValue("LeftMargin", GV.ReadOnly);
                leftInd = -leftPgMrg.Point;
                Unit rightPgMrg = (Unit)parentSec.PageSetup.GetValue("RightMargin", GV.ReadOnly);
                rightInd = -rightPgMrg;
            }

            LeftPosition leftPos = (LeftPosition)GetValueOrDefault("Left", new LeftPosition());

            switch (leftPos.ShapePosition)
            {
            case ShapePosition.Undefined:
                leftInd += leftPos.Position;
                leftInd += ((Unit)GetValueOrDefault("WrapFormat.DistanceLeft", (Unit)0)).Point;
                break;

            case ShapePosition.Left:
                leftInd += ((Unit)GetValueOrDefault("WrapFormat.DistanceLeft", (Unit)0)).Point;
                break;

            case ShapePosition.Right:
                rightInd += ((Unit)GetValueOrDefault("WrapFormat.DistanceRight", (Unit)0)).Point;
                break;
            }
            RenderUnit("li", leftInd);
            RenderUnit("lin", leftInd);
            RenderUnit("ri", rightInd);
            RenderUnit("rin", rightInd);
        }