Hi,
I’ve just come across a problem developing a custom dll using C++ API toolkit v2.3 and LSX 3.1.
Whenever my code tries to export a richtext field that contains a table to a Word document I get an error message ‘This function should not be called in this situation’. I’ve looked this up in the lnerrors.h file and found that this maps to UNANTICIPATED_FUNCTION_CALLED.
What’s got me stumped is that this used to work fine. I recently had to recompile my dll due to a bug fix in a different function. Since then the export function refuses to work for richtext fields with tables.
Has anyone else encountered this problem and know of a fix/workaround ? If I can’t solve this it will be a major issue as the client needs this custom reporting facility.
I’ve included the code below. The function takes the name of a text file which contains a list of the document UNIDs that are to be exported together with the filenames I want the exported docs to have. It then loops through the file and exports each ‘Body’ richtext field within those documents.
LSSSHORT CppDB::Export(LSXString file)
{
LSSSHORT retvalue = 0;
FILE *fp;
LNViewFolder ByUNID;
LNString lns_unid;
LNString ln_field;
LNRichText rtfield;
char filetoExport[50]; //File to export field to
char KeyWord[50]; // first keyword
char field[50]; // Field to export
LNString lnRADFile; // for dynamic cast
LNString lnRADKeyString; // for dynamic cast
try
{
//Get view
m_LNDB.GetViewFolder("vw_UNID", &ByUNID);
//Open view
ByUNID.Open();
//Open text file
fp = fopen(file,"r");
if (fp ==NULL)
{
fnRADUpdateErrFile(-300, "Cannot open search file", "Export");
return -300;
}
//Position pointer at beginning of file
fseek( fp, 0L, SEEK_SET );
// loop for each keyword
while ( fscanf(fp, "%s %s", filetoExport, KeyWord) != EOF )
{
// dynamic cast
lnRADFile = filetoExport;
lnRADKeyString = KeyWord;
LNRichText rtfield;
LNRTCursor sCursor, eCursor;
LNDocument pq;
LNVFEntry entry;
LNDocument doc;
//Find doc
if( ByUNID.Find(lnRADKeyString, &entry) == LNNOERROR)
{
//Get Doc
if( entry.GetDocument(&doc) == LNNOERROR )
{
doc.Open();
//Does it have field we need to export?
if(doc.HasItem("Body"))
{
doc.GetItem("Body", &rtfield);
//Get start and end of field
LNSTATUS cStart = rtfield.GetCursor(&sCursor);
LNSTATUS cEnd = rtfield.GetEndCursor(&eCursor);
//Export file
if (cStart == LNNOERROR && cEnd == LNNOERROR) {
//export all text between start and end
LNSTATUS Exp = rtfield.Export(lnRADFile, sCursor, eCursor);
}
}
//Close down doc
doc.Close();
}
}
}
//Close down file
fclose(fp);
//Close down view
ByUNID.Close();
}
catch (LNSTATUS Lnerror)
{
char ErrorBuf[LNERROR_MESSAGE_LENGTH];
LNGetErrorMessage(Lnerror, ErrorBuf, LNERROR_MESSAGE_LENGTH);
//Write error out to file
fnRADUpdateErrFile(-200, ErrorBuf, "Export");
LSXSetErrorCode(LSX_ERROR);
//Tell LotusScript to read file for error message
retvalue = -200;
}
return retvalue;
}
This code worked consistently on 4.6.6b and was working fine up until I had to recompile due to the bug fix. I’ve tried other versions of the C++ API (namely 2.4 and 3.0) but cannot get the compiled dll to work in Notes, I keep getting assertion errors in lsxcomm.cpp.
Any help would be greatly appreciated.
Thanks