internal void GetParagraphIndents(RPLFormat.Directions direction, float dpiX, out float leftIndent, out float rightIndent, out float hangingIndent)
 {
     leftIndent    = TextBox.ConvertToPixels(m_paragraphProps.LeftIndent, dpiX);
     rightIndent   = TextBox.ConvertToPixels(m_paragraphProps.RightIndent, dpiX);
     hangingIndent = TextBox.ConvertToPixels(m_paragraphProps.HangingIndent, dpiX);
     if (hangingIndent < 0f)
     {
         if (direction == RPLFormat.Directions.LTR)
         {
             leftIndent -= hangingIndent;
         }
         else
         {
             rightIndent -= hangingIndent;
         }
     }
     if (m_paragraphProps.ListLevel > 0)
     {
         float num = m_paragraphProps.ListLevel * TextBox.ConvertToPixels(10.583333f, dpiX);
         if (direction == RPLFormat.Directions.LTR)
         {
             leftIndent += num;
         }
         else
         {
             rightIndent += num;
         }
     }
 }
Beispiel #2
0
 public void RenderFontWeight(RPLFormat.FontWeights?fontWeights, RPLFormat.Directions dir)
 {
     if (fontWeights.HasValue)
     {
         this.RenderFontWeight(fontWeights.Value, dir);
     }
 }
Beispiel #3
0
 public void RenderFontStyle(RPLFormat.FontStyles?value, RPLFormat.Directions dir)
 {
     if (value.HasValue)
     {
         this.RenderFontStyle(value.Value, dir);
     }
 }
Beispiel #4
0
 public void ScriptItemize()
 {
     RPLFormat.Directions direction = this.m_textBoxProps.Direction;
     for (int i = 0; i < this.m_paragraphs.Count; i++)
     {
         this.m_paragraphs[i].ScriptItemize(direction);
     }
 }
Beispiel #5
0
 internal void ScriptItemize()
 {
     RPLFormat.Directions direction = m_textBoxProps.Direction;
     for (int i = 0; i < m_paragraphs.Count; i++)
     {
         m_paragraphs[i].ScriptItemize(direction);
     }
 }
        public void RenderFontSize(string size, RPLFormat.Directions dir)
        {
            int param = (int)Math.Round(new RPLReportSize(size).ToPoints() * 2.0);

            m_charFormat.AddSprm(19011, param, null);
            if (dir == RPLFormat.Directions.RTL)
            {
                m_charFormat.AddSprm(19041, param, null);
            }
        }
Beispiel #7
0
        public void Render(Graphics g, RectangleF rectangle, PointF offset, IEnumerable <RTSelectionHighlight> highlights, bool unitsInMM)
        {
            List <Paragraph> rTParagraphs = this.RTParagraphs;

            if (rTParagraphs != null && rTParagraphs.Count != 0)
            {
                using (RevertingDeviceContext revertingDeviceContext = new RevertingDeviceContext(g, this.Dpi))
                {
                    Win32DCSafeHandle hdc = revertingDeviceContext.Hdc;
                    if (highlights != null)
                    {
                        RPLFormat.Directions direction = this.RTTextbox.TextBoxProps.Direction;
                        foreach (RTSelectionHighlight highlight in highlights)
                        {
                            if (!RichTextRenderer.HighlightStartLessThanOrEqualToEnd(highlight.SelectionStart, highlight.SelectionEnd))
                            {
                                TextBoxContext selectionStart = highlight.SelectionStart;
                                highlight.SelectionStart = highlight.SelectionEnd;
                                highlight.SelectionEnd   = selectionStart;
                            }
                            TextRun   textRun    = default(TextRun);
                            CaretInfo caretInfo  = this.MapLocation(hdc, highlight.SelectionStart, true, true, out textRun);
                            TextRun   textRun2   = default(TextRun);
                            CaretInfo caretInfo2 = this.MapLocation(hdc, highlight.SelectionEnd, true, true, out textRun2);
                            if (caretInfo != null && caretInfo2 != null && textRun != null && textRun2 != null)
                            {
                                this.SetHighlighting(rTParagraphs, hdc, highlight, textRun, textRun2, caretInfo.Position.X, caretInfo2.Position.X);
                            }
                        }
                    }
                    Rectangle rectangle2 = (!unitsInMM) ? Rectangle.Round(rectangle) : new Rectangle(TextBox.ConvertToPixels(rectangle.X, this.m_dpi), TextBox.ConvertToPixels(rectangle.Y, this.m_dpi), TextBox.ConvertToPixels(rectangle.Width, this.m_dpi), TextBox.ConvertToPixels(rectangle.Height, this.m_dpi));
                    revertingDeviceContext.XForm.Transform(ref rectangle2);
                    Win32ObjectSafeHandle win32ObjectSafeHandle = Win32.CreateRectRgn(rectangle2.Left - 1, rectangle2.Top - 1, rectangle2.Right + 1, rectangle2.Bottom + 1);
                    if (!win32ObjectSafeHandle.IsInvalid)
                    {
                        try
                        {
                            if (Win32.SelectClipRgn(hdc, win32ObjectSafeHandle) == 0)
                            {
                                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                            }
                        }
                        finally
                        {
                            win32ObjectSafeHandle.Close();
                        }
                    }
                    TextBox.Render(this.RTTextbox, rTParagraphs, hdc, this.FontCache, offset, rectangle, this.m_dpi, unitsInMM);
                    if (Win32.SelectClipRgn(hdc, Win32ObjectSafeHandle.Zero) == 0)
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }
                }
            }
        }
Beispiel #8
0
        public void RenderFontSize(string size, RPLFormat.Directions dir)
        {
            RPLReportSize rPLReportSize = new RPLReportSize(size);
            double        num           = rPLReportSize.ToPoints();
            int           param         = (int)Math.Round(num * 2.0);

            this.m_charFormat.AddSprm(19011, param, null);
            if (dir == RPLFormat.Directions.RTL)
            {
                this.m_charFormat.AddSprm(19041, param, null);
            }
        }
Beispiel #9
0
        public void RenderFontFamily(string font, RPLFormat.Directions dir)
        {
            int param = this.WriteFont(font);

            this.m_charFormat.AddSprm(19023, param, null);
            this.m_charFormat.AddSprm(19024, param, null);
            this.m_charFormat.AddSprm(19025, param, null);
            if (dir == RPLFormat.Directions.RTL)
            {
                this.m_charFormat.AddSprm(19038, param, null);
            }
        }
Beispiel #10
0
        public static string GetValue(RPLFormat.Directions val)
        {
            switch (val)
            {
            case RPLFormat.Directions.LTR:
                return("ltr");

            case RPLFormat.Directions.RTL:
                return("rtl");

            default:
                return(null);
            }
        }
Beispiel #11
0
        private static List <TextRun> CreateLinePrefix(Paragraph paragraph, RPLFormat.Directions direction)
        {
            IParagraphProps paragraphProps = paragraph.ParagraphProps;

            if (paragraphProps.ListStyle == RPLFormat.ListStyles.None || paragraphProps.ListLevel <= 0)
            {
                return(null);
            }
            Paragraph     paragraph2    = new Paragraph();
            StringBuilder stringBuilder = new StringBuilder();
            PrefixRun     prefixRun     = null;

            if (paragraphProps.ListStyle == RPLFormat.ListStyles.Bulleted)
            {
                prefixRun = new BulletPrefixRun();
                stringBuilder.Append(BulletChars[(paragraphProps.ListLevel - 1) % 3]);
            }
            else
            {
                prefixRun = new NumberPrefixRun();
                switch ((paragraphProps.ListLevel - 1) % 3)
                {
                case 0:
                    stringBuilder.Append(GetAsDecimalString(paragraph.ParagraphNumber));
                    break;

                case 1:
                    stringBuilder.Append(GetAsRomanNumeralString(paragraph.ParagraphNumber));
                    break;

                case 2:
                    stringBuilder.Append(GetAsLatinAlphaString(paragraph.ParagraphNumber));
                    break;
                }
                stringBuilder.Append('.');
            }
            paragraph2.Runs.Add(new TextRun(stringBuilder.ToString(), prefixRun));
            paragraph2.ScriptItemize(direction);
            TextLine textLine = new TextLine();

            for (int i = 0; i < paragraph2.Runs.Count; i++)
            {
                textLine.LogicalRuns.Add(paragraph2.Runs[i]);
            }
            textLine.ScriptLayout(Win32DCSafeHandle.Zero, null);
            return(textLine.LogicalRuns);
        }
Beispiel #12
0
 public void RenderFontStyle(RPLFormat.FontStyles value, RPLFormat.Directions dir)
 {
     if (value == RPLFormat.FontStyles.Italic)
     {
         this.m_charFormat.AddSprm(2102, 1, null);
         if (dir == RPLFormat.Directions.RTL)
         {
             this.m_charFormat.AddSprm(2141, 1, null);
         }
     }
     else
     {
         this.m_charFormat.AddSprm(2102, 0, null);
         if (dir == RPLFormat.Directions.RTL)
         {
             this.m_charFormat.AddSprm(2141, 0, null);
         }
     }
 }
Beispiel #13
0
 public void RenderFontWeight(RPLFormat.FontWeights fontWeights, RPLFormat.Directions dir)
 {
     if ((int)fontWeights >= 5)
     {
         this.m_charFormat.AddSprm(2101, 1, null);
         if (dir == RPLFormat.Directions.RTL)
         {
             this.m_charFormat.AddSprm(2140, 1, null);
         }
     }
     else
     {
         this.m_charFormat.AddSprm(2101, 0, null);
         if (dir == RPLFormat.Directions.RTL)
         {
             this.m_charFormat.AddSprm(2140, 0, null);
         }
     }
 }
 public static void GetFontFormatInformation(RPLElementProps elementProperties, out RPLFormat.WritingModes writingMode, out RPLFormat.Directions direction, out RPLFormat.VerticalAlignments verticalAlign, out RPLFormat.TextAlignments textAlign, ref bool stringFormatFromInstance)
 {
     writingMode   = (RPLFormat.WritingModes)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)30, ref stringFormatFromInstance);
     direction     = (RPLFormat.Directions)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)29, ref stringFormatFromInstance);
     verticalAlign = (RPLFormat.VerticalAlignments)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)26, ref stringFormatFromInstance);
     textAlign     = (RPLFormat.TextAlignments)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)25, ref stringFormatFromInstance);
 }
Beispiel #15
0
        public override void DrawTextRun(Win32DCSafeHandle hdc, FontCache fontCache, ReportTextBox textBox, AspNetCore.ReportingServices.Rendering.RichText.TextRun run, TypeCode typeCode, RPLFormat.TextAlignments textAlign, RPLFormat.VerticalAlignments verticalAlign, RPLFormat.WritingModes writingMode, RPLFormat.Directions direction, Point pointPosition, System.Drawing.Rectangle layoutRectangle, int lineHeight, int baselineY)
        {
            if (!string.IsNullOrEmpty(run.Text))
            {
                int x;
                int baselineY2;
                switch (writingMode)
                {
                case RPLFormat.WritingModes.Horizontal:
                    x          = layoutRectangle.X + pointPosition.X;
                    baselineY2 = layoutRectangle.Y + baselineY;
                    break;

                case RPLFormat.WritingModes.Vertical:
                    x          = layoutRectangle.X + (layoutRectangle.Width - baselineY);
                    baselineY2 = layoutRectangle.Y + pointPosition.X;
                    break;

                case RPLFormat.WritingModes.Rotate270:
                    x          = layoutRectangle.X + baselineY;
                    baselineY2 = layoutRectangle.Y + layoutRectangle.Height - pointPosition.X;
                    break;

                default:
                    throw new NotSupportedException();
                }
                Underline underline = null;
                if (run.UnderlineHeight > 0)
                {
                    underline = new Underline(run, hdc, fontCache, layoutRectangle, pointPosition.X, baselineY, writingMode);
                }
                if (!this.IsEmf)
                {
                    AspNetCore.ReportingServices.Rendering.RichText.TextBox.DrawTextRun(run, hdc, fontCache, x, baselineY2, underline);
                }
                else
                {
                    AspNetCore.ReportingServices.Rendering.RichText.TextBox.ExtDrawTextRun(run, hdc, fontCache, x, baselineY2, underline);
                }
            }
        }
Beispiel #16
0
        public static float FlowVertical(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, out float width, out float nextWidth)
        {
            width = (nextWidth = 0f);
            List <Paragraph> list               = null;
            int               num               = 0;
            int               val               = 2147483647;
            int               num2              = 0;
            float             result            = 0f;
            int               num3              = 0;
            List <TextLine>   list2             = null;
            float             dpiX              = g.DpiX;
            Win32DCSafeHandle win32DCSafeHandle = new Win32DCSafeHandle(g.GetHdc(), false);

            if (textBox.VerticalText)
            {
                flowContext.VerticalCanGrow = textBox.TextBoxProps.CanGrow;
                num3 = TextBox.ConvertToPixels(flowContext.Height, dpiX);
            }
            else
            {
                num3 = TextBox.ConvertToPixels(flowContext.Width, dpiX);
            }
            try
            {
                list = LineBreaker.Flow(textBox, win32DCSafeHandle, dpiX, fontCache, flowContext, true, out result);
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        list2 = list[i].TextLines;
                        if (list2 != null)
                        {
                            float num4 = 0f;
                            float num5 = 0f;
                            float num6 = 0f;
                            float num7 = 0f;
                            RPLFormat.Directions direction = textBox.TextBoxProps.Direction;
                            list[i].GetParagraphIndents(direction, dpiX, out num4, out num5, out num6);
                            num7 = num4 + num5;
                            if (list2[0].FirstLine)
                            {
                                num7 += num6;
                            }
                            num2 = Math.Max(num2, (int)num7);
                            for (int j = 0; j < list2.Count; j++)
                            {
                                num = Math.Max(num, list2[j].GetWidth(win32DCSafeHandle, fontCache, false) + (int)num7);
                                val = Math.Min(val, list2[j].GetWidth(win32DCSafeHandle, fontCache, false) + (int)num7);
                            }
                            list[i].TextLines = null;
                        }
                    }
                }
                val = Math.Max(val, num2);
                if (num > 0)
                {
                    int num8 = 0;
                    if (flowContext.VerticalCanGrow && flowContext.ForcedCharTrim)
                    {
                        num8 = flowContext.CharTrimmedRunWidth;
                    }
                    else
                    {
                        num8 = (num - val) / 2;
                        if (num8 == 0)
                        {
                            num8 = num / 2;
                        }
                        else
                        {
                            num8 += val;
                            if (num8 >= num3)
                            {
                                num8 /= 2;
                            }
                        }
                    }
                    width     = TextBox.ConvertToMillimeters(num, dpiX);
                    nextWidth = TextBox.ConvertToMillimeters(num8, dpiX);
                    return(result);
                }
                return(result);
            }
            finally
            {
                fontCache.ResetGraphics();
                if (!win32DCSafeHandle.IsInvalid)
                {
                    g.ReleaseHdc();
                }
            }
        }
Beispiel #17
0
        internal static float FlowVertical(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, out float width, out float nextWidth)
        {
            width = (nextWidth = 0f);
            List <Paragraph> list               = null;
            int               num               = 0;
            int               val               = int.MaxValue;
            int               num2              = 0;
            float             height            = 0f;
            int               num3              = 0;
            List <TextLine>   list2             = null;
            float             dpiX              = g.DpiX;
            Win32DCSafeHandle win32DCSafeHandle = new Win32DCSafeHandle(g.GetHdc(), ownsHandle: false);

            if (textBox.VerticalText)
            {
                flowContext.VerticalCanGrow = textBox.TextBoxProps.CanGrow;
                num3 = TextBox.ConvertToPixels(flowContext.Height, dpiX);
            }
            else
            {
                num3 = TextBox.ConvertToPixels(flowContext.Width, dpiX);
            }
            try
            {
                list = Flow(textBox, win32DCSafeHandle, dpiX, fontCache, flowContext, keepLines: true, out height);
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        list2 = list[i].TextLines;
                        if (list2 != null)
                        {
                            float leftIndent               = 0f;
                            float rightIndent              = 0f;
                            float hangingIndent            = 0f;
                            float num4                     = 0f;
                            RPLFormat.Directions direction = textBox.TextBoxProps.Direction;
                            list[i].GetParagraphIndents(direction, dpiX, out leftIndent, out rightIndent, out hangingIndent);
                            num4 = leftIndent + rightIndent;
                            if (list2[0].FirstLine)
                            {
                                num4 += hangingIndent;
                            }
                            num2 = Math.Max(num2, (int)num4);
                            for (int j = 0; j < list2.Count; j++)
                            {
                                num = Math.Max(num, list2[j].GetWidth(win32DCSafeHandle, fontCache, useVisualRunsIfAvailable: false) + (int)num4);
                                val = Math.Min(val, list2[j].GetWidth(win32DCSafeHandle, fontCache, useVisualRunsIfAvailable: false) + (int)num4);
                            }
                            list[i].TextLines = null;
                        }
                    }
                }
                val = Math.Max(val, num2);
                if (num > 0)
                {
                    int num5 = 0;
                    if (flowContext.VerticalCanGrow && flowContext.ForcedCharTrim)
                    {
                        num5 = flowContext.CharTrimmedRunWidth;
                    }
                    else
                    {
                        num5 = (num - val) / 2;
                        if (num5 == 0)
                        {
                            num5 = num / 2;
                        }
                        else
                        {
                            num5 += val;
                            if (num5 >= num3)
                            {
                                num5 /= 2;
                            }
                        }
                    }
                    width     = TextBox.ConvertToMillimeters(num, dpiX);
                    nextWidth = TextBox.ConvertToMillimeters(num5, dpiX);
                    return(height);
                }
                return(height);
            }
            finally
            {
                fontCache.ResetGraphics();
                if (!win32DCSafeHandle.IsInvalid)
                {
                    g.ReleaseHdc();
                }
            }
        }
Beispiel #18
0
        public void RenderTextRunDirection(RPLFormat.Directions direction)
        {
            int param = (direction == RPLFormat.Directions.RTL) ? 1 : 0;

            this.m_charFormat.AddSprm(2138, param, null);
        }
Beispiel #19
0
        public void RenderTextAlign(TypeCode type, RPLFormat.TextAlignments textAlignments, RPLFormat.Directions direction)
        {
            int param = 0;

            if (textAlignments == RPLFormat.TextAlignments.General)
            {
                textAlignments = (RPLFormat.TextAlignments)((!this.GetTextAlignForType(type)) ? 1 : 3);
            }
            else if (direction == RPLFormat.Directions.RTL)
            {
                switch (textAlignments)
                {
                case RPLFormat.TextAlignments.Left:
                    textAlignments = RPLFormat.TextAlignments.Right;
                    break;

                case RPLFormat.TextAlignments.Right:
                    textAlignments = RPLFormat.TextAlignments.Left;
                    break;
                }
            }
            switch (textAlignments)
            {
            case RPLFormat.TextAlignments.Left:
                param = 0;
                break;

            case RPLFormat.TextAlignments.Center:
                param = 1;
                break;

            case RPLFormat.TextAlignments.Right:
                param = 2;
                break;
            }
            this.m_parFormat.AddSprm(9313, param, null);
        }
Beispiel #20
0
        private static bool FlowParagraph(Paragraph paragraph, RPLFormat.Directions direction, Win32DCSafeHandle hdc, float dpiX, FontCache fontCache, FlowContext flowContext, bool keepLines, SizeF flowContextSize, ref int contentOffset)
        {
            List <TextLine> list    = new List <TextLine>();
            TextBoxContext  context = flowContext.Context;
            int             num     = paragraph.OffsetY;

            paragraph.ProcessedEmptyParagraph = false;
            bool            flag           = false;
            IParagraphProps paragraphProps = paragraph.ParagraphProps;

            if (!flowContext.Updatable || !paragraph.Updated)
            {
                flag = (context.TextRunIndex == 0 && context.TextRunCharacterIndex == 0);
            }
            if (flag)
            {
                num += TextBox.ConvertToPixels(paragraphProps.SpaceBefore, dpiX);
                if ((float)num >= flowContextSize.Height)
                {
                    paragraph.Height = num - paragraph.OffsetY;
                    return(false);
                }
            }
            int   num2          = contentOffset;
            float leftIndent    = 0f;
            float rightIndent   = 0f;
            float hangingIndent = 0f;

            paragraph.GetParagraphIndents(direction, dpiX, out leftIndent, out rightIndent, out hangingIndent);
            Stack <int> stack    = null;
            Stack <int> stack2   = null;
            TextLine    textLine = null;

            while (true)
            {
                float num3 = leftIndent;
                float num4 = rightIndent;
                if (flag)
                {
                    if (direction == RPLFormat.Directions.LTR)
                    {
                        num3 += hangingIndent;
                    }
                    else
                    {
                        num4 += hangingIndent;
                    }
                }
                stack    = new Stack <int>();
                stack2   = new Stack <int>();
                textLine = new TextLine();
                if (flag)
                {
                    textLine.Prefix    = CreateLinePrefix(paragraph, direction);
                    textLine.FirstLine = true;
                }
                if (!GetLine(paragraph, textLine, hdc, fontCache, flowContext, num3, flowContextSize.Width - num4, flowContextSize.Height - (float)num, stack, stack2, (int)(num3 + num4)))
                {
                    if (list.Count > 0)
                    {
                        list[list.Count - 1].LastLine = true;
                    }
                    num += TextBox.ConvertToPixels(paragraphProps.SpaceAfter, dpiX);
                    break;
                }
                if (keepLines)
                {
                    textLine.ScriptLayout(hdc, fontCache);
                }
                num += textLine.GetHeight(hdc, fontCache);
                list.Add(textLine);
                num2 = num;
                if ((float)num >= flowContextSize.Height)
                {
                    break;
                }
                flag = false;
            }
            paragraph.Height = num - paragraph.OffsetY;
            if ((float)num > flowContextSize.Height)
            {
                if (list.Count > 0 && (float)num2 > flowContextSize.Height)
                {
                    TextLine textLine2             = list[list.Count - 1];
                    int      textRunIndex          = 0;
                    int      textRunCharacterIndex = 0;
                    while (stack.Count > 0)
                    {
                        textRunIndex = stack.Pop();
                    }
                    while (stack2.Count > 0)
                    {
                        textRunCharacterIndex = stack2.Pop();
                    }
                    if (flowContext.LineLimit)
                    {
                        context.TextRunIndex          = textRunIndex;
                        context.TextRunCharacterIndex = textRunCharacterIndex;
                        list.RemoveAt(list.Count - 1);
                        flowContext.OmittedLineHeight = TextBox.ConvertToMillimeters(textLine2.GetHeight(hdc, fontCache), dpiX);
                        if (textLine2.FirstLine)
                        {
                            num2 -= TextBox.ConvertToPixels(paragraphProps.SpaceBefore, dpiX);
                        }
                    }
                    else
                    {
                        TextBoxContext textBoxContext = context.Clone();
                        textBoxContext.TextRunIndex          = textRunIndex;
                        textBoxContext.TextRunCharacterIndex = textRunCharacterIndex;
                        flowContext.ClipContext = textBoxContext;
                    }
                    num2 -= textLine2.GetHeight(hdc, fontCache);
                }
                paragraph.AdvanceToNextRun(context, skipEmptyRuns: false);
                paragraph.AdvanceToNextRun(flowContext.ClipContext, skipEmptyRuns: false);
                if (list.Count > 0)
                {
                    if (flowContext.ClipContext == null && paragraph.AtEndOfParagraph(context))
                    {
                        contentOffset = num;
                    }
                    else
                    {
                        contentOffset = num2;
                    }
                    paragraph.TextLines = list;
                    return(true);
                }
                paragraph.TextLines = null;
                if (paragraph.AtEndOfParagraph(context))
                {
                    contentOffset = num;
                }
                return(false);
            }
            paragraph.AdvanceToNextRun(context);
            paragraph.TextLines = list;
            contentOffset       = num;
            return(true);
        }
Beispiel #21
0
        private void RenderDirection(RPLFormat.Directions directions)
        {
            int param = (directions == RPLFormat.Directions.RTL) ? 1 : 0;

            this.m_parFormat.AddSprm(9281, param, null);
        }
Beispiel #22
0
        internal static List <Paragraph> Flow(TextBox textBox, Win32DCSafeHandle hdc, float dpiX, FontCache fontCache, FlowContext flowContext, bool keepLines, out float height)
        {
            if (flowContext.Height <= 0f || flowContext.Width <= 0f)
            {
                height = 0f;
                return(null);
            }
            int            num           = TextBox.ConvertToPixels(flowContext.ContentOffset, dpiX);
            int            contentOffset = num;
            TextBoxContext context       = flowContext.Context;

            RPLFormat.Directions  direction             = textBox.TextBoxProps.Direction;
            List <Paragraph>      list                  = new List <Paragraph>();
            Win32ObjectSafeHandle win32ObjectSafeHandle = Win32.SelectObject(hdc, Win32ObjectSafeHandle.Zero);
            SizeF flowContextSize;

            if (!textBox.VerticalText)
            {
                flowContextSize = new SizeF(TextBox.ConvertToPixels(flowContext.Width, dpiX), TextBox.ConvertToPixels(flowContext.Height, dpiX));
            }
            else
            {
                flowContext.VerticalCanGrow = textBox.TextBoxProps.CanGrow;
                flowContextSize             = new SizeF(TextBox.ConvertToPixels(flowContext.Height, dpiX), TextBox.ConvertToPixels(flowContext.Width, dpiX));
            }
            fontCache.WritingMode = textBox.TextBoxProps.WritingMode;
            try
            {
                while (context.ParagraphIndex < textBox.Paragraphs.Count)
                {
                    Paragraph paragraph = textBox.Paragraphs[context.ParagraphIndex];
                    paragraph.OffsetY = num;
                    bool num2 = FlowParagraph(paragraph, direction, hdc, dpiX, fontCache, flowContext, keepLines, flowContextSize, ref contentOffset);
                    num += paragraph.Height;
                    if (!keepLines)
                    {
                        paragraph.TextLines = null;
                    }
                    if (!num2)
                    {
                        break;
                    }
                    list.Add(paragraph);
                    if ((float)num >= flowContextSize.Height)
                    {
                        if (paragraph.AtEndOfParagraph(context))
                        {
                            context.IncrementParagraph();
                        }
                        break;
                    }
                    context.IncrementParagraph();
                }
                if ((float)num < flowContextSize.Height)
                {
                    flowContext.AtEndOfTextBox = true;
                }
            }
            finally
            {
                if (!win32ObjectSafeHandle.IsInvalid)
                {
                    Win32.SelectObject(hdc, win32ObjectSafeHandle).SetHandleAsInvalid();
                    win32ObjectSafeHandle.SetHandleAsInvalid();
                }
            }
            height = TextBox.ConvertToMillimeters(num, dpiX);
            flowContext.ContentOffset = TextBox.ConvertToMillimeters(contentOffset, dpiX);
            return(list);
        }
        internal void ScriptItemize(RPLFormat.Directions direction)
        {
            SCRIPT_ITEM[] array         = null;
            int           num           = 0;
            StringBuilder stringBuilder = new StringBuilder();
            string        nextTextBlock;

            while ((nextTextBlock = GetNextTextBlock()) != null)
            {
                if (nextTextBlock.Length <= 0)
                {
                    continue;
                }
                SCRIPT_CONTROL psControl = default(SCRIPT_CONTROL);
                psControl.dword1 = 16777216u;
                SCRIPT_STATE psState = new ScriptState
                {
                    uBidiLevel = ((direction != 0) ? 1 : 0)
                }.GetAs_SCRIPT_STATE();
                SCRIPT_ITEM[] array2  = new SCRIPT_ITEM[nextTextBlock.Length + 1];
                int           pcItems = 0;
                int           num2    = Win32.ScriptItemize(nextTextBlock, nextTextBlock.Length, array2.Length, ref psControl, ref psState, array2, ref pcItems);
                if (Win32.Failed(num2))
                {
                    Marshal.ThrowExceptionForHR(num2);
                }
                if (array == null)
                {
                    array = array2;
                    num   = pcItems;
                }
                else
                {
                    SCRIPT_ITEM[] array3 = new SCRIPT_ITEM[num + array2.Length];
                    Array.Copy(array, 0, array3, 0, num);
                    for (int i = 0; i < array2.Length; i++)
                    {
                        SCRIPT_ITEM sCRIPT_ITEM = array2[i];
                        sCRIPT_ITEM.iCharPos += stringBuilder.Length;
                        array3[num + i]       = sCRIPT_ITEM;
                    }
                    array = array3;
                    num  += pcItems;
                }
                stringBuilder.Append(nextTextBlock);
            }
            if (num <= 0)
            {
                return;
            }
            List <SCRIPT_ITEM> list = new List <SCRIPT_ITEM>();
            int num3 = -1;

            for (int j = 0; j < num; j++)
            {
                int bidiLevel  = ScriptState.GetBidiLevel(array[j].analysis.state.word1);
                int bidiLevel2 = ScriptState.GetBidiLevel(array[j + 1].analysis.state.word1);
                if (bidiLevel == bidiLevel2 && CanMergeItemizedRuns(array[j].iCharPos, array[j + 1].iCharPos - 1, stringBuilder))
                {
                    if (num3 < 0)
                    {
                        num3 = j;
                    }
                    continue;
                }
                if (num3 >= 0)
                {
                    list.Add(array[num3]);
                }
                list.Add(array[j]);
                num3 = -1;
            }
            if (num3 >= 0)
            {
                list.Add(array[num3]);
            }
            list.Add(array[num]);
            array = null;
            num   = list.Count - 1;
            if (num == 1)
            {
                for (int k = 0; k < m_runs.Count; k++)
                {
                    m_runs[k].SCRIPT_ANALYSIS = list[0].analysis;
                }
                AnalyzeForBreakPositions(m_runs, stringBuilder.ToString());
                return;
            }
            List <TextRun> list2 = new List <TextRun>();

            for (int l = 0; l < num; l++)
            {
                int            iCharPos            = list[l].iCharPos;
                int            endingParaCharIndex = list[l + 1].iCharPos - 1;
                List <TextRun> collection          = ExtractRuns(iCharPos, endingParaCharIndex, list[l].analysis);
                list2.AddRange(collection);
            }
            m_runs = list2;
        }
Beispiel #24
0
 public virtual void DrawTextRun(Win32DCSafeHandle hdc, FontCache fontCache, ReportTextBox textBox, TextRun run, TypeCode typeCode, RPLFormat.TextAlignments textAlign, RPLFormat.VerticalAlignments verticalAlign, RPLFormat.WritingModes writingMode, RPLFormat.Directions direction, Point position, Rectangle layoutRectangle, int lineHeight, int baselineY)
 {
 }
 public void RenderFontStyle(RPLFormat.FontStyles value, RPLFormat.Directions dir)
 {
     this.GetCurrentTextStyle().SetItalic(value == RPLFormat.FontStyles.Italic, dir == RPLFormat.Directions.RTL);
 }
 internal static void GetFontFormatInformation(RPLElementProps elementProperties, out RPLFormat.WritingModes writingMode, out RPLFormat.Directions direction, out RPLFormat.VerticalAlignments verticalAlign, out RPLFormat.TextAlignments textAlign, ref bool stringFormatFromInstance)
 {
     writingMode   = (RPLFormat.WritingModes)GetStylePropertyValueObject(elementProperties, 30, ref stringFormatFromInstance);
     direction     = (RPLFormat.Directions)GetStylePropertyValueObject(elementProperties, 29, ref stringFormatFromInstance);
     verticalAlign = (RPLFormat.VerticalAlignments)GetStylePropertyValueObject(elementProperties, 26, ref stringFormatFromInstance);
     textAlign     = (RPLFormat.TextAlignments)GetStylePropertyValueObject(elementProperties, 25, ref stringFormatFromInstance);
 }
        public void ScriptItemize(RPLFormat.Directions direction)
        {
            SCRIPT_ITEM[] array         = null;
            int           num           = 0;
            StringBuilder stringBuilder = new StringBuilder();
            string        nextTextBlock;

            while ((nextTextBlock = this.GetNextTextBlock()) != null)
            {
                if (nextTextBlock.Length > 0)
                {
                    SCRIPT_CONTROL sCRIPT_CONTROL = default(SCRIPT_CONTROL);
                    sCRIPT_CONTROL.dword1 = 16777216u;
                    ScriptState scriptState = new ScriptState();
                    scriptState.uBidiLevel = ((direction != 0) ? 1 : 0);
                    SCRIPT_STATE  as_SCRIPT_STATE = scriptState.GetAs_SCRIPT_STATE();
                    SCRIPT_ITEM[] array2          = new SCRIPT_ITEM[nextTextBlock.Length + 1];
                    int           num2            = 0;
                    int           num3            = Win32.ScriptItemize(nextTextBlock, nextTextBlock.Length, array2.Length, ref sCRIPT_CONTROL, ref as_SCRIPT_STATE, array2, ref num2);
                    if (Win32.Failed(num3))
                    {
                        Marshal.ThrowExceptionForHR(num3);
                    }
                    if (array == null)
                    {
                        array = array2;
                        num   = num2;
                    }
                    else
                    {
                        SCRIPT_ITEM[] array3 = new SCRIPT_ITEM[num + array2.Length];
                        Array.Copy(array, 0, array3, 0, num);
                        for (int i = 0; i < array2.Length; i++)
                        {
                            SCRIPT_ITEM sCRIPT_ITEM = array2[i];
                            sCRIPT_ITEM.iCharPos += stringBuilder.Length;
                            array3[num + i]       = sCRIPT_ITEM;
                        }
                        array = array3;
                        num  += num2;
                    }
                    stringBuilder.Append(nextTextBlock);
                }
            }
            if (num > 0)
            {
                List <SCRIPT_ITEM> list = new List <SCRIPT_ITEM>();
                int  num4 = -1;
                bool flag = false;
                for (int j = 0; j < num; j++)
                {
                    int bidiLevel  = ScriptState.GetBidiLevel(array[j].analysis.state.word1);
                    int bidiLevel2 = ScriptState.GetBidiLevel(array[j + 1].analysis.state.word1);
                    if (bidiLevel == bidiLevel2 && this.CanMergeItemizedRuns(array[j].iCharPos, array[j + 1].iCharPos - 1, stringBuilder))
                    {
                        if (num4 < 0)
                        {
                            num4 = j;
                        }
                    }
                    else
                    {
                        if (num4 >= 0)
                        {
                            list.Add(array[num4]);
                        }
                        list.Add(array[j]);
                        num4 = -1;
                    }
                }
                if (num4 >= 0)
                {
                    list.Add(array[num4]);
                }
                list.Add(array[num]);
                array = null;
                num   = list.Count - 1;
                if (num == 1)
                {
                    for (int k = 0; k < this.m_runs.Count; k++)
                    {
                        this.m_runs[k].SCRIPT_ANALYSIS = list[0].analysis;
                    }
                    Paragraph.AnalyzeForBreakPositions(this.m_runs, stringBuilder.ToString());
                }
                else
                {
                    List <TextRun> list2 = new List <TextRun>();
                    for (int l = 0; l < num; l++)
                    {
                        int            iCharPos            = list[l].iCharPos;
                        int            endingParaCharIndex = list[l + 1].iCharPos - 1;
                        List <TextRun> collection          = this.ExtractRuns(iCharPos, endingParaCharIndex, list[l].analysis);
                        list2.AddRange(collection);
                    }
                    this.m_runs = list2;
                }
            }
        }
 internal static RPLFormat.TextAlignments GetTextAlignForGeneral(TypeCode typeCode, RPLFormat.Directions direction)
 {
     if ((uint)(typeCode - 5) <= 11u)
     {
         if (direction == RPLFormat.Directions.LTR)
         {
             return(RPLFormat.TextAlignments.Right);
         }
         return(RPLFormat.TextAlignments.Left);
     }
     if (direction == RPLFormat.Directions.LTR)
     {
         return(RPLFormat.TextAlignments.Left);
     }
     return(RPLFormat.TextAlignments.Right);
 }
        public static RPLFormat.TextAlignments GetTextAlignForGeneral(TypeCode typeCode, RPLFormat.Directions direction)
        {
            switch (typeCode)
            {
            case TypeCode.SByte:
            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.UInt16:
            case TypeCode.Int32:
            case TypeCode.UInt32:
            case TypeCode.Int64:
            case TypeCode.UInt64:
            case TypeCode.Single:
            case TypeCode.Double:
            case TypeCode.Decimal:
            case TypeCode.DateTime:
                if (direction == RPLFormat.Directions.LTR)
                {
                    return(RPLFormat.TextAlignments.Right);
                }
                return(RPLFormat.TextAlignments.Left);

            default:
                if (direction == RPLFormat.Directions.LTR)
                {
                    return(RPLFormat.TextAlignments.Left);
                }
                return(RPLFormat.TextAlignments.Right);
            }
        }
 public void RenderFontFamily(string font, RPLFormat.Directions dir)
 {
     this.GetCurrentTextStyle().SetFont(font, dir == RPLFormat.Directions.RTL);
 }