diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_core/src/Windows/clipboard.cpp | 64 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 3 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 3 |
3 files changed, 41 insertions, 29 deletions
diff --git a/src/mir_core/src/Windows/clipboard.cpp b/src/mir_core/src/Windows/clipboard.cpp index 13c52a5c44..61ddef6875 100644 --- a/src/mir_core/src/Windows/clipboard.cpp +++ b/src/mir_core/src/Windows/clipboard.cpp @@ -26,22 +26,35 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static UINT g_iRtf = 0; +static void sttCopyAnsi(const char *pszString) +{ + if (size_t cbLen = mir_strlen(pszString)) + if (HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, cbLen + 1)) { + mir_strcpy((char *)GlobalLock(hData), pszString); + GlobalUnlock(hData); + SetClipboardData(CF_TEXT, hData); + } +} + +static void sttCopyUnicode(const wchar_t *pwszString) +{ + if (size_t cbLen = mir_wstrlen(pwszString)) + if (HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, (cbLen + 1) * sizeof(wchar_t))) { + mir_wstrcpy((wchar_t *)GlobalLock(hData), pwszString); + GlobalUnlock(hData); + SetClipboardData(CF_UNICODETEXT, hData); + } +} + +///////////////////////////////////////////////////////////////////////////////////////// + MClipAnsi::MClipAnsi(const char *pszString) : m_szString(pszString) {} void MClipAnsi::Copy() const { - size_t cbLen = mir_strlen(m_szString); - if (!cbLen) - return; - - HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, cbLen + 1); - if (hData) { - mir_strcpy((char *)GlobalLock(hData), m_szString); - GlobalUnlock(hData); - SetClipboardData(CF_TEXT, hData); - } + sttCopyAnsi(m_szString); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -52,19 +65,10 @@ MClipRtf::MClipRtf(const char *pszString) : void MClipRtf::Copy() const { - size_t cbLen = mir_strlen(m_szString); - if (!cbLen) - return; - if (g_iRtf == 0) g_iRtf = RegisterClipboardFormatW(CF_RTF); - HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, cbLen + 1); - if (hData) { - mir_strcpy((char *)GlobalLock(hData), m_szString); - GlobalUnlock(hData); - SetClipboardData(g_iRtf, hData); - } + sttCopyAnsi(m_szString); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -75,16 +79,18 @@ MClipUnicode::MClipUnicode(const wchar_t *pwszString) : void MClipUnicode::Copy() const { - size_t cbLen = mir_wstrlen(m_wszString); - if (!cbLen) - return; + sttCopyUnicode(m_wszString); +} + +///////////////////////////////////////////////////////////////////////////////////////// - HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, (cbLen + 1) * sizeof(wchar_t)); - if (hData) { - mir_wstrcpy((wchar_t *)GlobalLock(hData), m_wszString); - GlobalUnlock(hData); - SetClipboardData(CF_UNICODETEXT, hData); - } +MClipUtf8::MClipUtf8(const char *pszString) : + m_szString(pszString) +{} + +void MClipUtf8::Copy() const +{ + sttCopyUnicode(Utf2T(m_szString)); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 5c192dbef0..ab3a5ec23d 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1580,3 +1580,6 @@ _newStrW@4 @1789 NONAME ?SetTooltip@CCtrlMButton@@QAEXPBD@Z @1805 NONAME
_db_event_delivered@8 @1806 NONAME
?Utils_GenerateUUID@@YG?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@XZ @1807 NONAME
+??0MClipUtf8@@QAE@PBD@Z @1808 NONAME
+??_7MClipUtf8@@6B@ @1809 NONAME
+?Copy@MClipUtf8@@UBEXXZ @1810 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index ee09358441..8cb06c15f1 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1580,3 +1580,6 @@ newStrW @1789 NONAME ?SetTooltip@CCtrlMButton@@QEAAXPEBD@Z @1805 NONAME
db_event_delivered @1806 NONAME
?Utils_GenerateUUID@@YA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@XZ @1807 NONAME
+??0MClipUtf8@@QEAA@PEBD@Z @1808 NONAME
+??_7MClipUtf8@@6B@ @1809 NONAME
+?Copy@MClipUtf8@@UEBAXXZ @1810 NONAME
|