Example #1
0
        public void AddImage(byte[] imgBuf, float height, float width, RPLFormat.Sizings sizing)
        {
            if (imgBuf == null || imgBuf.Length == 0)
            {
                sizing = RPLFormat.Sizings.Clip;
                imgBuf = PictureDescriptor.INVALIDIMAGEDATA;
            }
            OfficeImageHasher officeImageHasher = new OfficeImageHasher(imgBuf);

            byte[]    hash = officeImageHasher.Hash;
            int       num  = Word97Writer.ToTwips(height);
            int       num2 = Word97Writer.ToTwips(width);
            int       num3 = (int)this.m_dataStream.Position;
            ImageHash key  = new ImageHash(hash, sizing, num2, num);

            if (this.m_images.ContainsKey(key))
            {
                num3 = this.m_images[key];
            }
            else
            {
                PictureDescriptor pictureDescriptor = new PictureDescriptor(imgBuf, hash, num2, num, sizing, this.m_imgIndex);
                pictureDescriptor.Serialize(this.m_dataStream);
                this.m_imgIndex++;
                this.m_images.Add(key, num3);
            }
            this.m_charFormat.SetIsInlineImage(num3);
            this.WriteSpecialText("\u0001");
        }
Example #2
0
        private void RenderLineHeight(string size)
        {
            RPLReportSize rPLReportSize = new RPLReportSize(size);
            int           param         = Word97Writer.ToTwips((float)rPLReportSize.ToMillimeters());

            this.m_parFormat.AddSprm(25618, param, null);
        }
Example #3
0
 public void SetPageDimensions(float pageHeight, float pageWidth, float leftMargin, float rightMargin, float topMargin, float bottomMargin)
 {
     if (pageWidth > 558.79998779296875)
     {
         RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "The maximum page width exceeded:{0}", pageWidth);
         pageWidth = 558.8f;
     }
     if (Word97Writer.FixMargins(pageHeight, ref topMargin, ref bottomMargin))
     {
         RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "The top or bottom margin is either <0 or the sum exceeds the page height.");
     }
     if (pageHeight > 558.79998779296875)
     {
         RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "The maximum page height exceeded:{0}", pageHeight);
         pageHeight = 558.8f;
     }
     this.m_secFormat.AddSprm(45088, Word97Writer.ToTwips(pageHeight), null);
     this.m_secFormat.AddSprm(45087, Word97Writer.ToTwips(pageWidth), null);
     this.m_secFormat.AddSprm(45089, Word97Writer.ToTwips(leftMargin), null);
     this.m_secFormat.AddSprm(45090, Word97Writer.ToTwips(rightMargin), null);
     this.m_secFormat.AddSprm(36899, Word97Writer.ToTwips(topMargin), null);
     this.m_secFormat.AddSprm(36900, Word97Writer.ToTwips(bottomMargin), null);
     if (pageWidth > pageHeight)
     {
         this.m_secFormat.AddSprm(12317, 2, null);
     }
     this.m_secFormat.AddSprm(45079, 0, null);
     this.m_secFormat.AddSprm(45080, 0, null);
 }
Example #4
0
        public void AddPadding(int cellIndex, byte code, object value, int defaultValue)
        {
            int twips = defaultValue;

            if (value != null)
            {
                twips = Word97Writer.ToTwips((string)value);
            }
            switch (code)
            {
            case 15:
                this.m_cellPadding.SetPaddingLeft(cellIndex, twips);
                break;

            case 16:
                this.m_cellPadding.SetPaddingRight(cellIndex, twips);
                break;

            case 17:
                this.m_cellPadding.SetPaddingTop(cellIndex, twips);
                break;

            case 18:
                this.m_cellPadding.SetPaddingBottom(cellIndex, twips);
                break;
            }
        }
Example #5
0
 public static ushort ToTwips(object size)
 {
     if (size == null)
     {
         return(0);
     }
     return(Word97Writer.ToTwips(size as string));
 }
Example #6
0
 public void InitTableRow(float leftStart, float rowHeight, float[] columnWidths, AutoFit autoFit)
 {
     if (this.m_tapx.Offset == 14)
     {
         float num = 0f;
         foreach (float num2 in columnWidths)
         {
             num += num2;
         }
         if (num / 25.399999618530273 > 22.0)
         {
             RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "The maximum page width of the report exceeds 22 inches (55.88 centimeters).");
         }
         else if (columnWidths.Length > 63)
         {
             RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "The rendered report contains a table that has more than 63 columns.");
         }
         this.m_columnWidths = columnWidths;
         this.m_numColumns   = columnWidths.Length;
         this.m_borderColors = new CellBorderColor(this.m_numColumns);
         this.m_cellShading  = new CellShading(this.m_numColumns, this.m_tableShd);
         this.m_cellPadding  = new CellPadding(this.m_numColumns);
         this.CreateTableDefSprm(leftStart);
         if (autoFit != AutoFit.Never)
         {
             this.m_tapx.AddSprm(13845, (int)autoFit, null);
         }
         if (this.m_tableShd != null)
         {
             this.m_tapx.AddSprm(54880, 0, this.m_tableShd);
         }
         this.m_startOffset = this.m_tapx.Offset;
     }
     else
     {
         this.m_tapx.Clear(this.m_startOffset, this.m_tapx.Buf.Length - this.m_startOffset);
         int tcLocation = this.GetTcLocation(this.m_numColumns, 0);
         this.m_tapx.Clear(tcLocation, this.m_numColumns * 20);
         this.m_borderColors.Reset();
         this.m_cellShading.Reset();
         this.m_cellPadding.Reset();
         this.m_tapx.Reset(this.m_startOffset);
     }
     this.m_rowHeight         = Word97Writer.ToTwips(rowHeight);
     this.WriteExactRowHeight = false;
     this.WriteRowHeight      = true;
 }
Example #7
0
        private void CreateTableDefSprm(float leftStart)
        {
            int num = 1 + 2 * (this.m_numColumns + 1) + 20 * this.m_numColumns;

            byte[] array = new byte[num + 4];
            int    num2  = 0;

            LittleEndian.PutUShort(array, num2, 54792);
            num2 += 2;
            LittleEndian.PutUShort(array, num2, (ushort)(num + 1));
            num2         += 2;
            array[num2++] = (byte)this.m_numColumns;
            ushort num4 = Word97Writer.ToTwips(leftStart);

            if (num4 > 31680)
            {
                num4 = 31680;
            }
            LittleEndian.PutUShort(array, num2, num4);
            num2 += 2;
            for (int i = 0; i < this.m_numColumns; i++)
            {
                ushort num5 = Word97Writer.ToTwips(this.m_columnWidths[i]);
                if (num5 == 0)
                {
                    num5 = 1;
                }
                num4 = (ushort)(num4 + num5);
                if (num4 > 31680)
                {
                    num4 = 31680;
                }
                LittleEndian.PutUShort(array, num2, num4);
                num2 += 2;
            }
            this.m_tapx.AddRawSprmData(array);
        }