Index: src/af/ev/xp/ev_EditBits.h =================================================================== RCS file: /cvsroot/abi/src/af/ev/xp/ev_EditBits.h,v retrieving revision 1.19 diff -p -u -5 -r1.19 ev_EditBits.h --- src/af/ev/xp/ev_EditBits.h 2 Feb 2005 00:23:20 -0000 1.19 +++ src/af/ev/xp/ev_EditBits.h 3 Sep 2006 15:10:46 -0000 @@ -68,10 +68,11 @@ typedef UT_uint32 EV_EditMouseContext; // different menus in dependence on the nature of the text of // the hyperlink #define EV_EMC_HYPERLINKTEXT ((EV_EditMouseContext) 0x000000002) #define EV_EMC_HYPERLINKMISSPELLED ((EV_EditMouseContext) 0x000000001) +#define EV_EMC_AVAIL ((EV_EditMouseContext) 0x000000003) #define EV_EMC_ToNumber(emc) (((emc)&EV_EMC__MASK__)>>27) typedef UT_uint32 EV_EditModifierState; /* may be ORed */ Index: src/af/gr/xp/gr_EmbedManager.h =================================================================== RCS file: /cvsroot/abi/src/af/gr/xp/gr_EmbedManager.h,v retrieving revision 1.10 diff -p -u -5 -r1.10 gr_EmbedManager.h --- src/af/gr/xp/gr_EmbedManager.h 28 Aug 2006 07:36:43 -0000 1.10 +++ src/af/gr/xp/gr_EmbedManager.h 3 Sep 2006 15:10:47 -0000 @@ -22,10 +22,11 @@ #define __gr_EmbedManager_h__ #include "ut_string_class.h" #include "ut_types.h" #include "ut_vector.h" #include "ut_misc.h" +#include "ev_EditBits.h" class GR_Graphics; class GR_Image; class UT_ByteBuf; class AD_Document; @@ -76,10 +77,12 @@ public: virtual bool convert(UT_uint32 iConvType, UT_ByteBuf & pFrom, UT_ByteBuf & pTo); virtual bool isEdittable(UT_sint32 uid); virtual bool isResizeable(UT_sint32 uid); virtual void setRun (UT_sint32 uid, fp_Run * run); virtual void updateData(UT_sint32 uid, UT_sint32 api); + virtual EV_EditMouseContext getContextualMenu(void) const + { return EV_EMC_EMBED; } private: GR_Graphics * m_pG; UT_GenericVector m_vecSnapshots; }; Index: src/af/xap/xp/xap_Menu_Layouts.h =================================================================== RCS file: /cvsroot/abi/src/af/xap/xp/xap_Menu_Layouts.h,v retrieving revision 1.13 diff -p -u -5 -r1.13 xap_Menu_Layouts.h --- src/af/xap/xp/xap_Menu_Layouts.h 21 Mar 2005 12:45:41 -0000 1.13 +++ src/af/xap/xp/xap_Menu_Layouts.h 3 Sep 2006 15:10:47 -0000 @@ -65,20 +65,19 @@ public: bool removeLabel(const char * szMenu, XAP_Menu_Id nukeID); void resetLabelsToDefault(void); + EV_EditMouseContext createContextMenu(const char * szMenu); + void removeContextMenu(EV_EditMouseContext menuID); + private: mutable UT_Vector m_vecTT; XAP_App * m_pApp; EV_Menu_LabelSet * m_pLabelSet; EV_Menu_LabelSet * m_pEnglishLabelSet; XAP_Menu_Id m_maxID; XAP_StringSet * m_pBSS; + EV_EditMouseContext m_NextContext; }; #endif /* XAP_MENU_LAYOUTS_H */ - - - - - Index: src/text/fmt/xp/fp_EmbedRun.cpp =================================================================== RCS file: /cvsroot/abi/src/text/fmt/xp/fp_EmbedRun.cpp,v retrieving revision 1.21 diff -p -u -5 -r1.21 fp_EmbedRun.cpp --- src/text/fmt/xp/fp_EmbedRun.cpp 28 Aug 2006 07:36:45 -0000 1.21 +++ src/text/fmt/xp/fp_EmbedRun.cpp 3 Sep 2006 15:10:48 -0000 @@ -565,5 +565,10 @@ void fp_EmbedRun::update() { m_iIndexAP = getBlock()->getDocument()->getAPIFromSOH(m_OH); m_pEmbedManager->updateData(m_iEmbedUID, m_iIndexAP); m_pEmbedManager->loadEmbedData(m_iEmbedUID); } + +EV_EditMouseContext fp_EmbedRun::getContextualMenu(void) const +{ + return m_pEmbedManager->getContextualMenu(); +} Index: src/text/fmt/xp/fp_EmbedRun.h =================================================================== RCS file: /cvsroot/abi/src/text/fmt/xp/fp_EmbedRun.h,v retrieving revision 1.7 diff -p -u -5 -r1.7 fp_EmbedRun.h --- src/text/fmt/xp/fp_EmbedRun.h 28 Aug 2006 07:36:45 -0000 1.7 +++ src/text/fmt/xp/fp_EmbedRun.h 3 Sep 2006 15:10:48 -0000 @@ -22,10 +22,11 @@ #ifndef FP_EMBEDRUN_H #define FP_EMBEDRUN_H #include "fp_Run.h" +#include "ev_EditBits.h" class fl_BlockLayout; class GR_EmbedManager; class FL_DocLayout; @@ -50,10 +51,12 @@ public: bool isResizeable(void); const char * getDataID(void) const; UT_sint32 getUID(void) const { return m_iEmbedUID;} void update(); + EV_EditMouseContext getContextualMenu(void) const; + protected: virtual void _lookupProperties(const PP_AttrProp * pSpanAP, const PP_AttrProp * pBlockAP, const PP_AttrProp * pSectionAP, GR_Graphics * pG = NULL); Index: src/wp/ap/xp/ap_EditMethods.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_EditMethods.cpp,v retrieving revision 1.825 diff -p -u -5 -r1.825 ap_EditMethods.cpp --- src/wp/ap/xp/ap_EditMethods.cpp 18 Aug 2006 02:21:23 -0000 1.825 +++ src/wp/ap/xp/ap_EditMethods.cpp 3 Sep 2006 15:11:01 -0000 @@ -4467,15 +4467,16 @@ Defun(contextImage) { CHECK_FRAME; ABIWORD_VIEW; XAP_Frame * pFrame = static_cast (pView->getParentData()); UT_return_val_if_fail(pFrame, false); + fp_Run *pRun = NULL; if ( pView->isSelectionEmpty () ) { - // select the image if it isn't already - UT_DEBUGMSG(("Selecting image: %d\n", pCallData->m_xPos)); + // select the object if it isn't already + UT_DEBUGMSG(("Selecting objec: %d\n", pCallData->m_xPos)); pView->warpInsPtToXY(pCallData->m_xPos, pCallData->m_yPos, true); pView->extSelHorizontal (true, 1); } PT_DocPosition pos = pView->getDocPositionFromXY(pCallData->m_xPos, pCallData->m_yPos); fl_BlockLayout * pBlock = pView->getBlockAtPosition(pos); @@ -4484,12 +4485,10 @@ Defun(contextImage) { UT_sint32 x1,x2,y1,y2,iHeight; bool bEOL = false; bool bDir = false; - fp_Run * pRun = NULL; - pRun = pBlock->findPointCoords(pos,bEOL,x1,y1,x2,y2,iHeight,bDir); while(pRun && ((pRun->getType() != FPRUN_IMAGE) && (pRun->getType() != FPRUN_EMBED))) { pRun = pRun->getNextRun(); } @@ -4508,11 +4507,13 @@ Defun(contextImage) } if(!bDoEmbed) { return s_doContextMenu(EV_EMC_IMAGE,pCallData->m_xPos, pCallData->m_yPos,pView,pFrame); } - return s_doContextMenu(EV_EMC_EMBED,pCallData->m_xPos, pCallData->m_yPos,pView,pFrame); + // get the menu from pRun + fp_EmbedRun *pEmbedRun = dynamic_cast(pRun); + return s_doContextMenu((pRun)? pEmbedRun->getContextualMenu(): EV_EMC_EMBED, pCallData->m_xPos, pCallData->m_yPos, pView, pFrame); } Defun(contextPosObject) { @@ -4528,11 +4529,49 @@ Defun(contextEmbedLayout) { CHECK_FRAME; ABIWORD_VIEW; XAP_Frame * pFrame = static_cast (pView->getParentData()); UT_return_val_if_fail(pFrame, false); - return s_doContextMenu(EV_EMC_EMBED,pCallData->m_xPos, pCallData->m_yPos,pView,pFrame); + fp_Run *pRun = NULL; + + if ( pView->isSelectionEmpty () ) + { + // select the image if it isn't already + UT_DEBUGMSG(("Selecting image: %d\n", pCallData->m_xPos)); + pView->warpInsPtToXY(pCallData->m_xPos, pCallData->m_yPos, true); + pView->extSelHorizontal (true, 1); + } + PT_DocPosition pos = pView->getDocPositionFromXY(pCallData->m_xPos, pCallData->m_yPos); + fl_BlockLayout * pBlock = pView->getBlockAtPosition(pos); + bool bDoEmbed = false; + if(pBlock) + { + UT_sint32 x1,x2,y1,y2,iHeight; + bool bEOL = false; + bool bDir = false; + + pRun = pBlock->findPointCoords(pos,bEOL,x1,y1,x2,y2,iHeight,bDir); + while(pRun && ((pRun->getType() != FPRUN_IMAGE) && (pRun->getType() != FPRUN_EMBED))) + { + pRun = pRun->getNextRun(); + } + if(pRun && ((pRun->getType() == FPRUN_IMAGE) || ((pRun->getType() == FPRUN_EMBED)))) + { + // Set the cursor context to image selected. + if(pRun->getType() == FPRUN_EMBED) + { + bDoEmbed = true; + } + } + else + { + // do nothing... + } + } + // get the menu from pRun + fp_EmbedRun *pEmbedRun = dynamic_cast(pRun); + return s_doContextMenu((pRun)? pEmbedRun->getContextualMenu(): EV_EMC_EMBED, pCallData->m_xPos, pCallData->m_yPos, pView, pFrame); } Defun(contextHyperlink) { CHECK_FRAME; Index: src/wp/ap/xp/ap_Menu_Layouts.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Menu_Layouts.cpp,v retrieving revision 1.28 diff -p -u -5 -r1.28 ap_Menu_Layouts.cpp --- src/wp/ap/xp/ap_Menu_Layouts.cpp 28 Dec 2005 22:05:23 -0000 1.28 +++ src/wp/ap/xp/ap_Menu_Layouts.cpp 3 Sep 2006 15:11:01 -0000 @@ -81,11 +81,11 @@ }; void insertItemAt(void * p, XAP_Menu_Id id) { UT_uint32 i = 0; bool bFound = false; - for(i=0; i< m_Vec_lt.getItemCount(); i++) + for(i=0; i< m_Vec_lt.getItemCount() && !bFound; i++) { _lt * plt = (_lt *) m_Vec_lt.getNthItem(i); if(plt->m_id == id) { if((i+1) == m_Vec_lt.getItemCount()) @@ -218,10 +218,11 @@ XAP_Menu_Factory::XAP_Menu_Factory(XAP_A _vectt * pVectt = new _vectt(&s_ttTable[k]); m_vecTT.addItem((void *) pVectt); } m_pEnglishLabelSet = NULL; m_pBSS = NULL; + m_NextContext = EV_EMC_AVAIL; } XAP_Menu_Factory::~XAP_Menu_Factory() { UT_VECTOR_PURGEALL(_vectt *,m_vecTT); @@ -374,29 +375,35 @@ XAP_Menu_Id XAP_Menu_Factory::addNewMenu { UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return 0; } + XAP_Menu_Id beforeID; // next we need to find the id of the label name // // OK now search for this label // - UT_String Before = szBefore; - XAP_Menu_Id beforeID = EV_searchMenuLabel( m_pLabelSet, Before); - if(beforeID == 0) + if (szBefore) { - if(m_pEnglishLabelSet == NULL) - { - buildBuiltInMenuLabelSet( m_pEnglishLabelSet); - } - beforeID = EV_searchMenuLabel( m_pEnglishLabelSet, Before); + UT_String Before = szBefore; + beforeID = EV_searchMenuLabel( m_pLabelSet, Before); if(beforeID == 0) - { - UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); - return 0; + { + if(m_pEnglishLabelSet == NULL) + { + buildBuiltInMenuLabelSet( m_pEnglishLabelSet); + } + beforeID = EV_searchMenuLabel( m_pEnglishLabelSet, Before); + if(beforeID == 0) + { + UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); + return 0; + } } } + else + beforeID = 0; // // OK got the menu ID at last, insert the new id here. // if(newID == 0) { @@ -609,5 +616,23 @@ bool XAP_Menu_Factory::removeLabel(const void XAP_Menu_Factory::resetLabelsToDefault(void) { // TODO - do nothing as extra labels in set don't hurt operation } +EV_EditMouseContext XAP_Menu_Factory::createContextMenu(const char * szMenu) +{ + struct _lt items[2] = + {{EV_MLF_BeginPopupMenu,AP_MENU_ID__BOGUS1__ }, + {EV_MLF_EndPopupMenu,AP_MENU_ID__BOGUS1__ }}; + struct _tt newtt; + newtt.m_name = szMenu; + newtt.m_nrEntries = 2; + newtt.m_lt = items; + newtt.m_emc = m_NextContext; + _vectt * pVectt = new _vectt(&newtt); + m_vecTT.addItem((void *) pVectt); + return m_NextContext++; +} + +void XAP_Menu_Factory::removeContextMenu(EV_EditMouseContext menuID) +{ +}