Examples of HSSFClientAnchor


Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

     */
    private void addImageToSheet(int colNumber, int rowNumber, HSSFSheet sheet,
            String imageFile, double reqImageWidthMM, double reqImageHeightMM,
            int resizeBehaviour) throws FileNotFoundException, IOException,
                                                     IllegalArgumentException  {
        HSSFClientAnchor anchor = null;
        HSSFPatriarch patriarch = null;
        ClientAnchorDetail rowClientAnchorDetail = null;
        ClientAnchorDetail colClientAnchorDetail = null;

        // Validate the resizeBehaviour parameter.
        if((resizeBehaviour != AddDimensionedImage.EXPAND_COLUMN) &&
           (resizeBehaviour != AddDimensionedImage.EXPAND_ROW) &&
           (resizeBehaviour != AddDimensionedImage.EXPAND_ROW_AND_COLUMN) &&
           (resizeBehaviour != AddDimensionedImage.OVERLAY_ROW_AND_COLUMN)) {
            throw new IllegalArgumentException("Invalid value passed to the " +
                    "resizeBehaviour parameter of AddDimensionedImage.addImageToSheet()");
        }

        // Call methods to calculate how the image and sheet should be
        // manipulated to accomodate the image; columns and then rows.
        colClientAnchorDetail = this.fitImageToColumns(sheet, colNumber,
                reqImageWidthMM, resizeBehaviour);
        rowClientAnchorDetail = this.fitImageToRows(sheet, rowNumber,
                reqImageHeightMM, resizeBehaviour);

        // Having determined if and how to resize the rows, columns and/or the
        // image, create the HSSFClientAnchor object to position the image on
        // the worksheet. Note how the two ClientAnchorDetail records are
        // interrogated to recover the row/column co-ordinates and any insets.
        // The first two parameters are not used currently but could be if the
        // need arose to extend the functionality of this code by adding the
        // ability to specify that a clear 'border' be placed around the image.
        anchor = new HSSFClientAnchor(0,
                                      0,
                                      colClientAnchorDetail.getInset(),
                                      rowClientAnchorDetail.getInset(),
                                      (short)colClientAnchorDetail.getFromIndex(),
                                      rowClientAnchorDetail.getFromIndex(),
                                      (short)colClientAnchorDetail.getToIndex(),
                                      rowClientAnchorDetail.getToIndex());

        // For now, set the anchor type to do not move or resize the
        // image as the size of the row/column is adjusted. This could easilly
        // become another parameter passed to the method.
        anchor.setAnchorType(HSSFClientAnchor.DONT_MOVE_AND_RESIZE);

        // Now, add the picture to the workbook. Note that the type is assumed
        // to be a JPEG/JPG, this could easily (and should) be parameterised
        // however.
        int index = sheet.getWorkbook().addPicture(this.imageToBytes(imageFile),
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

      // Could be a group, or a base object
      if(shapeContainer.getChildRecords().size() == 1 &&
          shapeContainer.getChildContainers().size() == 1) {
        // Group
        HSSFShapeGroup group =
          new HSSFShapeGroup(null, new HSSFClientAnchor());
        patriarch.getChildren().add(group);

        EscherContainerRecord groupContainer =
          (EscherContainerRecord)shapeContainer.getChild(0);
        convertRecordsToUserModel(groupContainer, group);
      } else if(shapeContainer.hasChildOfType((short)0xF00D)) {
        // TextBox
        HSSFTextbox box =
          new HSSFTextbox(null, new HSSFClientAnchor());
        patriarch.getChildren().add(box);

        convertRecordsToUserModel(shapeContainer, box);
      } else if(shapeContainer.hasChildOfType((short)0xF011)) {
        // Not yet supporting EscherClientDataRecord stuff
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

      short column = (short) image.getColumn();
      int width = Math.abs(image.getWidth());
      int height = Math.abs(image.getHeight());

      int index = workbook.addPicture(bytes, type);
      HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, row, column, row, column);

      HSSFPatriarch patriarch = s.createDrawingPatriarch();
      HSSFPicture picture = patriarch.createPicture(anchor, index);

      picture.resize();
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

   
    int index = wb.addPicture(imgBytes.toByteArray(),imgType);
    imgBytes.close();
    fis.close();
   
    HSSFClientAnchor anchor = new HSSFClientAnchor(dx1, dy1, dx2, dy2, (short) col,  row, (short) colend, rowend);
    Picture pict = drawing.createPicture(anchor, index);
   
    //HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
    //patriarch.createPicture(anchor, index);
    //anchor.setAnchorType(0);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

    protected void exportImage(IImageArea image, HSSFCell cell, short x,
            short y, short x2, short y2, HSSFPatriarch patriarch) {
        int idx = loadPicture(image);

        if (idx != -1) {
            HSSFClientAnchor anchor = new HSSFClientAnchor(0,
                    0,
                    0,
                    0,
                    x,
                    y,
                    (short) (x2 + 1),
                    y2 + 1);
            anchor.setAnchorType(2);
            HSSFPicture pic = patriarch.createPicture(anchor, idx);
            // pic.resize( );
        } else if (!suppressUnknownImage) {
            cell.setCellValue(new HSSFRichTextString("<<Unsupported Image>>")); //$NON-NLS-1$
        }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

                if (sourceObj instanceof ReportElementHandle) {
                    String comments = ((ReportElementHandle) sourceObj).getComments();

                    if (comments != null && comments.length() > 0) {
                        HSSFComment hssfcomment = patriarch.createComment(new HSSFClientAnchor(0,
                                0,
                                0,
                                0,
                                (short) commentsAnchorColumnIndex,
                                commentsAnchorRowIndex,
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

{
    public static EscherRecord createAnchor( HSSFAnchor userAnchor )
    {
        if (userAnchor instanceof HSSFClientAnchor)
        {
            HSSFClientAnchor a = (HSSFClientAnchor) userAnchor;

            EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
            anchor.setRecordId( EscherClientAnchorRecord.RECORD_ID );
            anchor.setOptions( (short) 0x0000 );
            anchor.setFlag( (short) a.getAnchorType() );
            anchor.setCol1( (short) Math.min(a.getCol1(), a.getCol2()) );
            anchor.setDx1( (short) a.getDx1() );
            anchor.setRow1( (short) Math.min(a.getRow1(), a.getRow2()) );
            anchor.setDy1( (short) a.getDy1() );

            anchor.setCol2( (short) Math.max(a.getCol1(), a.getCol2()) );
            anchor.setDx2( (short) a.getDx2() );
            anchor.setRow2( (short) Math.max(a.getRow1(), a.getRow2()) );
            anchor.setDy2( (short) a.getDy2() );
            return anchor;
        }
        HSSFChildAnchor a = (HSSFChildAnchor) userAnchor;
        EscherChildAnchorRecord anchor = new EscherChildAnchorRecord();
        anchor.setRecordId( EscherChildAnchorRecord.RECORD_ID );
        anchor.setOptions( (short) 0x0000 );
        anchor.setDx1( (short) Math.min(a.getDx1(), a.getDx2()) );
        anchor.setDy1( (short) Math.min(a.getDy1(), a.getDy2()) );
        anchor.setDx2( (short) Math.max(a.getDx2(), a.getDx1()) );
        anchor.setDy2( (short) Math.max(a.getDy2(), a.getDy1()) );
        return anchor;
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

      {
        // Group
        if (shapeContainer.getChildRecords().size() > 0)
        {
          HSSFShapeGroup group = new HSSFShapeGroup( null,
              new HSSFClientAnchor() );
          patriarch.getChildren().add( group );

          EscherContainerRecord groupContainer = (EscherContainerRecord) shapeContainer
              .getChild( 0 );
          convertRecordsToUserModel( groupContainer, group );
        } else
        {
          log.log( POILogger.WARN,
              "Found drawing group without children." );
        }

      } else if (shapeContainer.getRecordId() == EscherContainerRecord.SP_CONTAINER)
      {
        EscherSpRecord spRecord = shapeContainer
            .getChildById( EscherSpRecord.RECORD_ID );
        int type = spRecord.getOptions() >> 4;

        switch (type)
        {
        case ST_TEXTBOX:
          HSSFTextbox box = new HSSFTextbox( null,
              new HSSFClientAnchor() );
          patriarch.getChildren().add( box );

          convertRecordsToUserModel( shapeContainer, box );
          break;
        case ST_PICTUREFRAME:
          // Duplicated from
          // org.apache.poi.hslf.model.Picture.getPictureIndex()
          EscherOptRecord opt = (EscherOptRecord) getEscherChild(
              shapeContainer, EscherOptRecord.RECORD_ID );
          EscherSimpleProperty prop = (EscherSimpleProperty) getEscherProperty(
              opt, EscherProperties.BLIP__BLIPTODISPLAY );
          if (prop == null)
          {
            log.log( POILogger.WARN,
                "Picture index for picture shape not found." );
          } else
          {
            int pictureIndex = prop.getPropertyValue();

            EscherClientAnchorRecord anchorRecord = (EscherClientAnchorRecord) getEscherChild(
                shapeContainer,
                EscherClientAnchorRecord.RECORD_ID );
            HSSFClientAnchor anchor = new HSSFClientAnchor();
            anchor.setCol1( anchorRecord.getCol1() );
            anchor.setCol2( anchorRecord.getCol2() );
            anchor.setDx1( anchorRecord.getDx1() );
            anchor.setDx2( anchorRecord.getDx2() );
            anchor.setDy1( anchorRecord.getDy1() );
            anchor.setDy2( anchorRecord.getDy2() );
            anchor.setRow1( anchorRecord.getRow1() );
            anchor.setRow2( anchorRecord.getRow2() );

            HSSFPicture picture = new HSSFPicture( null, anchor );
            picture.setPictureIndex( pictureIndex );
            patriarch.getChildren().add( picture );
          }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

     *
     * See Bug 51332
     */
    public void testShapeId(){

        HSSFClientAnchor anchor = new HSSFClientAnchor();
        AbstractShape shape;
        CommonObjectDataSubRecord cmo;

        shape = new TextboxShape(new HSSFTextbox(null, anchor), 1025);
        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFClientAnchor

        // Could be a group, or a base object
        if(shapeContainer.getChildRecords().size() == 1 &&
            shapeContainer.getChildContainers().size() == 1) {
          // Group
          HSSFShapeGroup group =
            new HSSFShapeGroup(null, new HSSFClientAnchor());
          patriarch.getChildren().add(group);
         
          EscherContainerRecord groupContainer =
            (EscherContainerRecord)shapeContainer.getChild(0);
          convertRecordsToUserModel(groupContainer, group);
        } else if(shapeContainer.hasChildOfType((short)0xF00D)) {
          // TextBox
          HSSFTextbox box =
            new HSSFTextbox(null, new HSSFClientAnchor());
          patriarch.getChildren().add(box);
         
          convertRecordsToUserModel(shapeContainer, box);
        } else if(shapeContainer.hasChildOfType((short)0xF011)) {
          // Not yet supporting EscherClientDataRecord stuff
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.