Jean-Marc Lasgouttes wrote:
> Actually, with this enum and maybe a few comment, I am OK with this
> patch in 1.4.2.

What about the attached?

Jürgen
Index: src/paragraph.h
===================================================================
--- src/paragraph.h	(Revision 13648)
+++ src/paragraph.h	(Arbeitskopie)
@@ -72,6 +72,15 @@ public:
 		META_INSET = 1
 		//META_INSET = 0x200001  // above 0x10ffff, for ucs-4
 	};
+	enum ChangeTracking
+	{
+		/// Change tracking is "on" in this buffer
+		CT_On,
+		/// Change tracking is "off" in this buffer
+		CT_Off,
+		/// Change tracking is "unknown" in this buffer
+		CT_Unknown
+	};
 	///
 	typedef lyx::char_type value_type;
 	///
@@ -209,7 +218,7 @@ public:
 	void untrackChanges();
 
 	/// set entire paragraph to new text for change tracking
-	void cleanChanges();
+	void cleanChanges(Paragraph::ChangeTracking ct = Paragraph::CT_Unknown);
 
 	/// look up change type at given pos
 	Change::Type lookupChange(lyx::pos_type pos) const;
Index: src/paragraph_pimpl.C
===================================================================
--- src/paragraph_pimpl.C	(Revision 13648)
+++ src/paragraph_pimpl.C	(Arbeitskopie)
@@ -14,6 +14,7 @@
 #include <config.h>
 
 #include "paragraph_pimpl.h"
+#include "paragraph.h"
 
 #include "bufferparams.h"
 #include "debug.h"
@@ -109,12 +110,20 @@ void Paragraph::Pimpl::untrackChanges()
 }
 
 
-void Paragraph::Pimpl::cleanChanges()
+void Paragraph::Pimpl::cleanChanges(Paragraph::ChangeTracking ct)
 {
-	// if we're not tracking, we don't want to reset...
-	if (!tracking())
+	// if the paragraph was not tracked and we don't know the buffer's
+	// change tracking state, we do nothing
+	if ((ct == Paragraph::CT_Unknown) && !tracking())
 		return;
 
+	// untrack everything if we are in a buffer where ct is disabled
+	else if (ct == Paragraph::CT_Off) {
+		untrackChanges();
+		return;
+	}
+	
+	// in a buffer where ct is enabled, set everything to INSERTED
 	changes_.reset(new Changes(Change::INSERTED));
 	changes_->set(Change::INSERTED, 0, size() + 1);
 }
Index: src/CutAndPaste.C
===================================================================
--- src/CutAndPaste.C	(Revision 13648)
+++ src/CutAndPaste.C	(Arbeitskopie)
@@ -172,6 +172,12 @@ pasteSelectionHelper(Buffer const & buff
 			    !pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
 				tmpbuf->erase(i--);
 		}
+
+		// reset change tracking status
+		if (buffer.params().tracking_changes)
+			tmpbuf->cleanChanges(Paragraph::CT_On);
+		else
+			tmpbuf->cleanChanges(Paragraph::CT_Off);
 	}
 
 	bool const empty = pars[pit].empty();
Index: src/paragraph_pimpl.h
===================================================================
--- src/paragraph_pimpl.h	(Revision 13648)
+++ src/paragraph_pimpl.h	(Arbeitskopie)
@@ -43,7 +43,7 @@ public:
 	/// stop tracking
 	void untrackChanges();
 	/// set all text as new for change mode
-	void cleanChanges();
+	void cleanChanges(Paragraph::ChangeTracking ct = Paragraph::CT_Unknown);
 	/// look up change type at given pos
 	Change::Type lookupChange(lyx::pos_type pos) const;
 	/// look up change at given pos
Index: src/paragraph.C
===================================================================
--- src/paragraph.C	(Revision 13648)
+++ src/paragraph.C	(Arbeitskopie)
@@ -1620,9 +1620,9 @@ void Paragraph::untrackChanges()
 }
 
 
-void Paragraph::cleanChanges()
+void Paragraph::cleanChanges(ChangeTracking ct)
 {
-	pimpl_->cleanChanges();
+	pimpl_->cleanChanges(ct);
 }
 
 

Reply via email to