Public Member Functions | Static Public Member Functions | Private Attributes

AP_CocoaApp Class Reference

#include <ap_CocoaApp.h>

Inheritance diagram for AP_CocoaApp:

List of all members.

Public Member Functions

 AP_CocoaApp (const char *szAppName)
virtual ~AP_CocoaApp ()
virtual bool initialize (void)
virtual void rebuildMenus (void)
virtual XAP_FramenewFrame (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_StringSetgetStringSet (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_ViewgetViewSelection (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_GraphicsnewDefaultScreenGraphics () const

Static Public Member Functions

static int main (const char *szAppName, int argc, char **argv)

Private Attributes

bool m_bHasSelection
bool m_bSelectionInFlux
bool m_cacheDeferClear
UT_ByteBuf m_selectionByteBuf
PD_DocumentRange m_cacheDocumentRangeOfSelection

Constructor & Destructor Documentation

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.

Member Function Documentation

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.

A const string containting the directory path

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
pLen a pointer to an integer representing the length
pszFormatFound a pointer for the data to be returned in
True if successful, false otherwise.

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.
True if successful, false otherwise.
support meaningful return values.

References gchar, getAbiSuiteAppDir(), and UT_ASSERT.

Referenced by initialize().

const XAP_StringSet * AP_CocoaApp::getStringSet ( void   )  const [virtual]

This returns the current StringSet

A const pointer to the StringSet
This function should be inilined.

References m_pStringSet.

virtual AV_View* AP_CocoaApp::getViewSelection ( void   )  [inline, virtual]

Gets the View Selection

The View currently selected.

References m_pViewSelection.

bool AP_CocoaApp::initialize ( void   )  [virtual]

Initialize the application. This involves preferences, keybindings, toolbars, graphics, spelling and everything else.

True if successfully initalized, False otherwise. if false the app is unusable, and loading should not continue.
This function is 136 lines - way too long. Needs to be refactored, to use a buzzword.

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 (  ) 
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.

A pointer to the new frame.

References AP_CocoaFrame::initialize(), and UT_DEBUGMSG.

void AP_CocoaApp::rebuildMenus ( void   )  [virtual]

References DELETEP, and UT_ASSERT.

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.

This function always returns true.
The return value should be fixed to check the return values of the functions it calls, and potentially handle errors. At a minimum, it should return false on errors.

Referenced by main().

Member Data Documentation

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