/// <summary>
        /// Writes the property Set To an output stream.
        /// </summary>
        /// <param name="out1">the output stream To Write the section To</param>
        public virtual void Write(Stream out1)
        {
            /* Write the number of sections in this property Set stream. */
            int nrSections = sections.Count;
            int length = 0;

            /* Write the property Set's header. */
            length += TypeWriter.WriteToStream(out1, (short)ByteOrder);
            length += TypeWriter.WriteToStream(out1, (short)Format);
            length += TypeWriter.WriteToStream(out1, OSVersion);
            length += TypeWriter.WriteToStream(out1, ClassID);
            length += TypeWriter.WriteToStream(out1, nrSections);
            int offset = OFFSet_HEADER;

            /* Write the section list, i.e. the references To the sections. Each
             * entry in the section list consist of the section's class ID and the
             * section's offset relative To the beginning of the stream. */
            offset += nrSections * (ClassID.Length + LittleEndianConstants.INT_SIZE);
            int sectionsBegin = offset;
            for (IEnumerator i = sections.GetEnumerator(); i.MoveNext(); )
            {
                MutableSection s = (MutableSection)i.Current;
                ClassID formatID = s.FormatID;
                if (formatID == null)
                    throw new NoFormatIDException();
                length += TypeWriter.WriteToStream(out1, s.FormatID);
                length += TypeWriter.WriteUIntToStream(out1, (uint)offset);

                offset += s.Size;

            }

            /* Write the sections themselves. */
            offset = sectionsBegin;
            for (IEnumerator i = sections.GetEnumerator(); i.MoveNext(); )
            {
                MutableSection s = (MutableSection)i.Current;
                offset += s.Write(out1);
            }
        }
예제 #2
0
        /// <summary>
        /// Removes the heading pair.
        /// </summary>
        public void RemoveHeadingPair()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_HEADINGPAIR);
        }
예제 #3
0
        /// <summary>
        /// Removes the MMClip count.
        /// </summary>
        public void RemoveMMClipCount()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_MMCLIPCOUNT);
        }
예제 #4
0
        /// <summary>
        /// Removes the note count.
        /// </summary>
        public void RemoveNoteCount()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_NOTECOUNT);
        }
예제 #5
0
        /// <summary>
        /// Removes the par count.
        /// </summary>
        public void RemoveParCount()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_PARCOUNT);
        }
예제 #6
0
        /**
         * Removes the document version string
         */
        public void RemoveDocumentVersion()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_DOCVERSION);
        }
예제 #7
0
        /**
         * Removes the content status of the file
         */
        public void RemoveContentStatus()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_CONTENTSTATUS);
        }
예제 #8
0
        /// <summary>
        /// Removes the last printed.
        /// </summary>
        public void RemoveLastPrinted()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_LASTPRINTED);
        }
예제 #9
0
        /// <summary>
        /// Removes the title.
        /// </summary>
        public void RemoveTitle()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_TITLE);
        }
예제 #10
0
        /// <summary>
        /// Removes the security code.
        /// </summary>
        public void RemoveSecurity()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_SECURITY);
        }
예제 #11
0
        /// <summary>
        /// Removes the name of the application.
        /// </summary>
        public void RemoveApplicationName()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_APPNAME);
        }
예제 #12
0
        /// <summary>
        /// Removes the thumbnail.
        /// </summary>
        public void RemoveThumbnail()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_THUMBNAIL);
        }
예제 #13
0
        /// <summary>
        /// Removes the word count.
        /// </summary>
        public void RemoveWordCount()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_WORDCOUNT);
        }
예제 #14
0
        /// <summary>
        /// Removes the last save date time.
        /// </summary>
        public void RemoveLastSaveDateTime()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_LASTSAVE_DTM);
        }
예제 #15
0
        /// <summary>
        /// Removes the create date time.
        /// </summary>
        public void RemoveCreateDateTime()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_Create_DTM);
        }
예제 #16
0
        /// <summary>
        /// Removes the manager.
        /// </summary>
        public void RemoveManager()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_MANAGER);
        }
예제 #17
0
        /// <summary>
        /// Removes the links dirty.
        /// </summary>
        public void RemoveLinksDirty()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_LINKSDIRTY);
        }
예제 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MutablePropertySet"/> class.
 /// All nested elements, i.e.<c>Section</c>s and <c>Property</c> instances, will be their
 /// mutable counterparts in the new <c>MutablePropertySet</c>.
 /// </summary>
 /// <param name="ps">The property Set To copy</param>
 public MutablePropertySet(PropertySet ps)
 {
     byteOrder = ps.ByteOrder;
     format = ps.Format;
     osVersion = ps.OSVersion;
     ClassID=ps.ClassID;
     ClearSections();
     if (sections == null)
         sections = new List<Section>();
     foreach (Section section in ps.Sections)
     {
         MutableSection s = new MutableSection(section);
         AddSection(s);
     }
 }
예제 #19
0
        /**
         * Removes the content type of the file
         */
        public void RemoveContentType()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_CONTENTTYPE);
        }
예제 #20
0
파일: TestWrite.cs 프로젝트: xoposhiy/npoi
        public void TestWriteSimplePropertySet()
        {
            String AUTHOR = "Rainer Klute";
            String TITLE = "Test Document";

            FileInfo fi = TempFile.CreateTempFile(POI_FS, ".doc");
            FileStream file = new FileStream(fi.FullName, FileMode.Open, FileAccess.ReadWrite);

            FileStream out1 = file;
            POIFSFileSystem poiFs = new POIFSFileSystem();

            MutablePropertySet ps = new MutablePropertySet();
            MutableSection si = new MutableSection();
            si.SetFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
            ps.Sections[0] = si;

            MutableProperty p = new MutableProperty();
            p.ID = PropertyIDMap.PID_AUTHOR;
            p.Type = Variant.VT_LPWSTR;
            p.Value = AUTHOR;
            si.SetProperty(p);
            si.SetProperty(PropertyIDMap.PID_TITLE, Variant.VT_LPSTR, TITLE);

            poiFs.CreateDocument(ps.GetStream(),
                                 SummaryInformation.DEFAULT_STREAM_NAME);
            poiFs.WriteFileSystem(out1);
            //out1.Close();
            file.Position = 0;

            POIFSReader reader1 = new POIFSReader();
            //reader1.StreamReaded += new POIFSReaderEventHandler(reader1_StreamReaded);
            POIFSReaderListener1 psl = new POIFSReaderListener1();
            reader1.RegisterListener(psl);
            reader1.Read(file);
            Assert.IsNotNull(psa[0]);
            Assert.IsTrue(psa[0].IsSummaryInformation);

            Section s = (Section)(psa[0].Sections[0]);
            Object p1 = s.GetProperty(PropertyIDMap.PID_AUTHOR);
            Object p2 = s.GetProperty(PropertyIDMap.PID_TITLE);
            Assert.AreEqual(AUTHOR, p1);
            Assert.AreEqual(TITLE, p2);
            file.Close();
            try
            {
                File.Delete(fi.FullName);
            }
            catch
            {
            }
        }
예제 #21
0
        /**
         * Removes the document language
         */
        public void RemoveLanguage()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_LANGUAGE);
        }
예제 #22
0
파일: TestWrite.cs 프로젝트: xoposhiy/npoi
        public void TestWriteTwoSections()
        {
            String STREAM_NAME = "PropertySetStream";
            String SECTION1 = "Section 1";
            String SECTION2 = "Section 2";

            FileInfo fi = TempFile.CreateTempFile(POI_FS, ".doc");
            FileStream file = new FileStream(fi.FullName, FileMode.Open, FileAccess.ReadWrite);
            //filename.deleteOnExit();
            FileStream out1 = file;

            POIFSFileSystem poiFs = new POIFSFileSystem();
            MutablePropertySet ps = new MutablePropertySet();
            ps.ClearSections();

            ClassID formatID = new ClassID();
            formatID.Bytes = new byte[]{0, 1,  2,  3,  4,  5,  6,  7,
                                     8, 9, 10, 11, 12, 13, 14, 15};
            MutableSection s1 = new MutableSection();
            s1.SetFormatID(formatID);
            s1.SetProperty(2, SECTION1);
            ps.AddSection(s1);

            MutableSection s2 = new MutableSection();
            s2.SetFormatID(formatID);
            s2.SetProperty(2, SECTION2);
            ps.AddSection(s2);

            poiFs.CreateDocument(ps.GetStream(), STREAM_NAME);
            poiFs.WriteFileSystem(out1);
            //out1.Close();

            /* Read the POIFS: */
            psa = new PropertySet[1];
            POIFSReader reader2 = new POIFSReader();
            //reader2.StreamReaded += new POIFSReaderEventHandler(reader2_StreamReaded);
            POIFSReaderListener2 prl = new POIFSReaderListener2();
            reader2.RegisterListener(prl);
            reader2.Read(file);
            Assert.IsNotNull(psa[0]);
            Section s = (Section)(psa[0].Sections[0]);
            Assert.AreEqual(s.FormatID, formatID);
            Object p = s.GetProperty(2);
            Assert.AreEqual(SECTION1, p);
            s = (Section)(psa[0].Sections[1]);
            p = s.GetProperty(2);
            Assert.AreEqual(SECTION2, p);

            file.Close();
            //File.Delete(dataDir + POI_FS);
            try
            {
                File.Delete(fi.FullName);
            }
            catch
            {
            }
        }
예제 #23
0
        /// <summary>
        /// Removes the presentation format.
        /// </summary>
        public void RemovePresentationFormat()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_PRESFORMAT);
        }
예제 #24
0
        public void TestGetCustomerProperties()
        {
            long ID_1 = 2;
            long ID_2 = 3;
            String NAME_1 = "Schlüssel";
            String VALUE_1 = "Wert 1";
            Hashtable dictionary = new Hashtable();

            DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
            CustomProperties cps;
            MutableSection s;

            /* A document summary information Set stream by default does have custom properties. */
            cps = dsi.CustomProperties;
            Assert.AreEqual(null, cps);

            /* Test an empty custom properties Set. */
            s = new MutableSection();
            s.SetFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID2);
            // s.SetCodepage(Constants.CP_UNICODE);
            dsi.AddSection(s);
            cps = dsi.CustomProperties;
            Assert.AreEqual(0, cps.Count);

            /* Add a custom property. */
            MutableProperty p = new MutableProperty();
            p.ID=ID_1;
            p.Type=Variant.VT_LPWSTR;
            p.Value=VALUE_1;
            s.SetProperty(p);
            dictionary[ID_1]=NAME_1;
            s.Dictionary=(dictionary);
            cps = dsi.CustomProperties;
            Assert.AreEqual(1, cps.Count);
            Assert.IsTrue(cps.IsPure);

            /* Add another custom property. */
            s.SetProperty((int)ID_2, Variant.VT_LPWSTR, VALUE_1);
            dictionary[ID_2]=NAME_1;
            s.Dictionary=(dictionary);
            cps = dsi.CustomProperties;
            Assert.AreEqual(1, cps.Count);
            Assert.IsFalse(cps.IsPure);
        }
예제 #25
0
        /// <summary>
        /// Removes the slide count.
        /// </summary>
        public void RemoveSlideCount()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_SLIDECOUNT);
        }
예제 #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MutablePropertySet"/> class.
 /// All nested elements, i.e.<c>Section</c>s and <c>Property</c> instances, will be their
 /// mutable counterparts in the new <c>MutablePropertySet</c>.
 /// </summary>
 /// <param name="ps">The property Set To copy</param>
 public MutablePropertySet(PropertySet ps)
 {
     byteOrder = ps.ByteOrder;
     format = ps.Format;
     osVersion = ps.OSVersion;
     ClassID=ps.ClassID;
     ClearSections();
     if (sections == null)
         sections = new List<Section>();
     for (IEnumerator i = ps.Sections.GetEnumerator(); i.MoveNext(); )
     {
         MutableSection s = new MutableSection((Section)(i.Current));
         AddSection(s);
     }
 }
예제 #27
0
        /// <summary>
        /// Removes the hidden count.
        /// </summary>
        public void RemoveHiddenCount()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_HIDDENCOUNT);
        }
예제 #28
0
 /// <summary>
 /// Creates section 2 if it is not alReady present.
 /// </summary>
 private void EnsureSection2()
 {
     if (SectionCount < 2)
     {
         MutableSection s2 = new MutableSection();
         s2.SetFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID2);
         AddSection(s2);
     }
 }
예제 #29
0
        /// <summary>
        /// Removes the scale.
        /// </summary>
        public void RemoveScale()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_SCALE);
        }
예제 #30
0
        /**
         * Removes the character count
         */
        public void RemoveCharCountWithSpaces()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_CCHWITHSPACES);
        }
예제 #31
0
        /// <summary>
        /// Removes the doc parts.
        /// </summary>
        public void RemoveDocparts()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_DOCPARTS);
        }
예제 #32
0
        /**
         * Removes the flag for if the User Defined Property Set has been updated
         *  outside of the Application.
         */
        public void RemoveHyperlinksChanged()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_HYPERLINKSCHANGED);
        }
예제 #33
0
        /// <summary>
        /// Removes the company.
        /// </summary>
        public void RemoveCompany()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_COMPANY);
        }
예제 #34
0
        /**
         * Removes the Application Version
         */
        public void RemoveApplicationVersion()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_VERSION);
        }
예제 #35
0
        /// <summary>
        /// Removes the category.
        /// </summary>
        public void RemoveCategory()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_CATEGORY);
        }
예제 #36
0
        /**
         * Removes the VBA Digital Signature
         */
        public void RemoveVBADigitalSignature()
        {
            MutableSection s = (MutableSection)FirstSection;

            s.RemoveProperty(PropertyIDMap.PID_DIGSIG);
        }