#include <ap_CocoaApp.h>
Public Member Functions | |
AP_CocoaApp (const char *szAppName) | |
virtual | ~AP_CocoaApp () |
virtual bool | initialize (void) |
virtual void | rebuildMenus (void) |
virtual XAP_Frame * | newFrame (void) |
virtual bool | forgetFrame (XAP_Frame *pFrame) |
virtual bool | shutdown (void) |
virtual bool | getPrefsValueDirectory (bool bAppSpecific, const gchar *szKey, const gchar **pszValue) const |
virtual const XAP_StringSet * | getStringSet (void) const |
virtual const char * | getAbiSuiteAppDir (void) const |
virtual void | copyToClipboard (PD_DocumentRange *pDocRange, bool bUseClipboard=true) |
virtual void | pasteFromClipboard (PD_DocumentRange *pDocRange, bool bUseClipboard, bool bHonorFormatting=true) |
virtual bool | canPasteFromClipboard (void) |
virtual void | setSelectionStatus (AV_View *pView) |
virtual void | setViewSelection (AV_View *pView) |
virtual AV_View * | getViewSelection (void) |
virtual void | clearSelection (void) |
virtual bool | getCurrentSelection (const char **formatList, void **ppData, UT_uint32 *pLen, const char **pszFormatFound) |
virtual void | cacheCurrentSelection (AV_View *) |
void | catchSignals (int sig_num) ABI_NORETURN |
void | loadAllPlugins () |
virtual void | errorMsgBadArg (const char *) |
virtual void | errorMsgBadFile (XAP_Frame *pFrame, const char *file, UT_Error error) |
virtual bool | doWindowlessArgs (const AP_Args *, bool &bSuccess) |
virtual GR_Graphics * | newDefaultScreenGraphics () const |
Static Public Member Functions | |
static int | main (const char *szAppName, int argc, char **argv) |
Private Attributes | |
XAP_StringSet * | m_pStringSet |
AP_CocoaClipboard * | m_pClipboard |
bool | m_bHasSelection |
bool | m_bSelectionInFlux |
bool | m_cacheDeferClear |
AV_View * | m_pViewSelection |
AV_View * | m_cacheSelectionView |
XAP_Frame * | m_pFrameSelection |
UT_ByteBuf | m_selectionByteBuf |
PD_DocumentRange | m_cacheDocumentRangeOfSelection |
AP_CocoaApp::AP_CocoaApp | ( | const char * | szAppName | ) |
Construct an AP_CocoaApp. /param pArgs Arguments from command line /param szAppName A string representing the name of the app. Currently always AbiWord (I think).
Referenced by main().
AP_CocoaApp::~AP_CocoaApp | ( | void | ) | [virtual] |
Destructor for AP_CocoaApp's. Cleans up spellcheck, clipboard, and StringSet.
References DELETEP, IE_ImpExp_UnRegisterXP(), m_pClipboard, and m_pStringSet.
void AP_CocoaApp::cacheCurrentSelection | ( | AV_View * | pView | ) | [virtual] |
bool AP_CocoaApp::canPasteFromClipboard | ( | void | ) | [virtual] |
This should determine if we can paste from the cliboard.
References aszFormatsAccepted, XAP_CocoaClipboard::hasFormats(), and m_pClipboard.
void AP_CocoaApp::catchSignals | ( | int | sig_num | ) |
This function actually handles signals. The most commonly recieved one is SIGSEGV, the segfault signal. We want to clean up, save the user's files to backup locations (currently <filename>.saved) and then call abort, so we still get a core dump that we can debug.
sig_num | the integer representing which signal we recieved |
References s_signal_count, AP_App::saveRecoveryFiles(), XAP_App::signalWrapper(), and UT_DEBUGMSG.
void AP_CocoaApp::clearSelection | ( | void | ) | [virtual] |
this method goes with setSelectionStatus().
we are called by the clipboard (thru the callback chain) in response to another application stealing the X Selection.
we need to notify the view so that it can clear the screen as is the custom on X -- only one selection at any time.
we have to watch out here because when we call up to clear the selection, the view will notify the view-listeners of the change, which may cause setSelectionStatus() to get called and thus update the clipboard -- this could recurse a while....
References FV_View::cmdUnselectSelection(), m_bHasSelection, m_bSelectionInFlux, m_pFrameSelection, m_pViewSelection, and UT_DEBUGMSG.
void AP_CocoaApp::copyToClipboard | ( | PD_DocumentRange * | pDocRange, | |
bool | bUseClipboard = true | |||
) | [virtual] |
copy the given subset of the given document to the system clipboard in a variety of formats.
to minimize the effects of race-conditions, we create all of the buffers we need and then post them to the server (well sorta) all at one time.
pDocRange | a range of the document to be copied |
References XAP_CocoaClipboard::addData(), IE_Exp::copyToBuffer(), DELETEP, UT_ByteBuf::getLength(), UT_ByteBuf::getPointer(), m_pClipboard, PD_DocumentRange::m_pDoc, XAP_CocoaClipboard::prepareForText(), UT_DEBUGMSG, XAP_CocoaClipboard::XAP_CLIPBOARD_RTF, and XAP_CocoaClipboard::XAP_CLIPBOARD_TEXTPLAIN_8BIT.
bool AP_CocoaApp::doWindowlessArgs | ( | const AP_Args * | Args, | |
bool & | bSuccess | |||
) | [virtual] |
A callback for AP_Args's doWindowlessArgs call which handles platform-specific windowless args.
Reimplemented from AP_App.
References AP_App::openCmdLinePlugins().
void AP_CocoaApp::errorMsgBadArg | ( | const char * | msg | ) | [virtual] |
References printf.
void AP_CocoaApp::errorMsgBadFile | ( | XAP_Frame * | pFrame, | |
const char * | file, | |||
UT_Error | error | |||
) | [virtual] |
Reimplemented from AP_App.
References s_CouldNotLoadFileMessage().
bool AP_CocoaApp::forgetFrame | ( | XAP_Frame * | pFrame | ) | [virtual] |
we intercept this so that we can erase our selection-related variables if necessary. wouldn't want to hold onto a stale frame or view pointer of a closed window when the selection is changed....
/param pFrame The frame to be forgotten /return The return value of the XAP_App::forgetFrame call /sa XAP_App::forgetFrame()
References XAP_CocoaClipboard::clearClipboard(), m_pClipboard, m_pFrameSelection, and m_pViewSelection.
const char * AP_CocoaApp::getAbiSuiteAppDir | ( | void | ) | const [virtual] |
This returns the AbiSuite application directory.
References gchar, and UT_ASSERT.
Referenced by getPrefsValueDirectory().
bool AP_CocoaApp::getCurrentSelection | ( | const char ** | formatList, | |
void ** | ppData, | |||
UT_uint32 * | pLen, | |||
const char ** | pszFormatFound | |||
) | [virtual] |
get the current contents of the selection in the window last known to have a selection using one of the formats in the given list.
formatList | the list of acceptable formats | |
ppData | ||
pLen | a pointer to an integer representing the length | |
pszFormatFound | a pointer for the data to be returned in |
References IE_Exp::copyToBuffer(), DELETEP, FV_View::getDocumentRangeOfCurrentSelection(), UT_ByteBuf::getLength(), UT_ByteBuf::getPointer(), m_bHasSelection, m_cacheDocumentRangeOfSelection, m_cacheSelectionView, PD_DocumentRange::m_pDoc, m_pFrameSelection, PD_DocumentRange::m_pos1, PD_DocumentRange::m_pos2, m_pViewSelection, m_selectionByteBuf, UT_ByteBuf::truncate(), UT_DEBUGMSG, XAP_CocoaClipboard::XAP_CLIPBOARD_RTF, XAP_CocoaClipboard::XAP_CLIPBOARD_STRING, and XAP_CocoaClipboard::XAP_CLIPBOARD_TEXTPLAIN_8BIT.
bool AP_CocoaApp::getPrefsValueDirectory | ( | bool | bAppSpecific, | |
const gchar * | szKey, | |||
const gchar ** | pszValue | |||
) | const [virtual] |
This function returns the absolute path to the directory specified in the desired key. In other words, if you want the path to the spelling files, you can't just get the prefs value, since that path isn't always absolute. This function gives it to you in absolute terms.
bAppSpecific | Is this key specific to the app, or is it general to AbiSuite? | |
szKey | A string of gchars representing the desired key | |
pszValue | pointer for the value to be returned in. |
References gchar, getAbiSuiteAppDir(), and UT_ASSERT.
Referenced by initialize().
const XAP_StringSet * AP_CocoaApp::getStringSet | ( | void | ) | const [virtual] |
This returns the current StringSet
References m_pStringSet.
virtual AV_View* AP_CocoaApp::getViewSelection | ( | void | ) | [inline, virtual] |
bool AP_CocoaApp::initialize | ( | void | ) | [virtual] |
Initialize the application. This involves preferences, keybindings, toolbars, graphics, spelling and everything else.
Build a labelset so the plugins can add themselves to something ///
Reimplemented from AP_App.
References abi_register_builtin_plugins(), AP_CreateMenuActionSet(), AP_CreateToolbarActionSet(), AP_GetEditMethods(), AP_PREF_DEFAULT_StringSet, AP_PREF_KEY_MenuLayout, AP_PREF_KEY_StringSet, AP_PREF_KEY_StringSetDirectory, DELETEP, fp_FieldFmts, fp_FieldTypes, FREEP, gchar, getPrefsValueDirectory(), XAP_StringSet::getValue(), IE_ImpExp_RegisterXP(), AP_App::initialize(), AP_DiskStringSet::loadStringsFromDisk(), fp_FieldData::m_DescId, fp_FieldTypeData::m_DescId, m_pClipboard, m_pStringSet, fp_FieldData::m_Tag, fp_FieldTypeData::m_Type, XAP_DiskStringSet::setFallbackStringSet(), UT_ASSERT, UT_createDirectoryIfNecessary(), UT_DEBUGMSG, UT_UTF8String::utf8_str(), and XAP_PREF_KEY_AutoLoadPlugins.
Referenced by main().
void AP_CocoaApp::loadAllPlugins | ( | ) |
int AP_CocoaApp::main | ( | const char * | szAppName, | |
int | argc, | |||
char ** | argv | |||
) | [static] |
References AP_CocoaApp(), AP_Args::doWindowlessArgs(), initialize(), AP_Args::parseOptions(), run, XAP_App::s_szBuild_CompileDate, XAP_App::s_szBuild_CompileTime, XAP_App::s_szBuild_ID, XAP_App::s_szBuild_Options, XAP_App::s_szBuild_Target, XAP_App::s_szBuild_Version, shutdown(), and UT_DEBUGMSG.
Referenced by main().
virtual GR_Graphics* AP_CocoaApp::newDefaultScreenGraphics | ( | ) | const [inline, virtual] |
XAP_Frame * AP_CocoaApp::newFrame | ( | void | ) | [virtual] |
Create a new frame based on the current one.
References AP_CocoaFrame::initialize(), and UT_DEBUGMSG.
void AP_CocoaApp::pasteFromClipboard | ( | PD_DocumentRange * | pDocRange, | |
bool | bUseClipboard, | |||
bool | bHonorFormatting = true | |||
) | [virtual] |
paste from the system clipboard using the best-for-us format that is present. try to get the content in the order listed.
References aszFormatsAccepted, FV_View::cmdInsertGraphic(), IE_ImpGraphic::constructImporter(), DELETEP, abicollab::service::error(), FREEP, XAP_CocoaClipboard::getClipboardData(), XAP_Frame::getCurrentView(), IE_ImpGraphic::importGraphic(), m_pClipboard, PD_DocumentRange::m_pDoc, IE_Imp_Text::pasteFromBuffer(), IE_Imp_RTF::pasteFromBuffer(), UT_DEBUGMSG, UT_MIN, UT_newNumber(), UT_UTF8String_sprintf(), XAP_CocoaClipboard::XAP_CLIPBOARD_IMAGE, XAP_CocoaClipboard::XAP_CLIPBOARD_RTF, XAP_CocoaClipboard::XAP_CLIPBOARD_STRING, and XAP_CocoaClipboard::XAP_CLIPBOARD_TEXTPLAIN_8BIT.
void AP_CocoaApp::setSelectionStatus | ( | AV_View * | pView | ) | [virtual] |
this is called by the view-listeners when the state of the X Selection is changed by the user on one of our windows.
we need to notify the clipboard so that it can assert or release the X Selection.
we remember the last view that called us so that clearSelection() can do it's job when another application asserts the X Selection.
pView | The view to be changed. |
References AV_View::getParentData(), AV_View::isSelectionEmpty(), m_bHasSelection, m_bSelectionInFlux, m_cacheDeferClear, m_cacheSelectionView, m_pFrameSelection, m_pViewSelection, setViewSelection(), UT_ASSERT, and UT_DEBUGMSG.
Referenced by ap_CocoaViewListener::notify().
virtual void AP_CocoaApp::setViewSelection | ( | AV_View * | pView | ) | [inline, virtual] |
Sets the view selection
pView | The veiw the selection view is to be set to. |
References m_pViewSelection.
Referenced by setSelectionStatus().
bool AP_CocoaApp::shutdown | ( | void | ) | [virtual] |
If the user has set the preferences to save them selves on shutdown, save them.
Referenced by main().
bool AP_CocoaApp::m_bHasSelection [private] |
Referenced by cacheCurrentSelection(), clearSelection(), getCurrentSelection(), and setSelectionStatus().
bool AP_CocoaApp::m_bSelectionInFlux [private] |
Referenced by clearSelection(), and setSelectionStatus().
bool AP_CocoaApp::m_cacheDeferClear [private] |
Referenced by cacheCurrentSelection(), and setSelectionStatus().
Referenced by cacheCurrentSelection(), and getCurrentSelection().
AV_View* AP_CocoaApp::m_cacheSelectionView [private] |
Referenced by cacheCurrentSelection(), getCurrentSelection(), and setSelectionStatus().
AP_CocoaClipboard* AP_CocoaApp::m_pClipboard [private] |
Referenced by cacheCurrentSelection(), canPasteFromClipboard(), copyToClipboard(), forgetFrame(), initialize(), pasteFromClipboard(), and ~AP_CocoaApp().
XAP_Frame* AP_CocoaApp::m_pFrameSelection [private] |
Referenced by clearSelection(), forgetFrame(), getCurrentSelection(), and setSelectionStatus().
XAP_StringSet* AP_CocoaApp::m_pStringSet [private] |
Referenced by getStringSet(), initialize(), and ~AP_CocoaApp().
AV_View* AP_CocoaApp::m_pViewSelection [private] |
Referenced by clearSelection(), forgetFrame(), getCurrentSelection(), getViewSelection(), setSelectionStatus(), and setViewSelection().
UT_ByteBuf AP_CocoaApp::m_selectionByteBuf [private] |
Referenced by getCurrentSelection().