Exemplo n.º 1
0
        public Relationship AddImageToTree(Stream data, ImageHash hash, string extension, string relationshipType, string locationHint, string parentLocation)
        {
            bool         newBlob;
            Relationship relationship = _relationshipTree.AddImageToTree(hash, extension, relationshipType, locationHint, parentLocation, ContentTypeAction.Default, out newBlob);

            if (newBlob)
            {
                Stream stream = _zipPackage.GetPart(new Uri(WordOpenXmlUtils.CleanName(relationship.RelatedPart), UriKind.Relative)).GetStream();
                WordOpenXmlUtils.CopyStream(data, stream);
            }
            return(relationship);
        }
Exemplo n.º 2
0
        public Relationship AddImageToTree(Stream data, ImageHash hash, string extension, string relationshipType, string locationHint, string parentLocation)
        {
            bool         flag         = default(bool);
            Relationship relationship = this._relationshipTree.AddImageToTree(hash, extension, relationshipType, locationHint, parentLocation, ContentTypeAction.Default, out flag);

            if (flag)
            {
                Package     zipPackage = this._zipPackage;
                PackagePart part       = zipPackage.GetPart(new Uri(WordOpenXmlUtils.CleanName(relationship.RelatedPart), UriKind.Relative));
                Stream      stream     = part.GetStream();
                WordOpenXmlUtils.CopyStream(data, stream);
            }
            return(relationship);
        }
        public void Interleave(Stream output, FinalWriteInterleaver writeInterleaver)
        {
            _textWriter.Flush();
            StoreInterleaver();
            _stream.Seek(0L, SeekOrigin.Begin);
            long num = 0L;

            foreach (IInterleave item in _interleavingContent)
            {
                WordOpenXmlUtils.CopyStream(_stream, output, item.Location - num);
                num = item.Location;
                StringBuilder stringBuilder = new StringBuilder();
                using (StringWriter output2 = new StringWriter(stringBuilder, CultureInfo.InvariantCulture))
                {
                    writeInterleaver(item, output2);
                }
                byte[] bytes = _textWriter.Encoding.GetBytes(stringBuilder.ToString());
                output.Write(bytes, 0, bytes.Length);
            }
            WordOpenXmlUtils.CopyStream(_stream, output, _stream.Length - num);
        }