/*!
	\brief Remove some text
	\param line target line
	\param pos target text position within line
	\param length length of the text to remove

	This helper method is provided so that subclasses may actually
	modify the document contents without using private API.
*/
void QDocumentCommand::removeText(int line, int pos, int length)
{
	if ( !m_doc )
		return;

	QDocumentPrivate *pd = m_doc->impl();
	QDocumentLineHandle *h = pd->m_lines.at(line);

	if ( !h || !length )
		return;

	h->lockForWriteText();
	h->textBuffer().remove(pos, length);
	h->shiftOverlays(pos, -length);
	h->unlock();
}
/*!
	\brief Insert some text
	\param line target line
	\param pos target text position within line
	\param s text to insert

	This helper method is provided so that subclasses may actually
	modify the document contents without using private API.
*/
void QDocumentCommand::insertText(int line, int pos, const QString& s)
{
	if ( !m_doc )
		return;

	QDocumentPrivate *pd = m_doc->impl();
	QDocumentLineHandle *h = pd->m_lines.at(line);

	if ( !h )
		return;
	
	h->lockForWriteText();
	h->textBuffer().insert(pos, s);
	h->shiftOverlays(pos, s.length());
	h->unlock();
}