Package org.apache.poi.hpsf

Examples of org.apache.poi.hpsf.DocumentSummaryInformation


        final int ID_2 = 3;
        final String NAME_1 = "Schl\u00fcssel \u00e4";
        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(new Long(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(new Long(ID_2), NAME_1);
        s.setDictionary(dictionary);
        cps = dsi.getCustomProperties();
        assertEquals(1, cps.size());
        assertFalse(cps.isPure());
    }
View Full Code Here


        /* Handling the document summary information is analogous to handling
         * the summary information. An additional feature, however, are the
         * custom properties. */

        /* Read the document summary information. */
        DocumentSummaryInformation dsi;
        try
        {
            DocumentEntry dsiEntry = (DocumentEntry)
                dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            DocumentInputStream dis = new DocumentInputStream(dsiEntry);
            PropertySet ps = new PropertySet(dis);
            dis.close();
            dsi = new DocumentSummaryInformation(ps);
        }
        catch (FileNotFoundException ex)
        {
            /* There is no document summary information yet. We have to create a
             * new one. */
            dsi = PropertySetFactory.newDocumentSummaryInformation();
        }

        /* Change the category to "POI example". Any former category value will
         * be lost. If there has been no category yet, it will be created. */
        dsi.setCategory("POI example");
        System.out.println("Category changed to " + dsi.getCategory() + ".");

        /* Read the custom properties. If there are no custom properties yet,
         * the application has to create a new CustomProperties object. It will
         * serve as a container for custom properties. */
        CustomProperties customProperties = dsi.getCustomProperties();
        if (customProperties == null)
            customProperties = new CustomProperties();
       
        /* Insert some custom properties into the container. */
        customProperties.put("Key 1", "Value 1");
        customProperties.put("Schl\u00fcssel 2", "Wert 2");
        customProperties.put("Sample Number", new Integer(12345));
        customProperties.put("Sample Boolean", new Boolean(true));
        customProperties.put("Sample Date", new Date());

        /* Read a custom property. */
        Object value = customProperties.get("Sample Number");

        /* Write the custom properties back to the document summary
         * information. */
        dsi.setCustomProperties(customProperties);

        /* Write the summary information and the document summary information
         * to the POI filesystem. */
        si.write(dir, SummaryInformation.DEFAULT_STREAM_NAME);
        dsi.write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);

        /* Write the POI filesystem back to the original file. Please note that
         * in production code you should never write directly to the origin
         * file! In case of a writing error everything would be lost. */
        OutputStream out = new FileOutputStream(poiFilesystem);
View Full Code Here

             */
            if (dsiEntry != null)
            {
                final DocumentInputStream dis = new DocumentInputStream(dsiEntry);
                final PropertySet ps = new PropertySet(dis);
                final DocumentSummaryInformation dsi = new DocumentSummaryInformation(ps);
               
                /* Execute the get... methods. */
                dsi.getByteCount();
                dsi.getByteOrder();
                dsi.getCategory();
                dsi.getCompany();
                dsi.getCustomProperties();
                // FIXME dsi.getDocparts();
                // FIXME dsi.getHeadingPair();
                dsi.getHiddenCount();
                dsi.getLineCount();
                dsi.getLinksDirty();
                dsi.getManager();
                dsi.getMMClipCount();
                dsi.getNoteCount();
                dsi.getParCount();
                dsi.getPresentationFormat();
                dsi.getScale();
                dsi.getSlideCount();
            }
        }
    }
View Full Code Here

      writePropertySet(SummaryInformation.DEFAULT_STREAM_NAME, si, outFS);
      if(writtenEntries != null) {
        writtenEntries.add(SummaryInformation.DEFAULT_STREAM_NAME);
      }
    }
        DocumentSummaryInformation dsi = getDocumentSummaryInformation();
        if(dsi != null) {
      writePropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME, dsi, outFS);
      if(writtenEntries != null) {
        writtenEntries.add(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
      }
View Full Code Here

        /* Handling the document summary information is analogous to handling
         * the summary information. An additional feature, however, are the
         * custom properties. */

        /* Read the document summary information. */
        DocumentSummaryInformation dsi;
        try
        {
            DocumentEntry dsiEntry = (DocumentEntry)
                dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            DocumentInputStream dis = new DocumentInputStream(dsiEntry);
            PropertySet ps = new PropertySet(dis);
            dis.close();
            dsi = new DocumentSummaryInformation(ps);
        }
        catch (FileNotFoundException ex)
        {
            /* There is no document summary information yet. We have to create a
             * new one. */
            dsi = PropertySetFactory.newDocumentSummaryInformation();
        }

        /* Change the category to "POI example". Any former category value will
         * be lost. If there has been no category yet, it will be created. */
        dsi.setCategory("POI example");
        System.out.println("Category changed to " + dsi.getCategory() + ".");

        /* Read the custom properties. If there are no custom properties yet,
         * the application has to create a new CustomProperties object. It will
         * serve as a container for custom properties. */
        CustomProperties customProperties = dsi.getCustomProperties();
        if (customProperties == null)
            customProperties = new CustomProperties();
       
        /* Insert some custom properties into the container. */
        customProperties.put("Key 1", "Value 1");
        customProperties.put("Schl\u00fcssel 2", "Wert 2");
        customProperties.put("Sample Number", new Integer(12345));
        customProperties.put("Sample Boolean", new Boolean(true));
        customProperties.put("Sample Date", new Date());

        /* Read a custom property. */
        Object value = customProperties.get("Sample Number");

        /* Write the custom properties back to the document summary
         * information. */
        dsi.setCustomProperties(customProperties);

        /* Write the summary information and the document summary information
         * to the POI filesystem. */
        si.write(dir, SummaryInformation.DEFAULT_STREAM_NAME);
        dsi.write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);

        /* Write the POI filesystem back to the original file. Please note that
         * in production code you should never write directly to the origin
         * file! In case of a writing error everything would be lost. */
        OutputStream out = new FileOutputStream(poiFilesystem);
View Full Code Here

         DocumentEntry dsiEntry = (DocumentEntry)
             dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
         DocumentInputStream dis = new DocumentInputStream(dsiEntry);
         PropertySet ps = new PropertySet(dis);
         dis.close();
         dsi = new DocumentSummaryInformation(ps);
      
        
     }
     catch (FileNotFoundException ex)
     {
View Full Code Here

           DocumentEntry dsiEntry = (DocumentEntry)
               dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
           DocumentInputStream dis = new DocumentInputStream(dsiEntry);
           PropertySet ps = new PropertySet(dis);
           dis.close();
           dsi = new DocumentSummaryInformation(ps);
       }
       catch (FileNotFoundException ex)
       {
           fail();
       } catch (IOException e) {
View Full Code Here

  public HPSFPropertiesExtractor(POIFSFileSystem fs) {
    super(new PropertiesOnlyDocument(fs));
  }

  public String getDocumentSummaryInformationText() {
    DocumentSummaryInformation dsi = document.getDocumentSummaryInformation();
    StringBuffer text = new StringBuffer();

    // Normal properties
    text.append( getPropertiesText(dsi) );

    // Now custom ones
    CustomProperties cps = dsi == null ? null : dsi.getCustomProperties();
    if(cps != null) {
      Iterator keys = cps.keySet().iterator();
      while(keys.hasNext()) {
        String key = (String)keys.next();
        String val = getPropertyValueText( cps.get(key) );
View Full Code Here

        /* Handling the document summary information is analogous to handling
         * the summary information. An additional feature, however, are the
         * custom properties. */

        /* Read the document summary information. */
        DocumentSummaryInformation dsi;
        try
        {
            DocumentEntry dsiEntry = (DocumentEntry)
                dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            DocumentInputStream dis = new DocumentInputStream(dsiEntry);
            PropertySet ps = new PropertySet(dis);
            dis.close();
            dsi = new DocumentSummaryInformation(ps);
        }
        catch (FileNotFoundException ex)
        {
            /* There is no document summary information yet. We have to create a
             * new one. */
            dsi = PropertySetFactory.newDocumentSummaryInformation();
        }

        /* Change the category to "POI example". Any former category value will
         * be lost. If there has been no category yet, it will be created. */
        dsi.setCategory("POI example");
        System.out.println("Category changed to " + dsi.getCategory() + ".");

        /* Read the custom properties. If there are no custom properties yet,
         * the application has to create a new CustomProperties object. It will
         * serve as a container for custom properties. */
        CustomProperties customProperties = dsi.getCustomProperties();
        if (customProperties == null)
            customProperties = new CustomProperties();
       
        /* Insert some custom properties into the container. */
        customProperties.put("Key 1", "Value 1");
        customProperties.put("Schl�ssel 2", "Wert 2");
        customProperties.put("Sample Number", new Integer(12345));
        customProperties.put("Sample Boolean", new Boolean(true));
        customProperties.put("Sample Date", new Date());

        /* Read a custom property. */
        Object value = customProperties.get("Sample Number");

        /* Write the custom properties back to the document summary
         * information. */
        dsi.setCustomProperties(customProperties);

        /* Write the summary information and the document summary information
         * to the POI filesystem. */
        si.write(dir, SummaryInformation.DEFAULT_STREAM_NAME);
        dsi.write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);

        /* Write the POI filesystem back to the original file. Please note that
         * in production code you should never write directly to the origin
         * file! In case of a writing error everything would be lost. */
        OutputStream out = new FileOutputStream(poiFilesystem);
View Full Code Here

                new PropertySet(new DocumentInputStream(entry));
            if (properties.isSummaryInformation()) {
                parse(new SummaryInformation(properties), metadata);
            }
            if (properties.isDocumentSummaryInformation()) {
                parse(new DocumentSummaryInformation(properties), metadata);
            }
        } catch (NoPropertySetStreamException e) {
            throw new TikaException("Not a HPSF document", e);
        } catch (UnexpectedPropertySetTypeException e) {
            throw new TikaException("Unexpected HPSF document", e);
View Full Code Here

TOP

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

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.