This patch adds a "Save Image As" option to the image context menu, allowing you to save images from a document to a png file.
Bye! Marc aka Uwog PS: This patch clearly breaks the strings freeze by adding a 2 new strings, so you could apply it post 1.0 it this is a problem.
Index: abi/src/wp/ap/xp/ap_EditMethods.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_EditMethods.cpp,v retrieving revision 1.464 diff -u -r1.464 ap_EditMethods.cpp --- abi/src/wp/ap/xp/ap_EditMethods.cpp 21 Mar 2002 21:56:24 -0000 1.464 +++ abi/src/wp/ap/xp/ap_EditMethods.cpp 22 Mar 2002 17:55:08 -0000 @@ -269,6 +269,7 @@ static EV_EditMethod_Fn fileOpen; static EV_EditMethod_Fn fileSave; static EV_EditMethod_Fn fileSaveAs; + static EV_EditMethod_Fn fileSaveImage; static EV_EditMethod_Fn fileExport; static EV_EditMethod_Fn fileImport; static EV_EditMethod_Fn formatPainter; @@ -686,6 +687,7 @@ EV_EditMethod(NF(fileSave), 0, ""), EV_EditMethod(NF(fileSaveAs), 0, ""), EV_EditMethod(NF(fileSaveAsWeb), 0, ""), + EV_EditMethod(NF(fileSaveImage), 0, ""), EV_EditMethod(NF(find), 0, ""), EV_EditMethod(NF(findAgain), 0, ""), EV_EditMethod(NF(fontFamily), _D_, ""), @@ -2114,6 +2116,58 @@ } return true; +} + +Defun1(fileSaveImage) +{ + CHECK_FRAME; + XAP_Frame * pFrame = static_cast<XAP_Frame *> ( pAV_View->getParentData()); + UT_ASSERT(pFrame); + + XAP_DialogFactory * pDialogFactory + = (XAP_DialogFactory *) pFrame->getDialogFactory(); + + XAP_Dialog_FileOpenSaveAs * pDialog + = (XAP_Dialog_FileOpenSaveAs *)(pDialogFactory->requestDialog(XAP_DIALOG_ID_FILE_SAVEAS)); + UT_ASSERT(pDialog); + + UT_uint32 filterCount = 1; + const char ** szDescList = (const char **) UT_calloc(filterCount + 1, sizeof(char *)); + const char ** szSuffixList = (const char **) UT_calloc(filterCount + 1, sizeof(char *)); + IEFileType * nTypeList = (IEFileType *) UT_calloc(filterCount + 1, sizeof(IEFileType)); + + // we only support saving images in png format for now + szDescList[0] = "Portable Network Graphics (.png)"; + szSuffixList[0] = "*.png"; + nTypeList[0] = (IEFileType)1; + + pDialog->setFileTypeList(szDescList, szSuffixList, + (const UT_sint32 *) nTypeList); + + pDialog->setDefaultFileType((IEFileType)1); + + pDialog->runModal(pFrame); + + XAP_Dialog_FileOpenSaveAs::tAnswer ans = pDialog->getAnswer(); + bool bOK = (ans == XAP_Dialog_FileOpenSaveAs::a_OK); + + if (bOK) + { + const char * szResultPathname = pDialog->getPathname(); + if (szResultPathname && *szResultPathname) + { + FV_View * pView = static_cast<FV_View *>(pAV_View); + pView->saveSelectedImage (szResultPathname); + } + } + + FREEP(szDescList); + FREEP(szSuffixList); + FREEP(nTypeList); + + pDialogFactory->releaseDialog(pDialog); + + return true; } Defun1(filePreviewWeb) Index: abi/src/wp/ap/xp/ap_ML_ContextImage.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_ML_ContextImage.h,v retrieving revision 1.2 diff -u -r1.2 ap_ML_ContextImage.h --- abi/src/wp/ap/xp/ap_ML_ContextImage.h 16 Nov 2001 21:24:24 -0000 1.2 +++ abi/src/wp/ap/xp/ap_ML_ContextImage.h 22 Mar 2002 17:55:09 -0000 @@ -29,6 +29,7 @@ BeginPopupMenu() MenuItem(AP_MENU_ID_FMT_IMAGE) + MenuItem(AP_MENU_ID_FILE_SAVEIMAGE) Separator() MenuItem(AP_MENU_ID_EDIT_CUT) MenuItem(AP_MENU_ID_EDIT_COPY) Index: abi/src/wp/ap/xp/ap_Menu_ActionSet.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Menu_ActionSet.cpp,v retrieving revision 1.82 diff -u -r1.82 ap_Menu_ActionSet.cpp --- abi/src/wp/ap/xp/ap_Menu_ActionSet.cpp 21 Mar 2002 15:20:50 -0000 1.82 +++ abi/src/wp/ap/xp/ap_Menu_ActionSet.cpp 22 Mar 2002 17:55:10 -0000 @@ -72,6 +72,7 @@ _s(AP_MENU_ID_FILE_OPEN, 0,1,0, "fileOpen", NULL, NULL); _s(AP_MENU_ID_FILE_SAVE, 0,0,0, "fileSave", ap_GetState_Changes, NULL); _s(AP_MENU_ID_FILE_SAVEAS, 0,1,0, "fileSaveAs", NULL, NULL); + _s(AP_MENU_ID_FILE_SAVEIMAGE, 0,1,0, "fileSaveImage", NULL, NULL); _s(AP_MENU_ID_FILE_IMPORT, 0,1,0, "fileImport", NULL, NULL); _s(AP_MENU_ID_FILE_EXPORT, 0,1,0, "fileExport", NULL, NULL); _s(AP_MENU_ID_FILE_CLOSE, 0,0,0, "closeWindow", NULL, NULL); Index: abi/src/wp/ap/xp/ap_Menu_Id_List.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Menu_Id_List.h,v retrieving revision 1.4 diff -u -r1.4 ap_Menu_Id_List.h --- abi/src/wp/ap/xp/ap_Menu_Id_List.h 2 Jan 2002 19:45:03 -0000 1.4 +++ abi/src/wp/ap/xp/ap_Menu_Id_List.h 22 Mar 2002 17:55:11 -0000 @@ -45,6 +45,7 @@ menuitem(FILE_OPEN) menuitem(FILE_SAVE) menuitem(FILE_SAVEAS) +menuitem(FILE_SAVEIMAGE) menuitem(FILE_EXPORT) menuitem(FILE_IMPORT) menuitem(FILE_CLOSE) Index: abi/src/wp/ap/xp/ap_String_Id.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_String_Id.h,v retrieving revision 1.141 diff -u -r1.141 ap_String_Id.h --- abi/src/wp/ap/xp/ap_String_Id.h 1 Feb 2002 00:17:14 -0000 1.141 +++ abi/src/wp/ap/xp/ap_String_Id.h 22 Mar 2002 17:55:15 -0000 @@ -619,6 +619,7 @@ dcl(MENU_LABEL_FILE_CLOSE,"&Close") dcl(MENU_LABEL_FILE_SAVE,"&Save") dcl(MENU_LABEL_FILE_SAVEAS,"Save &As") +dcl(MENU_LABEL_FILE_SAVEIMAGE,"Save &Image As") dcl(MENU_LABEL_FILE_IMPORT,"Op&en Copy") dcl(MENU_LABEL_FILE_EXPORT,"Sa&ve Copy") dcl(MENU_LABEL_FILE_PAGESETUP,"Page Set&up") @@ -817,6 +818,7 @@ dcl(MENU_STATUSLINE_FILE_CLOSE,"Close the document") dcl(MENU_STATUSLINE_FILE_SAVE,"Save the document") dcl(MENU_STATUSLINE_FILE_SAVEAS,"Save the document under a different name") +dcl(MENU_STATUSLINE_FILE_SAVEIMAGE,"Save the selected image to a file") dcl(MENU_STATUSLINE_FILE_IMPORT,"Open a document by making a copy") dcl(MENU_STATUSLINE_FILE_EXPORT,"Save the document without changing the current name") dcl(MENU_STATUSLINE_FILE_PAGESETUP,"Change the printing options")