Search in sources :

Example 1 with PrintDataElement

use of org.compiere.print.PrintDataElement in project adempiere by adempiere.

the class PrintDataExcelExporter method getValueAt.

@Override
public Object getValueAt(int row, int col) {
    PrintDataElement pde = getPDE(row, col);
    Object value = null;
    if (pde == null)
        ;
    else if (pde.isDate()) {
        Object o = pde.getValue();
        if (o instanceof Date)
            value = new Timestamp(((Date) o).getTime());
        else
            value = (Timestamp) pde.getValue();
    } else if (pde.isNumeric()) {
        Object o = pde.getValue();
        if (o instanceof Number) {
            value = ((Number) o).doubleValue();
        }
    } else if (pde.isYesNo()) {
        value = pde.getValue();
    } else if (pde.isPKey()) {
        value = pde.getValueAsString();
    } else {
        value = pde.getValueDisplay(getLanguage());
    }
    //
    return value;
}
Also used : PrintDataElement(org.compiere.print.PrintDataElement) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 2 with PrintDataElement

use of org.compiere.print.PrintDataElement in project adempiere by adempiere.

the class LayoutEngine method layoutTable.

//	getColor
/**************************************************************************
	 * 	Layout Table.
	 *	Convert PrintData into TableElement
	 *  @param format format to use
	 *  @param printData data to use
	 *  @param xOffset X Axis - offset (start of table) i.e. indentation
	 *  @return TableElement
	 */
private PrintElement layoutTable(MPrintFormat format, PrintData printData, int xOffset) {
    log.info(format.getName() + " - " + printData.getName());
    MPrintTableFormat tf = format.getTableFormat();
    //	Initial Values
    HashMap<Point, Font> rowColFont = new HashMap<Point, Font>();
    MPrintFont printFont = MPrintFont.get(format.getAD_PrintFont_ID());
    rowColFont.put(new Point(TableElement.ALL, TableElement.ALL), printFont.getFont());
    tf.setStandard_Font(printFont.getFont());
    rowColFont.put(new Point(TableElement.HEADER_ROW, TableElement.ALL), tf.getHeader_Font());
    //
    HashMap<Point, Color> rowColColor = new HashMap<Point, Color>();
    MPrintColor printColor = MPrintColor.get(getCtx(), format.getAD_PrintColor_ID());
    rowColColor.put(new Point(TableElement.ALL, TableElement.ALL), printColor.getColor());
    rowColColor.put(new Point(TableElement.HEADER_ROW, TableElement.ALL), tf.getHeaderFG_Color());
    //
    HashMap<Point, Color> rowColBackground = new HashMap<Point, Color>();
    rowColBackground.put(new Point(TableElement.HEADER_ROW, TableElement.ALL), tf.getHeaderBG_Color());
    //	Sizes
    boolean multiLineHeader = tf.isMultiLineHeader();
    int pageNoStart = m_pageNo;
    int repeatedColumns = 1;
    Rectangle firstPage = new Rectangle(m_content);
    firstPage.x += xOffset;
    firstPage.width -= xOffset;
    int yOffset = (int) m_position[AREA_CONTENT].y - m_content.y;
    firstPage.y += yOffset;
    firstPage.height -= yOffset;
    Rectangle nextPages = new Rectangle(m_content);
    nextPages.x += xOffset;
    nextPages.width -= xOffset;
    //	Column count
    int columnCount = 0;
    for (int c = 0; c < format.getItemCount(); c++) {
        if (format.getItem(c).isPrinted())
            columnCount++;
    }
    //	System.out.println("Cols=" + cols);
    //	Header & Column Setup
    ValueNamePair[] columnHeader = new ValueNamePair[columnCount];
    int[] columnMaxWidth = new int[columnCount];
    int[] columnMaxHeight = new int[columnCount];
    boolean[] fixedWidth = new boolean[columnCount];
    boolean[] colSuppressRepeats = new boolean[columnCount];
    String[] columnJustification = new String[columnCount];
    HashMap<Integer, Integer> additionalLines = new HashMap<Integer, Integer>();
    int col = 0;
    for (int c = 0; c < format.getItemCount(); c++) {
        MPrintFormatItem item = format.getItem(c);
        if (item.isPrinted()) {
            if (item.isNextLine() && item.getBelowColumn() != 0) {
                additionalLines.put(new Integer(col), new Integer(item.getBelowColumn() - 1));
                if (!item.isSuppressNull()) {
                    //	display size will be set to 0 in TableElement
                    item.setIsSuppressNull(true);
                    item.saveEx();
                }
            }
            columnHeader[col] = new ValueNamePair(item.getColumnName(), item.getPrintName(format.getLanguage()));
            columnMaxWidth[col] = item.getMaxWidth();
            fixedWidth[col] = (columnMaxWidth[col] != 0 && item.isFixedWidth());
            colSuppressRepeats[col] = item.isSuppressRepeats();
            if (item.isSuppressNull()) {
                if (columnMaxWidth[col] == 0)
                    //	indication suppress if Null
                    columnMaxWidth[col] = -1;
                else
                    columnMaxWidth[col] *= -1;
            }
            columnMaxHeight[col] = item.getMaxHeight();
            if (item.isHeightOneLine())
                columnMaxHeight[col] = -1;
            columnJustification[col] = item.getFieldAlignmentType();
            if (columnJustification[col] == null || columnJustification[col].equals(MPrintFormatItem.FIELDALIGNMENTTYPE_Default))
                //	when generated sets correct alignment
                columnJustification[col] = MPrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft;
            //	Column Fonts
            if (item.getAD_PrintFont_ID() != 0 && item.getAD_PrintFont_ID() != format.getAD_PrintFont_ID()) {
                MPrintFont font = MPrintFont.get(item.getAD_PrintFont_ID());
                rowColFont.put(new Point(TableElement.ALL, col), font.getFont());
            }
            if (item.getAD_PrintColor_ID() != 0 && item.getAD_PrintColor_ID() != format.getAD_PrintColor_ID()) {
                MPrintColor color = MPrintColor.get(getCtx(), item.getAD_PrintColor_ID());
                rowColColor.put(new Point(TableElement.ALL, col), color.getColor());
            }
            //
            col++;
        }
    }
    //	The Data
    int rows = printData.getRowCount();
    //	System.out.println("Rows=" + rows);
    Object[][] data = new Object[rows][columnCount];
    KeyNamePair[] pk = new KeyNamePair[rows];
    String pkColumnName = null;
    ArrayList<Integer> functionRows = new ArrayList<Integer>();
    ArrayList<Integer> pageBreak = new ArrayList<Integer>();
    //	for all rows
    for (int row = 0; row < rows; row++) {
        //	System.out.println("row=" + row);
        printData.setRowIndex(row);
        if (printData.isFunctionRow()) {
            functionRows.add(new Integer(row));
            rowColFont.put(new Point(row, TableElement.ALL), tf.getFunct_Font());
            rowColColor.put(new Point(row, TableElement.ALL), tf.getFunctFG_Color());
            rowColBackground.put(new Point(row, TableElement.ALL), tf.getFunctBG_Color());
            if (printData.isPageBreak()) {
                pageBreak.add(new Integer(row));
                log.finer("PageBreak row=" + row);
            }
        } else //	Summary/Line Levels for Finanial Reports
        {
            int levelNo = printData.getLineLevelNo();
            if (levelNo != 0) {
                if (levelNo < 0)
                    levelNo = -levelNo;
                Font base = printFont.getFont();
                if (levelNo == 1)
                    rowColFont.put(new Point(row, TableElement.ALL), new Font(base.getName(), Font.ITALIC, base.getSize() - levelNo));
                else if (levelNo == 2)
                    rowColFont.put(new Point(row, TableElement.ALL), new Font(base.getName(), Font.PLAIN, base.getSize() - levelNo));
            }
        }
        //	for all columns
        col = 0;
        for (int c = 0; c < format.getItemCount(); c++) {
            MPrintFormatItem item = format.getItem(c);
            Object dataElement = null;
            if (//	Text Columns
            item.isPrinted()) {
                if (item.isTypeImage()) {
                    if (item.isImageField())
                        data[row][col] = createImageElement(item);
                    else if (item.isImageIsAttached())
                        data[row][col] = ImageElement.get(item.get_ID());
                    else
                        data[row][col] = ImageElement.get(item.getImageURL());
                    // Image layout - teo_sarca, [ 1673548 ]
                    if (data[row][col] != null)
                        ((ImageElement) data[row][col]).layout(item.getMaxWidth(), item.getMaxHeight(), false, item.getFieldAlignmentType());
                } else if (item.isBarcode()) {
                    Object obj = null;
                    if (// teo_sarca, [ 1673542 ]
                    item.getAD_Column_ID() > 0)
                        obj = printData.getNode(new Integer(item.getAD_Column_ID()));
                    if (obj == null)
                        ;
                    else if (obj instanceof PrintDataElement) {
                        PrintDataElement pde = (PrintDataElement) obj;
                        // Get the PrintDataElement string value - teo_sarca [ 1673505 ]
                        String value = null;
                        Object o = pde.getValue();
                        if (o == null)
                            value = "";
                        if (o instanceof KeyNamePair)
                            value = ((KeyNamePair) o).getID();
                        else
                            value = o.toString();
                        BarcodeElement element = new BarcodeElement(value, item);
                        if (element.isValid())
                            data[row][col] = element;
                    }
                    if (data[row][col] != null)
                        ((BarcodeElement) data[row][col]).layout(item.getMaxWidth(), item.getMaxHeight(), false, item.getFieldAlignmentType());
                } else if (item.isTypeText()) {
                    data[row][col] = item.getPrintName(format.getLanguage());
                } else if (item.isTypeField()) {
                    Object obj = null;
                    if (// teo_sarca, [ 1673542 ]
                    item.getAD_Column_ID() > 0)
                        obj = printData.getNode(new Integer(item.getAD_Column_ID()));
                    if (obj == null)
                        ;
                    else if (obj instanceof PrintDataElement) {
                        PrintDataElement pde = (PrintDataElement) obj;
                        if (pde.isID() || pde.isYesNo())
                            dataElement = pde.getValue();
                        else
                            dataElement = pde.getValueDisplay(format.getLanguage());
                    } else
                        log.log(Level.SEVERE, "Element not PrintDataElement " + obj.getClass());
                    //	System.out.println("  row=" + row + ",col=" + col + " - " + item.getAD_Column_ID() + " => " + dataElement);
                    data[row][col] = dataElement;
                } else if (item.isTypePrintFormat()) {
                    m_currPage.addElement(includeFormat(item, printData));
                } else // item.isTypeBox() or isTypePrintFormat()
                {
                    log.warning("Unsupported: " + (item.isTypeBox() ? "Box" : "PrintFormat") + " in Table: " + item);
                }
                col++;
            }
        //	printed
        }
        //	for all columns
        PrintDataElement pde = printData.getPKey();
        if (//	for FunctionRows
        pde != null) {
            pk[row] = (KeyNamePair) pde.getValue();
            if (pkColumnName == null)
                pkColumnName = pde.getColumnName();
        }
    //	else
    //		System.out.println("No PK " + printData);
    }
    //	for all rows
    //
    TableElement table = new TableElement(columnHeader, columnMaxWidth, columnMaxHeight, columnJustification, fixedWidth, functionRows, multiLineHeader, data, pk, pkColumnName, pageNoStart, firstPage, nextPages, repeatedColumns, additionalLines, rowColFont, rowColColor, rowColBackground, tf, pageBreak, colSuppressRepeats);
    table.layout(0, 0, false, MPrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft);
    if (m_tableElement == null)
        m_tableElement = table;
    return table;
}
Also used : HashMap(java.util.HashMap) Rectangle(java.awt.Rectangle) ArrayList(java.util.ArrayList) MPrintFont(org.compiere.print.MPrintFont) Font(java.awt.Font) ValueNamePair(org.compiere.util.ValueNamePair) Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor) MPrintFont(org.compiere.print.MPrintFont) MPrintFormatItem(org.compiere.print.MPrintFormatItem) Point(java.awt.Point) Point(java.awt.Point) PrintDataElement(org.compiere.print.PrintDataElement) MPrintTableFormat(org.compiere.print.MPrintTableFormat) MPrintColor(org.compiere.print.MPrintColor) KeyNamePair(org.compiere.util.KeyNamePair)

Example 3 with PrintDataElement

use of org.compiere.print.PrintDataElement in project adempiere by adempiere.

the class LayoutEngine method includeFormat.

//	layoutForm
/**
	 * 	Include Table Format
	 *	@param item print format item
	 *	@param data print data
	 *	@return Print Element
	 */
private PrintElement includeFormat(MPrintFormatItem item, PrintData data) {
    newLine();
    PrintElement element = null;
    //
    MPrintFormat format = MPrintFormat.get(getCtx(), item.getAD_PrintFormatChild_ID(), false);
    format.setLanguage(m_format.getLanguage());
    if (m_format.isTranslationView())
        format.setTranslationLanguage(m_format.getLanguage());
    int AD_Column_ID = item.getAD_Column_ID();
    log.info(format + " - Item=" + item.getName() + " (" + AD_Column_ID + ")");
    //
    Object obj = data.getNode(new Integer(AD_Column_ID));
    //	Object obj = data.getNode(item.getColumnName());	//	slower
    if (obj == null) {
        data.dumpHeader();
        data.dumpCurrentRow();
        log.log(Level.SEVERE, "No Node - AD_Column_ID=" + AD_Column_ID + " - " + item + " - " + data);
        return null;
    }
    PrintDataElement dataElement = (PrintDataElement) obj;
    String recordString = dataElement.getValueKey();
    if (recordString == null || recordString.length() == 0) {
        data.dumpHeader();
        data.dumpCurrentRow();
        log.log(Level.SEVERE, "No Record Key - " + dataElement + " - AD_Column_ID=" + AD_Column_ID + " - " + item);
        return null;
    }
    int Record_ID = 0;
    try {
        Record_ID = Integer.parseInt(recordString);
    } catch (Exception e) {
        data.dumpCurrentRow();
        log.log(Level.SEVERE, "Invalid Record Key - " + recordString + " (" + e.getMessage() + ") - AD_Column_ID=" + AD_Column_ID + " - " + item);
        return null;
    }
    MQuery query = new MQuery(format.getAD_Table_ID());
    query.addRestriction(item.getColumnName(), MQuery.EQUAL, new Integer(Record_ID));
    format.setTranslationViewQuery(query);
    log.fine(query.toString());
    //
    DataEngine de = new DataEngine(format.getLanguage(), m_TrxName);
    PrintData includedData = de.getPrintData(data.getCtx(), format, query);
    if (includedData == null)
        return null;
    data.addNode(includedData);
    log.fine(includedData.toString());
    //
    element = layoutTable(format, includedData, item.getXSpace());
    //	handle multi page tables
    if (element.getPageCount() > 1) {
        Point2D.Double loc = m_position[m_area];
        element.setLocation(loc);
        for (//	don't add last one
        int p = 1; //	don't add last one
        p < element.getPageCount(); //	don't add last one
        p++) {
            m_currPage.addElement(element);
            newPage(true, false);
        }
        m_position[m_area] = loc;
        ((TableElement) element).setHeightToLastPage();
    }
    m_lastWidth[m_area] = element.getWidth();
    m_lastHeight[m_area] = element.getHeight();
    if (!isXspaceFor(m_lastWidth[m_area])) {
        log.finest("Not enough X space for " + m_lastWidth[m_area] + " - remaining " + getXspace() + " - Area=" + m_area);
        newLine();
    }
    if (m_area == AREA_CONTENT && !isYspaceFor(m_lastHeight[m_area])) {
        log.finest("Not enough Y space " + m_lastHeight[m_area] + " - remaining " + getYspace() + " - Area=" + m_area);
        newPage(true, false);
    }
    //
    return element;
}
Also used : MQuery(org.compiere.model.MQuery) Point(java.awt.Point) PrinterException(java.awt.print.PrinterException) IOException(java.io.IOException) MPrintFormat(org.compiere.print.MPrintFormat) PrintDataElement(org.compiere.print.PrintDataElement) Point2D(java.awt.geom.Point2D) PrintData(org.compiere.print.PrintData) DataEngine(org.compiere.print.DataEngine)

Example 4 with PrintDataElement

use of org.compiere.print.PrintDataElement in project adempiere by adempiere.

the class LayoutEngine method createFieldElement.

//	createStringElement
/**
	 * 	Create Field Element
	 * 	@param item Format Item
	 * 	@param maxWidth max width
	 * 	@param FieldAlignmentType alignment type (MPrintFormatItem.FIELD_ALIGN_*)
	 * 	@param isForm true if document
	 * 	@return Print Element or null if nothing to print
	 */
private PrintElement createFieldElement(MPrintFormatItem item, int maxWidth, String FieldAlignmentType, boolean isForm) {
    //	Get Data
    Object obj = m_data.getNode(new Integer(item.getAD_Column_ID()));
    if (obj == null)
        return null;
    else if (obj instanceof PrintDataElement)
        ;
    else {
        log.log(Level.SEVERE, "Element not PrintDataElement " + obj.getClass());
        return null;
    }
    //	Convert DataElement to String
    PrintDataElement data = (PrintDataElement) obj;
    if (data.isNull() && item.isSuppressNull())
        return null;
    String stringContent = data.getValueDisplay(m_format.getLanguage());
    if ((stringContent == null || stringContent.length() == 0) && item.isSuppressNull())
        return null;
    //	non-string
    Object content = stringContent;
    if (data.getValue() instanceof Boolean)
        content = data.getValue();
    //	Convert AmtInWords Content to alpha
    if (item.getColumnName().equals("AmtInWords")) {
        log.fine("AmtInWords: " + stringContent);
        stringContent = Msg.getAmtInWords(m_format.getLanguage(), stringContent);
        content = stringContent;
    }
    //	Label
    String label = item.getPrintName(m_format.getLanguage());
    String labelSuffix = item.getPrintNameSuffix(m_format.getLanguage());
    //	ID Type
    NamePair ID = null;
    if (data.isID()) {
        //	Record_ID/ColumnName
        Object value = data.getValue();
        if (value instanceof KeyNamePair)
            ID = new KeyNamePair(((KeyNamePair) value).getKey(), item.getColumnName());
        else if (value instanceof ValueNamePair)
            ID = new ValueNamePair(((ValueNamePair) value).getValue(), item.getColumnName());
    } else if (MPrintFormatItem.FIELDALIGNMENTTYPE_Default.equals(FieldAlignmentType)) {
        if (data.isNumeric())
            FieldAlignmentType = MPrintFormatItem.FIELDALIGNMENTTYPE_TrailingRight;
        else
            FieldAlignmentType = MPrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft;
    }
    //	Get Color/ Font
    //	default
    Color color = getColor();
    if (ID != null && !isForm)
        //	link color/underline handeled in PrintElement classes
        ;
    else if (item.getAD_PrintColor_ID() != 0 && m_printColor.get_ID() != item.getAD_PrintColor_ID()) {
        MPrintColor c = MPrintColor.get(getCtx(), item.getAD_PrintColor_ID());
        if (c.getColor() != null)
            color = c.getColor();
    }
    //	default
    Font font = m_printFont.getFont();
    if (item.getAD_PrintFont_ID() != 0 && m_printFont.get_ID() != item.getAD_PrintFont_ID()) {
        MPrintFont f = MPrintFont.get(item.getAD_PrintFont_ID());
        if (f.getFont() != null)
            font = f.getFont();
    }
    //	Create String, HTML or Location
    PrintElement e = null;
    if (data.getDisplayType() == DisplayType.Location) {
        e = new LocationElement(m_printCtx, ((KeyNamePair) ID).getKey(), font, color, item.isHeightOneLine(), label, labelSuffix, m_format.getLanguage().getAD_Language());
        e.layout(maxWidth, item.getMaxHeight(), item.isHeightOneLine(), FieldAlignmentType);
    } else {
        if (HTMLElement.isHTML(stringContent))
            e = new HTMLElement(stringContent);
        else
            e = new StringElement(content, font, color, isForm ? null : ID, label, labelSuffix);
        e.layout(maxWidth, item.getMaxHeight(), item.isHeightOneLine(), FieldAlignmentType);
    }
    return e;
}
Also used : Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor) NamePair(org.compiere.util.NamePair) ValueNamePair(org.compiere.util.ValueNamePair) KeyNamePair(org.compiere.util.KeyNamePair) MPrintFont(org.compiere.print.MPrintFont) MPrintFont(org.compiere.print.MPrintFont) Font(java.awt.Font) PrintDataElement(org.compiere.print.PrintDataElement) MPrintColor(org.compiere.print.MPrintColor) KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair)

Example 5 with PrintDataElement

use of org.compiere.print.PrintDataElement in project adempiere by adempiere.

the class ReportEngineEx method createEXCEL_HTML.

//	createHTML
/**
	 * 	Write EXCEL HTML to writer
	 * 	@param writer writer
	 *  @param onlyTable if false create complete HTML document
	 *  @param language optional language - if null nubers/dates are not formatted
	 * 	@return true if success
	 */
public static boolean createEXCEL_HTML(ReportEngine re, Properties m_ctx, Writer writer, boolean onlyTable, Language language) {
    PrintData m_printData = re.getPrintData();
    MPrintFormat m_printFormat = re.getPrintFormat();
    ///Properties m_ctx = new Properties();
    MQuery m_query = re.getQuery();
    try {
        table table = new table();
        //	for all rows (-1 = header row)
        for (int row = -1; row < m_printData.getRowCount(); row++) {
            tr tr = new tr();
            table.addElement(tr);
            if (row != -1)
                m_printData.setRowIndex(row);
            //	for all columns
            for (int col = 0; col < m_printFormat.getItemCount(); col++) {
                MPrintFormatItem item = m_printFormat.getItem(col);
                if (item.isPrinted()) {
                    //	header row
                    if (row == -1) {
                        th th = new th();
                        tr.addElement(th);
                        th.addElement(Util.maskHTML(item.getPrintName(language)));
                        th.setClass("xl_head");
                    } else {
                        td td = new td();
                        tr.addElement(td);
                        Object obj = m_printData.getNode(new Integer(item.getAD_Column_ID()));
                        if (obj == null)
                            td.addElement("&nbsp;");
                        else if (obj instanceof PrintDataElement) {
                            //	formatted
                            String value = ((PrintDataElement) obj).getValueDisplay(null);
                            int displayType = ((PrintDataElement) obj).getDisplayType();
                            if (((PrintDataElement) obj).isNumeric()) {
                                if (displayType == DisplayType.Integer) {
                                    td.addAttribute("x:num", value);
                                    td.addElement(Util.maskHTML(value));
                                } else if (displayType == DisplayType.Quantity) {
                                    td.addAttribute("x:num", value);
                                    td.addElement(Util.maskHTML(value));
                                } else if (displayType == DisplayType.Amount) {
                                    td.addAttribute("x:num", value);
                                    td.addElement(Util.maskHTML(value));
                                } else if (displayType == DisplayType.CostPrice) {
                                    td.addAttribute("x:num", "");
                                    td.addAttribute("u1:num", value);
                                    td.setClass("xl25");
                                    td.addElement(Util.maskHTML(value));
                                } else //else if (displayType == DisplayType.YesNo)
                                //{
                                //}
                                //	if (displayType == Number)										
                                {
                                    td.addElement(Util.maskHTML(value));
                                }
                            } else if (((PrintDataElement) obj).isDate()) {
                                if (displayType == DisplayType.Date) {
                                    td.setClass("xl24");
                                    td.addElement(Util.maskHTML(value));
                                } else if (displayType == DisplayType.DateTime) {
                                    td.setClass("xl26");
                                    td.addElement(Util.maskHTML(value));
                                } else {
                                    td.addElement(Util.maskHTML(value));
                                }
                            } else
                                td.addElement(Util.maskHTML(value));
                        } else if (obj instanceof PrintData) {
                        //	ignore contained Data
                        } else
                            log.log(Level.SEVERE, "createHTML - Element not PrintData(Element) " + obj.getClass());
                    }
                }
            //	printed
            }
        //	for all columns
        }
        //	for all rows
        table table1 = new table();
        table1.setBorder(0).setCols(10).setCellPadding(0).setCellSpacing(2);
        table1.addElement(new tr().addElement(new td().setColSpan(10).addElement(new h1(re.getName())).setStyle("border:none;")));
        tr tr1;
        String tmp = "Jednostka: ";
        MOrg o = MOrg.get(m_ctx, Env.getAD_Org_ID(m_ctx));
        tmp += o.getName();
        tr1 = new tr();
        tr1.addElement(new td().addElement(tmp).setColSpan(10).setStyle("border:none;"));
        table1.addElement(tr1);
        java.text.DateFormat dateFormat = java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL, new Locale("pl_PL"));
        String dateData = "Czas wygenerowania: " + dateFormat.format(new java.util.Date());
        tr1 = new tr();
        tr1.addElement(new td().addElement(dateData).setColSpan(10).setStyle("border:none;"));
        table1.addElement(tr1);
        for (int r = 0; r < m_query.getRestrictionCount(); r++) {
            tr1 = new tr();
            td td1 = new td().addElement(new i(m_query.getInfoName(r)));
            td1.addElement("   " + m_query.getInfoOperator(r) + "   " + m_query.getInfoDisplayAll(r)).setColSpan(10);
            td1.setStyle("border:none;");
            tr1.addElement(td1);
            table1.addElement(tr1);
        }
        tr1 = new tr();
        tr1.addElement(new td().addElement("&nbsp;").setColSpan(10).setStyle("border:none;height:20px;"));
        table1.addElement(tr1);
        //
        PrintWriter w = new PrintWriter(writer);
        if (onlyTable)
            table.output(w);
        else {
            XhtmlDocument doc = new XhtmlDocument();
            String st = "<!--table " + "	{mso-displayed-decimal-separator:\".\"; " + "	mso-displayed-thousand-separator:\" \";} " + "@page " + "	{margin:.98in .79in .98in .79in; " + "	mso-header-margin:.5in; " + "	mso-footer-margin:.5in;} " + "tr " + "	{mso-height-source:auto;} " + "col " + "	{mso-width-source:auto;} " + "br " + "	{mso-data-placement:same-cell;} " + ".style0 " + "	{mso-number-format:General; " + "	text-align:general; " + "	vertical-align:bottom; " + "	white-space:nowrap; " + "	mso-rotate:0; " + "	mso-background-source:auto; " + "	mso-pattern:auto; " + "	color:windowtext; " + "	font-size:10.0pt; " + "	font-weight:400; " + "	font-style:normal; " + "	text-decoration:none; " + "	font-family:Arial; " + "	mso-generic-font-family:auto; " + "	mso-font-charset:238; " + "	border:none; " + "	mso-protection:locked visible; " + "	mso-style-name:Normalny; " + "	mso-style-id:0;} " + "td " + "	{mso-style-parent:style0; " + "	padding-top:1px; " + "	padding-right:1px; " + "	padding-left:1px; " + "	mso-ignore:padding; " + "	color:windowtext; " + "	font-size:10.0pt; " + "	font-weight:400; " + "	font-style:normal; " + "	text-decoration:none; " + "	font-family:Arial; " + "	mso-generic-font-family:auto; " + "	mso-font-charset:238; " + "	mso-number-format:General; " + "	text-align:general; " + "	vertical-align:bottom; " + //"	border:none; "+
            "border:.5pt solid #a0a0a0; " + //windowtext
            "	mso-background-source:auto; " + "	mso-pattern:auto; " + "	mso-protection:locked visible; " + "	white-space:nowrap; " + "	mso-rotate:0;} " + ".xl24 " + "{mso-style-parent:style0; " + "mso-number-format:\"Short Date\";} " + ".xl25 " + "{mso-style-parent:style0; " + "mso-number-format:Fixed;} " + ".xl26 " + "{mso-style-parent:style0; " + "mso-number-format:\"yy\\/mm\\/dd\\ h\\:mm\\;\\@\";} " + ".xl_head " + "{text-align:center; mso-style-parent:style0; " + "font-weight:700; " + "font-family:Arial, sans-serif; " + "mso-font-charset:238; " + "border:.5pt solid windowtext; " + "background:silver; " + "mso-pattern:auto none;} " + "-->  ";
            doc.appendHead(new style().addElement(st));
            doc.appendBody(table1);
            doc.appendBody(table);
            doc.output(w);
        }
        w.flush();
        w.close();
    } catch (Exception e) {
        log.log(Level.SEVERE, "createHTML(w)", e);
    }
    return false;
}
Also used : Locale(java.util.Locale) org.apache.ecs.xhtml.h1(org.apache.ecs.xhtml.h1) XhtmlDocument(org.apache.ecs.XhtmlDocument) PrintData(org.compiere.print.PrintData) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table) PrintWriter(java.io.PrintWriter) MPrintFormatItem(org.compiere.print.MPrintFormatItem) org.apache.ecs.xhtml.i(org.apache.ecs.xhtml.i) MQuery(org.compiere.model.MQuery) FileNotFoundException(java.io.FileNotFoundException) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) MPrintFormat(org.compiere.print.MPrintFormat) MOrg(org.compiere.model.MOrg) org.apache.ecs.xhtml.th(org.apache.ecs.xhtml.th) PrintDataElement(org.compiere.print.PrintDataElement) org.apache.ecs.xhtml.style(org.apache.ecs.xhtml.style) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr)

Aggregations

PrintDataElement (org.compiere.print.PrintDataElement)8 MPrintFormatItem (org.compiere.print.MPrintFormatItem)3 Color (java.awt.Color)2 Font (java.awt.Font)2 Point (java.awt.Point)2 MQuery (org.compiere.model.MQuery)2 MPrintColor (org.compiere.print.MPrintColor)2 MPrintFont (org.compiere.print.MPrintFont)2 MPrintFormat (org.compiere.print.MPrintFormat)2 PrintData (org.compiere.print.PrintData)2 KeyNamePair (org.compiere.util.KeyNamePair)2 ValueNamePair (org.compiere.util.ValueNamePair)2 Rectangle (java.awt.Rectangle)1 Point2D (java.awt.geom.Point2D)1 PrinterException (java.awt.print.PrinterException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1