Index: src/af/xap/unix/xap_UnixClipboard.cpp =================================================================== RCS file: /cvsroot/abi/src/af/xap/unix/xap_UnixClipboard.cpp,v retrieving revision 1.35 diff -p -u -5 -r1.35 xap_UnixClipboard.cpp --- src/af/xap/unix/xap_UnixClipboard.cpp 22 Jul 2006 17:58:37 -0000 1.35 +++ src/af/xap/unix/xap_UnixClipboard.cpp 22 Sep 2006 06:04:21 -0000 @@ -71,10 +71,19 @@ void XAP_UnixClipboard::AddFmt(const cha UT_return_if_fail(szFormat && strlen(szFormat)); m_vecFormat_AP_Name.addItem(szFormat); m_vecFormat_GdkAtom.addItem(gdk_atom_intern(szFormat,FALSE)); } +void XAP_UnixClipboard::deleteFmt(const char * szFormat) +{ + UT_return_if_fail(szFormat && strlen(szFormat)); + UT_sint32 item = m_vecFormat_AP_Name.findItem(szFormat); + m_vecFormat_AP_Name.deleteNthItem(item); + m_vecFormat_GdkAtom.findItem(gdk_atom_intern(szFormat,FALSE)); + m_vecFormat_GdkAtom.deleteNthItem(item); +} + void XAP_UnixClipboard::initialize() { m_nTargets = m_vecFormat_AP_Name.getItemCount(); m_Targets = g_new0(GtkTargetEntry, m_nTargets); Index: src/af/xap/unix/xap_UnixClipboard.h =================================================================== RCS file: /cvsroot/abi/src/af/xap/unix/xap_UnixClipboard.h,v retrieving revision 1.18 diff -p -u -5 -r1.18 xap_UnixClipboard.h --- src/af/xap/unix/xap_UnixClipboard.h 23 Mar 2004 00:12:00 -0000 1.18 +++ src/af/xap/unix/xap_UnixClipboard.h 22 Sep 2006 06:04:21 -0000 @@ -58,13 +58,14 @@ public: bool getTextData(T_AllowGet tFrom, void ** ppData, UT_uint32 * pLen); bool canPaste(T_AllowGet tFrom); - protected: - - void AddFmt(const char * fmt); +protected: + + void AddFmt(const char * fmt); + void deleteFmt(const char * fmt); private: GtkClipboard * gtkClipboardForTarget(XAP_UnixClipboard::_T_AllowGet get); Index: src/af/xap/xp/xap_App.h =================================================================== RCS file: /cvsroot/abi/src/af/xap/xp/xap_App.h,v retrieving revision 1.136 diff -p -u -5 -r1.136 xap_App.h --- src/af/xap/xp/xap_App.h 24 Mar 2006 12:37:35 -0000 1.136 +++ src/af/xap/xp/xap_App.h 22 Sep 2006 06:04:21 -0000 @@ -179,10 +179,12 @@ public: virtual bool findAbiSuiteAppFile(UT_String & path, const char * filename, const char * subdir = 0); // doesn't check user-dir virtual void copyToClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard = true) = 0; virtual void pasteFromClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard, bool bHonorFormatting = true) = 0; virtual bool canPasteFromClipboard() = 0; virtual void cacheCurrentSelection(AV_View *) = 0; + virtual void addClipboardFmt (const char * szFormat) {} + virtual void deleteClipboardFmt (const char * szFormat) {} void rememberFocussedFrame(void * pJustFocussedFrame); XAP_Frame * getLastFocussedFrame() const; XAP_Frame * findValidFrame() const; bool safeCompare(XAP_Frame * lff, XAP_Frame * f); UT_sint32 safefindFrame(XAP_Frame * f) const; Index: src/wp/ap/unix/ap_UnixApp.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixApp.cpp,v retrieving revision 1.302 diff -p -u -5 -r1.302 ap_UnixApp.cpp --- src/wp/ap/unix/ap_UnixApp.cpp 16 Sep 2006 15:08:58 -0000 1.302 +++ src/wp/ap/unix/ap_UnixApp.cpp 22 Sep 2006 06:04:23 -0000 @@ -666,10 +666,22 @@ void AP_UnixApp::pasteFromClipboard(PD_D IE_Imp_XHTML * pImpHTML = new IE_Imp_XHTML(pDocRange->m_pDoc); bSuccess = pImpHTML->pasteFromBuffer(pDocRange,reinterpret_cast(pData),iLen); DELETEP(pImpHTML); } } + else if (AP_UnixClipboard::isDynamicTag (szFormatFound)) + { + UT_DEBUGMSG(("Format Found = %s \n",szFormatFound)); + IE_Imp * pImp = NULL; + IEFileType ieft = IE_Imp::fileTypeForContents(reinterpret_cast(const_cast(pData)),iLen); + UT_DEBUGMSG(("found file type %d\n",ieft)); + IE_Imp::constructImporter(pDocRange->m_pDoc,NULL,ieft,&pImp); + if(pImp == NULL) + goto retry_text; + bSuccess = pImp->pasteFromBuffer(pDocRange,pData,iLen); + DELETEP(pImp); + } else if (AP_UnixClipboard::isImageTag(szFormatFound)) { UT_DEBUGMSG(("Format Found = %s \n",szFormatFound)); if(strncmp(szFormatFound,"application",11) == 0) // embedded object { Index: src/wp/ap/unix/ap_UnixApp.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixApp.h,v retrieving revision 1.53 diff -p -u -5 -r1.53 ap_UnixApp.h --- src/wp/ap/unix/ap_UnixApp.h 26 Feb 2006 20:13:15 -0000 1.53 +++ src/wp/ap/unix/ap_UnixApp.h 22 Sep 2006 06:04:23 -0000 @@ -77,10 +77,12 @@ public: virtual const char * getAbiSuiteAppGladeDir(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 addClipboardFmt (const char * szFormat) {m_pClipboard->addFormat(szFormat);} + virtual void deleteClipboardFmt (const char * szFormat) {m_pClipboard->deleteFormat(szFormat);} virtual void setSelectionStatus(AV_View * pView); /*! Sets the view selection Index: src/wp/ap/unix/ap_UnixClipboard.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixClipboard.cpp,v retrieving revision 1.30 diff -p -u -5 -r1.30 ap_UnixClipboard.cpp --- src/wp/ap/unix/ap_UnixClipboard.cpp 16 Jun 2005 07:44:19 -0000 1.30 +++ src/wp/ap/unix/ap_UnixClipboard.cpp 22 Sep 2006 06:04:23 -0000 @@ -25,10 +25,11 @@ #include "ut_types.h" #include "ut_string.h" #include "ut_vector.h" #include "ap_UnixClipboard.h" #include "ap_UnixApp.h" +#include ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// // RichText: cut and paste @@ -93,10 +94,12 @@ static const char * imgszFormatsAccepted AP_CLIPBOARD_IMAGE_WMF, AP_CLIPBOARD_IMAGE_SVG, AP_CLIPBOARD_IMAGE_SVG_XML, 0 } ; +std::vector vec_DynamicFormatsAccepted; + AP_UnixClipboard::AP_UnixClipboard(AP_UnixApp * pApp) : XAP_UnixClipboard(pApp) { // DECLARE IN ORDER OF PREFERENCE RECEIVING @@ -130,10 +133,11 @@ AP_UnixClipboard::AP_UnixClipboard(AP_Un AddFmt(AP_CLIPBOARD_TEXT_COMPOUND); // hypertext types AddFmt ( AP_CLIPBOARD_TXT_HTML ) ; // actually XHTML, but who's counting? AddFmt ( AP_CLIPBOARD_APPLICATION_XHTML ) ; + vec_DynamicFormatsAccepted.insert(vec_DynamicFormatsAccepted.begin(), NULL); } bool AP_UnixClipboard::addTextData(T_AllowGet tTo, const void* pData, UT_sint32 iNumBytes) { if ( addData(tTo, AP_CLIPBOARD_TEXT_UTF8_STRING, pData, iNumBytes) && @@ -171,14 +175,16 @@ bool AP_UnixClipboard::getSupportedData const void ** ppData, UT_uint32 * pLen, const char **pszFormatFound) { if (getData(tFrom, rtfszFormatsAccepted, (void**)ppData, pLen, pszFormatFound)) return true; - else if (getData(tFrom, imgszFormatsAccepted, (void**)ppData, pLen, pszFormatFound)) - return true; else if (getData (tFrom, htmlszFormatsAccepted, (void**)ppData, pLen, pszFormatFound)) return true; + else if (getData(tFrom, vec_DynamicFormatsAccepted.data(), (void**)ppData, pLen, pszFormatFound)) + return true; + else if (getData(tFrom, imgszFormatsAccepted, (void**)ppData, pLen, pszFormatFound)) + return true; else if (getTextData (tFrom, ppData, pLen, pszFormatFound)) return true; return false; } @@ -203,10 +209,17 @@ bool AP_UnixClipboard::getImageData(T_Al const char **pszFormatFound) { return getData ( tFrom, imgszFormatsAccepted, (void**)ppData, pLen, pszFormatFound ); } +bool AP_UnixClipboard::getDynamicData(T_AllowGet tFrom, + const void ** ppData, UT_uint32 * pLen, + const char **pszFormatFound) +{ + return getData ( tFrom, vec_DynamicFormatsAccepted.data(), (void**)ppData, pLen, pszFormatFound ); +} + bool AP_UnixClipboard::isTextTag ( const char * tag ) { if ( !tag || !strlen(tag) ) return false ; @@ -251,5 +264,29 @@ bool AP_UnixClipboard::isImageTag ( cons if ( !strncmp ( tag, "application/x-goffice", 21 ) ) return true ; return false ; } + +bool AP_UnixClipboard::isDynamicTag ( const char * tag ) +{ + std::vector::iterator i = vec_DynamicFormatsAccepted.begin(); + while (*i && strcmp (tag, *i)) + i++; + return *i != NULL; +} + +void AP_UnixClipboard::addFormat(const char * fmt) +{ + AddFmt(fmt); + vec_DynamicFormatsAccepted.insert(vec_DynamicFormatsAccepted.begin(), fmt); +} + +void AP_UnixClipboard::deleteFormat(const char * fmt) +{ + deleteFmt(fmt); + std::vector::iterator i = vec_DynamicFormatsAccepted.begin(); + while (*i && strcmp (fmt, *i)) + i++; + if (*i) + vec_DynamicFormatsAccepted.erase(i); +} Index: src/wp/ap/unix/ap_UnixClipboard.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixClipboard.h,v retrieving revision 1.10 diff -p -u -5 -r1.10 ap_UnixClipboard.h --- src/wp/ap/unix/ap_UnixClipboard.h 13 Aug 2003 03:09:06 -0000 1.10 +++ src/wp/ap/unix/ap_UnixClipboard.h 22 Sep 2006 06:04:23 -0000 @@ -53,12 +53,20 @@ public: bool getImageData(T_AllowGet tFrom, const void ** ppData, UT_uint32 * pLen, const char **pszFormatFound); + bool getDynamicData(T_AllowGet tFrom, + const void ** ppData, UT_uint32 * pLen, + const char **pszFormatFound); + + void addFormat(const char * fmt); + void deleteFormat(const char * fmt); + static bool isTextTag ( const char * tag ) ; static bool isRichTextTag ( const char * tag ) ; static bool isHTMLTag ( const char * tag ) ; static bool isImageTag ( const char * tag ) ; + static bool isDynamicTag ( const char * tag ) ; }; #endif /* AP_UNIXCLIPBOARD_H */