예제 #1
0
/*
    SaveAs
    ------

    calls the common Windows dialog function to prompt the user for the
    filename to use
*/
void
TOLEDocument::SaveAs ()
{
  char          path[MAXPATHLENGTH];  // result of GetSaveFileName()
  OPENFILENAME  fnStruct;

  Setup (&fnStruct);
  fnStruct.Flags |= OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
  wsprintf (path, "*.%s", (LPSTR) szFileExt);
  fnStruct.lpstrFile = path;

  if (GetSaveFileName (&fnStruct)) {
    type = doctypeFromFile;
    SetDocumentName (path);  // we must do this BEFORE we call SaveDoc()
    SaveDoc();

    //
    // now inform the server library that we have renamed the document
    //
    OleRenameServerDoc (lhDoc, szName);
  }
}
예제 #2
0
BOOL HandleSaveCommand(HWND hWindow, WPARAM wParam, BOOL fCommand)
/***********************************************************************/
{
FNAME szFileName;
//LPSTR lpString;
int idDataType, idOldDataType, idFileType, idOldFileType;
BOOL fChanged, fStatus;
DWORD dwReturn;

if (ImgInMaskEditMode(lpImage))
	{
	ImgSetupMaskEditMode(lpImage);
	UpdateStatusBar(NO, NO, NO, NO);
	}
fStatus = YES;
switch (wParam)
	{
	case IDM_SAVE:
	if ( !lpImage )
		break;
	PPOLEClientNotify( (LPIMAGEOBJECT)lpImage->pObj, OLE_CHANGED );
#ifdef USEOLE
	OleSavedServerDoc( lpImage->lhDoc );
#endif // #ifdef USEOLE
	if ( lpImage->fOwnedByClient )
		{ // If it IS embedded client data, inform the client
//		ImgEditApplyAll( lpImage, YES/*fApplyData*/, YES/*fApplyAlpha*/ );
		break;
		}
	/* Save the image under the current name */
	if ( !lpImage->fUntitled) /* If the picture has a name, save into it */
		{
		if ( !(fStatus = AstralImageSave( lpImage->FileType,
			lpImage->DataType, lpImage->CurFile )) )
			break;
		SetImgChanged(lpImage, NO);
//		ImgEditApplyAll( lpImage, YES/*fApplyData*/, YES/*fApplyAlpha*/ );
		break;
		}
	/* else fall through to SaveAs... */

	case IDM_SAVEAS:
	if ( !lpImage )
		break;
	/* Bring up the modal 'SaveAs' box */
	// save current image format information
	lstrcpy(szFileName, lpImage->CurFile);
	fChanged = lpImage->fChanged;
	idOldDataType = lpImage->DataType;
	idOldFileType = IDN_ART;    // save all as ART files

	// ask user for a name
	if ( !(dwReturn = DoOpenDlg( hWindow, IDD_SAVEAS,
	     lpImage->FileType, szFileName, YES )) )
		{
		fStatus = NO;
		break;
		}

	// save the image in the user specified file type and data type
	idFileType = LOWORD( dwReturn );
	idDataType = HIWORD( dwReturn );

	if ( !(fStatus = AstralImageSave( idFileType, idDataType, szFileName )))
		break;

//	// If it IS NOT embedded client data, inform the client
	PPOLEClientNotify( (LPIMAGEOBJECT)lpImage->pObj, OLE_CHANGED );
	
#ifdef USEOLE
	OleSavedServerDoc( lpImage->lhDoc );
#endif // #ifdef USEOLE
	
	// whenever you save changes become permanent - NOT ANY MORE - tmr
	SetImgChanged(lpImage, NO);
//	ImgEditApplyAll( lpImage, YES/*fApplyData*/, YES/*fApplyAlpha*/ );

	// Add the file name to our recall list
	AddRecallImageName( szFileName );

	if (!fCommand)
		break;

	// If this is a chunked image, don't revert or change name
	if (lpImage->DocumentType == IMG_DOCPIECE)
		break;
	if (ImgInMaskEditMode(lpImage))
		break;

	// if data type or file type did not change, just take new name
	if ( idDataType == idOldDataType && idFileType == idOldFileType )
		{ // it has the same FileType, same DataType
		lpImage->fUntitled = NO;
			lstrcpy( lpImage->CurFile, szFileName );
			/* Force the non-client area (title bar) of image to paint */
				SetTitleBar(lpImage->hWnd);
#ifdef USEOLE		
		// If it IS NOT embedded client data, inform the client
		OleRenameServerDoc( lpImage->lhDoc, lpImage->CurFile);
#endif // #ifdef USEOLE		
		break;
		}

	// see if the user wants to convert to using the new format
	if ( !AstralAffirm(IDS_CONFIRM_CONVERT) )
		{ // the user doesn't want to convert to the new format
		lpImage->fChanged = fChanged; // restore the changed flag
		break;
		}

	// the user wants to convert to the new format
	lpImage->FileType = idFileType;
	lpImage->DataType = idDataType;
	lpImage->fUntitled = NO;
	lstrcpy( lpImage->CurFile, szFileName );
	/* Force the non-client area (title bar) of image to paint */
		SetTitleBar(lpImage->hWnd);
#ifdef USEOLE		
		// If it IS NOT embedded client data, inform the client
		OleRenameServerDoc( lpImage->lhDoc, lpImage->CurFile);
#endif // #ifdef USEOLE		
	DoCommand(hWindow, IDM_REVERT, 0L);
	break;

	case IDM_SAVESPECIAL:
	if ( !lpImage )
		break;
	// save current image format information
	lstrcpy(szFileName, lpImage->CurFile);
	fChanged = lpImage->fChanged;
	idOldDataType = lpImage->DataType;
	idOldFileType = IDN_ART;    // save all as ART files

	if (lpImage->fUntitled)
	{
    	// get the new name for the file
    	GetNextIniFilename ((char FAR *)&szFileName);
    	SaveToIniEntry (szFileName, NULL);
    }
	else
	{
		lstrcpy (szFileName, lpImage->CurFile);
	}
    // save the image as the same type
    idFileType = idOldFileType;
    idDataType = idOldDataType;
	if ( !(fStatus = AstralImageSave( idFileType, idDataType, szFileName )))
		break;

	// whenever you save changes become permanent - NOT ANY MORE - tmr
	SetImgChanged(lpImage, NO);
//	ImgEditApplyAll( lpImage, YES/*fApplyData*/, YES/*fApplyAlpha*/ );

	// Add the file name to our recall list
	AddRecallImageName( szFileName );

	if (!fCommand)
		break;

	// If this is a chunked image, don't revert or change name
	if (lpImage->DocumentType == IMG_DOCPIECE)
		break;
	if (ImgInMaskEditMode(lpImage))
		break;

	// if data type or file type did not change, just take new name
	if ( idDataType == idOldDataType && idFileType == idOldFileType )
		{ // it has the same FileType, same DataType
		lpImage->fUntitled = NO;
			lstrcpy( lpImage->CurFile, szFileName );
			/* Force the non-client area (title bar) of image to paint */
				SetTitleBar(lpImage->hWnd);
#ifdef USEOLE
	OleRenameServerDoc( lpImage->lhDoc, lpImage->CurFile );
#endif // #ifdef USEOLE
		break;
		}

	// see if the user wants to convert to using the new format
	if ( !AstralAffirm(IDS_CONFIRM_CONVERT) )
		{ // the user doesn't want to convert to the new format
		lpImage->fChanged = fChanged; // restore the changed flag
		break;
		}

	// the user wants to convert to the new format
	lpImage->FileType = idFileType;
	lpImage->DataType = idDataType;
	lpImage->fUntitled = NO;
	lstrcpy( lpImage->CurFile, szFileName );
	/* Force the non-client area (title bar) of image to paint */
		SetTitleBar(lpImage->hWnd);
	// If it IS NOT embedded client data, inform the client
#ifdef USEOLE
	OleRenameServerDoc( lpImage->lhDoc, lpImage->CurFile );
#endif // #ifdef USEOLE
	DoCommand(hWindow, IDM_REVERT, 0L);
	break;

	default:
	break;
	}

return( fStatus );
}