From: Jordi Mas (jmas@softcatala.org)
Date: Tue Jul 16 2002 - 08:48:29 EDT
Hello,
Please, can someone commit these changes for the OLE drag and drop support?
I'm going on holiday for 10 days. I talk your soon.
Thanks,
--Jordi Mas http://www.softcatala.org
Index: src/af/xap/win/xap_Win32DragAndDrop.cpp
===================================================================
RCS file: /cvsroot/abi/src/af/xap/win/xap_Win32DragAndDrop.cpp,v
retrieving revision 1.1
diff -u -r1.1 xap_Win32DragAndDrop.cpp
--- src/af/xap/win/xap_Win32DragAndDrop.cpp 13 Jul 2002 13:13:05 -0000 1.1
+++ src/af/xap/win/xap_Win32DragAndDrop.cpp 16 Jul 2002 12:38:43 -0000
@@ -36,7 +36,12 @@
#include "xap_Win32DragAndDrop.h"
#include "fl_DocLayout.h"
-char szName[]="Softcatala";
+XAP_Win32DropTarget::XAP_Win32DropTarget()
+{
+ m_uCF_RTF = RegisterClipboardFormat(CF_RTF);
+ m_nCount = 0;
+
+};
STDMETHODIMP XAP_Win32DropTarget::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
{
@@ -58,35 +63,41 @@
}
//
-// Called when the mouse first enters our DropTarget window
+// Called when the mouse first enters our DropTarget window
+// We check which formats we really support
//
-
-/*
-TODO:
-
-determine what the data object contains, call the data object's
-IDataObject::EnumFormatEtc method. Use the enumerator object returned by the
-method to enumerate the formats contained by the data object. If your
-application does not want to accept any of these formats, return
-DROPEFFECT_NONE. For the purposes of this scenario, your application should
-ignore any data objects that do not contain formats used to transfer files, such
-as CF_HDROP.
-*/
STDMETHODIMP XAP_Win32DropTarget::DragEnter (LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pointl, LPDWORD pdwEffect)
-{
- //TODO: Check which formats we really support
- *pdwEffect = DROPEFFECT_COPY;
+{
+ FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
+
+ m_bSupportedFormat = false;
+
+ // Dropping files
+ if (NOERROR == pDataObj->QueryGetData(&fmte))
+ m_bSupportedFormat = true;
+
+ // RTF
+ fmte.cfFormat = m_uCF_RTF;
+
+ if (NOERROR == pDataObj->QueryGetData(&fmte))
+ m_bSupportedFormat = true;
+
+ *pdwEffect = (m_bSupportedFormat) ? DROPEFFECT_COPY : DROPEFFECT_NONE;
+
return S_OK;
}
-STDMETHODIMP XAP_Win32DropTarget::DragOver (DWORD grfKeyState, POINTL pointl, LPDWORD pdwEffect)
-{
+STDMETHODIMP XAP_Win32DropTarget::DragOver(DWORD grfKeyState, POINTL pointl, LPDWORD pdwEffect)
+{
+ *pdwEffect = (m_bSupportedFormat) ? DROPEFFECT_COPY : DROPEFFECT_NONE;
+
+ SendMessage(m_pFrame->getTopLevelWindow(), WM_VSCROLL, SB_LINEDOWN, NULL);
+
return S_OK;
}
-
-STDMETHODIMP XAP_Win32DropTarget::DragLeave ()
+STDMETHODIMP XAP_Win32DropTarget::DragLeave()
{
return S_OK;
}
@@ -100,8 +111,7 @@
FORMATETC formatetc;
STGMEDIUM medium;
- char* pData;
- UINT uCF_RTF;
+ char* pData;
UT_uint32 iStrLen;
IE_Imp* pImp = 0;
const char * szEncoding = 0;
@@ -120,18 +130,17 @@
// We send an event Message Window to the Win32Frame since historicaly
// the file loading was processed there
if (count)
- SendMessage(pFrame->getTopLevelWindow(), WM_DROPFILES, (WPARAM)medium.hGlobal, 0);
+ SendMessage(m_pFrame->getTopLevelWindow(), WM_DROPFILES, (WPARAM)medium.hGlobal, 0);
ReleaseStgMedium(&medium);
return S_OK;
}
+
//
- // Is the user dropping RTF Files?
- //
- uCF_RTF = RegisterClipboardFormat(CF_RTF);
-
- formatetc.cfFormat = uCF_RTF;
+ // Is the user dropping RTF text?
+ //
+ formatetc.cfFormat = m_uCF_RTF;
formatetc.ptd = NULL;
formatetc.dwAspect = DVASPECT_CONTENT;
formatetc.lindex = -1;
@@ -139,8 +148,7 @@
medium.hGlobal = NULL;
medium.pUnkForRelease = NULL;
-
- // TODO: Add more formats
+
// Does not support RTF
if (!SUCCEEDED(pDataObj->GetData(&formatetc, &medium)))
return S_OK;
@@ -149,7 +157,7 @@
iStrLen = strlen(pData);
// Get document range
- AP_FrameData* pFrameData = (AP_FrameData*) pFrame->getFrameData();
+ AP_FrameData* pFrameData = (AP_FrameData*) m_pFrame->getFrameData();
FL_DocLayout *pDocLy = pFrameData->m_pDocLayout;
FV_View * pView = pDocLy->getView();
PD_DocumentRange dr(pView->getDocument(),pView->getPoint(),pView->getPoint());
@@ -159,8 +167,7 @@
if (pImp)
{
szEncoding = XAP_EncodingManager::get_instance()->getNative8BitEncodingName();
-
- //szEncoding = XAP_EncodingManager::get_instance()->getUCS2LEName();
+
pImp->pasteFromBuffer(&dr, (unsigned char *)pData, iStrLen,szEncoding);
delete pImp;
Index: src/af/xap/win/xap_Win32DragAndDrop.h
===================================================================
RCS file: /cvsroot/abi/src/af/xap/win/xap_Win32DragAndDrop.h,v
retrieving revision 1.1
diff -u -r1.1 xap_Win32DragAndDrop.h
--- src/af/xap/win/xap_Win32DragAndDrop.h 13 Jul 2002 13:13:06 -0000 1.1
+++ src/af/xap/win/xap_Win32DragAndDrop.h 16 Jul 2002 12:38:44 -0000
@@ -45,28 +45,34 @@
interface XAP_Win32DropTarget : public IDropTarget
{
-
- XAP_Win32DropTarget() {};
+public:
+
+ XAP_Win32DropTarget();
~XAP_Win32DropTarget() {};
+ // Ole Methods
STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR* ppv);
STDMETHODIMP_(ULONG) AddRef ();
STDMETHODIMP_(ULONG) Release ();
- // Drap and drop methods
+
STDMETHODIMP DragEnter (LPDATAOBJECT pDataObj, DWORD grfKeyState,
POINTL pt, LPDWORD pdwEffect);
STDMETHODIMP DragOver (DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
STDMETHODIMP DragLeave ();
STDMETHODIMP Drop (LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt,
LPDWORD pdwEffect);
-
- XAP_Win32Frame* pFrame;
-
+
+ // Helper
+ void setFrame(XAP_Win32Frame* pFrame) {m_pFrame = pFrame;};
private:
int m_nCount; // reference count
+ UINT m_uCF_RTF;
+ bool m_bSupportedFormat;
+ XAP_Win32Frame* m_pFrame;
+
};
Index: src/af/xap/win/xap_Win32Frame.cpp
===================================================================
RCS file: /cvsroot/abi/src/af/xap/win/xap_Win32Frame.cpp,v
retrieving revision 1.79
diff -u -r1.79 xap_Win32Frame.cpp
--- src/af/xap/win/xap_Win32Frame.cpp 13 Jul 2002 13:13:06 -0000 1.79
+++ src/af/xap/win/xap_Win32Frame.cpp 16 Jul 2002 12:38:44 -0000
@@ -303,7 +303,7 @@
// Register drag and drop data and files
- m_dropTarget.pFrame = this;
+ m_dropTarget.setFrame(this);
RegisterDragDrop(m_hwndFrame, &m_dropTarget);
return;
Index: src/wp/ap/win/ap_Win32App.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/win/ap_Win32App.cpp,v
retrieving revision 1.92
diff -u -r1.92 ap_Win32App.cpp
--- src/wp/ap/win/ap_Win32App.cpp 14 Jul 2002 23:06:34 -0000 1.92
+++ src/wp/ap/win/ap_Win32App.cpp 16 Jul 2002 12:40:51 -0000
@@ -790,8 +790,7 @@
// OLE Stuff
if (SUCCEEDED(OleInitialize(NULL)))
- bInitialized = TRUE;
-
+ bInitialized = TRUE;
// We put this in a block to force the destruction of Args in the stack
{
This archive was generated by hypermail 2.1.4 : Tue Jul 16 2002 - 08:50:41 EDT