Package org.apache.poi.hmef.attribute

Examples of org.apache.poi.hmef.attribute.MAPIRtfAttribute


            throw new ChunkNotFoundException();
         }
      }
     
      try {
         MAPIRtfAttribute rtf = new MAPIRtfAttribute(
               MAPIProperty.RTF_COMPRESSED, Types.BINARY, chunk.getValue()
         );
         return rtf.getDataString();
      } catch(IOException e) {
         throw new RuntimeException("Shouldn't happen", e);
      }
   }
View Full Code Here


            throw new ChunkNotFoundException();
         }
      }
     
      try {
         MAPIRtfAttribute rtf = new MAPIRtfAttribute(
               MAPIProperty.RTF_COMPRESSED, Types.BINARY, chunk.getValue()
         );
         return rtf.getDataString();
      } catch(IOException e) {
         throw new RuntimeException("Shouldn't happen", e);
      }
   }
View Full Code Here

      HMEFMessage msg = new HMEFMessage(
            _samples.openResourceAsStream("quick-winmail.dat")
      );
     
      // Firstly by byte
      MAPIRtfAttribute rtf = (MAPIRtfAttribute)
         msg.getMessageMAPIAttribute(MAPIProperty.RTF_COMPRESSED);
      assertContents("message.rtf", rtf.getData());
     
      // Then by String
      String contents = msg.getBody();
      // It's all low bytes
      byte[] contentsBytes = contents.getBytes("ASCII");
View Full Code Here

   public void testMessageSample1() throws Exception {
    HMEFMessage msg = new HMEFMessage(
        _samples.openResourceAsStream("winmail-sample1.dat"));

    // Firstly by byte
    MAPIRtfAttribute rtf = (MAPIRtfAttribute) msg
        .getMessageMAPIAttribute(MAPIProperty.RTF_COMPRESSED);
    // assertContents("message.rtf", rtf.getData());
    assertNotNull(rtf);

    // Then by String
View Full Code Here

             _samples.openResourceAsStream("quick-winmail.dat")
       );
      
       MAPIAttribute attr = msg.getMessageMAPIAttribute(MAPIProperty.RTF_COMPRESSED);
       assertNotNull(attr);
       MAPIRtfAttribute rtfAttr = (MAPIRtfAttribute)attr;

       // Truncate to header + flag + data for flag
       byte[] data = new byte[16+12];
       System.arraycopy(rtfAttr.getRawData(), 0, data, 0, data.length);
      
       // Decompress it
       CompressedRTF comp = new CompressedRTF();
       byte[] decomp = comp.decompress(new ByteArrayInputStream(data));
       String decompStr = new String(decomp, "ASCII");
View Full Code Here

             _samples.openResourceAsStream("quick-winmail.dat")
       );

       MAPIAttribute attr = msg.getMessageMAPIAttribute(MAPIProperty.RTF_COMPRESSED);
       assertNotNull(attr);
       MAPIRtfAttribute rtfAttr = (MAPIRtfAttribute)attr;

       // Truncate to header + flag + data for flag + flag + data
       byte[] data = new byte[16+12+13];
       System.arraycopy(rtfAttr.getRawData(), 0, data, 0, data.length);
      
       // Decompress it
       CompressedRTF comp = new CompressedRTF();
       byte[] decomp = comp.decompress(new ByteArrayInputStream(data));
       String decompStr = new String(decomp, "ASCII");
View Full Code Here

             _samples.openResourceAsStream("quick-winmail.dat")
       );
      
       MAPIAttribute attr = msg.getMessageMAPIAttribute(MAPIProperty.RTF_COMPRESSED);
       assertNotNull(attr);
       MAPIRtfAttribute rtfAttr = (MAPIRtfAttribute)attr;
      
       InputStream stream = _samples.openResourceAsStream("quick-contents/message.rtf");
       try {
           byte[] expected = IOUtils.toByteArray(stream);
          
           CompressedRTF comp = new CompressedRTF();
           byte[] data = rtfAttr.getRawData();
           byte[] decomp = comp.decompress(new ByteArrayInputStream(data));
          
           // Check the length was as expected
           assertEquals(data.length, comp.getCompressedSize() + 16);
           assertEquals(expected.length, comp.getDeCompressedSize());
          
           // Will have been padded though
           assertEquals(expected.length+2, decomp.length);
           byte[] tmp = new byte[expected.length];
           System.arraycopy(decomp, 0, tmp, 0, tmp.length);
           decomp = tmp;
          
           // By byte
           assertEquals(expected.length, decomp.length);
           for(int i=0; i<expected.length; i++) {
               assertEquals(expected[i], decomp[i]);
           }
          
           // By String
           String expString = new String(expected, "ASCII");
           String decompStr = rtfAttr.getDataString();
           assertEquals(expString.length(), decompStr.length());
           assertEquals(expString, decompStr);
       } finally {
           stream.close();
       }
View Full Code Here

                 doneBody = true;
              }
           }
           if(rtfChunk != null && !doneBody) {
              ByteChunk chunk = (ByteChunk)rtfChunk;
              MAPIRtfAttribute rtf = new MAPIRtfAttribute(
                    MAPIProperty.RTF_COMPRESSED, Types.BINARY, chunk.getValue()
              );
              RTFParser rtfParser = new RTFParser();
              rtfParser.parse(
                              new ByteArrayInputStream(rtf.getData()),
                              new EmbeddedContentHandler(new BodyContentHandler(xhtml)),
                              new Metadata(), new ParseContext());
              doneBody = true;
           }
           if(textChunk != null && !doneBody) {
View Full Code Here

            throw new ChunkNotFoundException();
         }
      }
     
      try {
         MAPIRtfAttribute rtf = new MAPIRtfAttribute(
               MAPIProperty.RTF_COMPRESSED, Types.BINARY, chunk.getValue()
         );
         return rtf.getDataString();
      } catch(IOException e) {
         throw new RuntimeException("Shouldn't happen", e);
      }
   }
View Full Code Here

            throw new ChunkNotFoundException();
         }
      }
     
      try {
         MAPIRtfAttribute rtf = new MAPIRtfAttribute(
               MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue()
         );
         return rtf.getDataString();
      } catch(IOException e) {
         throw new RuntimeException("Shouldn't happen", e);
      }
   }
View Full Code Here

TOP

Related Classes of org.apache.poi.hmef.attribute.MAPIRtfAttribute

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.