diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 14020121..7dd7a5f6 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -940,7 +940,7 @@ bool Notepad_plus::doReload(const char *fileName, bool alert) return false; } -bool Notepad_plus::doSave(const char *filename, UniMode mode) +bool Notepad_plus::doSave(const char *filename, UniMode mode, bool isCopy) { bool isHidden = false; bool isSys = false; @@ -974,13 +974,16 @@ bool Notepad_plus::doSave(const char *filename, UniMode mode) if (fp) { - // Notify plugins that current file is about to be saved SCNotification scnN; - scnN.nmhdr.code = NPPN_FILEBEFORESAVE; - scnN.nmhdr.hwndFrom = _hSelf; - scnN.nmhdr.idFrom = 0; - _pluginsManager.notify(&scnN); - + // Notify plugins that current file is about to be saved + if (!isCopy) + { + + scnN.nmhdr.code = NPPN_FILEBEFORESAVE; + scnN.nmhdr.hwndFrom = _hSelf; + scnN.nmhdr.idFrom = 0; + _pluginsManager.notify(&scnN); + } char data[blockSize + 1]; int lengthDoc = _pEditView->getCurrentDocLen(); for (int i = 0; i < lengthDoc; i += blockSize) @@ -994,17 +997,20 @@ bool Notepad_plus::doSave(const char *filename, UniMode mode) } UnicodeConvertor.fclose(); - _pEditView->updateCurrentBufTimeStamp(); - _pEditView->execute(SCI_SETSAVEPOINT); - if (isHidden) - ::SetFileAttributes(filename, attrib | FILE_ATTRIBUTE_HIDDEN); + ::SetFileAttributes(filename, attrib | FILE_ATTRIBUTE_HIDDEN); if (isSys) ::SetFileAttributes(filename, attrib | FILE_ATTRIBUTE_SYSTEM); - scnN.nmhdr.code = NPPN_FILESAVED; - _pluginsManager.notify(&scnN); + if (!isCopy) + { + _pEditView->updateCurrentBufTimeStamp(); + _pEditView->execute(SCI_SETSAVEPOINT); + + scnN.nmhdr.code = NPPN_FILESAVED; + _pluginsManager.notify(&scnN); + } return true; } ::MessageBox(_hSelf, "Please check whether if this file is opened in another program", "Save failed", MB_OK); @@ -1397,7 +1403,7 @@ bool Notepad_plus::findInOpenedFiles() { return true; } -bool Notepad_plus::fileSaveAs() +bool Notepad_plus::fileSaveAs(bool isSaveCopy) { FileDialog fDlg(_hSelf, _hInst); @@ -1418,13 +1424,16 @@ bool Notepad_plus::fileSaveAs() int i = _pEditView->findDocIndexByName(pfn); if ((i == -1) || (i == currentDocIndex)) { - doSave(pfn, _pEditView->getCurrentBuffer().getUnicodeMode()); - _pEditView->setCurrentTitle(pfn); - _pEditView->setCurrentDocReadOnly(false); - _pDocTab->updateCurrentTabItem(PathFindFileName(pfn)); - setTitleWith(pfn); - setLangStatus(_pEditView->getCurrentDocType()); - checkLangsMenu(-1); + doSave(pfn, _pEditView->getCurrentBuffer().getUnicodeMode(), isSaveCopy); + if (!isSaveCopy) + { + _pEditView->setCurrentTitle(pfn); + _pEditView->setCurrentDocReadOnly(false); + _pDocTab->updateCurrentTabItem(PathFindFileName(pfn)); + setTitleWith(pfn); + setLangStatus(_pEditView->getCurrentDocType()); + checkLangsMenu(-1); + } return true; } else @@ -2652,6 +2661,10 @@ void Notepad_plus::command(int id) fileSaveAs(); break; + case IDM_FILE_SAVECOPYAS : + fileSaveAs(true); + break; + case IDM_FILE_LOADSESSION: fileLoadSession(); break; diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 9142ff4a..cc5bce97 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -117,9 +117,9 @@ public: bool fileCloseAllButCurrent(); bool fileSave(); bool fileSaveAll(); - bool fileSaveAs(); + bool fileSaveAs(bool isSaveCopy = false); - bool doSave(const char *filename, UniMode mode); + bool doSave(const char *filename, UniMode mode, bool isSaveCopy = false); // end fileOperation void filePrint(bool showDialog); diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 37f78c82..77749c33 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -249,6 +249,7 @@ BEGIN MENUITEM "Re&load from disk", IDM_FILE_RELOAD MENUITEM "&Save", IDM_FILE_SAVE MENUITEM "Save &As...", IDM_FILE_SAVEAS + MENUITEM "Save Copy As...", IDM_FILE_SAVECOPYAS MENUITEM "Sav&e All", IDM_FILE_SAVEALL MENUITEM "&Close", IDM_FILE_CLOSE MENUITEM "Cl&ose All", IDM_FILE_CLOSEALL diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 860fc058..85eb48c9 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -36,6 +36,7 @@ #define IDM_FILE_LOADSESSION (IDM_FILE + 12) #define IDM_FILE_SAVESESSION (IDM_FILE + 13) #define IDM_FILE_RELOAD (IDM_FILE + 14) + #define IDM_FILE_SAVECOPYAS (IDM_FILE + 15) // A mettre à jour si on ajoute nouveau menu item dans le menu "File" #define IDM_FILEMENU_LASTONE IDM_FILE_RELOAD