Author: gedmurphy Date: Wed May 25 20:12:34 2011 New Revision: 51908
URL: http://svn.reactos.org/svn/reactos?rev=51908&view=rev Log: [SHELL32_NEW] - Merge 49969, refactored to use CComPtr's thanks to the new C++ model (it's sooo much cleaner now)
- Implement copy / paste for files when tree view is present - Don't add shortcuts / executables to recent file list
Modified: branches/shell32_new-bringup/dll/win32/shell32/shellord.cpp branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp
Modified: branches/shell32_new-bringup/dll/win32/shell32/shellord.cpp URL: http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/sh... ============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shellord.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shellord.cpp [iso-8859-1] Wed May 25 20:12:34 2011 @@ -685,6 +685,7 @@ CHAR link_dir[MAX_PATH]; CHAR new_lnk_filepath[MAX_PATH]; CHAR new_lnk_name[MAX_PATH]; + CHAR * ext; CComPtr<IMalloc> ppM; LPITEMIDLIST pidl; HWND hwnd = 0; /* FIXME: get real window handle */ @@ -817,6 +818,23 @@ }
TRACE("full document name %s\n", debugstr_a(doc_name)); + + /* check if file is a shortcut */ + ext = strrchr(doc_name, '.'); + if (!lstrcmpiA(ext, ".lnk")) + { + CComPtr<IShellLinkA> ShellLink; + IShellLink_ConstructFromFile(NULL, IID_IShellLinkA, (LPCITEMIDLIST)SHSimpleIDListFromPathA(doc_name), (LPVOID*)&ShellLink); + ShellLink->GetPath(doc_name, MAX_PATH, NULL, 0); + } + + ext = strrchr(doc_name, '.'); + if (!lstrcmpiA(ext, ".exe")) + { + /* executables are not added */ + return; + } + PathStripPathA(doc_name); TRACE("stripped document name %s\n", debugstr_a(doc_name));
Modified: branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp URL: http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/sh... ============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp [iso-8859-1] Wed May 25 20:12:34 2011 @@ -1831,11 +1831,139 @@ } else if(plvKeyDown->wVKey == 'C' && ctrl) { - FIXME("Need to copy\n"); + if (GetSelections()) + { + CComPtr<IDataObject> pda; + + if (SUCCEEDED(pSFParent->GetUIObjectOf(m_hWnd, cidl, (LPCITEMIDLIST*)apidl, IID_IDataObject, 0, (LPVOID *)&pda))) + { + HRESULT hr = OleSetClipboard(pda); + if (FAILED(hr)) + { + WARN("OleSetClipboard failed"); + } + } + } + break; } else if(plvKeyDown->wVKey == 'V' && ctrl) { - FIXME("Need to paste\n"); + CComPtr<IDataObject> pda; + STGMEDIUM medium; + FORMATETC formatetc; + LPITEMIDLIST * apidl; + LPITEMIDLIST pidl; + CComPtr<IShellFolder> psfFrom; + CComPtr<IShellFolder> psfDesktop; + CComPtr<IShellFolder> psfTarget; + LPIDA lpcida; + CComPtr<ISFHelper> psfhlpdst; + CComPtr<ISFHelper> psfhlpsrc; + HRESULT hr; + + hr = OleGetClipboard(&pda); + if (hr != S_OK) + { + ERR("Failed to get clipboard with %lx\n", hr); + return E_FAIL; + } + + InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); + hr = pda->GetData(&formatetc, &medium); + + if (FAILED(hr)) + { + ERR("Failed to get clipboard data with %lx\n", hr); + return E_FAIL; + } + + /* lock the handle */ + lpcida = (LPIDA)GlobalLock(medium.hGlobal); + if (!lpcida) + { + ERR("failed to lock pidl\n"); + ReleaseStgMedium(&medium); + return E_FAIL; + } + + /* convert the data into pidl */ + apidl = _ILCopyCidaToaPidl(&pidl, lpcida); + + if (!apidl) + { + ERR("failed to copy pidl\n"); + return E_FAIL; + } + + if (FAILED(SHGetDesktopFolder(&psfDesktop))) + { + ERR("failed to get desktop folder\n"); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + return E_FAIL; + } + + if (_ILIsDesktop(pidl)) + { + /* use desktop shellfolder */ + psfFrom = psfDesktop; + } + else if (FAILED(psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (LPVOID*)&psfFrom))) + { + ERR("no IShellFolder\n"); + + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + + return E_FAIL; + } + + psfTarget = pSFParent; + + + /* get source and destination shellfolder */ + if (FAILED(psfTarget->QueryInterface(IID_ISFHelper, (LPVOID*)&psfhlpdst))) + { + ERR("no IID_ISFHelper for destination\n"); + + //IShellFolder_Release(psfFrom); + //IShellFolder_Release(psfTarget); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + + return E_FAIL; + } + + if (FAILED(psfFrom->QueryInterface(IID_ISFHelper, (LPVOID*)&psfhlpsrc))) + { + ERR("no IID_ISFHelper for source\n"); + + //ISFHelper_Release(psfhlpdst); + ///IShellFolder_Release(psfFrom); + //IShellFolder_Release(psfTarget); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + return E_FAIL; + } + + /* FIXXME + * do we want to perform a copy or move ??? + */ + hr = psfhlpdst->CopyItems(psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl); + + //ISFHelper_Release(psfhlpdst); + //ISFHelper_Release(psfhlpsrc); + //IShellFolder_Release(psfFrom); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + //IDataObject_Release(pda); + TRACE("paste end hr %x\n", hr); + break; } else FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);