Package ag.ion.bion.officelayer.clone

Examples of ag.ion.bion.officelayer.clone.CloneException


   *
   * @author Miriam Sutter
   */
  public ETextTableCellRangeCloneService(IETextTableCellRange textTableCellRange, ITextDocument textDocument) throws CloneException{
    if(textTableCellRange == null) {
      throw new CloneException("The submitted range is not valid");
    }
    if(!(textTableCellRange instanceof ETextTableCellRange)) {
      throw new CloneException("The submitted range is not valid");
    }
    if(textDocument == null) {
      throw new CloneException("The submitted text document is not valid");
    }
    this.textTableCellRange = (ETextTableCellRange)textTableCellRange;
    this.textDocument = textDocument;
  }
View Full Code Here


      }
      else
        return null;
    }
    catch(TextException textException) {
      CloneException cloneException = new CloneException("Error while cloning table");
      cloneException.initCause(textException);
      throw cloneException;
    }
  }
View Full Code Here

        textTablePropertyStore = oldTable.getPropertyStore();
      }
      int columnStart = 0;
      int rowStart = 0;
      if(cellCloneServices.length == 0 ) {
        CloneException cloneException =  new CloneException("No range selected.");
        throw cloneException;
      }
      int columnArrayLength = cellCloneServices[0].length;
     
      if(position.getType() == null) {
        CloneException cloneException =  new CloneException("No valid type for the position.");
        throw cloneException;
      }
     
      if(ITextRange.class.isAssignableFrom(position.getType())) {
        ITextRange range = (ITextRange)position.getDestinationObject();
        if(textTableService == null)
          textTableService = textDocument.getTextTableService();
        newTable = (ITextTable)textTableService.constructTextTable(rowCount, columnCount);
        newTable.getProperties().setRepeatHeadline(textTablePropertyStore.repeatHeadline());
        if(textContentService == null)
          textContentService = textDocument.getTextService().getTextContentService();
        if (range != null) {
          textContentService.insertTextContent(range,newTable);
          newTable.getProperties().setTableColumnSeparators(textTablePropertyStore.getTableColumnSeparators());
        }
        else {
          CloneException cloneException =  new CloneException("No destination selected..");
          throw cloneException;
        }
      }
      else if(ITextTable.class.isAssignableFrom(position.getType())) {
        ITextTable range = (ITextTable)position.getDestinationObject();
        TextTableService tableService = new TextTableService(textDocument);

        newTable = (ITextTable)tableService.constructTextTable(rowCount, columnCount);
        newTable.getProperties().setRepeatHeadline(textTablePropertyStore.repeatHeadline());
       
        if (range != null) {
          if(textContentService == null)
            textContentService = textDocument.getTextService().getTextContentService();
          textContentService.insertTextContentAfter(newTable,range);
          newTable.getProperties().setTableColumnSeparators(textTablePropertyStore.getTableColumnSeparators());
        }
        else {
          CloneException cloneException =  new CloneException("No destination selected..");
          throw cloneException;
        }
      }
      else if(TextTableCell.class.isAssignableFrom(position.getType())) {
        TextTableCell textTableCell = ((TextTableCell)position.getDestinationObject());
        newTable = textTableCell.getTextTable();
        ITextTableCellName cellName = textTableCell.getName();
        columnStart = cellName.getColumnIndex();
        rowStart = cellName.getRowIndex();
        int newTableColumnCount = newTable.getColumnCount();
        int newTableRowCount = newTable.getRowCount();
        if(columnStart + columnArrayLength > newTableColumnCount) {
          CloneException cloneException =  new CloneException("Too much columns selected.");
          throw cloneException;
        }
        if((rowStart + rowCount)*newTableColumnCount > ITextTable.MAX_CELLS_IN_TABLE) {
          CloneException cloneException =  new CloneException("The sumbitted range is too big.");
          throw cloneException;
        }
        if(rowStart + rowCount > newTableRowCount) {
          newTable.addRow(rowStart, (rowStart + rowCount)-newTableRowCount);
        }
      }
      else if(TextTableCellRange.class.isAssignableFrom(position.getType())) {
        TextTableCellRange tableCellRange = ((TextTableCellRange)position.getDestinationObject());
        int tmpColumnCount = tableCellRange.getColumnCount();
        int tmpRowCount = tableCellRange.getRowCount();
        if(tmpColumnCount == 0 || tmpRowCount==0) {
          CloneException cloneException =  new CloneException("No range selected.");
          throw cloneException;
        }
        newTable = tableCellRange.getCell(0,0).getTextTable();;
        ITextTableCellRangeName rangeName = tableCellRange.getRangeName();
        columnStart = rangeName.getRangeStartColumnIndex();
        rowStart = rangeName.getRangeStartRowIndex();
        if(tmpColumnCount != columnCount || tmpRowCount != rowCount) {
          CloneException cloneException =  new CloneException("The selected range is not valid.");
          throw cloneException;
        }
      }
      else if(TextTableRow.class.isAssignableFrom(position.getType())) {
        TextTableRow textTableRow = ((TextTableRow)position.getDestinationObject());       
        ITextTableCellRange tableCellRange = textTableRow.getCellRange();
        int tmpColumnCount = tableCellRange.getColumnCount();
        int tmpRowCount = tableCellRange.getRowCount();
        if(tmpColumnCount == 0 || tmpRowCount==0) {
          CloneException cloneException =  new CloneException("No range selected.");
          throw cloneException;
        }
        newTable = tableCellRange.getCell(0,0).getTextTable();;
        ITextTableCellRangeName rangeName = tableCellRange.getRangeName();
        columnStart = rangeName.getRangeStartColumnIndex();
        rowStart = rangeName.getRangeStartRowIndex();
        if(tmpColumnCount != columnCount || tmpRowCount != rowCount) {
          CloneException cloneException =  new CloneException("The selected range is not valid.");
          throw cloneException;
        }
      }
      else if(TextTableColumn.class.isAssignableFrom(position.getType())) {
        //TODO fill with logic
      }
      else {
        CloneException cloneException =  new CloneException("No range selected.");
        throw cloneException;
      }
      if(newTable != null) {
        int rowArrayLength = cellCloneServices.length;
        for (int rows = 0; rows < rowArrayLength; rows++) {
          for (int columns = 0; columns < columnArrayLength ; columns++) {
            ICloneService cellClone = cellCloneServices[rows][columns];
            ITextTableCell textTableCell = newTable.getCell(columnStart + columns, rowStart + rows);
            CloneDestinationPosition destinationCell = new CloneDestinationPosition(textTableCell, textTableCell.getClass());
            cellClone.cloneToPositionNoReturn(destinationCell, adoptContent,propertyKeysContainer);
          }
        }
        if(generateReturnValue) {
          ITextTableCellRange textTableCellRange = newTable.getCellRange(columnStart,rowStart,columnArrayLength,rowArrayLength);
          return new ClonedObject(textTableCellRange, textTableCellRange.getClass());
        }
        else
          return null;
      }
      else {
        CloneException cloneException =  new CloneException("No range selected.");
        throw cloneException;
      }
    }
    catch (Exception exception) {
      CloneException cloneException =  new CloneException(exception.getMessage());
      cloneException.initCause(exception);
      throw cloneException;
    }
  }
View Full Code Here

        try {
          ITextTableCell currentTableCell = textTableCellRange.getCell(h,i);
          cellCloneServices[i][h] = currentTableCell.getCloneService();
        }
        catch(TextException excep) {
          CloneException cloneException =  new CloneException(excep.getMessage());
          cloneException.initCause(excep);
          throw cloneException;

        }
      }
    }
View Full Code Here

        .queryInterface(XMultiServiceFactory.class, document
            .getXTextDocument());
    try {
      analyseParagraph(paragraph);
    } catch (TextException excep) {
      CloneException cloneException = new CloneException(excep
          .getMessage());
      cloneException.initCause(excep);
      throw cloneException;
    }
  }
View Full Code Here

          return new ClonedObject(newParagraph, newParagraph
              .getClass());
        else
          return null;
      } else {
        throw new CloneException(
            "Error constructing TextContentService to clone paragraph");
      }
    } catch (Exception excep) {
      CloneException cloneException = new CloneException(excep
          .getMessage());
      cloneException.initCause(excep);
      throw cloneException;
    }
  }
View Full Code Here

        textTablePropertyStore = oldTable.getPropertyStore();
      }
      int columnStart = 0;
      int rowStart = 0;
      if (cellCloneServices.length == 0) {
        CloneException cloneException = new CloneException(
            "No range selected.");
        throw cloneException;
      }
      int columnArrayLength = cellCloneServices[0].length;

      if (position.getType() == null) {
        CloneException cloneException = new CloneException(
            "No valid type for the position.");
        throw cloneException;
      }

      if (ITextRange.class.isAssignableFrom(position.getType())) {
        ITextRange range = (ITextRange) position.getDestinationObject();
        if (textTableService == null)
          textTableService = textDocument.getTextTableService();
        newTable = (ITextTable) textTableService.constructTextTable(
            rowCount, columnCount);
        newTable.getProperties().setRepeatHeadline(
            textTablePropertyStore.repeatHeadline());
        if (textContentService == null)
          textContentService = textDocument.getTextService()
              .getTextContentService();
        if (range != null) {
          textContentService.insertTextContent(range, newTable);
          newTable.getProperties().setTableColumnSeparators(
              textTablePropertyStore.getTableColumnSeparators());
        } else {
          CloneException cloneException = new CloneException(
              "No destination selected..");
          throw cloneException;
        }
      } else if (ITextTable.class.isAssignableFrom(position.getType())) {
        ITextTable range = (ITextTable) position.getDestinationObject();
        TextTableService tableService = new TextTableService(
            textDocument);

        newTable = (ITextTable) tableService.constructTextTable(
            rowCount, columnCount);
        newTable.getProperties().setRepeatHeadline(
            textTablePropertyStore.repeatHeadline());

        if (range != null) {
          if (textContentService == null)
            textContentService = textDocument.getTextService()
                .getTextContentService();
          textContentService.insertTextContentAfter(newTable, range);
          newTable.getProperties().setTableColumnSeparators(
              textTablePropertyStore.getTableColumnSeparators());
        } else {
          CloneException cloneException = new CloneException(
              "No destination selected..");
          throw cloneException;
        }
      } else if (TextTableCell.class.isAssignableFrom(position.getType())) {
        TextTableCell textTableCell = ((TextTableCell) position
            .getDestinationObject());
        newTable = textTableCell.getTextTable();
        ITextTableCellName cellName = textTableCell.getName();
        columnStart = cellName.getColumnIndex();
        rowStart = cellName.getRowIndex();
        int newTableColumnCount = newTable.getColumnCount();
        int newTableRowCount = newTable.getRowCount();
        if (columnStart + columnArrayLength > newTableColumnCount) {
          CloneException cloneException = new CloneException(
              "Too much columns selected.");
          throw cloneException;
        }
        if ((rowStart + rowCount) * newTableColumnCount > ITextTable.MAX_CELLS_IN_TABLE) {
          CloneException cloneException = new CloneException(
              "The sumbitted range is too big.");
          throw cloneException;
        }
        if (rowStart + rowCount > newTableRowCount) {
          newTable.addRow(rowStart, (rowStart + rowCount)
              - newTableRowCount);
        }
      } else if (TextTableCellRange.class.isAssignableFrom(position
          .getType())) {
        TextTableCellRange tableCellRange = ((TextTableCellRange) position
            .getDestinationObject());
        int tmpColumnCount = tableCellRange.getColumnCount();
        int tmpRowCount = tableCellRange.getRowCount();
        if (tmpColumnCount == 0 || tmpRowCount == 0) {
          CloneException cloneException = new CloneException(
              "No range selected.");
          throw cloneException;
        }
        newTable = tableCellRange.getCell(0, 0).getTextTable();
        ;
        ITextTableCellRangeName rangeName = tableCellRange
            .getRangeName();
        columnStart = rangeName.getRangeStartColumnIndex();
        rowStart = rangeName.getRangeStartRowIndex();
        if (tmpColumnCount != columnCount || tmpRowCount != rowCount) {
          CloneException cloneException = new CloneException(
              "The selected range is not valid.");
          throw cloneException;
        }
      } else if (TextTableRow.class.isAssignableFrom(position.getType())) {
        TextTableRow textTableRow = ((TextTableRow) position
            .getDestinationObject());
        ITextTableCellRange tableCellRange = textTableRow
            .getCellRange();
        int tmpColumnCount = tableCellRange.getColumnCount();
        int tmpRowCount = tableCellRange.getRowCount();
        if (tmpColumnCount == 0 || tmpRowCount == 0) {
          CloneException cloneException = new CloneException(
              "No range selected.");
          throw cloneException;
        }
        newTable = tableCellRange.getCell(0, 0).getTextTable();
        ;
        ITextTableCellRangeName rangeName = tableCellRange
            .getRangeName();
        columnStart = rangeName.getRangeStartColumnIndex();
        rowStart = rangeName.getRangeStartRowIndex();
        if (tmpColumnCount != columnCount || tmpRowCount != rowCount) {
          CloneException cloneException = new CloneException(
              "The selected range is not valid.");
          throw cloneException;
        }
      } else if (TextTableColumn.class.isAssignableFrom(position
          .getType())) {
        // TODO fill with logic
      } else {
        CloneException cloneException = new CloneException(
            "No range selected.");
        throw cloneException;
      }
      if (newTable != null) {
        int rowArrayLength = cellCloneServices.length;
        for (int rows = 0; rows < rowArrayLength; rows++) {
          for (int columns = 0; columns < columnArrayLength; columns++) {
            ICloneService cellClone = cellCloneServices[rows][columns];
            ITextTableCell textTableCell = newTable.getCell(
                columnStart + columns, rowStart + rows);
            CloneDestinationPosition destinationCell = new CloneDestinationPosition(
                textTableCell, textTableCell.getClass());
            cellClone.cloneToPositionNoReturn(destinationCell,
                adoptContent, propertyKeysContainer);
          }
        }
        if (generateReturnValue) {
          ITextTableCellRange textTableCellRange = newTable
              .getCellRange(columnStart, rowStart,
                  columnArrayLength, rowArrayLength);
          return new ClonedObject(textTableCellRange,
              textTableCellRange.getClass());
        } else
          return null;
      } else {
        CloneException cloneException = new CloneException(
            "No range selected.");
        throw cloneException;
      }
    } catch (Exception exception) {
      CloneException cloneException = new CloneException(exception
          .getMessage());
      cloneException.initCause(exception);
      throw cloneException;
    }
  }
View Full Code Here

          ITextTableCell currentTableCell = textTableCellRange
              .getCell(h, i);
          cellCloneServices[i][h] = currentTableCell
              .getCloneService();
        } catch (TextException excep) {
          CloneException cloneException = new CloneException(excep
              .getMessage());
          cloneException.initCause(excep);
          throw cloneException;

        }
      }
    }
View Full Code Here

   * @author Miriam Sutter
   */
  public ETextTableCloneService(IETextTable textTable,
      ITextDocument textDocument) throws CloneException {
    if (textTable == null) {
      throw new CloneException("The submitted table is not valid");
    }
    if (textDocument == null) {
      throw new CloneException("The submitted text document is not valid");
    }
    if (!(textTable instanceof ETextTable)) {
      throw new CloneException("The submitted table is not valid");
    }
    this.textTable = (ETextTable) textTable;
    this.textDocument = textDocument;
  }
View Full Code Here

          .getCloneService()
          .cloneToPosition(destinationPosition, propertyKeysContainer);
      try {
        eTextTable.addTable(table);
      } catch (TextException textException) {
        CloneException cloneException = new CloneException(
            "Error while cloning table");
        cloneException.initCause(textException);
        throw cloneException;
      }
    }
    if (generateReturnValue)
      return new ClonedObject(eTextTable, eTextTable.getClass());
View Full Code Here

TOP

Related Classes of ag.ion.bion.officelayer.clone.CloneException

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.