Ben Langhinrichs

Photograph of Ben Langhinrichs

E-mail address - Ben Langhinrichs






September, 2004
SMTWTFS
   01 02 03 04
05 06 07 08 09 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30

Search the weblog





























Genii Weblog


Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.


Thu 16 Sep 2004, 11:02 PM
You can read the press release and read all about how our new Midas Rich Text C++ API lets you build new kinds of extensions, but you can also get an evaluation license and download the sample program, and build yourself a little menu add-in to see for yourself.  Take a look down below at the bottom two items on the Actions menu, and these actions are now available from any view in any database.  What could you build in to your Notes client with that kind of power?  (I have a menu add-in which just sorts tables and exports graphics, because those are two things I like to do a lot)  See below the image for a brief excerpt of the code involved.



Part of the code (but you can download the whole thing):
void ExportRenderedDoc (NAM_COMMAND_INFO *pInfo)
{
STATUS      sError;
VIEWIXDATA *viewData_;
HANDLE   hSelectedList;  /* handle to ID table of Selected notes */
DBHANDLE hDB;
DWORD    notes_scanned;  /* used in procedure IDScan() */
NOTEID   note_id;        /* gets NOTEIDs stored in ID table */
NOTEHANDLE hNote;
NOTEHANDLE hTempNote;
HANDLE     hCompound;
char       filepath[256];
USHORT     len;

  viewData_ = &(pInfo->Data.IXData.View);
  if (viewData_->hNoteFile == NULLHANDLE)
    return;

  hSelectedList = viewData_->hSelectedList;
  if (hSelectedList == NULLHANDLE)
    return;

  GeniiSession *gSession;
  GeniiRTItem  *rtitem;

  gSession = new GeniiSession;
  len = OSGetDataDirectory(filepath);
  if (len > 0)
    {
    if (filepath[strlen(filepath)-1] != '\\')
      strcat(filepath, "\\");
    strcat(filepath, "midisv.lic");
    IXPostMessage(filepath);
    }
  else
    strcpy(filepath, "c:\\lotus\\notes\\data\\midisv.lic");

  if (gSession != NULL)
    gSession->VerifyVersion = MIDAS_VERSION;
  if (gSession == NULL || !gSession->Authenticate(filepath))
    {
    IXPostMessage("Midas NOT authenticated");
    return;
    }

  hDB = viewData_->hNoteFile;
  notes_scanned = 0L;
  while(IDScan(hSelectedList, (FLAG)(notes_scanned++==0L), &note_id))
    {
    /* Open the selected document */
    sError = NSFNoteOpen (hDB, note_id, 0, &hNote);
    if (sError != NOERROR)
      return;

    /* Create a temporary document, with a compound context */
    sError = NSFNoteCreate(hDB, &hTempNote);
    if (sError != NOERROR)
      {
      NSFNoteClose(hNote);
      return;
      }

    /* Create the CompoundText context */
    sError = CompoundTextCreate (hTempNote, "Body", &hCompound);
    if (sError != NOERROR)
      {
      NSFNoteClose(hNote);
      NSFNoteClose(hTempNote);
      return;
      }

    /* Render the note into the context */
    sError = CompoundTextAddRenderedNote(hCompound, hNote, NULLHANDLE, (DWORD) 0);
    if (sError != NOERROR)
      {
     NSFNoteClose(hNote);
      NSFNoteClose(hTempNote);
      CompoundTextDiscard(hCompound);
      return;
      }

    /* Close the compound context */
    sError = CompoundTextClose (hCompound, NULL, NULL, NULL, 0);
    if (sError != NOERROR)
      {
      NSFNoteClose(hNote);
      NSFNoteClose(hTempNote);
      CompoundTextDiscard(hCompound);
      return;
      }

    /* Connect to temp field using Midas and Export to Mime */
    rtitem = new GeniiRTItem(gSession);
    sError = rtitem->ConnectBackend(hTempNote, "Body", FALSE);
    rtitem->Everything = rtitem->DefineChunk("Everything");
    rtitem->Everything->ConvertBitmaps("");
    sprintf(filepath, "c:\\temp\\NF%0X.htm", (unsigned long) note_id);
    IXPostMessage(filepath);
    rtitem->ExportToHTML(filepath, "XHTML",
                         "MoveStylesInline='Yes' "
                         "CSSBorders='Yes' "
                         "Generation='Fragment' "
                         "RespectHiddenFormulas='Yes' "
                         "RaiseLinkEvent='Doclink' "
                         "LocalDominoSymbols='Yes' "
                         "AttachmentHandling='To Disk' "
                         "AttachmentDirectory='c:\\temp' "
                         "AttachmentURLDirectory='c:\\temp' "
                         "AttachmentTextInLink='No' "
                         "ImageHandling='TO DISK' "
                         "ImageDirectory='c:\\temp' "
                         "ImageURLDirectory='c:\\temp' ",
                         0,
                         FixUpLinks);

    delete (rtitem);
    rtitem = NULL;
    }
}

Copyright © 2004 Genii Software Ltd.