//----------------------------------------------------------------------------------------------------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.rGetTextWidth(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; } }
//----------------------------------------------------------------------------------------------------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]; if (c == '\r') { iLineBreakIndex = iIndex; iIndex++; c = sText[iIndex]; if (c == '\n') { iIndex++; } break; } rPosX += fp.rGetTextWidth(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; } 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; } }
//----------------------------------------------------------------------------------------------------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 (status == Status.Init) { if (_container_Cur == null) { CreateNewContainer(); } } 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_Cur.rHeight) { _container_Cur = null; CreateNewContainer(); } 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.rGetTextWidth(Convert.ToString(c)); if (rPosX >= container_Cur.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_Cur.Add(rX_Cur, rY_Cur, repObj); rX_Cur = rLineBreakPos; break; } String sLine = sText.Substring(iLineStartIndex, iLineBreakIndex - iLineStartIndex); container_Cur.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_Cur.Add(rX_Cur, rY_Cur, repObj); } }