public override void Write(Converter converter, DocWriter writer)
        {
            writer.WriteLine($"## {Name} `{Title}`");

            converter.WriteSummary(writer, this);

            TypeReference fieldType     = Event.EventType;
            string        fieldTypeName = fieldType.FullName.Replace('/', '.');

            converter.Items.TryGetValue($"{TypeItem.Id}{fieldTypeName}", out AMemberItem parentTypeItem);

            writer.WriteLine("```C#");
            writer.Write("public ");
            if (Event.AddMethod?.IsStatic ?? Event.RemoveMethod?.IsStatic ?? false)
            {
                writer.Write("static ");
            }
            writer.WriteLine($"event {parentTypeItem?.FullName ?? fieldTypeName} {Name};");
            writer.WriteLine("```");

            writer.WriteLine("#### Event Type");
            writer.WriteLine(parentTypeItem?.AsLink() ?? fieldTypeName.AsDotNetApiLink());

            base.Write(converter, writer);
        }
예제 #2
0
        /**
         * Writes the definition of the stylesheet list.
         */
        public virtual byte[] WriteDefinition()
        {
            MemoryStream result = new MemoryStream();

            byte[] t;
            try {
                result.Write(t = DocWriter.GetISOBytes("{"), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\stylesheet"), 0, t.Length);
                result.Write(t = RtfElement.DELIMITER, 0, t.Length);
                if (this.document.GetDocumentSettings().IsOutputDebugLineBreaks())
                {
                    result.Write(t = DocWriter.GetISOBytes("\n"), 0, t.Length);
                }
                foreach (RtfParagraphStyle it in this.styleMap.Values)
                {
                    result.Write(t = (it).WriteDefinition(), 0, t.Length);
                }
                result.Write(t = DocWriter.GetISOBytes("}"), 0, t.Length);
                if (this.document.GetDocumentSettings().IsOutputDebugLineBreaks())
                {
                    result.WriteByte((byte)'\n');
                }
            } catch (IOException) {
            }
            return(result.ToArray());
        }
        public override void Write(Converter converter, DocWriter writer)
        {
            writer.WriteLine($"## {Name} `{Title}`");

            converter.WriteSummary(writer, this);

            TypeReference fieldType     = Field.FieldType;
            string        fieldTypeName = fieldType.FullName.Replace('/', '.');

            converter.Items.TryGetValue($"{TypeItem.Id}{fieldTypeName}", out AMemberItem parentTypeItem);

            writer.WriteLine("```C#");
            writer.Write("public ");
            if (Field.IsStatic)
            {
                writer.Write("static ");
            }
            if (Field.IsInitOnly)
            {
                writer.Write("readonly ");
            }
            writer.WriteLine($"{parentTypeItem?.FullName ?? fieldTypeName} {Name};");
            writer.WriteLine("```");

            writer.WriteLine("#### Field Value");
            writer.WriteLine(parentTypeItem?.AsLink() ?? fieldTypeName.AsDotNetApiLink());

            base.Write(converter, writer);
        }
        public override void Write(Converter converter, DocWriter writer)
        {
            writer.WriteLine($"## {Name} `{Title}`");

            converter.WriteSummary(writer, this);

            writer.WriteLine("```C#");
            writer.Write("public ");
            if (Constructor.IsStatic)
            {
                writer.Write("static ");
            }
            writer.WriteLine($"{Parent.Name}({string.Join(", ", Parameters.Select(p => p.Signature))});");
            writer.WriteLine("```");

            if (Parameters.Length > 0)
            {
                writer.WriteLine($"### {Parameters[0].Header}");

                foreach (ParameterItem parameter in Parameters)
                {
                    parameter.Write(converter, writer);
                    writer.Break();
                }
            }

            base.Write(converter, writer);
        }
예제 #5
0
        /**
         * Writes the content of the RtfAnnotation
         *
         * @return The content of this RtfAnnotation
         */
        public override byte[] Write()
        {
            MemoryStream result = new MemoryStream();

            byte[] t;
            try {
                result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
                result.Write(ANNOTATION_ID, 0, ANNOTATION_ID.Length);
                result.Write(DELIMITER, 0, DELIMITER.Length);
                result.Write(t = IntToByteArray(document.GetRandomInt()), 0, t.Length);
                result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
                result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
                result.Write(ANNOTATION_AUTHOR, 0, ANNOTATION_AUTHOR.Length);
                result.Write(DELIMITER, 0, DELIMITER.Length);
                result.Write(t = DocWriter.GetISOBytes(title), 0, t.Length);
                result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
                result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
                result.Write(ANNOTATION, 0, ANNOTATION.Length);
                result.Write(RtfParagraph.PARAGRAPH_DEFAULTS, 0, RtfParagraph.PARAGRAPH_DEFAULTS.Length);
                result.Write(DELIMITER, 0, DELIMITER.Length);
                result.Write(t = DocWriter.GetISOBytes(content), 0, t.Length);
                result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
            } catch (IOException) {
            }
            return(result.ToArray());
        }
예제 #6
0
 /**
  * Write the content of this RtfCell
  */
 public virtual void WriteContent(Stream result)
 {
     byte[] t;
     if (this.content.Count == 0)
     {
         result.Write(RtfParagraph.PARAGRAPH_DEFAULTS, 0, RtfParagraph.PARAGRAPH_DEFAULTS.Length);
         if (this.parentRow.GetParentTable().GetTableFitToPage())
         {
             result.Write(RtfParagraphStyle.KEEP_TOGETHER_WITH_NEXT, 0, RtfParagraphStyle.KEEP_TOGETHER_WITH_NEXT.Length);
         }
         result.Write(RtfParagraph.IN_TABLE, 0, RtfParagraph.IN_TABLE.Length);
     }
     else
     {
         for (int i = 0; i < this.content.Count; i++)
         {
             IRtfBasicElement rtfElement = (IRtfBasicElement)this.content[i];
             if (rtfElement is RtfParagraph)
             {
                 ((RtfParagraph)rtfElement).SetKeepTogetherWithNext(this.parentRow.GetParentTable().GetTableFitToPage());
             }
             rtfElement.WriteContent(result);
             if (rtfElement is RtfParagraph && i < (this.content.Count - 1))
             {
                 result.Write(RtfParagraph.PARAGRAPH, 0, RtfParagraph.PARAGRAPH.Length);
             }
         }
     }
     result.Write(t = DocWriter.GetISOBytes("\\cell"), 0, t.Length);
 }
예제 #7
0
        /**
         * Write the cell definition part of this RtfCell
         *
         * @return A byte array with the cell definition
         */
        public virtual void WriteDefinition(Stream result)
        {
            byte[] t;
            if (this.mergeType == MERGE_VERT_PARENT)
            {
                result.Write(t = DocWriter.GetISOBytes("\\clvmgf"), 0, t.Length);
            }
            else if (this.mergeType == MERGE_VERT_CHILD)
            {
                result.Write(t = DocWriter.GetISOBytes("\\clvmrg"), 0, t.Length);
            }
            switch (verticalAlignment)
            {
            case Element.ALIGN_BOTTOM:
                result.Write(t = DocWriter.GetISOBytes("\\clvertalb"), 0, t.Length);
                break;

            case Element.ALIGN_CENTER:
            case Element.ALIGN_MIDDLE:
                result.Write(t = DocWriter.GetISOBytes("\\clvertalc"), 0, t.Length);
                break;

            case Element.ALIGN_TOP:
                result.Write(t = DocWriter.GetISOBytes("\\clvertalt"), 0, t.Length);
                break;
            }
            this.borders.WriteContent(result);

            if (this.backgroundColor != null)
            {
                result.Write(t = DocWriter.GetISOBytes("\\clcbpat"), 0, t.Length);
                result.Write(t = IntToByteArray(this.backgroundColor.GetColorNumber()), 0, t.Length);
            }
            this.document.OutputDebugLinebreak(result);

            result.Write(t = DocWriter.GetISOBytes("\\clftsWidth3"), 0, t.Length);
            this.document.OutputDebugLinebreak(result);

            result.Write(t = DocWriter.GetISOBytes("\\clwWidth"), 0, t.Length);
            result.Write(t = IntToByteArray(this.cellWidth), 0, t.Length);
            this.document.OutputDebugLinebreak(result);

            if (this.cellPadding > 0)
            {
                result.Write(t = DocWriter.GetISOBytes("\\clpadl"), 0, t.Length);
                result.Write(t = IntToByteArray(this.cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\clpadt"), 0, t.Length);
                result.Write(t = IntToByteArray(this.cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\clpadr"), 0, t.Length);
                result.Write(t = IntToByteArray(this.cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\clpadb"), 0, t.Length);
                result.Write(t = IntToByteArray(this.cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\clpadfl3"), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\clpadft3"), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\clpadfr3"), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\clpadfb3"), 0, t.Length);
            }
            result.Write(t = DocWriter.GetISOBytes("\\cellx"), 0, t.Length);
            result.Write(t = IntToByteArray(this.cellRight), 0, t.Length);
        }
예제 #8
0
        private void WriteField(Stream outp)
        {
            // always hide the toc entry
            outp.WriteByte(RtfWriter.openGroup);
            outp.WriteByte(RtfWriter.escape);
            outp.WriteByte((byte)'v');

            // tc field entry
            outp.WriteByte(RtfWriter.openGroup);
            outp.WriteByte(RtfWriter.escape);
            byte[] t;
            if (!hidePageNumber)
            {
                t = DocWriter.GetISOBytes("tc");
                outp.Write(t, 0, t.Length);
            }
            else
            {
                t = DocWriter.GetISOBytes("tcn");
                outp.Write(t, 0, t.Length);
            }
            outp.WriteByte(RtfWriter.delimiter);
            t = DocWriter.GetISOBytes(RtfWriter.FilterSpecialChar(entryName, true));
            outp.Write(t, 0, t.Length);
            outp.WriteByte(RtfWriter.delimiter);
            outp.WriteByte(RtfWriter.closeGroup);

            outp.WriteByte(RtfWriter.closeGroup);
        }
예제 #9
0
        /**
         * Returns the PDF representation of this <CODE>PdfArray</CODE>.
         *
         * @return		an array of <CODE>byte</CODE>s
         */

        public override byte[] toPdf(PdfWriter writer)
        {
            try {
                MemoryStream stream = new MemoryStream();
                byte[]       tmp    = DocWriter.getISOBytes("[");
                stream.Write(tmp, 0, tmp.Length);

                if (dash >= 0)
                {
                    tmp = new PdfNumber(dash).toPdf(null);
                    stream.Write(tmp, 0, tmp.Length);
                    if (gap >= 0)
                    {
                        tmp = DocWriter.getISOBytes(" ");
                        stream.Write(tmp, 0, tmp.Length);
                        tmp = new PdfNumber(gap).toPdf(null);
                        stream.Write(tmp, 0, tmp.Length);
                    }
                }
                tmp = DocWriter.getISOBytes("]");
                stream.Write(tmp, 0, tmp.Length);
                if (phase >= 0)
                {
                    tmp = DocWriter.getISOBytes(" ");
                    stream.Write(tmp, 0, tmp.Length);
                    tmp = new PdfNumber(phase).toPdf(null);
                    stream.Write(tmp, 0, tmp.Length);
                }

                return(stream.ToArray());
            }
            catch (IOException ioe) {
                throw ioe;
            }
        }
예제 #10
0
 /**
  * Writes the start information of this RtfParagraphStyle.
  *
  * @param result The <code>OutputStream</code> to write to.
  * @throws IOException On i/o errors.
  */
 public override void WriteBegin(Stream result)
 {
     byte[] t;
     result.Write(t = DocWriter.GetISOBytes("\\s"), 0, t.Length);
     result.Write(t = IntToByteArray(this.styleNumber), 0, t.Length);
     WriteParagraphSettings(result);
 }
예제 #11
0
        /// <summary>
        /// Write the cell definition part of this RtfCell
        /// </summary>
        /// <returns>A byte array with the cell definition</returns>
        public virtual void WriteDefinition(Stream result)
        {
            byte[] t;
            if (_mergeType == MergeVertParent)
            {
                result.Write(t = DocWriter.GetIsoBytes("\\clvmgf"), 0, t.Length);
            }
            else if (_mergeType == MergeVertChild)
            {
                result.Write(t = DocWriter.GetIsoBytes("\\clvmrg"), 0, t.Length);
            }
            switch (verticalAlignment)
            {
            case ALIGN_BOTTOM:
                result.Write(t = DocWriter.GetIsoBytes("\\clvertalb"), 0, t.Length);
                break;

            case ALIGN_CENTER:
            case ALIGN_MIDDLE:
                result.Write(t = DocWriter.GetIsoBytes("\\clvertalc"), 0, t.Length);
                break;

            case ALIGN_TOP:
                result.Write(t = DocWriter.GetIsoBytes("\\clvertalt"), 0, t.Length);
                break;
            }
            _borders.WriteContent(result);

            if (_backgroundColor != null)
            {
                result.Write(t = DocWriter.GetIsoBytes("\\clcbpat"), 0, t.Length);
                result.Write(t = intToByteArray(_backgroundColor.GetColorNumber()), 0, t.Length);
            }
            _document.OutputDebugLinebreak(result);

            result.Write(t = DocWriter.GetIsoBytes("\\clftsWidth3"), 0, t.Length);
            _document.OutputDebugLinebreak(result);

            result.Write(t = DocWriter.GetIsoBytes("\\clwWidth"), 0, t.Length);
            result.Write(t = intToByteArray(_cellWidth), 0, t.Length);
            _document.OutputDebugLinebreak(result);

            if (_cellPadding > 0)
            {
                result.Write(t = DocWriter.GetIsoBytes("\\clpadl"), 0, t.Length);
                result.Write(t = intToByteArray(_cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadt"), 0, t.Length);
                result.Write(t = intToByteArray(_cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadr"), 0, t.Length);
                result.Write(t = intToByteArray(_cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadb"), 0, t.Length);
                result.Write(t = intToByteArray(_cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadfl3"), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadft3"), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadfr3"), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadfb3"), 0, t.Length);
            }
            result.Write(t = DocWriter.GetIsoBytes("\\cellx"), 0, t.Length);
            result.Write(t = intToByteArray(_cellRight), 0, t.Length);
        }
예제 #12
0
 /// <summary>
 /// Write the content of this RtfCell
 /// </summary>
 public virtual void WriteContent(Stream result)
 {
     byte[] t;
     if (_content.Count == 0)
     {
         result.Write(RtfPhrase.ParagraphDefaults, 0, RtfPhrase.ParagraphDefaults.Length);
         if (_parentRow.GetParentTable().GetTableFitToPage())
         {
             result.Write(RtfParagraphStyle.KeepTogetherWithNext, 0, RtfParagraphStyle.KeepTogetherWithNext.Length);
         }
         result.Write(RtfPhrase.InTable, 0, RtfPhrase.InTable.Length);
     }
     else
     {
         for (var i = 0; i < _content.Count; i++)
         {
             var rtfElement = (IRtfBasicElement)_content[i];
             if (rtfElement is RtfParagraph)
             {
                 ((RtfParagraph)rtfElement).SetKeepTogetherWithNext(_parentRow.GetParentTable().GetTableFitToPage());
             }
             rtfElement.WriteContent(result);
             if (rtfElement is RtfParagraph && i < (_content.Count - 1))
             {
                 result.Write(RtfParagraph.Paragraph, 0, RtfParagraph.Paragraph.Length);
             }
         }
     }
     result.Write(t = DocWriter.GetIsoBytes("\\cell"), 0, t.Length);
 }
예제 #13
0
        /**
         * Writes the RtfChapter and its contents
         *
         * @return A byte array containing the RtfChapter and its contents
         */
        public override byte[] Write()
        {
            MemoryStream result = new MemoryStream();

            byte[] t;
            try {
                if (this.document.GetLastElementWritten() != null && !(this.document.GetLastElementWritten() is RtfChapter))
                {
                    result.Write(t = DocWriter.GetISOBytes("\\page"), 0, t.Length);
                }
                result.Write(t = DocWriter.GetISOBytes("\\sectd"), 0, t.Length);
                result.Write(t = document.GetDocumentHeader().WriteSectionDefinition(), 0, t.Length);
                if (this.title != null)
                {
                    result.Write(t = this.title.Write(), 0, t.Length);
                }
                for (int i = 0; i < items.Count; i++)
                {
                    result.Write(t = ((IRtfBasicElement)items[i]).Write(), 0, t.Length);
                }
                result.Write(t = DocWriter.GetISOBytes("\\sect"), 0, t.Length);
            } catch (IOException) {
            }
            return(result.ToArray());
        }
예제 #14
0
        /**
         * Writes the content of this RtfListItem.
         *
         * @return A byte array with the content of this RtfListItem.
         */
        public override byte[] Write()
        {
            MemoryStream result = new MemoryStream();

            try {
                byte[] t;
                for (int i = 0; i < chunks.Count; i++)
                {
                    IRtfBasicElement rtfElement = (IRtfBasicElement)chunks[i];
                    if (rtfElement is RtfChunk)
                    {
                        ((RtfChunk)rtfElement).SetSoftLineBreaks(true);
                    }
                    else if (rtfElement is RtfList)
                    {
                        result.Write(RtfParagraph.PARAGRAPH, 0, RtfParagraph.PARAGRAPH.Length);
                        this.containsInnerList = true;
                    }
                    result.Write(t = rtfElement.Write(), 0, t.Length);
                    if (rtfElement is RtfList)
                    {
                        result.Write(t = this.parentList.WriteListBeginning(), 0, t.Length);
                        result.Write(t = DocWriter.GetISOBytes("\\tab"), 0, t.Length);
                    }
                }
            } catch (IOException) {
            }
            return(result.ToArray());
        }
예제 #15
0
        /**
         * Writes the definition of this RtfParagraphStyle for the stylesheet list.
         */
        public override byte[] WriteDefinition()
        {
            MemoryStream result = new MemoryStream();

            byte[] t;
            try {
                result.Write(t = DocWriter.GetISOBytes("{"), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\style"), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("\\s"), 0, t.Length);
                result.Write(t = IntToByteArray(this.styleNumber), 0, t.Length);
                result.Write(t = RtfElement.DELIMITER, 0, t.Length);
                result.Write(t = WriteParagraphSettings(), 0, t.Length);
                result.Write(t = base.WriteBegin(), 0, t.Length);
                result.Write(t = RtfElement.DELIMITER, 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes(this.styleName), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes(";"), 0, t.Length);
                result.Write(t = DocWriter.GetISOBytes("}"), 0, t.Length);
                if (this.document.GetDocumentSettings().IsOutputDebugLineBreaks())
                {
                    result.WriteByte((byte)'\n');
                }
            } catch (IOException) {
            }
            return(result.ToArray());
        }
예제 #16
0
        public override void Write(Converter converter, DocWriter writer)
        {
            writer.WriteLine($"## {Name} `{Title}`");

            converter.WriteSummary(writer, this);

            writer.WriteLine("```C#");
            writer.Write("public ");
            switch (Title)
            {
            case "delegate":
                break;

            case "enum":
                break;

            case "interface":
                break;

            case "struct":
                break;

            case "class":
                if (Type.IsAbstract && Type.IsSealed)
                {
                    writer.Write("static ");
                }
                else if (Type.IsAbstract)
                {
                    writer.Write("abstract ");
                }
                else if (Type.IsSealed)
                {
                    writer.Write("sealed ");
                }
                break;
            }
            writer.WriteLine($"{Title} {Name};");
            writer.WriteLine("```");

            bool hasHeader = false;

            foreach (GenericItem parameter in Generics)
            {
                if (!hasHeader)
                {
                    writer.WriteLine($"### {parameter.Header}");
                    hasHeader = true;
                }
                else
                {
                    writer.Break();
                }

                parameter.Write(converter, writer);
            }

            base.Write(converter, writer);
        }
예제 #17
0
 /// <summary>
 /// Appends a  string  to the buffer. The  string  is
 /// converted according to the encoding ISO-8859-1.
 /// </summary>
 /// <param name="str">the  string  to be appended</param>
 /// <returns>a reference to this  ByteBuffer  object</returns>
 public ByteBuffer Append(string str)
 {
     if (str != null)
     {
         return(Append(DocWriter.GetIsoBytes(str)));
     }
     return(this);
 }
예제 #18
0
 /**
  * method for writing custom stuff to the Field Result part of an
  * RtfField.
  * @param outp
  * @throws IOException
  */
 public override void WriteRtfFieldResultStuff(Stream outp)
 {
     if (null != fieldResult)
     {
         byte[] t = DocWriter.GetISOBytes(fieldResult.Trim());
         outp.Write(t, 0, t.Length);
     }
 }
예제 #19
0
 /**
  * write this RtfField into a stream using the writer given as
  * first argument.
  * @param writer the RtfWriter to use to write this RtfField
  * @param outp the Stream to write this RtfField into.
  * @throws IOException
  */
 public override void Write(RtfWriter writer, Stream outp)
 {
     writer.WriteInitialFontSignature(outp, this);
     byte[] t = DocWriter.GetISOBytes(content);
     outp.Write(t, 0, t.Length);
     writer.WriteFinishingFontSignature(outp, this);
     base.Write(writer, outp);
 }
예제 #20
0
        virtual public bool ReadKey(PdfDictionary enc, byte[] password)
        {
            if (password == null)
            {
                password = new byte[0];
            }
            byte[]  oValue     = DocWriter.GetISOBytes(enc.Get(PdfName.O).ToString());
            byte[]  uValue     = DocWriter.GetISOBytes(enc.Get(PdfName.U).ToString());
            byte[]  oeValue    = DocWriter.GetISOBytes(enc.Get(PdfName.OE).ToString());
            byte[]  ueValue    = DocWriter.GetISOBytes(enc.Get(PdfName.UE).ToString());
            byte[]  perms      = DocWriter.GetISOBytes(enc.Get(PdfName.PERMS).ToString());
            bool    isUserPass = false;
            IDigest md         = DigestUtilities.GetDigest("SHA-256");

            md.BlockUpdate(password, 0, Math.Min(password.Length, 127));
            md.BlockUpdate(oValue, VALIDATION_SALT_OFFSET, SALT_LENGHT);
            md.BlockUpdate(uValue, 0, OU_LENGHT);
            byte[]            hash        = DigestUtilities.DoFinal(md);
            bool              isOwnerPass = CompareArray(hash, oValue, 32);
            AESCipherCBCnoPad ac;

            if (isOwnerPass)
            {
                md.BlockUpdate(password, 0, Math.Min(password.Length, 127));
                md.BlockUpdate(oValue, KEY_SALT_OFFSET, SALT_LENGHT);
                md.BlockUpdate(uValue, 0, OU_LENGHT);
                md.DoFinal(hash, 0);
                ac  = new AESCipherCBCnoPad(false, hash);
                key = ac.ProcessBlock(oeValue, 0, oeValue.Length);
            }
            else
            {
                md.BlockUpdate(password, 0, Math.Min(password.Length, 127));
                md.BlockUpdate(uValue, VALIDATION_SALT_OFFSET, SALT_LENGHT);
                md.DoFinal(hash, 0);
                isUserPass = CompareArray(hash, uValue, 32);
                if (!isUserPass)
                {
                    throw new BadPasswordException(MessageLocalization.GetComposedMessage("bad.user.password"));
                }
                md.BlockUpdate(password, 0, Math.Min(password.Length, 127));
                md.BlockUpdate(uValue, KEY_SALT_OFFSET, SALT_LENGHT);
                md.DoFinal(hash, 0);
                ac  = new AESCipherCBCnoPad(false, hash);
                key = ac.ProcessBlock(ueValue, 0, ueValue.Length);
            }
            ac = new AESCipherCBCnoPad(false, key);
            byte[] decPerms = ac.ProcessBlock(perms, 0, perms.Length);
            if (decPerms[9] != (byte)'a' || decPerms[10] != (byte)'d' || decPerms[11] != (byte)'b')
            {
                throw new BadPasswordException(MessageLocalization.GetComposedMessage("bad.user.password"));
            }
            permissions = (decPerms[0] & 0xff) | ((decPerms[1] & 0xff) << 8)
                          | ((decPerms[2] & 0xff) << 16) | ((decPerms[2] & 0xff) << 24);
            encryptMetadata = decPerms[8] == (byte)'T';
            return(isOwnerPass);
        }
예제 #21
0
 public override void Write(Converter converter, DocWriter writer)
 {
     writer.Write(
         converter.Items.TryGetValue(Reference, out AMemberItem reference)
         ? reference.AsLink()
         : Reference.Substring(2).AsDotNetApiLink());
     writer.WriteLine("  ");
     converter.WriteSummary(writer, this);
 }
예제 #22
0
        /**
         * Get the RTF control word for <code>style</code>
         * @param style a style value
         * @return a byte array corresponding with a style control word
         */
        protected internal static byte[] GetStyleControlWord(int style)
        {
            switch (style)
            {
            case BORDER_UNDEFINED: return(DocWriter.GetISOBytes("brdrs"));

            case BORDER_SINGLE: return(DocWriter.GetISOBytes("brdrs"));

            case BORDER_DOUBLE_THICK: return(DocWriter.GetISOBytes("brdrth"));

            case BORDER_SHADOWED: return(DocWriter.GetISOBytes("brdrsh"));

            case BORDER_DOTTED: return(DocWriter.GetISOBytes("brdrdot"));

            case BORDER_DASHED: return(DocWriter.GetISOBytes("brdrdash"));

            case BORDER_HAIRLINE: return(DocWriter.GetISOBytes("brdrhair"));

            case BORDER_DOUBLE: return(DocWriter.GetISOBytes("brdrdb"));

            case BORDER_DOT_DASH: return(DocWriter.GetISOBytes("brdrdashd"));

            case BORDER_DOT_DOT_DASH: return(DocWriter.GetISOBytes("brdrdashdd"));

            case BORDER_TRIPLE: return(DocWriter.GetISOBytes("brdrtriple"));

            case BORDER_THICK_THIN: return(DocWriter.GetISOBytes("brdrtnthsg"));

            case BORDER_THIN_THICK: return(DocWriter.GetISOBytes("brdrthtnsg"));

            case BORDER_THIN_THICK_THIN: return(DocWriter.GetISOBytes("brdrtnthtnsg"));

            case BORDER_THICK_THIN_MED: return(DocWriter.GetISOBytes("brdrtnthmg"));

            case BORDER_THIN_THICK_MED: return(DocWriter.GetISOBytes("brdrthtnmg"));

            case BORDER_THIN_THICK_THIN_MED: return(DocWriter.GetISOBytes("brdrtnthtnmg"));

            case BORDER_THICK_THIN_LARGE: return(DocWriter.GetISOBytes("brdrtnthlg"));

            case BORDER_THIN_THICK_LARGE: return(DocWriter.GetISOBytes("brdrthtnlg"));

            case BORDER_THIN_THICK_THIN_LARGE: return(DocWriter.GetISOBytes("brdrtnthtnlg"));

            case BORDER_WAVY: return(DocWriter.GetISOBytes("brdrwavy"));

            case BORDER_DOUBLE_WAVY: return(DocWriter.GetISOBytes("brdrwavydb"));

            case BORDER_STRIPED: return(DocWriter.GetISOBytes("brdrdashdotstr"));

            case BORDER_EMBOSS: return(DocWriter.GetISOBytes("brdremboss"));

            case BORDER_ENGRAVE: return(DocWriter.GetISOBytes("brdrengrave"));
            }

            return(DocWriter.GetISOBytes("brdrs"));
        }
예제 #23
0
 /// <summary>
 /// Writes the RTF generator group.
 /// </summary>
 public override void WriteContent(Stream result)
 {
     result.Write(OpenGroup, 0, OpenGroup.Length);
     result.Write(_generator, 0, _generator.Length);
     result.Write(Delimiter, 0, Delimiter.Length);
     byte[] t;
     result.Write(t = DocWriter.GetIsoBytes(iTextSharp.text.Document.Version), 0, t.Length);
     result.Write(CloseGroup, 0, CloseGroup.Length);
     Document.OutputDebugLinebreak(result);
 }
        public override void Write(Converter converter, DocWriter writer)
        {
            string parameterTypeName = Parameter.ParameterType.FullName.Replace('/', '.');

            converter.Items.TryGetValue($"{TypeItem.Id}{parameterTypeName}", out AMemberItem parameterTypeItem);

            writer.WriteLine(this.AsLinkTarget());
            writer.WriteLine($"`{Name}` {parameterTypeItem?.AsLink() ?? parameterTypeName.AsDotNetApiLink()}  ");
            converter.WriteSummary(writer, this);
        }
예제 #25
0
 /**
  * Writes the RTF generator group.
  */
 public override void WriteContent(Stream result)
 {
     result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
     result.Write(GENERATOR, 0, GENERATOR.Length);
     result.Write(DELIMITER, 0, DELIMITER.Length);
     byte[] t;
     result.Write(t = DocWriter.GetISOBytes(Legacy.Text.Document.Version), 0, t.Length);
     result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
     this.document.OutputDebugLinebreak(result);
 }
예제 #26
0
        public override void Write(Converter converter, DocWriter writer)
        {
            writer.WriteLine($"### {Header}");
            string valueTypeName = Type.FullName.Replace('/', '.');

            converter.Items.TryGetValue($"{TypeItem.Id}{valueTypeName}", out AMemberItem valueTypeItem);
            writer.WriteLine(valueTypeItem?.AsLink() ?? valueTypeName.AsDotNetApiLink());

            converter.WriteSummary(writer, this);
        }
예제 #27
0
        /**
         * Write the field instructions for this RtfAnchor. Sets the field
         * type to HYPERLINK and then writes the url.
         *
         * @return The field instructions for this RtfAnchor
         * @throws IOException
         */
        protected override byte[] WriteFieldInstContent()
        {
            MemoryStream result = new MemoryStream();

            result.Write(HYPERLINK, 0, HYPERLINK.Length);
            result.Write(DELIMITER, 0, DELIMITER.Length);
            byte[] t;
            result.Write(t = DocWriter.GetISOBytes(url), 0, t.Length);

            return(result.ToArray());
        }
예제 #28
0
 /// <summary>
 /// Writes eficiently to a stream
 /// @throws IOException on write error
 /// </summary>
 /// <param name="os">the stream to write to</param>
 internal void WriteTo(Stream os)
 {
     byte[] tmp = DocWriter.GetIsoBytes(Number.ToString());
     os.Write(tmp, 0, tmp.Length);
     os.WriteByte((byte)' ');
     tmp = DocWriter.GetIsoBytes(Generation.ToString());
     os.Write(tmp, 0, tmp.Length);
     os.Write(Startobj, 0, Startobj.Length);
     Objecti.ToPdf(Writer, os);
     os.Write(Endobj, 0, Endobj.Length);
 }
예제 #29
0
 /**
  * Writes eficiently to a stream
  *
  * @param os the stream to write to
  * @throws IOException on write error
  */
 internal protected void WriteTo(Stream os)
 {
     byte[] tmp = DocWriter.GetISOBytes(number.ToString());
     os.Write(tmp, 0, tmp.Length);
     os.WriteByte((byte)' ');
     tmp = DocWriter.GetISOBytes(generation.ToString());
     os.Write(tmp, 0, tmp.Length);
     os.Write(STARTOBJ, 0, STARTOBJ.Length);
     objecti.ToPdf(writer, os);
     os.Write(ENDOBJ, 0, ENDOBJ.Length);
 }
예제 #30
0
        /**
         * Writes this RtfInfoElement
         *
         * @return A byte array containing the RtfInfoElement data
         */
        public override byte[] Write()
        {
            MemoryStream result = new MemoryStream();

            try {
                result.Write(OPEN_GROUP, 0, OPEN_GROUP.Length);
                switch (infoType)
                {
                case Element.AUTHOR:
                    result.Write(INFO_AUTHOR, 0, INFO_AUTHOR.Length);
                    break;

                case Element.SUBJECT:
                    result.Write(INFO_SUBJECT, 0, INFO_SUBJECT.Length);
                    break;

                case Element.KEYWORDS:
                    result.Write(INFO_KEYWORDS, 0, INFO_KEYWORDS.Length);
                    break;

                case Element.TITLE:
                    result.Write(INFO_TITLE, 0, INFO_TITLE.Length);
                    break;

                case Element.PRODUCER:
                    result.Write(INFO_PRODUCER, 0, INFO_PRODUCER.Length);
                    break;

                case Element.CREATIONDATE:
                    result.Write(INFO_CREATION_DATE, 0, INFO_CREATION_DATE.Length);
                    break;

                default:
                    result.Write(INFO_AUTHOR, 0, INFO_AUTHOR.Length);
                    break;
                }
                result.Write(DELIMITER, 0, DELIMITER.Length);
                byte[] t;
                if (infoType == Element.CREATIONDATE)
                {
                    t = DocWriter.GetISOBytes(ConvertDate(content));
                }
                else
                {
                    t = DocWriter.GetISOBytes(content);
                }
                result.Write(t, 0, t.Length);
                result.Write(CLOSE_GROUP, 0, CLOSE_GROUP.Length);
            } catch (IOException) {
            }
            return(result.ToArray());
        }
예제 #31
0
			internal void  SetNext(DocWriter next)
			{
				this.next = next;
			}
예제 #32
0
			public bool Add(DocWriter doc)
			{
				lock (this)
				{
					
					System.Diagnostics.Debug.Assert(doc.docID >= nextWriteDocID);
					
					if (doc.docID == nextWriteDocID)
					{
						WriteDocument(doc);
						while (true)
						{
							doc = waiting[nextWriteLoc];
							if (doc != null)
							{
								numWaiting--;
								waiting[nextWriteLoc] = null;
								waitingBytes -= doc.SizeInBytes();
								WriteDocument(doc);
							}
							else
								break;
						}
					}
					else
					{
						
						// I finished before documents that were added
						// before me.  This can easily happen when I am a
						// small doc and the docs before me were large, or,
						// just due to luck in the thread scheduling.  Just
						// add myself to the queue and when that large doc
						// finishes, it will flush me:
						int gap = doc.docID - nextWriteDocID;
						if (gap >= waiting.Length)
						{
							// Grow queue
							DocWriter[] newArray = new DocWriter[ArrayUtil.GetNextSize(gap)];
							System.Diagnostics.Debug.Assert(nextWriteLoc >= 0);
							Array.Copy(waiting, nextWriteLoc, newArray, 0, waiting.Length - nextWriteLoc);
							Array.Copy(waiting, 0, newArray, waiting.Length - nextWriteLoc, nextWriteLoc);
							nextWriteLoc = 0;
							waiting = newArray;
							gap = doc.docID - nextWriteDocID;
						}
						
						int loc = nextWriteLoc + gap;
						if (loc >= waiting.Length)
							loc -= waiting.Length;
						
						// We should only wrap one time
						System.Diagnostics.Debug.Assert(loc < waiting.Length);
						
						// Nobody should be in my spot!
						System.Diagnostics.Debug.Assert(waiting [loc] == null);
						waiting[loc] = doc;
						numWaiting++;
						waitingBytes += doc.SizeInBytes();
					}
					
					return DoPause();
				}
			}
예제 #33
0
			private void  WriteDocument(DocWriter doc)
			{
                System.Diagnostics.Debug.Assert(doc == Enclosing_Instance.skipDocWriter || nextWriteDocID == doc.docID);
				bool success = false;
				try
				{
					doc.Finish();
					nextWriteDocID++;
					Enclosing_Instance.numDocsInStore++;
					nextWriteLoc++;
					System.Diagnostics.Debug.Assert(nextWriteLoc <= waiting.Length);
					if (nextWriteLoc == waiting.Length)
						nextWriteLoc = 0;
					success = true;
				}
				finally
				{
					if (!success)
						Enclosing_Instance.SetAborting();
				}
			}
예제 #34
0
		/// <summary>Does the synchronized work to finish/flush the
		/// inverted document. 
		/// </summary>
		private void  FinishDocument(DocumentsWriterThreadState perThread, DocWriter docWriter)
		{
			
			if (DoBalanceRAM())
			// Must call this w/o holding synchronized(this) else
			// we'll hit deadlock:
				BalanceRAM();
			
			lock (this)
			{
				
				System.Diagnostics.Debug.Assert(docWriter == null || docWriter.docID == perThread.docState.docID);
				
				if (aborting)
				{
					
					// We are currently aborting, and another thread is
					// waiting for me to become idle.  We just forcefully
					// idle this threadState; it will be fully reset by
					// abort()
					if (docWriter != null)
						try
						{
							docWriter.Abort();
						}
						catch (System.Exception)
						{
						}
					
					perThread.isIdle = true;
					System.Threading.Monitor.PulseAll(this);
					return ;
				}
				
				bool doPause;
				
				if (docWriter != null)
					doPause = waitQueue.Add(docWriter);
				else
				{
					skipDocWriter.docID = perThread.docState.docID;
					doPause = waitQueue.Add(skipDocWriter);
				}
				
				if (doPause)
					WaitForWaitQueue();
				
				if (bufferIsFull && !flushPending)
				{
					flushPending = true;
					perThread.doFlushAfter = true;
				}
				
				perThread.isIdle = true;
				System.Threading.Monitor.PulseAll(this);
			}
		}