Public Member Functions | Protected Attributes

XAP_CocoaPlugin Class Reference

This class provides the main interface between the plug-in and AbiWord. More...

#import <xap_CocoaPlugin.h>

List of all members.

Public Member Functions

(id- init
 The plug-in's delegate, by default the bundle's principal class.
(void) - dealloc
 (For internal use only.
(BOOL) - loadBundleWithPath:
 (For internal use only.
(void) - setDelegate:
 If the plug-in bundle's principal class does not implement the XAP_CocoaPluginDelegate protocol, then, when the pluginCanRegisterForAbiWord:version:interface: method is called, it should set a new delegate object which does implement the protocol.
(id< NSObject,
XAP_CocoaPluginDelegate >) 
- delegate
 The plug-in's delegate.
(void) - appendMenuItem:
 Add a menu item to the end of the Tools menu.
(void) - removeMenuItem:
 Remove a menu item from the end of the Tools menu.
(id< NSObject,
XAP_CocoaPlugin_Document >) 
- currentDocument
 Get a reference to the current document window, if any.
(NSArray *) - documents
 Get an array of references to the current document windows, if any.
(NSString *) - selectMailMergeSource
 Pops up a File Open dialog for the user to select a source file for mail merge.
(NSMutableArray *) - importMailMergeSource:
 Loads a mail merge source file and builds an array of arrays containing the fields.
(id< NSObject,
XAP_CocoaPlugin_FramelessDocument >) 
- importDocumentFromFile:importOptions:
 Open the specified document without creating a document window.
(id< NSObject,
XAP_CocoaPlugin_MenuItem >) 
- contextMenuItemWithLabel:
 Add a menu item to the context menu.
(NSArray *) - toolProviders
 Get a list of all the tool providers.
(id< NSObject,
XAP_CocoaPlugin_ToolProvider >) 
- toolProvider:
 Find a tool provider by name.
(NSString *) - findResourcePath:
 Find a file in one of AbiWord's resource locations.
(NSString *) - userResourcePath:
 Generate a path in the user's AbiSuite resource location.
(NSString *) - parseFile:simpleXML:
 Parse an XML file using a simple XML call-back interface.

Protected Attributes

id< NSObject,
XAP_CocoaPluginDelegate
m_delegate

Detailed Description

This class provides the main interface between the plug-in and AbiWord.


Member Function Documentation

- (void) appendMenuItem: (NSMenuItem *)  menuItem  

Add a menu item to the end of the Tools menu.

This is an NSMenuItem object that the plug-in makes itself (or loads from a nib file) and so can have submenus etc. This procedure for adding menu items to AbiWord's main menu does not use AbiWord's cross-platform method for adding menu items (which may not currently work anyway - I'm not sure).

Parameters:
menuItem The menu item to add to the Tools menu.

References XAP_CocoaAppController::appendPluginMenuItem:.

- (id< NSObject, XAP_CocoaPlugin_MenuItem >) contextMenuItemWithLabel: (NSString *)  label  

Add a menu item to the context menu.

You should retain the returned context menu item object, since the menu item is removed from the context menu when the object is deleted.

Parameters:
label The label of the menu item in the context menu.
Returns:
A reference to a context menu item object.
See also:
XAP_CocoaPlugin_MenuItem

References AP_CocoaPlugin_ContextMenuItem::itemWithLabel:.

- (id< NSObject, XAP_CocoaPlugin_Document >) currentDocument  

Get a reference to the current document window, if any.

Please bear in mind that documents can be closed, so be careful when keeping references to documents lying around for future use.

Note: These are really references to document windows, and sometimes the actual documents can change even though the document window is the same.

Returns:
Returns a reference to the currently active document window; or nil if none.

References AP_CocoaPlugin_Document::currentDocument.

- (void) dealloc  

(For internal use only.

)

- (id< NSObject, XAP_CocoaPluginDelegate >) delegate  

The plug-in's delegate.

Returns:
The delegate object - the bundle's principal class, unless the plug-in has substituted another.

References m_delegate.

Referenced by XAP_CocoaAppController::deactivateAllPlugins, XAP_CocoaAppController::deactivatePlugin:overridePlugin:, XAP_CocoaPluginReference::initWithPlugin:, and XAP_CocoaAppController::notifyFrameViewChange.

- (NSArray *) documents  

Get an array of references to the current document windows, if any.

Please bear in mind that documents can be closed, so be careful when keeping references to documents lying around for future use.

Note: These are really references to document windows, and sometimes the actual documents can change even though the document window is the same.

Returns:
Returns an array of references to the available document windows.

References AP_CocoaPlugin_Document::documents.

- (NSString *) findResourcePath: (NSString *)  relativePath  

Find a file in one of AbiWord's resource locations.

This looks in the user's AbiSuite folder first, then the system AbiSuite folder, and finally the AbiWord bundle's Resources folder. Must be a regular file.

Parameters:
relativePath A filename or relative path, e.g., "MyPlugin/config.xml".
Returns:
The full path to the specified resource, or nil if not found.

References XAP_CocoaApp::findAbiSuiteLibFile(), and XAP_App::getApp().

- (id< NSObject, XAP_CocoaPlugin_FramelessDocument >) importDocumentFromFile: (NSString *)  path
importOptions: (NSDictionary *)  options 

Open the specified document without creating a document window.

This can be useful for automated document processing (printing, conversion, etc.).

Parameters:
path The input file path.
options A dictionary mapping of NSString keys to NSString values; these options are passed to the importer. May be nil.
Returns:
Returns the frameless document on success, nil on failure.
See also:
XAP_CocoaPlugin_FramelessDocument

References AP_CocoaPlugin_FramelessDocument::documentFromFile:importOptions:.

- (NSMutableArray *) importMailMergeSource: (NSString *)  path  

Loads a mail merge source file and builds an array of arrays containing the fields.

Parameters:
path The file name of the mail merge source file.
Returns:
Returns an NSMutableArray whose objects are NSMutableArray of NSString, the first row holding the field names, the rest being records; returns nil on failure.

References AP_CocoaPlugin_Document::importMailMergeSource:.

- (id) init  

The plug-in's delegate, by default the bundle's principal class.

(For internal use only.)

References m_delegate.

Referenced by loadBundleWithPath:.

- (BOOL) loadBundleWithPath: (NSString *)  path  

(For internal use only.

)

.Abi plug-ins are bundles; loadBundle attempts to load the bundle specified to initWithPath, returns NO if the bundle is already loaded (to avoid duplication) or if it can't be loaded. The plug-in's principal class is initialized with init and is set as the delegate, and must conform therefore to the XAP_CocoaPluginDelegate protocol (or set a new delegate when pluginCanRegisterForAbiWord:version:interface: is called).

References BOOL(), init, instance, and setDelegate:.

- (NSString *) parseFile: (NSString *)  path
simpleXML: (id <XAP_CocoaPlugin_SimpleXML>)  callback 

Parse an XML file using a simple XML call-back interface.

Parameters:
path The path to the XML file.
callback An object which implements the XAP_CocoaPlugin_SimpleXML protocol.
Returns:
A string with an error message on failure, or nil on success.

References abicollab::service::error(), and s_SimpleXML_Listener::parse().

- (void) removeMenuItem: (NSMenuItem *)  menuItem  

Remove a menu item from the end of the Tools menu.

Parameters:
menuItem The menu item to remove from the Tools menu.

References XAP_CocoaAppController::removePluginMenuItem:.

- (NSString *) selectMailMergeSource  

Pops up a File Open dialog for the user to select a source file for mail merge.

Returns:
Returns the path of the selected mail merge source file; or nil if none selected.

References AP_CocoaPlugin_Document::selectMailMergeSource.

- (void) setDelegate: (id <NSObject, XAP_CocoaPluginDelegate>)  delegate  

If the plug-in bundle's principal class does not implement the XAP_CocoaPluginDelegate protocol, then, when the pluginCanRegisterForAbiWord:version:interface: method is called, it should set a new delegate object which does implement the protocol.

Parameters:
delegate The new delegate (must not be nil). The delegate is not retained.
See also:
XAP_CocoaPluginDelegate

References m_delegate.

Referenced by loadBundleWithPath:.

- (id< NSObject, XAP_CocoaPlugin_ToolProvider >) toolProvider: (NSString *)  name  

Find a tool provider by name.

(TODO: If plug-ins are registering tool providers, we need to implement a notification system to update toolbar systems.)

Parameters:
name The name of the tool provider to find.
Returns:
The tool provider, or nil if none is registered with the given name.

References XAP_CocoaAppController::toolProvider:.

- (NSArray *) toolProviders  

Get a list of all the tool providers.

Each tool provider is of type id <NSObject, XAP_CocoaPlugin_ToolProvider>.

Returns:
The tool providers.

References XAP_CocoaAppController::toolProviders.

- (NSString *) userResourcePath: (NSString *)  relativePath  

Generate a path in the user's AbiSuite resource location.

Parameters:
relativePath A filename or relative path, e.g., "MyPlugin/config.xml".
Returns:
The full path to the specified resource.

References XAP_App::getApp().


Member Data Documentation

- (id<NSObject, XAP_CocoaPluginDelegate>) m_delegate [protected]

Referenced by delegate, init, and setDelegate:.


The documentation for this class was generated from the following files: