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
@@ -1042,6 +1042,8 @@ bool fp_TextRun::canMergeWithNext(void)
 		    && !(*getRevisions() == *(pNext->getRevisions()))) //
 															   //non-null but different
 		|| (pNext->getVisibility() != getVisibility())
+		// The merge must make just one item
+		|| (!isOneItem(pNext))
 
 #if 0
 		// I do not think this should happen at all
@@ -2712,6 +2714,22 @@ UT_sint32 fp_TextRun::getStr(UT_UCSChar 
 	return -1;
 }
 
+/*!
+ * Returns if this run plus the next can be combined to make one contiguous 
+ * item
+ */
+bool fp_TextRun::isOneItem(fp_Run * pNext)
+{
+	GR_Itemization I;
+	bool b = getBlock()->itemizeSpan(getBlockOffset(), getLength()+pNext->getLength(),I);
+	UT_return_val_if_fail(b,false);
+	UT_DEBUGMSG(("Found %d items \n",I.getItemCount()-1));
+	if(I.getItemCount() <= 2)
+	{
+		return true;
+	}
+	return false;
+}
 void fp_TextRun::itemize(void)
 {
 	GR_Itemization I;
Index: src/text/fmt/xp/fp_TextRun.h
===================================================================
--- src/text/fmt/xp/fp_TextRun.h.orig
+++ src/text/fmt/xp/fp_TextRun.h
@@ -65,6 +65,7 @@ public:
 	bool					canMergeWithNext(void);
 	void					mergeWithNext(void);
 	bool                    findFirstNonBlankSplitPoint(fp_RunSplitInfo & splitInfo);
+	bool                    isOneItem(fp_Run * pNext);
 	enum
 	{
 		Calculate_full_width = -1