From c5dc28ec2272a865ef2f28fd7ab151b55517fedf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 26 Sep 2022 19:16:12 +0300 Subject: more clipboard shit removed --- plugins/Msg_Export/src/FileViewer.cpp | 52 +++++++++++++++-------------------- 1 file changed, 22 insertions(+), 30 deletions(-) (limited to 'plugins/Msg_Export/src') diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp index 6390f435e1..f6f018936b 100644 --- a/plugins/Msg_Export/src/FileViewer.cpp +++ b/plugins/Msg_Export/src/FileViewer.cpp @@ -548,41 +548,33 @@ bool bAdvancedCopy(HWND hwnd) CHARRANGE sSelectRange; SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sSelectRange); int nSelLenght = sSelectRange.cpMax - sSelectRange.cpMin + 1; // +1 for null termination - if (nSelLenght > 1) { - if (OpenClipboard(nullptr)) { - EmptyClipboard(); - - wchar_t *pszSrcBuf = new wchar_t[nSelLenght]; - pszSrcBuf[0] = 0; - SendMessage(hwnd, EM_GETSELTEXT, 0, (LPARAM)pszSrcBuf); - - HANDLE hDecMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, nSelLenght * sizeof(wchar_t)); - wchar_t *pszCurDec = (wchar_t*)GlobalLock(hDecMem); - - bool bInSpaces = false; - for (wchar_t *pszCur = pszSrcBuf; pszCur[0]; pszCur++) { - if (bInSpaces) { - if (pszCur[0] == ' ') - continue; - bInSpaces = false; - } + if (nSelLenght <= 1) + return false; - if (pszCur[0] == '\n') - bInSpaces = true; + wchar_t *pszSrcBuf = new wchar_t[nSelLenght]; + pszSrcBuf[0] = 0; + SendMessage(hwnd, EM_GETSELTEXT, 0, (LPARAM)pszSrcBuf); - pszCurDec[0] = pszCur[0]; - pszCurDec++; - } - pszCurDec[0] = 0; - GlobalUnlock(hDecMem); + wchar_t *pszCurDec = pszSrcBuf; - SetClipboardData(CF_UNICODETEXT, hDecMem); - delete[] pszSrcBuf; - CloseClipboard(); - return true; + bool bInSpaces = false; + for (wchar_t *pszCur = pszSrcBuf; pszCur[0]; pszCur++) { + if (bInSpaces) { + if (pszCur[0] == ' ') + continue; + bInSpaces = false; } + + if (pszCur[0] == '\n') + bInSpaces = true; + + *pszCurDec = *pszCur; + pszCurDec++; } - return false; + pszCurDec[0] = 0; + Utils_ClipboardCopy(pszSrcBuf); + delete[] pszSrcBuf; + return true; } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3