File:  [mozdev] / abimoz / plugin / nsWPPlugin.cpp
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Fri Oct 25 14:42:28 2002 UTC (15 years, 1 month ago) by mikep
Branches: MAIN
CVS tags: HEAD
Upgraded to Mozilla 1.2b and abiword 1.0.3.

/*
This file is part of AbiMoz.

nsWPPlugin.cpp - Implements the nsWPPluginInterface for the WordProcessor plugin
Copyright (C) 2001 OEone Corporation

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

The author of this program can be contacted in writing at
OEone Corporation, 290 St-Joseph Blvd., Hull, QC J8Y 3Y3, CANADA.
*/
    
/*
*   Author: Mostafa Hosseini ( mostafah@oeone.com )
*   Contributor: Mike Potter ( mikep@oeone.com )
*   Aug 16 2001
*/

#include <gdk/gdkx.h>
#include "nsWPPlugin.h"
#include "gtkmozbox.h"
#include "nsMemory.h"

//List of plugin commands accepted by the AbiWord library
#define PL_SHUTDOWN             100
#define PL_DESTROY              0
#define PL_NEWFRAME             1
#define PL_CLONE                2
#define PL_SETGEOMETRY          3
#define PL_INVOKEMENUMETHOD     4
#define PL_FILENEW              5
#define PL_FILEOPENBYNAME       6
#define PL_FILESAVEBYNAME       7
#define PL_FILESAVEASFILETYPE   8
#define PL_GETCURRENTDOC        9
#define PL_ISDOCMODIFIED        10
#define PL_SETCOLOR             11
#define PL_SETBGCOLOR           12
#define PL_GETATTRIBUTE         13
#define PL_GETALIGNMENT         14
#define PL_ISLIST               15
#define PL_GETFONTLIST          16
#define PL_GETRECENTLIST        17
#define PL_SETZOOM              18
#define PL_SETFONT              19
#define PL_SETFONTSIZE          20
#define PL_INSERTIMGFROMFILE    21
#define PL_SETTABSTOP           22
#define PL_SETCOLUMNS           23
#define PL_HIDEMENU             24
#define PL_SETNORMALSTYLE       25
#define PL_STARTSEARCH          26
#define PL_FIND                 27
#define PL_REPLACE              28
#define PL_SETPORTRAIT          29
#define PL_SETPRINTSCALE        30
#define PL_SETPAPERSIZE         31
#define PL_SETMARGINS           32
#define PL_CLEARTOOLBARS        33
#define PL_FILEOPEN             34
#define PL_SETFOCUS             35
#define PL_CLRHDRFTR            36

int abwmain( int, char ** );
char *pluginCommand( void *, int c, void * );
struct _Filenametype {
    const char *name;
    const char *type;
};


////////////////////////////////////////////////////////////////////////////
// Plugin Instance API Methods

//Listener for wordprocessor events
nsIWPPluginListener* nsWPPluginInstance::m_listener;

/*
*   Constructor of the plugin instance
*/
nsWPPluginInstance::nsWPPluginInstance(NPP pNPInstance) :
  m_pNPInstance(pNPInstance),
  m_pNPStream(NULL),
  m_NPWindow(NULL),
  m_bInitialized(FALSE),
  m_pScriptablePeer(NULL)
{
#ifdef PLUGIN_DEBUG
    printf("nsWPPluginInstance::nsWPPluginInstance()\n");
#endif
    nsWPPluginInstance::m_listener = nsnull;
    Initialize();
    pluginFrame = nsnull;
}

/*
*   Destructor of the plugin instance
*/
nsWPPluginInstance::~nsWPPluginInstance(void)
{
#ifdef PLUGIN_DEBUG
    printf("nsWPPluginInstance::~nsWPPluginInstance()\n");
#endif 

    if( pluginFrame != NULL ) {
        //This is to inform AbiWord to destroy the frame that was being used
	    pluginCommand( &pluginFrame, PL_DESTROY, NULL );
	    pluginFrame = nsnull;
    }

    NS_IF_RELEASE(m_pScriptablePeer);
}

/*
*   Plugin Initializer
*   All one time initialization is placed here
*   abwmain is called everytime so 
*   taking care of whether AbiWord has already been initialized or not is done in the function itself
*/
NS_METHOD
nsWPPluginInstance::Initialize()
{
#ifdef PLUGIN_DEBUG
    printf("nsWPPluginInstance::Initialize()\n");
#endif

    char *argv[2];
    argv[0] = "AbiWord";
    argv[1] = "--nosplash";

    abwmain( 2, argv );
    
    return NS_OK;
}

NPBool
nsWPPluginInstance::isInitialized()
{
    return true;
}

// ==============================
// ! Scriptability related code !
// ==============================
//
// this method will return the scriptable object (and create it if necessary)
nsIWPPluginInstance* nsWPPluginInstance::getScriptablePeer()
{
  if (!m_pScriptablePeer) {
    m_pScriptablePeer = new pnWPPluginScriptablePeer(this);
    if(!m_pScriptablePeer)
      return NULL;

    NS_ADDREF(m_pScriptablePeer);
  }

  // add reference for the caller requesting the object
  NS_ADDREF(m_pScriptablePeer);
  return m_pScriptablePeer;
}

NS_METHOD
nsWPPluginInstance::ShutDown( void )
{
#ifdef PLUGIN_DEBUG
    printf("nsWPPluginInstance::Destroy()\n");
#endif
    return NS_OK;
}

/*
*   This function is called when the window is ready for the plugin to use
*   or
*   in case the window is no longer available
*/
NS_METHOD
nsWPPluginInstance::SetWindow( NPWindow *window )
{
#ifdef PLUGIN_DEBUG
    printf("nsWPPluginInstance::SetWindow()\n");
#endif

    //If the window is no longer available we don't have much to do
    if (window == NULL || window->window == NULL)
        return NS_OK;

    //If the window has been passed aready we don't have much to do
    if (m_window == window)
        return NS_OK;

    //Store the window for future reference
    m_window = window;

    //Create a clean widget from the window
    Display *display = XOpenDisplay( getenv( "DISPLAY" ) );

    GdkWindow *win = gdk_window_foreign_new( (XID)window->window );
    pluginWidget = gtk_mozbox_new(win);

    //Set the geometry based on the given window's size
    int geo[2];
    geo[0] = window->width;
    geo[1] = window->height;
    pluginCommand( &pluginFrame, PL_SETGEOMETRY, geo );

    //We don't want toolbars and status bars
    pluginCommand( &pluginFrame, PL_CLEARTOOLBARS, NULL );

    //Uncomment if you don't want the menu
    //pluginCommand( &pluginFrame, PL_HIDEMENU, NULL );

    if( pluginFrame ) {
        //If the window has changed just copy the previous window contents into the new one by cloning
    	pluginCommand( &pluginFrame, PL_CLONE, pluginWidget );
    }
    else {
        //If this is the first time we're getting a window set up a new frame for it
    	pluginCommand( &pluginFrame, PL_NEWFRAME, pluginWidget );
    }
    return NS_OK;
}

// End of Plugin Instance API Methods.
////////////////////////////////////////////////////////////////////////////

/*
*   A general purpose function to access all functions available to menus
*   Params: char *cmd: The name of the function to call
*/
NS_IMETHODIMP
nsWPPluginInstance::DoCommand(const char *cmd)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD , (void *)cmd );
    return NS_OK;
}

/*
*   Function for requesting a new clean document
*/
NS_IMETHODIMP
nsWPPluginInstance::New(void)
{
    //We should provide a new widget for the plugin
    GdkWindow *win = gdk_window_lookup((XID)m_window->window);
    pluginWidget = gtk_mozbox_new(win);

    pluginCommand( &pluginFrame, PL_FILENEW , pluginWidget );

    return NS_OK;
}

/*
*   Function for opening a specific document
*   Params: char* pathname: Pathname of the document to open
*           type: type of the document
*   Returns: Name of the opened document on success, Null otherwise
*/
NS_IMETHODIMP
nsWPPluginInstance::OpenByName( const char *pathname, const char *filetype, char **retval )
{
#ifdef PLUGIN_DEBUG
    printf("nsWPPluginInstance::OpenByName(%s,%s)\n", pathname, filetype);
#endif
    //We should provide a new widget for the plugin
   	GdkWindow *win = gdk_window_lookup((XID)m_window->window);
   	pluginWidget = gtk_mozbox_new(win);

    pluginCommand( &pluginFrame, PL_FILENEW , pluginWidget );
    
    struct _Filenametype nametype;
    nametype.name = pathname;
    nametype.type = filetype;
    
    char *result = pluginCommand( &pluginFrame, PL_FILEOPENBYNAME, &nametype );
    if ( result == NULL ) {
    	*retval = NULL;
    } else {
    	*retval =(char*) nsMemory::Clone( result, strlen(result)+1);
    }
    return NS_OK;
}

/*
*   Function for saving documents
*/
NS_IMETHODIMP
nsWPPluginInstance::Save(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"fileSave" );
    return NS_OK;
}

/*
*   Function for saving documents with a new name
*/
NS_IMETHODIMP
nsWPPluginInstance::SaveAs(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"fileSaveAs" );
    return NS_OK;
}

/*
*   Function for saving documents by a specified name and a specified type
*   Params: char *pathname: Path and name of the document to save to
*           type: type of document to save to
*/
NS_IMETHODIMP
nsWPPluginInstance::SaveAsFileType(const char *pathname, const char *filetype, PRBool *retval )
{
#ifdef PLUGIN_DEBUG
    printf("nsWPPluginInstance::SaveAsFileType(%s,%s)\n", pathname, filetype);
#endif

    struct _Filenametype nametype;

    nametype.name = pathname;
    nametype.type = filetype;
    
    char *result = pluginCommand( &pluginFrame, PL_FILESAVEASFILETYPE, &nametype );
    if ( strcmp( result, "true" ) == 0 ) {
    	*retval = true;
    } else {
    	*retval = false;
    }
    return NS_OK;
}

/*
*   Function to toggle the bold attribute
*/
NS_IMETHODIMP
nsWPPluginInstance::ToggleBold(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"toggleBold" );
    return NS_OK;
}

/*
*   Function to toggle the italic attribute
*/
NS_IMETHODIMP
nsWPPluginInstance::ToggleItalic(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"toggleItalic" );
    return NS_OK;
}

/*
*   Function to Toggle the underline attribute
*/
NS_IMETHODIMP
nsWPPluginInstance::ToggleUline(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"toggleUline" );
    return NS_OK;
}

/*
*   Function to provide a choice of fonts
*/
NS_IMETHODIMP
nsWPPluginInstance::ChooseFont(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"dlgFont" );
    return NS_OK;
}

/*
*   Function to bring up the spell check dialog
*/
NS_IMETHODIMP
nsWPPluginInstance::SpellCheck(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"dlgSpell" );
    return NS_OK;
}

/*
*   Function for inserting an image
*/
NS_IMETHODIMP
nsWPPluginInstance::InsertImage(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"fileInsertGraphic" );
    return NS_OK;
}

/*
*   Function for setting the style of the paragraph
*   Params: style: ( 0 = Normal, 1= Heading1, 2= Heading2, 3= Heading3 )
*/
NS_IMETHODIMP
nsWPPluginInstance::SetStyle(PRInt32 style)
{
	switch( style ) {
		case 0:
			pluginCommand( &pluginFrame, PL_SETNORMALSTYLE, NULL );
			break;
		case 1:
			pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"setStyleHeading1" );
			break;
		case 2:
			pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"setStyleHeading2" );
			break;
		case 3:
			pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"setStyleHeading3" );
			break;
	}
    return NS_OK;
}

/*
*   Function for setting alignment of text
*   Params: alignment: ( 0 = Left, 1= Right, 2= Center, 3= Justify )
*/
NS_IMETHODIMP
nsWPPluginInstance::SetAlignment(PRInt32 alignment)
{
	switch( alignment ) {
		case 0:
			pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"alignLeft" );
			break;
		case 1:
			pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"alignRight" );
			break;
		case 2:
			pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"alignCenter" );
			break;
		case 3:
			pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"alignJustify" );
			break;
	}
    return NS_OK;
}

/*
*   Function to toggle bullets
*/
NS_IMETHODIMP
nsWPPluginInstance::ToggleBullets(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"doBullets" );
    return NS_OK;
}

/*
*   Function to increase the indent
*/

NS_IMETHODIMP
nsWPPluginInstance::IncreaseIndent(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"toggleIndent" );
    return NS_OK;
}

/*
*   Function to derease the indent
*/
NS_IMETHODIMP
nsWPPluginInstance::DecreaseIndent(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"toggleUnIndent"  );
    return NS_OK;
}

/*
*   Function to get the name of the current document
*   Returns: Pathname of the current document or NULL if no name has been assigned
*/
NS_IMETHODIMP
nsWPPluginInstance::GetCurrentDocument(char **retval)
{
    char *result = pluginCommand( &pluginFrame, PL_GETCURRENTDOC, NULL );
    if ( result == NULL ) {
    	*retval = NULL;
    } else {
    	*retval =(char*) nsMemory::Clone( result, strlen(result)+1);
    }
    return NS_OK;
}

/*
*   Function to check whether the document is dirty
*   Returns: bool value indicating document is dirty or not
*/
NS_IMETHODIMP
nsWPPluginInstance::IsDocumentModified(PRBool *retval)
{
    char *result = pluginCommand( &pluginFrame, PL_ISDOCMODIFIED, NULL );
    if ( strcmp( result, "true" ) == 0 ) {
    	*retval = true;
    } else {
    	*retval = false;
    }
    return NS_OK;
}

/*
*   Function to set the foreground color
*   Params: color: Specified color ( e.g. "ff0000" )
*/
NS_IMETHODIMP
nsWPPluginInstance::SetColor(const char *color)
{
    pluginCommand( &pluginFrame, PL_SETCOLOR, (void *)color);
    return NS_OK;
}

/*
*   Function to get the text attribute
*   Returns: Attribute of the text
*/
NS_IMETHODIMP
nsWPPluginInstance::GetAttribute(const char *attrname, char **attrval)
{
    char *result = pluginCommand( &pluginFrame, PL_GETATTRIBUTE, (char *)attrname );
    *attrval = (char*) nsMemory::Clone( result, strlen(result)+1);
    return NS_OK;
}

/*
*   Function to get the text alignment
*   Returns: Alignment of the text
*/
NS_IMETHODIMP
nsWPPluginInstance::GetAlignment(char **alignment)
{
    char *result = pluginCommand( &pluginFrame, PL_GETALIGNMENT, NULL );
    *alignment =  (char*) nsMemory::Clone( result, strlen(result)+1);
    return NS_OK;
}

/*
*   Function to check whether the text is bulleted or numberred
*   Returns: boolean value indicating whether text if part of a bulleted or numberred list
*/
NS_IMETHODIMP
nsWPPluginInstance::IsList(PRBool *retval)
{
    char *result = pluginCommand( &pluginFrame, PL_ISLIST, NULL );
    if ( strcmp( result, "true" ) == 0 ) {
    	*retval = true;
    } else {
    	*retval = false;
    }
    return NS_OK;
}

/*
*   Function to get the list of available fonts
*   Returns: A string representation of font names seperated by commas
*/
NS_IMETHODIMP
nsWPPluginInstance::GetFontList(char **flist)
{
    char *result = pluginCommand( &pluginFrame, PL_GETFONTLIST, NULL );
    *flist =  (char*) nsMemory::Clone( result, strlen(result)+1);
    return NS_OK;
}

/*
*   Function to get the list of recent documents
*   Returns: A string representation of recent documents seperated by commas
*/
NS_IMETHODIMP
nsWPPluginInstance::GetRecentList(char **recentlist)
{
    char *result = pluginCommand( &pluginFrame, PL_GETRECENTLIST, NULL );
    *recentlist =  (char*) nsMemory::Clone( result, strlen(result)+1);
    return NS_OK;
}

/*
*   Function to set the zoom percentage
*/

NS_IMETHODIMP
nsWPPluginInstance::SetZoom(PRInt32 zoomval)
{
    int tmp;
    tmp = zoomval;
    pluginCommand( &pluginFrame, PL_SETZOOM, &tmp);
    return NS_OK;
}

/*
*   Function to toggle numbers
*/
NS_IMETHODIMP
nsWPPluginInstance::ToggleNumbers(void)
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"doNumbers" );
    return NS_OK;
}

/*
*   Function to set the current font
*   Params: font: Name of the font to change to
*/
NS_IMETHODIMP
nsWPPluginInstance::SetFont(const char *font)
{
    pluginCommand( &pluginFrame, PL_SETFONT, (void *)font);
    return NS_OK;
}

/*
*   Function to insert a specified image into the document
*   Params: pathname: Pathname of the image to be inserted
*   Returns: Pathname of the inserted image on success, NULL otherwise
*/
NS_IMETHODIMP
nsWPPluginInstance::InsertImageFromFile( const char *pathname, char **retval )
{
    char *result = pluginCommand( &pluginFrame, PL_INSERTIMGFROMFILE, (void *)pathname );
    if ( result == NULL ) {
    	*retval = NULL;
    } else {
    	*retval =(char*) nsMemory::Clone( result, strlen(result)+1);
    }
    return NS_OK;
}

/*
*   Function to set the current font size
*   Params: fontzise: String defining the font size ( e.g. "12pt" )
*/
NS_IMETHODIMP
nsWPPluginInstance::SetFontSize(const char *fontsize)
{
    pluginCommand( &pluginFrame, PL_SETFONTSIZE, (void *)fontsize);
    return NS_OK;
}

/*
*   Function to set the tab width
*   Params: tabstop: String defining the tab width ( e.g. ""2.0in"" )
*/
NS_IMETHODIMP
nsWPPluginInstance::SetTabStop(const char *tabstop)
{
    pluginCommand( &pluginFrame, PL_SETTABSTOP, (void *)tabstop);
    return NS_OK;
}

/*
*   Function to set the background color
*   Params: color: String defining the RGB color ( e.g. "ff0000" )
*/
NS_IMETHODIMP
nsWPPluginInstance::SetBGColor(const char *color)
{
    pluginCommand( &pluginFrame, PL_SETBGCOLOR, (void *)color);
    return NS_OK;
}

/*
*   Function to set the number of columns
*   Params: colomns : String defining the number of columnsGB color ( e.g. "3" )
*/
NS_IMETHODIMP
nsWPPluginInstance::SetColumns(const char *columns)
{
    pluginCommand( &pluginFrame, PL_SETCOLUMNS, (void *)columns);
    return NS_OK;
}

/*
*   Function to request editting of header
*/
NS_IMETHODIMP
nsWPPluginInstance::EditHeader()
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"editHeader" );
    return NS_OK;
}

/*
*   Function to request editting of footer
*/
NS_IMETHODIMP
nsWPPluginInstance::EditFooter()
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"editFooter" );
    return NS_OK;
}

/*
*   Function to request undo
*/
NS_IMETHODIMP
nsWPPluginInstance::Undo()
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"undo" );
    return NS_OK;
}

/*
*   Function to request redo
*/
NS_IMETHODIMP
nsWPPluginInstance::Redo()
{
    pluginCommand( &pluginFrame, PL_INVOKEMENUMETHOD, (void *)"redo"  );
    return NS_OK;
}

/*
*   Function to define whether the document is portrait or not
*   Params: val:   true: is portrait, false: is landscape
*/
NS_IMETHODIMP
nsWPPluginInstance::SetPortrait( PRBool val ) {
    char tmp[1];
    tmp[0] = val;
    pluginCommand( &pluginFrame, PL_SETPORTRAIT, tmp );
    return NS_OK;
}

/*
*   Function to set the printing scale
*   Params: scale: printing scale ( 0 - 100 )
*/
NS_IMETHODIMP
nsWPPluginInstance::SetPrintScale( PRInt16 scale ) {
    unsigned short tmp[1];
    tmp[0] = scale;
    pluginCommand( &pluginFrame, PL_SETPRINTSCALE, (void *)tmp );
    return NS_OK;
}

/*
*   Function to set the papaer size
*   Params: String representing the paper size ( e.g. "Letter" )
*/
NS_IMETHODIMP
nsWPPluginInstance::SetPaperSize( const char *papersize ) {
    pluginCommand( &pluginFrame, PL_SETPAPERSIZE, (void *)papersize );
    return NS_OK;
}

/*
*   Function to set the margins
*   Params: left,right,top,bottom,footer and header margins
*/
NS_IMETHODIMP
nsWPPluginInstance::SetMargins( float left, float right, float top, float bottom, float footer, float header ) {
    float tmp[6];
    tmp[0] = left;
    tmp[1] = right;
    tmp[2] = top;
    tmp[3] = bottom;
    tmp[4] = footer;
    tmp[5] = header;
    pluginCommand( &pluginFrame, PL_SETMARGINS, tmp );
    return NS_OK;
}

/*
*   Function to set the listener which should be informed of changes in the text
*   Params: Instance of the listener
*/
NS_IMETHODIMP
nsWPPluginInstance::SetListener( nsIWPPluginListener *wplistener ) {
    NS_ADDREF(wplistener);
    nsWPPluginInstance::m_listener = wplistener;
    return NS_OK;
}

/*
*   This function is invoked when an attribute is toggled in the text
*/
void PL_EventHandler_Toggle( char *event, bool value ) {
//    printf( "Event: %s - Value: %d\n", event, value );
    if( nsWPPluginInstance::m_listener == NULL )
        return;
    if( strcasecmp( event, "toggleBold" ) == 0 ) {
        nsWPPluginInstance::m_listener->OnBoldChange( value );
    } else if( strcasecmp( event, "toggleItalic" ) == 0 ) {
        nsWPPluginInstance::m_listener->OnItalicChange( value );
    } else if( strcasecmp( event, "toggleUline" ) == 0 ) {
        nsWPPluginInstance::m_listener->OnUnderlineChange( value );
    } else if( strcasecmp( event, "doBullets" ) == 0 ) {
        nsWPPluginInstance::m_listener->OnBulletChange( value );
    } else if( strcasecmp( event, "doNumbers" ) == 0 ) {
        nsWPPluginInstance::m_listener->OnNumberlistChange( value );
    }
}

/*
*   This function is invoked when a value setting is changed in the text
*/
void PL_EventHandler_Value( char *event, char *strval ) {
//    printf( "Event: %s - Value: %s\n", event, strval );
    if( nsWPPluginInstance::m_listener == NULL )
        return;
    if( strcasecmp( event, "fontFamily" ) == 0 ) {
        nsWPPluginInstance::m_listener->OnFontChange( strval );
    } else if( strcasecmp( event, "fontSize" ) == 0 ) {
        nsWPPluginInstance::m_listener->OnFontSizeChange( strval );
    } else if( strcasecmp( event, "alignment" ) == 0 ) {
        nsWPPluginInstance::m_listener->OnAlignmentChange( strval );
    } else if( strcasecmp( event, "color" ) == 0 ) {
        nsWPPluginInstance::m_listener->OnColorChange( strval );
    }
}

// END of Generic WP Interface
//////////////////////////////////////////////////////////////////////////////

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>