' DocumentDiffer class v1.00 by yamachan 2006/11/08 Public Class DocumentDiffer Private oldDoc As NotesDocument Private diffDoc As NotesDocument ' ------- Public methods ------- Sub addItem(doc As NotesDocument, itemName$) Dim tmpItem As NotesItem Set tmpItem = doc.getFirstItem(itemName$) If Not(tmpItem Is Nothing) Then Call tmpItem.CopyItemToDocument(Me.oldDoc, itemName$) End If End Sub Sub removeItem(itemName$) Call Me.oldDoc.removeItem(itemName$) End Sub Function process(doc As NotesDocument) As NotesDocument Dim session As New NotesSession Dim tmpItem As NotesItem If Not(Me.diffDoc Is Nothing) Then Delete Me.diffDoc End If Set Me.diffDoc = session.CurrentDatabase.CreateDocument Forall item In Me.oldDoc.Items If doc.HasItem(item.Name) Then Set tmpItem = doc.GetFirstItem(item.Name) If tmpItem.Text <> item.Text Then Call tmpItem.CopyItemToDocument(Me.diffDoc, item.Name) End If End If End Forall Set process = Me.diffDoc End Function Function getOldValue(itemName$) As String Dim tmpItem As NotesItem Set tmpItem = Me.oldDoc.getFirstItem(itemName$) If Not(tmpItem Is Nothing) Then getOldValue = tmpItem.Text End If End Function Function toString() As String toString = "" If Me.diffDoc Is Nothing Then Exit Function End If Forall item In Me.diffDoc.Items toString = toString & item.Name & ": " & Me.getOldValue(item.Name) & " -> " & item.Text & Chr(10) End Forall End Function Function toStringWithLabel(labelList$ List) As String toStringWithLabel = "" If Me.diffDoc Is Nothing Then Exit Function End If Forall item In Me.diffDoc.Items If Iselement(labelList(item.Name)) = True Then toStringWithLabel = toStringWithLabel & labelList(item.Name) & ": " & Me.getOldValue(item.Name) & " -> " & item.Text & Chr(10) End If End Forall End Function Sub workWith(coWoker As Variant) If Typename(coWoker) = "CORELOG" Then Call coWoker.logText(toString()) End If End Sub ' ------- Constractor/Destractor methods ------- Sub New(doc As NotesDocument) Dim session As New NotesSession Set Me.oldDoc = session.CurrentDatabase.CreateDocument Forall item In doc.Items If item.Type = DATETIMES Or item.Type = NAMES Or item.Type = NUMBERS Or item.Type = TEXT Then If Left$(item.Name, 1) <> "$" Then Call item.CopyItemToDocument(Me.oldDoc, item.Name) End If End If End Forall End Sub Sub Delete Delete Me.oldDoc If Not(Me.diffDoc Is Nothing) Then Delete Me.diffDoc End If End Sub End Class