From a5083edfb577ba93a69db4929b75b3fcb02a3639 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 11 Mar 2011 00:57:06 +0000 Subject: [PATCH] [NEW_FEATURE] Add "paste HTML content" and "paste RTF content" commands. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@740 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/installer/nativeLang/english.xml | 1 + PowerEditor/installer/nativeLang/french.xml | 2 +- PowerEditor/src/Notepad_plus.rc | 9 +++-- PowerEditor/src/NppCommands.cpp | 33 +++++++++++++++++++ PowerEditor/src/localizationString.h | Bin 7402 -> 7486 bytes PowerEditor/src/menuCmdID.h | 3 ++ 6 files changed, 45 insertions(+), 3 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 1f340a039..314b505d9 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -28,6 +28,7 @@ + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index b16121420..93af8c63a 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -22,7 +22,7 @@ - + diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 33c6b659f..19f03d9ae 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -255,14 +255,19 @@ BEGIN POPUP "Blank Operations" BEGIN MENUITEM "Trim Trailing Space", IDM_EDIT_TRIMTRAILING - MENUITEM "Trim Leading Space", IDM_EDIT_TRIMLINEHEAD - MENUITEM "Trim Leading and Trailing Space", IDM_EDIT_TRIM_BOTH + MENUITEM "Trim Leading Space", IDM_EDIT_TRIMLINEHEAD + MENUITEM "Trim Leading and Trailing Space", IDM_EDIT_TRIM_BOTH MENUITEM "EOL to Space", IDM_EDIT_EOL2WS MENUITEM "Remove Unnecessary Blank and EOL", IDM_EDIT_TRIMALL MENUITEM SEPARATOR MENUITEM "TAB to Space", IDM_EDIT_TAB2SW MENUITEM "Space to TAB", IDM_EDIT_SW2TAB END + POPUP "Paste Special" + BEGIN + MENUITEM "Paste HTML Content", IDM_EDIT_PASTE_AS_HTML + MENUITEM "Paste RTF Content", IDM_EDIT_PASTE_AS_RTF + END MENUITEM SEPARATOR MENUITEM "Column Mode...", IDM_EDIT_COLUMNMODETIP MENUITEM "Column Editor...", IDM_EDIT_COLUMNMODE diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 751c17736..143b5b7ec 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -21,6 +21,10 @@ #include "ShortcutMapper.h" #include "TaskListDlg.h" +#define CF_HTML TEXT("HTML Format") +#define CF_RTF TEXT("Rich Text Format") + + void Notepad_plus::macroPlayback(Macro macro) { _pEditView->execute(SCI_BEGINUNDOACTION); @@ -142,6 +146,35 @@ void Notepad_plus::command(int id) } break; + case IDM_EDIT_PASTE_AS_RTF: + case IDM_EDIT_PASTE_AS_HTML: + { + UINT f = RegisterClipboardFormat(id==IDM_EDIT_PASTE_AS_HTML?CF_HTML:CF_RTF); + + if (!IsClipboardFormatAvailable(f)) + return; + + if (!OpenClipboard(NULL)) + return; + + HGLOBAL hglb = GetClipboardData(f); + if (hglb != NULL) + { + LPSTR lptstr = (LPSTR)GlobalLock(hglb); + if (lptstr != NULL) + { + // Call the application-defined ReplaceSelection + // function to insert the text and repaint the + // window. + _pEditView->execute(SCI_REPLACESEL, 0, (LPARAM)lptstr); + + GlobalUnlock(hglb); + } + } + CloseClipboard(); + } + break; + case IDM_EDIT_DELETE: _pEditView->execute(WM_CLEAR); break; diff --git a/PowerEditor/src/localizationString.h b/PowerEditor/src/localizationString.h index 8d187bc077c761c17709fd905dd3c5b86893cb2c..a2c6c59d7845f9d9591d0eeadeebc8c43acc339b 100644 GIT binary patch delta 45 ycmaE5xzB3DDw)X%Tq3+t45