#include <stdio.h>
#include <string.h>
#include <global.h>
#include <nsfdb.h>
#include <nsfnote.h>
#include <oleods.h>
/* Prototypes */
STATUS LNPUBLIC ProcessOneCDRecord(
char *RecordPtr,
WORD RecordType,
DWORD RecordLength,
void *p_ptr_void );
void CleanUp(
DBHANDLE db_handle,
NOTEHANDLE note_handle);
void ProcessImageHeader(
char *RecordPtr,
DWORD RecordLength,
WORD RecordType );
int main(int argc, char *argv[])
{
char db_filename[]="rt.nsf";
DBHANDLE db_handle;
NOTEHANDLE note_handle;
STATUS error = NOERROR;
char itemname[] ="Body";
DWORD NoteID = 2294;
BLOCKID item_blockid;
BLOCKID value_blockid;
WORD value_datatype;
DWORD value_len;
if (error = NotesInitExtended (argc, argv))
{ printf("\n Unable to initialize Notes.\n");
return (1); }
/*Open Database*/
if (error = NSFDbOpen (db_filename, &db_handle))
{ printf("\n Unable to open database.\n");
NotesTerm();
return (1); }
/*Open Note*/
if (error = NSFNoteOpen (db_handle, NoteID, 0, ¬e_handle))
{ printf("\n Unable to open note.\n");
NotesTerm();
return (1); }
if (error = NSFItemInfo (
note_handle,
itemname,
strlen(itemname),
&item_blockid,
&value_datatype,
&value_blockid,
&value_len))
{
printf("\n Unable to get note-info.\n");
CleanUp (db_handle, note_handle);
return (1);
}
if (error = EnumCompositeBuffer(
value_blockid,
value_len,
ProcessOneCDRecord,
NULL ) )
{
CleanUp(db_handle, note_handle);
return(0);
}
if (error = NSFDbClose (db_handle))
return (1);
NotesTerm();
return (0);
}
/*************************************************************************
FUNCTION: CleanUp
**************************************************************************/
void CleanUp(DBHANDLE db_handle, NOTEHANDLE note_handle)
{
NSFDbClose (db_handle);
NSFNoteClose (note_handle);
NotesTerm();
}
/************************************************************************
FUNCTION: ProcessOneCDRecord
*************************************************************************/
STATUS LNPUBLIC ProcessOneCDRecord(
char *RecordPtr,
WORD RecordType,
DWORD RecordLength,
void *p_ptr_void )
{
switch (RecordType)
{
case SIG_CD_IMAGEHEADER:
ProcessImageHeader( RecordPtr, RecordLength, RecordType );
break;
}
return(NOERROR);
}
/*************************************************************************
FUNCTION: ProcessImageHeader
**************************************************************************/
void ProcessImageHeader( char *RecordPtr, DWORD RecordLength, WORD RecordType )
{
char far * p = RecordPtr;
char ImgType[4];
CDIMAGEHEADER cdImgageHeader;
ODSReadMemory( &p, _CDIMAGEHEADER, &cdImgageHeader, 1 );
printf("\n");
printf("Embedded Image Groesse: %d Bytes\n", cdImgageHeader.ImageDataSize);
printf("Embedded Image Breite: %d Pixel\n", cdImgageHeader.Width);
printf("Embedded Image Hoehe: %d Pixel\n", cdImgageHeader.Height);
switch (cdImgageHeader.ImageType)
{
case CDIMAGETYPE_GIF:
strcpy (ImgType,"GIF");
break;
case CDIMAGETYPE_JPEG:
strcpy (ImgType,"JPG");
break;
case CDIMAGETYPE_BMP:
strcpy (ImgType,"BMP");
break;
}
printf("Embedded Image Type: %s \n", ImgType);
return;
}
nein, mit LS2CAPI kann man da nix machen, da Lotusscript keine Callbacks unterstützt.Kleine Korrektur: Mit ein paar Tricks geht das doch in gewissen Grenzen. Wie das funktioniert, verrate ich auf dem EntwicklerCamp
kennt ihr zufällig eine Möglichkeit mir der ich die Größe von eingebetteten Bildern in einem RTF ermitteln kann?
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim doc As NotesDocument
On Error Goto oops
Source.Refresh True ' update rich text data into back end.
Set doc = Source.Document
Dim session As New NotesSession
Dim stream As NotesStream
Dim dxle As NotesDXLExporter
Dim domp As NotesDOMParser
Dim domd As NotesDOMDocumentNode
Dim nl As NotesDOMNodeList
Set stream = session.CreateStream
Set dxle = session.CreateDXLExporter(doc, stream)
dxle.RestrictToItemNames = "Body"
' at this point you might want to set additional properties for efficiency, e.g. to omit attachments
' please note that if you want to disallow certain types of content, you can use a Rich Text Lite field,
' so this is not the preferrred way to block users from adding an image.
dxle.Process
Set domp = session.CreateDOMParser(stream)
domp.Parse
Set domd = domp.Document
Set nl = domd.GetElementsByTagName("picture")
If nl.NumberOfEntries <> 1 Then
Msgbox "You must have exactly one image in the Body field."
Continue = False
Exit Sub
End If
Dim picture As NotesDOMElementNode
Set picture = nl.GetItem(1)
Dim picX As Long, picY As Long
picX = Clng("0"+Strleft(picture.GetAttribute("width"), "px"))
picY = Clng("0"+Strleft(picture.GetAttribute("height"), "px"))
If picX > 400 Or picY > 400 Then
Msgbox "The image may not exceed 400x400 pixels."
Continue = False
Exit Sub
End If
If stream.Bytes > 160000 Then
Msgbox "The image is too large. Please IMPORT the image from a GIF or JPEG file; do not paste graphics or import a BMP file. Thanks."
Continue = False
Exit Sub
End If
' else: success!
Exit Sub
oops:
' if a validation failure don't bother to display the error because user already saw one.
If Err <> 4412 Then Msgbox "Error " & Err & " in Querysave line " & Erl & ": " & Error
Continue = False
Exit Sub
End Sub
Andre Guriard (spell?)
<?xml version="1.0" encoding="UTF-16" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:doc="http://www.lotus.com/dxl">
<xsl:template match="/doc:document">
<xsl:apply-templates select="doc:item[@name='body']" />
</xsl:template>
<xsl:template match="doc:item">
<xsl:copy-of select="./child::*" />
</xsl:template>
</xsl:stylesheet>