Created
March 25, 2011 17:22
-
-
Save turumbay/887216 to your computer and use it in GitHub Desktop.
lotusscript howto: sign hotspots in rich text fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Declare Function NSFNoteSignHotspots Lib "nnotes.dll" ( Byval hNote As Long, Byval dwFlags As Long , Byval retfSigned As Integer) As Integer | |
Declare Function NSFNoteUpdate Lib "nnotes.dll" (Byval hNote As Long, Byval flags As Integer) As Integer | |
'' USAGE: | |
'' Dim signer As New HotSpotSigner(doc) | |
'' Call signer.sign() | |
Class HotSpotSigner | |
Private t_doc As NotesDocument | |
Private t_db As NotesDatabase | |
Private t_unid As String | |
Sub new( i_doc As NotesDocument ) | |
Set t_doc = i_doc | |
Set t_db = i_doc.ParentDatabase | |
t_unid = i_doc.UniversalID | |
End Sub | |
Sub sign() | |
' clear hotspots signatures, using dxl bug | |
Call reexport() | |
Call signHotSpots() | |
'** a little trick to avoid this message on recompiled forms: | |
'** This document has been altered since the last time it was signed! Intentional tampering may have occurred. | |
Call reopenDocFromFromDisk() | |
Call t_doc.Sign() | |
Call t_doc.Save(True, False) | |
End Sub | |
' export and import doc via dxl. clears hotspots signatures | |
Private Sub reexport() | |
Dim session As New NotesSession | |
Dim stream As NotesStream | |
Set stream = session.CreateStream | |
Dim exporter As NotesDXLExporter | |
Set exporter = session.CreateDXLExporter | |
Call exporter.SetInput( t_doc) | |
Call exporter.SetOutput(stream) | |
Call exporter.Process | |
Dim importer As NotesDXLImporter | |
Set importer = session.CreateDXLImporter(stream, t_db ) | |
importer.DocumentImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE | |
Call importer.Process | |
Call reopenDocFromFromDisk() | |
End Sub | |
Private Sub signHotSpots | |
If NSFNoteSignHotspots( t_doc.Handle , 0 , False ) <> 0 Then | |
Error 1001 , "Cannot sign: " | |
End If | |
If NSFNoteUpdate( t_doc.Handle , 0) <> 0 Then | |
Error 1001 , "Cannot save: " | |
End If | |
End Sub | |
' update in-memory reference to document | |
Private Sub reopenDocFromFromDisk() | |
Delete t_doc | |
Set t_doc = t_db.GetDocumentByUNID(t_unid) | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment