Package org.apache.poi.hslf.usermodel

Examples of org.apache.poi.hslf.usermodel.ObjectData


      }
     
      for( Shape shape : shapes ) {
         if( shape instanceof OLEShape ) {
            OLEShape oleShape = (OLEShape)shape;
            ObjectData data = null;
            try {
                data = oleShape.getObjectData();
            } catch( NullPointerException e ) {
                /* getObjectData throws NPE some times. */
            }
            if (data != null) {
               String objID = Integer.toString(oleShape.getObjectID());

               // Embedded Object: add a <div
               // class="embedded" id="X"/> so consumer can see where
               // in the main text each embedded document
               // occurred:
               AttributesImpl attributes = new AttributesImpl();
               attributes.addAttribute("", "class", "class", "CDATA", "embedded");
               attributes.addAttribute("", "id", "id", "CDATA", objID);
               xhtml.startElement("div", attributes);
               xhtml.endElement("div");

               TikaInputStream stream =
                    TikaInputStream.get(data.getData());
               try {
                  String mediaType = null;
                  if ("Excel.Chart.8".equals(oleShape.getProgID())) {
                     mediaType = "application/vnd.ms-excel";
                  }
View Full Code Here


        int cnt = 0;
        for (int i = 0; i < sh.length; i++) {
            if(sh[i] instanceof OLEShape){
                cnt++;
                OLEShape ole = (OLEShape)sh[i];
                ObjectData data = ole.getObjectData();
                if("Worksheet".equals(ole.getInstanceName())){
                    //Voila! we created a workbook from the embedded OLE data
                    HSSFWorkbook wb = new HSSFWorkbook(data.getData());
                    HSSFSheet sheet = wb.getSheetAt(0);
                    //verify we can access the xls data
                    assertEquals(1, sheet.getRow(0).getCell(0).getNumericCellValue(), 0);
                    assertEquals(1, sheet.getRow(1).getCell(0).getNumericCellValue(), 0);
                    assertEquals(2, sheet.getRow(2).getCell(0).getNumericCellValue(), 0);
                    assertEquals(3, sheet.getRow(3).getCell(0).getNumericCellValue(), 0);
                    assertEquals(8, sheet.getRow(5).getCell(0).getNumericCellValue(), 0);
                } else if ("Document".equals(ole.getInstanceName())){
                    //creating a HWPF document
                    HWPFDocument doc = new HWPFDocument(data.getData());
                    String txt = doc.getRange().getParagraph(0).text();
                    assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);
                }
            }
View Full Code Here

    public ObjectData[] getEmbeddedObjects() {
        if (_objects == null) {
            List objects = new ArrayList();
            for (int i = 0; i < _records.length; i++) {
                if (_records[i] instanceof ExOleObjStg) {
                    objects.add(new ObjectData((ExOleObjStg) _records[i]));
                }
            }
            _objects = (ObjectData[]) objects.toArray(new ObjectData[objects.size()]);
        }
        return _objects;
View Full Code Here

    public ObjectData[] getEmbeddedObjects() {
        if (_objects == null) {
            List<ObjectData> objects = new ArrayList<ObjectData>();
            for (int i = 0; i < _records.length; i++) {
                if (_records[i] instanceof ExOleObjStg) {
                    objects.add(new ObjectData((ExOleObjStg) _records[i]));
                }
            }
            _objects = objects.toArray(new ObjectData[objects.size()]);
        }
        return _objects;
View Full Code Here

    public ObjectData[] getEmbeddedObjects() {
        if (_objects == null) {
            List<ObjectData> objects = new ArrayList<ObjectData>();
            for (Record r : _records) {
                if (r instanceof ExOleObjStg) {
                    objects.add(new ObjectData((ExOleObjStg)r));
                }
            }
            _objects = objects.toArray(new ObjectData[objects.size()]);
        }
        return _objects;
View Full Code Here

        int cnt = 0;
        for (int i = 0; i < sh.length; i++) {
            if(sh[i] instanceof OLEShape){
                cnt++;
                OLEShape ole = (OLEShape)sh[i];
                ObjectData data = ole.getObjectData();
                if("Worksheet".equals(ole.getInstanceName())){
                    //Voila! we created a workbook from the embedded OLE data
                    HSSFWorkbook wb = new HSSFWorkbook(data.getData());
                    HSSFSheet sheet = wb.getSheetAt(0);
                    //verify we can access the xls data
                    assertEquals(1, sheet.getRow(0).getCell(0).getNumericCellValue(), 0);
                    assertEquals(1, sheet.getRow(1).getCell(0).getNumericCellValue(), 0);
                    assertEquals(2, sheet.getRow(2).getCell(0).getNumericCellValue(), 0);
                    assertEquals(3, sheet.getRow(3).getCell(0).getNumericCellValue(), 0);
                    assertEquals(8, sheet.getRow(5).getCell(0).getNumericCellValue(), 0);
                } else if ("Document".equals(ole.getInstanceName())){
                    //creating a HWPF document
                    HWPFDocument doc = new HWPFDocument(data.getData());
                    String txt = doc.getRange().getParagraph(0).text();
                    assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);
                }
            }
View Full Code Here

        SlideShow ppt = getSheet().getSlideShow();
        ObjectData[] ole = ppt.getEmbeddedObjects();

        //persist reference
        ExEmbed exEmbed = getExEmbed();
        ObjectData data = null;
        if(exEmbed != null) {
            int ref = exEmbed.getExOleObjAtom().getObjStgDataRef();

            for (int i = 0; i < ole.length; i++) {
                if(ole[i].getExOleObjStg().getPersistId() == ref) {
View Full Code Here

      }
     
      for( Shape shape : shapes ) {
         if( shape instanceof OLEShape ) {
            OLEShape oleShape = (OLEShape)shape;
            ObjectData data = null;
            try {
                data = oleShape.getObjectData();
            } catch( NullPointerException e ) {
                /* getObjectData throws NPE some times. */
            }
            if (data != null) {
               String objID = Integer.toString(oleShape.getObjectID());

               // Embedded Object: add a <div
               // class="embedded" id="X"/> so consumer can see where
               // in the main text each embedded document
               // occurred:
               AttributesImpl attributes = new AttributesImpl();
               attributes.addAttribute("", "class", "class", "CDATA", "embedded");
               attributes.addAttribute("", "id", "id", "CDATA", objID);
               xhtml.startElement("div", attributes);
               xhtml.endElement("div");

               TikaInputStream stream =
                    TikaInputStream.get(data.getData());
               try {
                  String mediaType = null;
                  if ("Excel.Chart.8".equals(oleShape.getProgID())) {
                     mediaType = "application/vnd.ms-excel";
                  }
View Full Code Here

        int cnt = 0;
        for (int i = 0; i < sh.length; i++) {
            if(sh[i] instanceof OLEShape){
                cnt++;
                OLEShape ole = (OLEShape)sh[i];
                ObjectData data = ole.getObjectData();
                if("Worksheet".equals(ole.getInstanceName())){
                    //Voila! we created a workbook from the embedded OLE data
                    HSSFWorkbook wb = new HSSFWorkbook(data.getData());
                    HSSFSheet sheet = wb.getSheetAt(0);
                    //verify we can access the xls data
                    assertEquals(1, sheet.getRow(0).getCell((short)0).getNumericCellValue(), 0);
                    assertEquals(1, sheet.getRow(1).getCell((short)0).getNumericCellValue(), 0);
                    assertEquals(2, sheet.getRow(2).getCell((short)0).getNumericCellValue(), 0);
                    assertEquals(3, sheet.getRow(3).getCell((short)0).getNumericCellValue(), 0);
                    assertEquals(8, sheet.getRow(5).getCell((short)0).getNumericCellValue(), 0);
                } else if ("Document".equals(ole.getInstanceName())){
                    //creating a HWPF document
                    HWPFDocument doc = new HWPFDocument(data.getData());
                    String txt = doc.getRange().getParagraph(0).text();
                    assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);
                }
            }
View Full Code Here

    public ObjectData[] getEmbeddedObjects() {
        if (_objects == null) {
            List objects = new ArrayList();
            for (int i = 0; i < _records.length; i++) {
                if (_records[i] instanceof ExOleObjStg) {
                    objects.add(new ObjectData((ExOleObjStg) _records[i]));
                }
            }
            _objects = (ObjectData[]) objects.toArray(new ObjectData[objects.size()]);
        }
        return _objects;
View Full Code Here

TOP

Related Classes of org.apache.poi.hslf.usermodel.ObjectData

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.