Package writer2latex.latex.style

Examples of writer2latex.latex.style.BeforeAfter


        // We may need a hyperlink target
        palette.getFieldCv().addTarget(node,"|region",ldp);

        // Apply the style
        String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
        BeforeAfter ba = new BeforeAfter();
        Context ic = (Context) oc.clone();
        palette.getSectionSc().applySectionStyle(sStyleName,ba,ic);

        // Do conversion
        if (ba.getBefore().length()>0) { ldp.append(ba.getBefore()).nl(); }
        traverseBlockText(node,ldp,ic);
        if (ba.getAfter().length()>0) { ldp.append(ba.getAfter()).nl(); }
    }
View Full Code Here


        if (!formatter.isSubtable()) {
            palette.getFieldCv().addTarget(node,"|table",ldp);
        }
   
        // Export table declaration
        BeforeAfter baTable = new BeforeAfter();
        formatter.applyTableStyle(baTable);
        ldp.append(baTable.getBefore()).nl();
   
        // Export rows
        if (bApplyCellFormat || !formatter.isLongtable()) { ic.setNoFootnotes(true); }
        int nRowCount = table.getRowCount();
        int nColCount = table.getColCount();
        boolean bInHeader = false;
        // Add interrow material before first row:
        ldp.append(formatter.getInterrowMaterial(0)).nl();
        for (int nRow=0; nRow<nRowCount; nRow++){
            // Longtables may have headers:
            if (formatter.isLongtable()) {
                if (nRow==0 && table.getRow(nRow).isHeader()) {
                    bInHeader = true;
                    if (!bApplyCellFormat) { ic.setNoFootnotes(true); }
                }
                else if (bInHeader && !table.getRow(nRow).isHeader()) {
                    bInHeader = false;
                    if (!bApplyCellFormat) { ic.setNoFootnotes(false); }
                    palette.getNoteCv().flushFootnotes(ldp,oc)
                    ldp.append("\\endhead").nl();
                }
            }
           
            // Export columns in this row
            int nCol = 0;
            while (nCol<nColCount) {
                Element cell = (Element) table.getCell(nRow,nCol);
                if (XMLString.TABLE_TABLE_CELL.equals(cell.getNodeName())) {
                    BeforeAfter baCell = new BeforeAfter();
                    formatter.applyCellStyle(nRow,nCol,baCell);
                    ldp.append(baCell.getBefore());
                    traverseBlockText(cell,ldp,ic);
                    ldp.append(baCell.getAfter());
                }
                // Otherwise ignore; the cell is covered by a \multicolumn entry.
                // (table:covered-table-cell)
                int nColSpan = Misc.getPosInteger(cell.getAttribute(
                                   XMLString.TABLE_NUMBER_COLUMNS_SPANNED),1);
View Full Code Here

        if (ic.getListStyleName()==null) {
            ic.setListStyleName(node.getAttribute(XMLString.TEXT_STYLE_NAME));
        }

        // Apply the style
        BeforeAfter ba = new BeforeAfter();
        palette.getListSc().applyListStyle(ic.getListStyleName(),ic.getListLevel(),
            bOrdered,"true".equals(node.getAttribute(XMLString.TEXT_CONTINUE_NUMBERING)),
            ba);
     
        // Export the list
        if (ba.getBefore().length()>0) { ldp.append(ba.getBefore()).nl(); }
        traverseList(node,ldp,ic);
        if (ba.getAfter().length()>0) { ldp.append(ba.getAfter()).nl(); }
    }
View Full Code Here

            traverseBlockText(node,ldp,oc);
            return;
        }
       
        // Apply the style
        BeforeAfter ba = new BeforeAfter();
        palette.getListSc().applyListItemStyle(
            oc.getListStyleName(), oc.getListLevel(),
            node.getNodeName().equals(XMLString.TEXT_LIST_HEADER),
            "true".equals(node.getAttribute(XMLString.TEXT_RESTART_NUMBERING)),
            Misc.getPosInteger(node.getAttribute(XMLString.TEXT_START_VALUE),1)-1,
            ba);
     
        // export the list item
        if (ba.getBefore().length()>0) {
            ldp.append(ba.getBefore());
            if (config.formatting()>=Config.CONVERT_MOST) { ldp.nl(); }
        }
        traverseBlockText(node,ldp,oc);
        if (ba.getAfter().length()>0) { ldp.append(ba.getAfter()).nl(); }
    }
View Full Code Here

        if (nLevel<=hm.getMaxLevel()) {
            // Always push the font used
            palette.getI18n().pushSpecialTable(palette.getParSc().getFontName(sStyleName));

            // Apply style
            BeforeAfter baHardPage = new BeforeAfter();
            BeforeAfter baHardChar = new BeforeAfter();
            Context ic = (Context) oc.clone();
            palette.getParSc().applyHardHeadingStyle(nLevel, sStyleName,
                baHardPage, baHardChar, ic);

            // Export the heading
            ldp.append(baHardPage.getBefore());
            ldp.append("\\"+hm.getName(nLevel));
            // If this heading contains formatting, add optional argument:
            if (baHardChar.getBefore().length()>0 || containsElements(node)) {
                ldp.append("[");
                palette.getInlineCv().traversePlainInlineText(node,ldp,ic);
                ldp.append("]");
            }
            ldp.append("{").append(baHardChar.getBefore());
            palette.getInlineCv().traverseInlineText(node,ldp,ic,false);
            ldp.append(baHardChar.getAfter()).append("}").nl();
            ldp.append(baHardPage.getAfter());

            // Include any floating frames
            palette.getDrawCv().flushFloatingFrames(ldp,ic);
View Full Code Here

   
        // Always push the font used
        palette.getI18n().pushSpecialTable(palette.getParSc().getFontName(sStyleName));

        // Apply the style
        BeforeAfter ba = new BeforeAfter();
        Context ic = (Context) oc.clone();
        palette.getParSc().applyParStyle(sStyleName,ba,ic);
   
        // Do conversion
        ldp.append(ba.getBefore());
        if (ic.isVerbatim()) {
            palette.getInlineCv().traverseVerbatimInlineText(node,ldp,ic,false);
        }
        else {
            palette.getInlineCv().traverseInlineText(node,ldp,ic,false);
        }
        ldp.append(ba.getAfter());
        // Add a blank line except within verbatim and last in a block:
        if (!bLastInBlock && !ic.isVerbatim()) { ldp.nl(); }
   
        // Flush any floating frames from this paragraph
        palette.getDrawCv().flushFloatingFrames(ldp,ic);
View Full Code Here

   
        // Always push the font used
        palette.getI18n().pushSpecialTable(palette.getCharSc().getFontName(styleName));
   
        // Apply the style
        BeforeAfter ba = new BeforeAfter();
        Context ic = (Context) oc.clone();
        palette.getCharSc().applyTextStyle(styleName,ba,ic);
   
        // Footnote problems:
        // No footnotes in sub/superscript (will disappear)
        // No multiparagraph footnotes embedded in text command (eg. \textbf{..})
        // Simple solution: styled text element is forbidden footnote area
        if (styled && !ic.isInFootnote()) { bNoFootnotes = true; }
        //String s = style.getProperty(XMLString.STYLE_TEXT_POSITION);
        //if (s!=null && !bProcessingFootnote) { bNoFootnotes = true; }

        // Temp solution: Ignore hard formatting in header/footer (name clash problem)
        // only in package format.
    //TODO: Reenable this!!!
        /*if (sxwDoc.getStyleDOM()!=null && palette.getCharSc().isAutomatic(styleName) && ic.isInHeaderFooter()) {
            styled = false;
        }*/

        if (styled) {   
            if (bNoFootnotes) { ic.setNoFootnotes(true); }
            ldp.append(ba.getBefore());
        }
                             
        if (node.hasChildNodes()) {
            NodeList nList = node.getChildNodes();
            int len = nList.getLength();
                      
            for (int i = 0; i < len; i++) {
               
                Node childNode = nList.item(i);
                short nodeType = childNode.getNodeType();
              
                switch (nodeType) {
                    case Node.TEXT_NODE:
                        String s = childNode.getNodeValue();
                        if (s.length() > 0) {
                            ldp.append(palette.getI18n().convert(s,false,ic.getLang()));
                        }
                        break;
                       
                    case Node.ELEMENT_NODE:
                        Element child = (Element)childNode;
                        String sName = child.getTagName();
                        if (child.getNodeName().startsWith("draw:")) {
                            palette.getDrawCv().handleDrawElement(child,ldp,ic);
                        }
                        else if (sName.equals(XMLString.TEXT_S)) {
                            if (config.ignoreDoubleSpaces()) {
                                ldp.append(" ");
                            }
                            else {
                                int count= Misc.getPosInteger(child.getAttribute(XMLString.TEXT_C),1);
                                String sSpace = config.ignoreDoubleSpaces() ? " " : "\\ ";
                                for ( ; count > 0; count--) { ldp.append("\\ "); }
                            }
                        }
                        else if (sName.equals(XMLString.TEXT_TAB_STOP)) {
                            // tab stops are not supported by the onverter, but the special usage
                            // of tab stops in header and footer can be emulated with \hfill
                            // TODO: Sometimes extra \hfill should be added at end of line
                            if (ic.isInHeaderFooter()) { ldp.append("\\hfill "); }
                            else { ldp.append(" "); }
                        }
                        else if (sName.equals(XMLString.TEXT_LINE_BREAK)) {
                            if (!ic.isInHeaderFooter() && !config.ignoreHardLineBreaks()) {
                                ldp.append("\\newline").nl();
                            }
                            else { ldp.append(" "); }
                        }
                        else if (sName.equals(XMLString.TEXT_SPAN)) {
                            if (ic.isVerbatim()) {
                                traverseVerbatimInlineText(child,ldp,ic,true);
                            }
                            else {
                                traverseInlineText (child,ldp,ic,true);
                            }
                        }
                        else if (sName.equals(XMLString.TEXT_A)) {
                            palette.getFieldCv().handleAnchor(child,ldp,ic);
                        }
                        else if (sName.equals(XMLString.OFFICE_ANNOTATION)) {
                            handleOfficeAnnotation(child,ldp,ic);
                        }
                        else if (sName.equals(XMLString.TEXT_PAGE_NUMBER)) {
                            palette.getFieldCv().handlePageNumber(child,ldp,ic);
                        }
                        else if (sName.equals(XMLString.TEXT_PAGE_COUNT)) {
                            palette.getFieldCv().handlePageCount(child,ldp,ic);
                        }
                        else if (ic.isInHeaderFooter()) {
                            if (sName.equals(XMLString.TEXT_CHAPTER)) {
                                handleChapterField(child,ldp,ic);
                            }
                            else if (sName.startsWith("text:")) {
                                traverseInlineText(child,ldp,ic,false);
                            }
                        }
                        else {
                          // These tags are ignored in header and footer
                            if (sName.equals(XMLString.TEXT_FOOTNOTE)) {
                                palette.getNoteCv().handleFootnote(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_ENDNOTE)) {
                                palette.getNoteCv().handleEndnote(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_SEQUENCE)) {
                              palette.getFieldCv().handleSequence(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_SEQUENCE_REF)) {
                              palette.getFieldCv().handleSequenceRef(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_FOOTNOTE_REF)) {
                              palette.getNoteCv().handleFootnoteRef(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_ENDNOTE_REF)) {
                                palette.getNoteCv().handleEndnoteRef(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_REFERENCE_MARK)) {
                              palette.getFieldCv().handleReferenceMark(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_REFERENCE_MARK_START)) {
                                palette.getFieldCv().handleReferenceMark(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_REFERENCE_REF)) {
                              palette.getFieldCv().handleReferenceRef(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_BOOKMARK)) {
                                palette.getFieldCv().handleBookmark(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_BOOKMARK_START)) {
                              palette.getFieldCv().handleBookmark(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_BOOKMARK_REF)) {
                                palette.getFieldCv().handleBookmarkRef(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_BIBLIOGRAPHY_MARK)) {
                                palette.getIndexCv().handleBibliographyMark(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_ALPHABETICAL_INDEX_MARK)) {
                                palette.getIndexCv().handleAlphabeticalIndexMark(child,ldp,ic);
                            }
                            else if (sName.equals(XMLString.TEXT_ALPHABETICAL_INDEX_MARK_START)) {
                                palette.getIndexCv().handleAlphabeticalIndexMark(child,ldp,ic);
                            }
                            else if (sName.startsWith("text:")) {
                                traverseInlineText(child,ldp,ic,false);
                            }
                        }
                        break;
                    default:
                        // Do nothing
                }
            }
        }
       
        if (styled) {   
            ldp.append(ba.getAfter());
            ic.setNoFootnotes(false);
            if (!ic.isInFootnote()) { palette.getNoteCv().flushFootnotes(ldp,oc); }
        }
   
        // finally pop the special table
View Full Code Here

        // We may need a hyperlink target
        palette.getFieldCv().addTarget(node,"|region",ldp);

        // Apply the style
        String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
        BeforeAfter ba = new BeforeAfter();
        Context ic = (Context) oc.clone();
        palette.getSectionSc().applySectionStyle(sStyleName,ba,ic);

        // Do conversion
        if (ba.getBefore().length()>0) { ldp.append(ba.getBefore()).nl(); }
        traverseBlockText(node,ldp,ic);
        if (ba.getAfter().length()>0) { ldp.append(ba.getAfter()).nl(); }
    }
View Full Code Here

        if (!formatter.isSubtable()) {
            palette.getFieldCv().addTarget(node,"|table",ldp);
        }
   
        // Export table declaration
        BeforeAfter baTable = new BeforeAfter();
        formatter.applyTableStyle(baTable);
        ldp.append(baTable.getBefore()).nl();
   
        // Export rows
        if (bApplyCellFormat || !formatter.isLongtable()) { ic.setNoFootnotes(true); }
        int nRowCount = table.getRowCount();
        int nColCount = table.getColCount();
        boolean bInHeader = false;
        // Add interrow material before first row:
        ldp.append(formatter.getInterrowMaterial(0)).nl();
        for (int nRow=0; nRow<nRowCount; nRow++){
            // Longtables may have headers:
            if (formatter.isLongtable()) {
                if (nRow==0 && table.getRow(nRow).isHeader()) {
                    bInHeader = true;
                    if (!bApplyCellFormat) { ic.setNoFootnotes(true); }
                }
                else if (bInHeader && !table.getRow(nRow).isHeader()) {
                    bInHeader = false;
                    if (!bApplyCellFormat) { ic.setNoFootnotes(false); }
                    palette.getNoteCv().flushFootnotes(ldp,oc)
                    ldp.append("\\endhead").nl();
                }
            }
           
            // Export columns in this row
            int nCol = 0;
            while (nCol<nColCount) {
                Element cell = (Element) table.getCell(nRow,nCol);
                if (XMLString.TABLE_TABLE_CELL.equals(cell.getNodeName())) {
                    BeforeAfter baCell = new BeforeAfter();
                    formatter.applyCellStyle(nRow,nCol,baCell);
                    ldp.append(baCell.getBefore());
                    traverseBlockText(cell,ldp,ic);
                    ldp.append(baCell.getAfter());
                }
                // Otherwise ignore; the cell is covered by a \multicolumn entry.
                // (table:covered-table-cell)
                int nColSpan = Misc.getPosInteger(cell.getAttribute(
                                   XMLString.TABLE_NUMBER_COLUMNS_SPANNED),1);
View Full Code Here

        if (ic.getListStyleName()==null) {
            ic.setListStyleName(node.getAttribute(XMLString.TEXT_STYLE_NAME));
        }

        // Apply the style
        BeforeAfter ba = new BeforeAfter();
        palette.getListSc().applyListStyle(ic.getListStyleName(),ic.getListLevel(),
            bOrdered,"true".equals(node.getAttribute(XMLString.TEXT_CONTINUE_NUMBERING)),
            ba);
     
        // Export the list
        if (ba.getBefore().length()>0) { ldp.append(ba.getBefore()).nl(); }
        traverseList(node,ldp,ic);
        if (ba.getAfter().length()>0) { ldp.append(ba.getAfter()).nl(); }
    }
View Full Code Here

TOP

Related Classes of writer2latex.latex.style.BeforeAfter

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.