コード例 #1
0
        //----------------------------------------------------------------------------------------------------x
        /// <summary>Adds a report object to the current container at the current position.</summary>
        /// <param name="al_RepObj">Result array for the report objects</param>
        /// <param name="repString">Report object to add to the container</param>
        /// <param name="rCurX"></param>
        /// <param name="rOfsX"></param>
        /// <param name="rAlignH">Horizontal allignment</param>
        /// <param name="rCurY"></param>
        /// <param name="rWidth"></param>
        internal void FormatString(ArrayList al_RepObj, RepString repString, ref Double rCurX, Double rOfsX, Double rAlignH,
                                   ref Double rCurY, Double rWidth)
        {
            FontProp fp    = repString.fontProp;
            String   sText = repString.sText;

            Int32 iLineStartIndex = 0;
            Int32 iIndex          = 0;

            while (true)
            {
                Int32  iLineBreakIndex = 0;
                Double rPosX           = rCurX;
                Double rLineBreakPos   = 0;
                while (true)
                {
                    if (iIndex >= sText.Length)
                    {
                        iLineBreakIndex = iIndex;
                        rLineBreakPos   = rPosX;
                        break;
                    }
                    Char c = sText[iIndex];
                    rPosX += fp.rWidth(Convert.ToString(c));
                    if (rPosX >= rWidth)
                    {
                        if (iLineBreakIndex == 0 && rCurX <= rOfsX + 0.01)
                        {
                            if (iIndex == iLineStartIndex) // at least one character must be printed
                            {
                                iIndex++;
                            }
                            iLineBreakIndex = iIndex;
                            break;
                        }
                        iIndex = iLineBreakIndex;
                        break;
                    }
                    if (c == ' ')
                    {
                        iLineBreakIndex = iIndex + 1;
                        rLineBreakPos   = rPosX;
                    }
                    else if (c == '\n')
                    {
                        iLineBreakIndex = iIndex;
                        iIndex++;
                        break;
                    }
                    iIndex++;
                }

                if (iLineStartIndex == 0 && iIndex >= sText.Length) // add entire object
                {
                    repString.matrixD.rDX = rCurX + (rWidth - rCurX) * rAlignH;
                    repString.rAlignH     = rAlignH;
                    repString.matrixD.rDY = rCurY;
                    repString.rAlignV     = RepObj.rAlignBottom;
                    al_RepObj.Add(repString);
                    rCurX = rLineBreakPos;
                    break;
                }
                if (iLineBreakIndex > iLineStartIndex && sText[iLineBreakIndex - 1] == ' ')
                {
                    iLineBreakIndex--;
                }
                String    sLine = sText.Substring(iLineStartIndex, iLineBreakIndex - iLineStartIndex);
                RepString rs    = new RepString(fp, sLine);
                rs.matrixD.rDX = rCurX + (rWidth - rCurX) * rAlignH;
                rs.rAlignH     = rAlignH;
                rs.matrixD.rDY = rCurY;
                rs.rAlignV     = RepObj.rAlignBottom;
                al_RepObj.Add(rs);
                if (iIndex >= sText.Length)
                {
                    rCurX = rLineBreakPos;
                    break;
                }
                rCurX           = rOfsX;
                rCurY          += fp.rLineFeed;
                iLineStartIndex = iIndex;
            }
        }
コード例 #2
0
        //----------------------------------------------------------------------------------------------------x
        /// <summary>Adds a report object to the current container at the current position.</summary>
        /// <param name="repString">Report object to add to the container</param>
        /// <param name="container">Container</param>
        /// <param name="rCurX"></param>
        /// <param name="rOfsX"></param>
        /// <param name="rCurY"></param>
        /// <param name="rWidth"></param>
        public void PrintString(RepString repString, Container container, ref Double rCurX, Double rOfsX, ref Double rCurY, Double rWidth)
        {
            FontProp fp    = repString.fontProp;
            String   sText = repString.sText;

            Int32 iLineStartIndex = 0;
            Int32 iIndex          = 0;

            while (true)
            {
                if (rCurY > container.rHeight)
                {
                    NextContainer();
                }
                Int32  iLineBreakIndex = 0;
                Double rPosX           = rCurX;
                Double rLineBreakPos   = 0;
                while (true)
                {
                    if (iIndex >= sText.Length)
                    {
                        iLineBreakIndex = iIndex;
                        rLineBreakPos   = rPosX;
                        break;
                    }
                    Char c = sText[iIndex];
                    rPosX += fp.rWidth(Convert.ToString(c));
                    if (rPosX >= rWidth)
                    {
                        if (iLineBreakIndex == 0)
                        {
                            if (iIndex == iLineStartIndex) // at least one character must be printed
                            {
                                iIndex++;
                            }
                            iLineBreakIndex = iIndex;
                            break;
                        }
                        iIndex = iLineBreakIndex;
                        break;
                    }
                    if (c == ' ')
                    {
                        iLineBreakIndex = iIndex + 1;
                        rLineBreakPos   = rPosX;
                    }
                    else if (c == '\n')
                    {
                        iLineBreakIndex = iIndex;
                        iIndex++;
                        break;
                    }
                    iIndex++;
                }

                if (iLineStartIndex == 0 && iIndex >= sText.Length) // add entire object
                {
                    container.Add(rOfsX + rCurX, rCurY, repString);
                    rCurX = rLineBreakPos;
                    break;
                }
                String sLine = sText.Substring(iLineStartIndex, iLineBreakIndex - iLineStartIndex);
                container.Add(rOfsX + rCurX, rCurY, new RepString(fp, sLine));
                if (iIndex >= sText.Length)
                {
                    rCurX = rLineBreakPos;
                    break;
                }
                rCurX           = 0;
                rCurY          += fp.rLineFeed;
                iLineStartIndex = iIndex;
            }
        }
コード例 #3
0
 //----------------------------------------------------------------------------------------------------x
 /// <summary>Adds a report object to the current container on a new line.</summary>
 /// <param name="repString">Report object to add to the container</param>
 public void AddNew(RepString repString)
 {
     NewLine(repString.fontProp.rLineFeed);
     Add(repString);
 }
コード例 #4
0
        //----------------------------------------------------------------------------------------------------x
        /// <summary>Adds a report object to the current container at the current position.</summary>
        /// <param name="repObj">Report object to add to the container</param>
        public void Add(RepObj repObj)
        {
            if (repObj is RepString)
            {
                RepString repString = (RepString)repObj;
                FontProp  fp        = repString.fontProp;
                String    sText     = repString.sText;

                Int32 iLineStartIndex = 0;
                Int32 iIndex          = 0;
                while (true)
                {
                    if (rY_Cur > container.rHeight)
                    {
                        NewContainer();
                    }
                    Int32  iLineBreakIndex = 0;
                    Double rPosX           = rX_Cur;
                    Double rLineBreakPos   = 0;
                    while (true)
                    {
                        if (iIndex >= sText.Length)
                        {
                            iLineBreakIndex = iIndex;
                            rLineBreakPos   = rPosX;
                            break;
                        }
                        Char c = sText[iIndex];
                        rPosX += fp.rWidth(Convert.ToString(c));
                        if (rPosX >= container.rWidth)
                        {
                            if (iLineBreakIndex == 0)
                            {
                                if (iIndex == iLineStartIndex) // at least one character must be printed
                                {
                                    iIndex++;
                                }
                                iLineBreakIndex = iIndex;
                                break;
                            }
                            iIndex = iLineBreakIndex;
                            break;
                        }
                        if (c == ' ')
                        {
                            iLineBreakIndex = iIndex + 1;
                            rLineBreakPos   = rPosX;
                        }
                        else if (c == '\n')
                        {
                            iLineBreakIndex = iIndex;
                            iIndex++;
                            break;
                        }
                        iIndex++;
                    }

                    if (iLineStartIndex == 0 && iIndex >= sText.Length) // add entire object
                    {
                        container.Add(rX_Cur, rY_Cur, repObj);
                        rX_Cur = rLineBreakPos;
                        break;
                    }
                    String sLine = sText.Substring(iLineStartIndex, iLineBreakIndex - iLineStartIndex);
                    container.Add(rX_Cur, rY_Cur, new RepString(fp, sLine));
                    if (iIndex >= sText.Length)
                    {
                        rX_Cur = rLineBreakPos;
                        break;
                    }
                    rX_Cur          = 0;
                    rY_Cur         += fp.rLineFeed;
                    iLineStartIndex = iIndex;
                }
            }
            else
            {
                Debug.Fail("Unknown object type");
                container.Add(rX_Cur, rY_Cur, repObj);
            }
        }
コード例 #5
0
ファイル: TlmCell.cs プロジェクト: mauriciocargas/pruebadlls
        //----------------------------------------------------------------------------------------------------x
        /// <overloads>
        ///   <summary>Adds a report object to the cell.</summary>
        /// </overloads>
        ///
        /// <summary>Adds a report object to the cell at the current position with the specified offset (inch version).</summary>
        /// <remarks>
        /// The current horizontal position <see cref="TlmCell.rCurX"/> will be incremented by the width of the report object.
        /// <para>The horizontal offset <paramref name="rOfsH"/> can be used for example to make a space in front of the report object.
        /// The vertical offset <paramref name="rOfsV"/> can be used for example to adjust the vertical position of an image or to set super-/subscript fonts.</para>
        /// <para>For the metric version see <see cref="TlmCell.AddMM"/>.</para>
        /// </remarks>
        /// <param name="rOfsH">Horizontal offset (points, 1/72 inch)</param>
        /// <param name="rOfsV">Vertical offset (points, 1/72 inch)</param>
        /// <param name="repObj">Report object that will be added to the cell</param>
        /// <seealso cref="TlmCell.AddMM"/>
        public void Add(Double rOfsH, Double rOfsV, RepObj repObj)
        {
            RepString repString = repObj as RepString;

            if (RT.bEquals(rAngle, -90, 0.001)) // vertical
            {
                Debug.Assert(tlmRow_Start.iIndex == tlmRow_End.iIndex, "vertically merged cell are not supported");
                Double rPreferredHeight = tlmRow_Start.rPreferredHeight;
                Double rInnerHeight     = rPreferredHeight - rIndentTop - rIndentBottom;
                if (status == Status.Init)
                {
                    if (Double.IsNaN(rPreferredHeight))
                    {
                        throw new ReportException("The preferred height of the row must be set");
                    }
                    rCurX  = rIndentLeft + rInnerWidth * rAlignV;
                    rCurY  = rPreferredHeight - rIndentBottom - rInnerHeight * rAlignH;
                    status = Status.Open;
                }
                CheckStatus_Open("cannot add a report object.");

                Double rUsedWidth = 0;
                if (iFirstRepObjOfCurLine < iRepObjCount)
                {
                    RepObj ro = repObj_Get(iRepObjCount - 1);
                    rUsedWidth  = ro.rPosBottom;
                    ro          = repObj_Get(iFirstRepObjOfCurLine);
                    rUsedWidth -= ro.rPosTop;
                }
                rUsedWidth += rOfsH;

                Double rRemainingWidth = rInnerHeight - rUsedWidth;
                if (repString != null)
                {
                    if (status == Status.Open)
                    {
                        if (Double.IsNaN(rLineFeed))
                        {
                            rLineFeed = repString.fontProp.rLineFeed;
                        }
                        //rCurX -= repString.fontProp.rHeight() * rAlignV;
                        status = Status.OpenText;
                    }
                    if (textMode == TlmBase.TextMode.EllipsisCharacter)
                    {
                        repString.sText = repString.fontProp.sTruncateText(repString.sText, rRemainingWidth);
                        // ... !!!
                    }
                }

                if (repString != null && textMode == TlmBase.TextMode.MultiLine)
                {
                    Debug.Fail("not implemented");
                }
                else
                {
                    Double rOfs = (repObj.rWidth + rOfsH) * rAlignH;
                    for (Int32 i = iFirstRepObjOfCurLine; i < iRepObjCount; i++)
                    {
                        RepObj ro = repObj_Get(i);
                        ro.matrixD.rDY += rOfs;
                    }
                    repObj.RotateTransform(rAngle);
                    repObj.matrixD.rDX = rCurX - rOfsV;
                    repObj.rAlignH     = rAlignH;
                    repObj.matrixD.rDY = rCurY - rOfsH * (1 - rAlignH);
                    repObj.rAlignV     = rAlignV;
                    AddRepObj(repObj);
                    rCurY = repObj.rPosTop;
                }
            }
            else // horizontal
            {
                if (status == Status.Init)
                {
                    rCurX  = rIndentLeft + rInnerWidth * rAlignH;
                    rCurY  = rIndentTop;
                    status = Status.Open;
                }
                CheckStatus_Open("cannot add a report object.");

                Double rUsedWidth = 0;
                if (iFirstRepObjOfCurLine < iRepObjCount)
                {
                    RepObj ro = repObj_Get(iRepObjCount - 1);
                    rUsedWidth  = ro.rPosRight;
                    ro          = repObj_Get(iFirstRepObjOfCurLine);
                    rUsedWidth -= ro.rPosLeft;
                }
                rUsedWidth += rOfsH;

                Double rRemainingWidth = rInnerWidth - rUsedWidth;
                if (repString != null)
                {
                    if (status == Status.Open)
                    {
                        if (Double.IsNaN(rLineFeed))
                        {
                            rLineFeed = repString.fontProp.rLineFeed;
                        }
                        rCurY += repString.fontProp.rHeight();
                        status = Status.OpenText;
                    }
                    if (textMode == TlmBase.TextMode.EllipsisCharacter)
                    {
                        Double rWidth = repString.fontProp.rWidth(repString.sText);
                        if (rWidth > rRemainingWidth)
                        {
                            if (bCut)
                            {
                                return;
                            }
                            repString.sText = repString.fontProp.sTruncateText(repString.sText, rRemainingWidth);
                            bCut            = true;
                            rWidth          = repString.fontProp.rWidth(repString.sText);
                            if (rWidth >= rRemainingWidth)
                            {
                                if (iFirstRepObjOfCurLine < iRepObjCount)
                                {
                                    RepObj    ro = repObj_Get(iRepObjCount - 1);
                                    RepString rs = ro as RepString;
                                    if (rs != null)
                                    {
                                        rs.sText = rs.sText.Substring(0, rs.sText.Length - 1) + "...";
                                    }
                                }
                                return;
                            }
                        }
                    }
                }

                if (repString != null && textMode == TlmBase.TextMode.MultiLine)
                {
                    Double rWidth = rInnerWidth + rIndentLeft;
                    lock (al_RepObj) {
                        Debug.Assert(al_RepObj.Count == 0);
                        Double rCopy = rCurY;
                        Double rOfs  = rWidth * rAlignH;
                        rCurX -= rOfs;
                        tlmBase.FormatString(al_RepObj, repString, ref rCurX, rIndentLeft, rAlignH, ref _rCurY, rWidth);
                        rCurX += rOfs;
                        foreach (RepObj ro in al_RepObj)
                        {
                            AddRepObj(ro);
                        }
                        al_RepObj.Clear();
                        if (!RT.bEquals(rCopy, _rCurY, TlmBase.rTol))
                        {
                            rCurY = _rCurY; // trigger iFirstRepObjOfCurLine
                            iFirstRepObjOfCurLine = iRepObjCount - 1;
                        }
                    }
                }
                else
                {
                    Double rOfs = (repObj.rWidth + rOfsH) * rAlignH;
                    for (Int32 i = iFirstRepObjOfCurLine; i < iRepObjCount; i++)
                    {
                        RepObj ro = repObj_Get(i);
                        ro.matrixD.rDX -= rOfs;
                    }
                    repObj.matrixD.rDX = rCurX + rOfsH * (1 - rAlignH);
                    repObj.rAlignH     = rAlignH;
                    repObj.matrixD.rDY = rCurY + rOfsV;
                    AddRepObj(repObj);
                    rCurX = repObj.rPosRight;
                }
            }
        }