Blob Blame History Raw
Index: src/text/fmt/xp/fp_TextRun.cpp
===================================================================
--- src/text/fmt/xp/fp_TextRun.cpp.orig
+++ src/text/fmt/xp/fp_TextRun.cpp
@@ -715,7 +715,7 @@ void fp_TextRun::mapXYToPosition(UT_sint
 			// don't set bBOL to false here
 			bEOL = false;
 		}
-
+		pos += adjustCaretPosition(pos,true);
 		return;
 	}
 
@@ -744,7 +744,7 @@ void fp_TextRun::mapXYToPosition(UT_sint
 			// the correct place to do it.	2001.02.25 jskov
 			bEOL = true;
 		}
-
+		pos += adjustCaretPosition(pos,true);
 		return;
 	}
 
@@ -779,6 +779,7 @@ void fp_TextRun::mapXYToPosition(UT_sint
 
 			bBOL = false;
 			bEOL = false;
+			pos += adjustCaretPosition(pos,true);
 			return;
 		}
 
@@ -812,6 +813,7 @@ void fp_TextRun::mapXYToPosition(UT_sint
 					iLog = getLength() - i;
 				
 				pos = getBlock()->getPosition() + getBlockOffset() + iLog;
+				pos += adjustCaretPosition(pos,true);
 				return;
 			}
 		}
@@ -838,6 +840,7 @@ void fp_TextRun::mapXYToPosition(UT_sint
 		// reset this, so we have no stale pointers there
 		m_pRenderInfo->m_pText = NULL;
 #endif
+		pos = adjustCaretPosition(pos,true);
 		return;
 	}
 	
@@ -853,18 +856,19 @@ void fp_TextRun::findPointCoords(UT_uint
 	UT_sint32 yoff2;
 	UT_sint32 xdiff = 0;
 	xxx_UT_DEBUGMSG(("findPointCoords: Text Run offset %d \n",iOffset));
-
 	if(!m_pRenderInfo || _getRefreshDrawBuffer() == GRSR_Unknown)
 	{
 		// this can happen immediately after run is inserted at the
 		// end of a paragraph.
 		_refreshDrawBuffer();
 	}
-
 	UT_return_if_fail(m_pRenderInfo);
 	
 	UT_return_if_fail(getLine());
 
+	//	UT_uint32 docPos = getBlockOffset() + getBlock()->getPosition() +iOffset;
+	//docPos = adjustCaretPosition(docPos,true);
+	//iOffset = docPos - getBlockOffset() + getBlock()->getPosition();
 	getLine()->getOffsets(this, xoff, yoff);
 
 	if (m_fPosition == TEXT_POSITION_SUPERSCRIPT)
@@ -3274,9 +3278,10 @@ void fp_TextRun::updateOnDelete(UT_uint3
 
 UT_uint32 fp_TextRun::adjustCaretPosition(UT_uint32 iDocumentPosition, bool bForward)
 {
+
 	UT_uint32 iRunOffset = getBlockOffset() + getBlock()->getPosition();
 
-	UT_return_val_if_fail( iDocumentPosition >= iRunOffset && iDocumentPosition < iRunOffset + getLength() &&
+	UT_return_val_if_fail( iDocumentPosition >= iRunOffset && iDocumentPosition <= iRunOffset + getLength() &&
 						   m_pRenderInfo,
 						   iDocumentPosition);
 
@@ -3294,8 +3299,11 @@ UT_uint32 fp_TextRun::adjustCaretPositio
 	m_pRenderInfo->m_pText = &text;
 	m_pRenderInfo->m_iOffset = iDocumentPosition - iRunOffset;
 	m_pRenderInfo->m_iLength = getLength();
-	
-	return iRunOffset + getGraphics()->adjustCaretPosition(*m_pRenderInfo, bForward);
+	UT_uint32 adjustedPos = iRunOffset + getGraphics()->adjustCaretPosition(*m_pRenderInfo, bForward);
+	if((adjustedPos - iRunOffset) > getLength())
+		adjustedPos = iRunOffset + getLength();
+	_refreshDrawBuffer();
+	return adjustedPos;
 }
 
 void fp_TextRun::adjustDeletePosition(UT_uint32 &iDocumentPosition, UT_uint32 &iCount)
Index: src/af/gr/unix/gr_UnixPangoGraphics.cpp
===================================================================
--- src/af/gr/unix/gr_UnixPangoGraphics.cpp.orig
+++ src/af/gr/unix/gr_UnixPangoGraphics.cpp
@@ -2122,7 +2122,7 @@ void GR_UnixPangoGraphics::positionToXY(
 		// withing range of our string
 		pOffset = g_utf8_offset_to_pointer (pUtf8, RI.m_iOffset);
 	}
-	else if(i > 1)
+	else if(i >= 1)
 	{
 		// this is the case where the requested offset is past the end
 		// of our string; we will use the last char; as we have more than one