00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 00002 00003 /* AbiSource Application Framework 00004 * Copyright (C) 2005 Francis James Franklin 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00019 * 02110-1301 USA. 00020 */ 00021 00022 #ifndef AP_COCOAPLUGIN_H 00023 #define AP_COCOAPLUGIN_H 00024 00025 #import <Cocoa/Cocoa.h> 00026 00027 #include "xap_CocoaPlugin.h" 00028 #include "xap_Types.h" 00029 00030 class XAP_Frame; 00031 00032 class EV_EditMethod; 00033 class EV_Menu_Action; 00034 00035 class FV_View; 00036 00037 class PD_Document; 00038 00039 @interface AP_CocoaPlugin_EditMethod : NSObject 00040 { 00041 EV_EditMethod * m_EditMethod; 00042 char m_EditMethod_Name[64]; 00043 00044 BOOL m_InContextMenu; 00045 00046 SEL m_Action; 00047 id <NSObject> m_Target; 00048 } 00049 - (id)init; 00050 - (void)dealloc; 00051 00052 - (const char *)editMethodName; 00053 00054 - (void)trigger; 00055 00056 - (void)setAction:(SEL)aSelector; 00057 - (SEL)action; 00058 00059 - (void)setTarget:(id <NSObject>)target; 00060 - (id <NSObject>)target; 00061 00062 @end 00063 00064 @interface AP_CocoaPlugin_MenuIDRef : NSObject 00065 { 00066 id <XAP_CocoaPlugin_MenuItem> m_NonRetainedRef; 00067 } 00068 + (AP_CocoaPlugin_MenuIDRef *)menuIDRefWithMenuItem:(id <XAP_CocoaPlugin_MenuItem>)menuItem; 00069 00070 - (id)initWithMenuItem:(id <XAP_CocoaPlugin_MenuItem>)menuItem; 00071 00072 - (id <XAP_CocoaPlugin_MenuItem>)menuItem; 00073 @end 00074 00075 @interface AP_CocoaPlugin_ContextMenuItem : AP_CocoaPlugin_EditMethod <XAP_CocoaPlugin_MenuItem> 00076 { 00077 NSString * m_Label; 00078 00079 EV_Menu_Action * m_pAction; 00080 00081 XAP_Menu_Id m_MenuID; 00082 00083 int m_Tag; 00084 int m_State; 00085 00086 BOOL m_Enabled; 00087 } 00088 + (AP_CocoaPlugin_ContextMenuItem *)itemWithLabel:(NSString *)label; 00089 00090 - (id)initWithLabel:(NSString *)label; 00091 - (void)dealloc; 00092 00093 - (void)setLabel:(NSString *)label; 00094 - (NSString *)label; 00095 00096 00097 - (void)setTag:(int)anInt; 00098 - (int)tag; 00099 00100 - (void)setState:(int)state; 00101 - (int)state; 00102 00103 - (void)setEnabled:(BOOL)enabled; 00104 - (BOOL)isEnabled; 00105 00106 @end 00107 00108 @interface AP_CocoaPlugin_FramelessDocument : NSObject <XAP_CocoaPlugin_FramelessDocument> 00109 { 00110 PD_Document * m_pDocument; 00111 } 00112 + (NSString *)optionsPropertyString:(NSDictionary *)options; 00113 00114 + (AP_CocoaPlugin_FramelessDocument *)documentFromFile:(NSString *)path importOptions:(NSDictionary *)options; 00115 00116 - (id)initWithPDDocument:(PD_Document *)document; 00117 - (void)dealloc; 00118 00119 /* XAP_CocoaPlugin_FramelessDocument 00120 */ 00121 - (BOOL)exportDocumentToFile:(NSString *)path exportOptions:(NSDictionary *)options; 00122 @end 00123 00124 @interface AP_CocoaPlugin_Document : NSObject <XAP_CocoaPlugin_Document> 00125 { 00126 XAP_Frame * m_pFrame; 00127 } 00128 /* Please bear in mind that documents can be closed, so don't keep references to documents 00129 * lying around for future use. 00130 */ 00131 + (id <NSObject, XAP_CocoaPlugin_Document>)currentDocument; // may return nil; 00132 + (NSArray *)documents; // array of id <XAP_CocoaPlugin_Document> 00133 00134 + (NSString *)selectMailMergeSource; // may return nil 00135 00136 /* Returns an NSMutableArray whose objects are NSMutableArray of NSString, the first row holding the 00137 * field names, the rest being records; returns nil on failure. 00138 */ 00139 + (NSMutableArray *)importMailMergeSource:(NSString *)path; 00140 00141 + (BOOL)frameExists:(XAP_Frame *)frame; 00142 00143 - (id)initWithXAPFrame:(XAP_Frame *)frame; 00144 00145 - (BOOL)documentStillExists; 00146 00147 - (NSString *)title; 00148 00149 - (NSString *)selectWord; 00150 - (NSString *)selectedText; 00151 00152 - (void)insertText:(NSString *)text; 00153 00154 - (NSString *)documentMailMergeSource; // may return nil 00155 - (void)setDocumentMailMergeSource:(NSString *)path; 00156 00157 - (void)insertDocumentMailMergeField:(NSString *)field_name; 00158 00159 - (NSArray *)documentMailMergeFields; 00160 - (void)setDocumentMailMergeFields:(NSArray *)field_array; 00161 - (void)unsetDocumentMailMergeFields; 00162 00163 /* value_dictionary maps (NSString *) keys [field names] to (NSString *) values. 00164 */ 00165 - (void)setDocumentMailMergeValues:(NSDictionary *)value_dictionary; 00166 @end 00167 00168 #endif /* ! AP_COCOAPLUGIN_H */