Package org.apache.poi.hpsf

Examples of org.apache.poi.hpsf.MutableSection


            /* Write: */
            final OutputStream out = new FileOutputStream(copy);
            final POIFSFileSystem poiFs = new POIFSFileSystem();
            final MutablePropertySet ps1 = new MutablePropertySet();
            final MutableSection s = (MutableSection) ps1.getSections().get(0);
            final Map m = new HashMap(3, 1.0f);
            m.put(new Long(1), "String 1");
            m.put(new Long(2), "String 2");
            m.put(new Long(3), "String 3");
            s.setDictionary(m);
            s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[0]);
            int codepage = 12345;
            s.setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2,
                          new Integer(codepage));
            poiFs.createDocument(ps1.toInputStream(), "Test");
            poiFs.writeFilesystem(out);
            out.close();
            fail("This testcase did not detect the invalid codepage value.");
View Full Code Here


         * formatID set: */
        final OutputStream out = new FileOutputStream(filename);
        final POIFSFileSystem poiFs = new POIFSFileSystem();
        final MutablePropertySet ps = new MutablePropertySet();
        ps.clearSections();
        ps.addSection(new MutableSection());

        /* Write it to a POIFS and the latter to disk: */
        try
        {
            final ByteArrayOutputStream psStream = new ByteArrayOutputStream();
View Full Code Here

        /* Create a mutable property set and write it to a POIFS: */
        final OutputStream out = new FileOutputStream(filename);
        final POIFSFileSystem poiFs = new POIFSFileSystem();
        final MutablePropertySet ps = new MutablePropertySet();
        final MutableSection s = (MutableSection) ps.getSections().get(0);
        s.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);

        final ByteArrayOutputStream psStream = new ByteArrayOutputStream();
        ps.write(psStream);
        psStream.close();
        final byte[] streamData = psStream.toByteArray();
View Full Code Here

        filename.deleteOnExit();
        final OutputStream out = new FileOutputStream(filename);
        final POIFSFileSystem poiFs = new POIFSFileSystem();

        final MutablePropertySet ps = new MutablePropertySet();
        final MutableSection si = new MutableSection();
        si.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
        ps.getSections().set(0, si);

        final MutableProperty p = new MutableProperty();
        p.setID(PropertyIDMap.PID_AUTHOR);
        p.setType(Variant.VT_LPWSTR);
        p.setValue(AUTHOR);
        si.setProperty(p);
        si.setProperty(PropertyIDMap.PID_TITLE, Variant.VT_LPSTR, TITLE);

        poiFs.createDocument(ps.toInputStream(),
                             SummaryInformation.DEFAULT_STREAM_NAME);
        poiFs.writeFilesystem(out);
        out.close();
View Full Code Here

        ps.clearSections();

        final ClassID formatID = new ClassID();
        formatID.setBytes(new byte[]{0, 1234567,
                                     8, 9, 10, 11, 12, 13, 14, 15});
        final MutableSection s1 = new MutableSection();
        s1.setFormatID(formatID);
        s1.setProperty(2, SECTION1);
        ps.addSection(s1);

        final MutableSection s2 = new MutableSection();
        s2.setFormatID(formatID);
        s2.setProperty(2, SECTION2);
        ps.addSection(s2);

        poiFs.createDocument(ps.toInputStream(), STREAM_NAME);
        poiFs.writeFilesystem(out);
        out.close();
View Full Code Here

     */
    public void testUnicodeWrite8Bit()
    {
        final String TITLE = "This is a sample title";
        final MutablePropertySet mps = new MutablePropertySet();
        final MutableSection ms = (MutableSection) mps.getSections().get(0);
        ms.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
        final MutableProperty p = new MutableProperty();
        p.setID(PropertyIDMap.PID_TITLE);
        p.setType(Variant.VT_LPSTR);
        p.setValue(TITLE);
        ms.setProperty(p);

        Throwable t = null;
        try
        {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

            /* Write: */
            final OutputStream out = new FileOutputStream(copy);
            final POIFSFileSystem poiFs = new POIFSFileSystem();
            final MutablePropertySet ps1 = new MutablePropertySet();
            final MutableSection s = (MutableSection) ps1.getSections().get(0);
            final Map m = new HashMap(3, 1.0f);
            m.put(Long.valueOf(1), "String 1");
            m.put(Long.valueOf(2), "String 2");
            m.put(Long.valueOf(3), "String 3");
            s.setDictionary(m);
            s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[0]);
            int codepage = Constants.CP_UNICODE;
            s.setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2,
                          Integer.valueOf(codepage));
            poiFs.createDocument(ps1.toInputStream(), "Test");
            poiFs.writeFilesystem(out);
            out.close();

View Full Code Here

            /* Write: */
            final OutputStream out = new FileOutputStream(copy);
            final POIFSFileSystem poiFs = new POIFSFileSystem();
            final MutablePropertySet ps1 = new MutablePropertySet();
            final MutableSection s = (MutableSection) ps1.getSections().get(0);
            final Map m = new HashMap(3, 1.0f);
            m.put(Long.valueOf(1), "String 1");
            m.put(Long.valueOf(2), "String 2");
            m.put(Long.valueOf(3), "String 3");
            s.setDictionary(m);
            s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[0]);
            int codepage = 12345;
            s.setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2,
                          Integer.valueOf(codepage));
            poiFs.createDocument(ps1.toInputStream(), "Test");
            poiFs.writeFilesystem(out);
            out.close();
            fail("This testcase did not detect the invalid codepage value.");
View Full Code Here

        final String VALUE_1 = "Wert 1";
        final Map dictionary = new HashMap();

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

        /* A document summary information set stream by default does have custom properties. */
        cps = dsi.getCustomProperties();
        assertEquals(null, cps);

        /* Test an empty custom properties set. */
        s = new MutableSection();
        s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[1]);
        // s.setCodepage(Constants.CP_UNICODE);
        dsi.addSection(s);
        cps = dsi.getCustomProperties();
        assertEquals(0, cps.size());

        /* Add a custom property. */
        MutableProperty p = new MutableProperty();
        p.setID(ID_1);
        p.setType(Variant.VT_LPWSTR);
        p.setValue(VALUE_1);
        s.setProperty(p);
        dictionary.put(Long.valueOf(ID_1), NAME_1);
        s.setDictionary(dictionary);
        cps = dsi.getCustomProperties();
        assertEquals(1, cps.size());
        assertTrue(cps.isPure());

        /* Add another custom property. */
        s.setProperty(ID_2, Variant.VT_LPWSTR, VALUE_1);
        dictionary.put(Long.valueOf(ID_2), NAME_1);
        s.setDictionary(dictionary);
        cps = dsi.getCustomProperties();
        assertEquals(1, cps.size());
        assertFalse(cps.isPure());
    }
View Full Code Here

         * formatID set: */
        final OutputStream out = new FileOutputStream(filename);
        final POIFSFileSystem poiFs = new POIFSFileSystem();
        final MutablePropertySet ps = new MutablePropertySet();
        ps.clearSections();
        ps.addSection(new MutableSection());

        /* Write it to a POIFS and the latter to disk: */
        try
        {
            final ByteArrayOutputStream psStream = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of org.apache.poi.hpsf.MutableSection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.