Writes all the lines to the text-object.

@return the displacement that was caused
@throws DocumentException on error
977369
protected float flushLines() throws DocumentException {
        // checks if the ArrayList with the lines is not null
        if (lines == null) {
            return 0;
        }
        // checks if a new Line has to be made.
        if (line != null && line.size() > 0) {
            lines.add(line);
            line = new PdfLine(indentLeft(), indentRight(), alignment, leading);
        }

        // checks if the ArrayList with the lines is empty
        if (lines.isEmpty()) {
            return 0;
        }

        // initialization of some parameters
        Object currentValues[] = new Object[2];
        PdfFont currentFont = null;
        float displacement = 0;
        PdfLine l;
        Float lastBaseFactor = new Float(0);
        currentValues[1] = lastBaseFactor;
        // looping over all the lines
        for (Iterator i = lines.iterator(); i.hasNext(); ) {

            // this is a line in the loop
            l = (PdfLine) i.next();

            float moveTextX = l.indentLeft() - indentLeft() + indentation.indentLeft + indentation.listIndentLeft + indentation.sectionIndentLeft;
            text.moveText(moveTextX, -l.height());
            // is the line preceded by a symbol?
            if (l.listSymbol() != null) {
                ColumnText.showTextAligned(graphics, Element.ALIGN_LEFT, new Phrase(l.listSymbol()), text.getXTLM() - l.listIndent(), text.getYTLM(), 0);
            }

            currentValues[0] = currentFont;

            writeLineToContent(l, text, graphics, currentValues, writer.getSpaceCharRatio());

            currentFont = (PdfFont)currentValues[0];
            displacement += l.height();
            text.moveText(-moveTextX, 0);

        }
        lines = new ArrayList();
        return displacement;
    }
476865
public boolean advanceToDoc(int docId) throws IOException {
    if (ignoreSpans == null || currentDocId == Spans.NO_MORE_DOCS) {
      return false;
    } else if (currentDocId == docId) {
      return true;
    } else {
      baseEndPositionList.clear();
      fullEndPositionList.clear();
      maxBaseEndPosition.clear();
      minFullStartPosition.clear();
      if (currentDocId < docId) {
        currentDocId = ignoreSpans.advance(docId);
        currentPosition = -1;
        minimumPosition = -1;
      }
      return currentDocId == docId;
    }
  }
499672
public void writeContent(final OutputStream result) throws IOException
    {
		this.shapeNr = this.doc.getRandomInt();
		
		this.properties.put("ShapeType", new RtfShapeProperty("ShapeType", this.type));
		if(this.position.isShapeBelowText()) {
			this.properties.put("fBehindDocument", new RtfShapeProperty("fBehindDocument", true));
		}
		if(this.inTable) {
			this.properties.put("fLayoutInCell", new RtfShapeProperty("fLayoutInCell", true));
		}
		if(this.properties.containsKey("posh")) {
			this.position.setIgnoreXRelative(true);
		}
		if(this.properties.containsKey("posv")) {
			this.position.setIgnoreYRelative(true);
		}
    	
    	result.write(OPEN_GROUP);
    	result.write(DocWriter.getISOBytes("\\shp"));
    	result.write(DocWriter.getISOBytes("\\shplid"));
    	result.write(intToByteArray(this.shapeNr));
    	this.position.writeContent(result);
    	switch(this.wrapping) {
    	case SHAPE_WRAP_NONE:
    		result.write(DocWriter.getISOBytes("\\shpwr3"));
    		break;
    	case SHAPE_WRAP_TOP_BOTTOM:
    		result.write(DocWriter.getISOBytes("\\shpwr1"));
    		break;
    	case SHAPE_WRAP_BOTH:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk0"));
    		break;
    	case SHAPE_WRAP_LEFT:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk1"));
    		break;
    	case SHAPE_WRAP_RIGHT:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk2"));
    		break;
    	case SHAPE_WRAP_LARGEST:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk3"));
    		break;
    	case SHAPE_WRAP_TIGHT_BOTH:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk0"));
    		break;
    	case SHAPE_WRAP_TIGHT_LEFT:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk1"));
    		break;
    	case SHAPE_WRAP_TIGHT_RIGHT:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk2"));
    		break;
    	case SHAPE_WRAP_TIGHT_LARGEST:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk3"));
    		break;
    	case SHAPE_WRAP_THROUGH:
    		result.write(DocWriter.getISOBytes("\\shpwr5"));
    		break;
    	default:
    		result.write(DocWriter.getISOBytes("\\shpwr3"));
    	}
    	if(this.inHeader) {
    		result.write(DocWriter.getISOBytes("\\shpfhdr1"));
    	} 
    	this.doc.outputDebugLinebreak(result);
    	result.write(OPEN_GROUP);
    	result.write(DocWriter.getISOBytes("\\*\\shpinst"));
    	Iterator it = this.properties.values().iterator();
    	while(it.hasNext()) {
    		RtfShapeProperty rsp = (RtfShapeProperty) it.next();
    		rsp.setRtfDocument(this.doc);
    		rsp.writeContent(result);
    	}
    	if(!this.shapeText.equals("")) {
    		result.write(OPEN_GROUP);
    		result.write(DocWriter.getISOBytes("\\shptxt"));
    		result.write(DELIMITER);
    		result.write(DocWriter.getISOBytes(this.shapeText));
    		result.write(CLOSE_GROUP);
    	}
    	result.write(CLOSE_GROUP);
    	this.doc.outputDebugLinebreak(result);
    	result.write(CLOSE_GROUP);
		
    }
502489
public String putDocument(Document document) {
		String key = UUID.randomUUID().toString();
		documentMap.put(key, document);
		return key;
	}
567085
protected String applyTextReplacements(Iterable<ITextReplacement> replacements) {
		ITextSegment region = getRegion();
		String input = region.getText();
		ArrayList<ITextReplacement> list = Lists.newArrayList(replacements);
		Collections.sort(list);
		int startOffset = region.getOffset();
		int lastOffset = 0;
		StringBuilder result = new StringBuilder();
		for (ITextReplacement r : list) {
			int offset = r.getOffset() - startOffset;
			result.append(input.subSequence(lastOffset, offset));
			result.append(r.getReplacementText());
			lastOffset = offset + r.getLength();
		}
		result.append(input.subSequence(lastOffset, input.length()));
		return result.toString();
	}
726131
public void writeContent(final OutputStream result) throws IOException
    {    	
    	result.write(DocWriter.getISOBytes("\\shpleft"));
    	result.write(intToByteArray(this.left));
    	result.write(DocWriter.getISOBytes("\\shptop"));
    	result.write(intToByteArray(this.top));
    	result.write(DocWriter.getISOBytes("\\shpright"));
    	result.write(intToByteArray(this.right));
    	result.write(DocWriter.getISOBytes("\\shpbottom"));
    	result.write(intToByteArray(this.bottom));
    	result.write(DocWriter.getISOBytes("\\shpz"));
    	result.write(intToByteArray(this.zOrder));
    	switch(this.xRelativePos) {
    	case POSITION_X_RELATIVE_PAGE: result.write(DocWriter.getISOBytes("\\shpbxpage")); break;
    	case POSITION_X_RELATIVE_MARGIN: result.write(DocWriter.getISOBytes("\\shpbxmargin")); break;
    	case POSITION_X_RELATIVE_COLUMN: result.write(DocWriter.getISOBytes("\\shpbxcolumn")); break;
    	}
    	if(this.ignoreXRelative) {
    		result.write(DocWriter.getISOBytes("\\shpbxignore"));
    	}
    	switch(this.yRelativePos) {
    	case POSITION_Y_RELATIVE_PAGE: result.write(DocWriter.getISOBytes("\\shpbypage")); break;
    	case POSITION_Y_RELATIVE_MARGIN: result.write(DocWriter.getISOBytes("\\shpbymargin")); break;
    	case POSITION_Y_RELATIVE_PARAGRAPH: result.write(DocWriter.getISOBytes("\\shpbypara")); break;
    	}
    	if(this.ignoreYRelative) {
    		result.write(DocWriter.getISOBytes("\\shpbyignore"));
    	}
    	if(this.shapeBelowText) {
    		result.write(DocWriter.getISOBytes("\\shpfblwtxt1"));
    	} else {
    		result.write(DocWriter.getISOBytes("\\shpfblwtxt0"));
    	}
    }
304497
private InputStream formatRawContent(final Document document) throws IOException {
        final String body = "<h1>" + escapeAndAddLineBreaks(resolveTitle(document)) + "</h1>"
                + "<p>" + escapeAndAddLineBreaks(document.getContent()) + "</p>";

        return IOUtils.toInputStream(body, StandardCharsets.UTF_8);
    }
133767
public void indent() throws IOException {
        for (int i=0; i<indent; i++) writeRawString("   ");
    }

    /**
     * Method to increase the indent depth of the output writer.
     * @throws IOException Thrown if an error occurs during write.
     */
    public void indentPush()
    {
        indent++;
    }

    /**
     * Method to reduce the indent depth of the output writer.
     */
    public void indentPop()
    {
        indent--;
        if (indent < 0) throw new IllegalStateException();
    }

    /**
     * Method to get a list of all the property names stored in a map.
     */
    public List getPropertyNames(Map map)
    {
        List propertyNames = super.getPropertyNames(map);

        Collections.sort(propertyNames);

        return propertyNames;
    }

}
558602
String getIndentation()
	{
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < count; i++)
		{
			sb.append(indent);
		}

		return sb.toString();
	}
169420
protected DocWriter createWriter(final MBasicTable table, final Document document,
			final OutputStream out) throws DocumentException {
		final PdfWriter writer = PdfWriter.getInstance(document, out);
		// writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);

		// title
		if (table.getName() != null) {
			final HeaderFooter header = new HeaderFooter(new Phrase(table.getName()), false);
			header.setAlignment(Element.ALIGN_LEFT);
			header.setBorder(Rectangle.NO_BORDER);
			document.setHeader(header);
			document.addTitle(table.getName());
		}

		// simple page numbers : x
		// HeaderFooter footer = new HeaderFooter(new Phrase(), true);
		// footer.setAlignment(Element.ALIGN_RIGHT);
		// footer.setBorder(Rectangle.TOP);
		// document.setFooter(footer);

		// add the event handler for advanced page numbers : x/y
		writer.setPageEvent(new AdvancedPageNumberEvents());

		return writer;
	}
1076671
public void writeContent(final OutputStream result) throws IOException
    {
        if(!inHeader) {
            if(this.offset != -1) {
                result.write(RtfFont.FONT_SIZE);
                result.write(intToByteArray(this.offset));
            }
            result.write(RtfParagraph.PARAGRAPH);
        }
        
        for(int i = 0; i < this.rows.size(); i++) {
        	RtfElement re = (RtfElement)this.rows.get(i);
            //.result.write(re.write());
        	re.writeContent(result);
        }
        
        result.write(RtfParagraph.PARAGRAPH_DEFAULTS);
    }
578868
def _write(self, text):
        """"""
        spaces = ' ' * (self.indent * self.indentlevel)
        t = spaces + text.strip() + '\n'
        if hasattr(t, 'encode'):
            t = t.encode(self.encoding, 'xmlcharrefreplace')
        self.stream.write(t)
360158
public void writeStartDocument() throws XMLStreamException {
		this.init();
		try {
			encoder.encodeStartDocument();
		} catch (Exception e) {
			throw new XMLStreamException(e.getLocalizedMessage(), e);
		}
	}
813341
public Writer writeTo(final Writer out) throws IOException {
        final Iterator iter = nodeIterator();
        while (iter.hasNext()) {
            ((Node) iter.next()).writeTo(out);
        }
        return out;
    }
1143989
private void write(String s) {
    synchronized (document) {
      int offset = document.getLength();
      try {
        document.insertString(offset, s, attributes);
      } catch (BadLocationException e) {
        throw new UnexpectedException(e);
      }
    }
  }
159018
private void writeDocument( Document document, File file )
        throws TransformerException, FileNotFoundException
    {
        document.normalize();
        DOMSource source = new DOMSource( document );
        StreamResult result = new StreamResult( new FileOutputStream( file ) );
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty( OutputKeys.INDENT, "yes" );
        transformer.transform( source, result );
    }
482497
public void write(Writer out)
         throws IOException
    {
        writeHtmlHead(out);
        
        out.write("<frameset "+border);
        
        if(colSpec!=null)
            out.write(" cols=\""+colSpec+"\"");
        if(rowSpec!=null)
            out.write(" rows=\""+rowSpec+"\"");
        out.write(">");

        for(int r=0;r<rows;r++)
            for(int c=0;c<cols;c++)
                frames[c][r].write(out);

        out.write("<noframes>");
        writeElements(out);
        out.write("</noframes>");

        out.write("</frameset>");
        out.write("</html>");
    }