[NEW_FEATURE] Add "Save Copy As" feature.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@199 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-05-08 23:17:43 +00:00
parent b177e060bc
commit fd437c9c7d
4 changed files with 38 additions and 23 deletions

View File

@ -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;
// 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);
if (isSys)
::SetFileAttributes(filename, attrib | FILE_ATTRIBUTE_SYSTEM);
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());
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;

View File

@ -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);

View File

@ -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

View File

@ -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