Ejemplo n.º 1
0
//-------------------------------------------------------------------------------
//
//	DoIt
//
//	Finally something interesting. You have been selected from your menu entry
//	or via the actions system to do your thing. Dump everything you can about
//	Photoshop by asking Photoshop. The output file is "Getter.log".
//
//-------------------------------------------------------------------------------
SPErr DoIt(PSActionsPlugInMessage * /*message*/)
{
	SPErr	error = 0;

	char logfilename[MAX_PATH];
	char* filename = (char*)"Getter.log";
	
	error = GetFullPathToDesktop(logfilename, MAX_PATH);
	if (error)
	{
		logfilename[0] = '\0';
		error = 0;
	}
	
	strncat(logfilename, filename, MAX_PATH-1);
	logfilename[MAX_PATH-1] = '\0';

	GetApplicationInfo(logfilename);
	GetLayerInfo(logfilename);
	GetActionInfo(logfilename);
	GetDocumentInfo(logfilename);
	GetChannelInfo(logfilename);
	GetBackgroundInfo(logfilename);

	// the above routines can do their job by indexing into the open objects
	// path info and history info are only available to the target document
	// 1. remember who is the current target
	// 2. target the other documents by indexing
	// 3. switch back to the original target 
	//    (use the ID it is the most reliable way to switch back)
	int32 currentDocumentID = 0;
	int32 numDocuments = 0;
	int32 docCounter = 0;

	// we are ignoring errors so this will not give an invalid error
	// message when there are no documents open
	(void) PIUGetInfo(classDocument, keyDocumentID, &currentDocumentID, NULL);

	(void) PIUGetInfo(classApplication, keyNumberOfDocuments, &numDocuments, NULL);

	if (numDocuments > 0)
	{
		for (docCounter = 1; docCounter <= numDocuments; docCounter++)
		{
			// this routine will error if we select the document
			// that is already selected, we don't care about this
			// as an error, keep chugging
			(void) PIUSelectByIndex(classDocument, docCounter);
			GetPathInfo(logfilename);
			GetHistoryInfo(logfilename);
		}
		// this routine will error if we select the document
		// that is already selected, we don't care about this
		// as an error, keep chugging
		(void) PIUSelectByID(classDocument, currentDocumentID);
	}

	return (error);
}
Ejemplo n.º 2
0
//-------------------------------------------------------------------------------
//
//	GetHistoryInfo
//
// This gets all the keys that the classHistoryState knows about
// check the log file for what key you specifically want
// You can't get the history information from the non-target document
//
//-------------------------------------------------------------------------------
SPErr GetHistoryInfo(char* logfilename)
{
	PIActionDescriptor	result = NULL;
	int32				numHistoryStates, counter;
	SPErr				error = kSPNoError;
	DescriptorTypeID	typeID = 0;
	
	sPSActionControl->StringIDToTypeID("Getting History Info", &typeID);

	error = PIUGetInfo(classHistoryState, keyCount, &numHistoryStates, NULL);
	if (error) goto returnError;

	 // appears to be counting one extra
	// fixed in version 7.0 numHistoryStates--;

	for (counter = 1; 
	     counter <= numHistoryStates && error == kSPNoError; 
		 counter++)
	{
		error = PIUGetInfoByIndex(counter, classHistoryState, 0, &result, 0);
		PIUDumpDescriptor(typeID, result, logfilename);
		if (result) sPSActionDescriptor->Free(result);
		result = NULL;
	}

returnError:
	if (result) sPSActionDescriptor->Free(result);
	return (error);
}
Ejemplo n.º 3
0
//-------------------------------------------------------------------------------
//
//	GetDocumentInfo
//
// This gets all the keys that the classDocument knows about
// check the log file for what key you specifically want
//
//-------------------------------------------------------------------------------
SPErr GetDocumentInfo(char* logfilename)
{
	PIActionDescriptor	result = NULL;
	int32				numDocuments;
	SPErr				error = kSPNoError;
	DescriptorTypeID	typeID = 0;

	sPSActionControl->StringIDToTypeID("Getting Document Info", &typeID);

	error = PIUGetInfo(classApplication, 
		               keyNumberOfDocuments, 
					   &numDocuments, 
					   NULL);
	if (error) goto returnError;
	
	if (numDocuments > 0)	
		for (int32 counter = 1; counter <= numDocuments; counter++)
		{
			error = PIUGetInfoByIndex(counter, classDocument, 0, &result, 0);
			if (error) break;

			PIUDumpDescriptor(typeID, result, logfilename);
	
			if (result) sPSActionDescriptor->Free(result);
			result = NULL;
		}

returnError:
	if (result) sPSActionDescriptor->Free(result);
	return (error);
}
Ejemplo n.º 4
0
//-------------------------------------------------------------------------------
//
//	GetApplicationInfo
//
// This gets all the keys that the classApplication knows about
// check the log file for what key you specifically want
//
//-------------------------------------------------------------------------------
SPErr GetApplicationInfo(char* logfilename)
{
	PIActionDescriptor	result = NULL;
	DescriptorTypeID typeID = 0;
	SPErr error = PIUGetInfo(classApplication, 0, &result, NULL);
	sPSActionControl->StringIDToTypeID("Getting Application Info", &typeID);
	PIUDumpDescriptor(typeID, result, logfilename);
	if (result) sPSActionDescriptor->Free(result);
	return (error);
}
Ejemplo n.º 5
0
//-------------------------------------------------------------------------------
//
//	GetBackgroundInfo
//
// This is a special call for the background of the document. You would think that
// the background would just be a special case for a layer. But nooooo. You need
// to see if the document has a background layer.
//
//-------------------------------------------------------------------------------
SPErr GetBackgroundInfo(char* logfilename)
{
	PIActionReference	reference = NULL;
	PIActionDescriptor	result = NULL;
	int32				numDocuments;
	SPErr				error = kSPNoError;
	DescriptorTypeID	typeID = 0;

	sPSActionControl->StringIDToTypeID("Getting Backround Layer Info", &typeID);

	error = PIUGetInfo(classApplication, 
		               keyNumberOfDocuments, 
					   &numDocuments, 
					   NULL);
	if (error) goto returnError;
	
	if (numDocuments > 0)	
		for (int32 docCounter = 1; docCounter <= numDocuments; docCounter++)
		{
			error = sPSActionReference->Make(&reference);
			if (error) goto returnError;

			error = sPSActionReference->PutProperty(reference, 
				                                    classBackgroundLayer, 
													keyBackground);
			if (error) goto returnError;

			error = sPSActionReference->PutIndex(reference, 
				                                 classDocument, 
												 docCounter);
			if (error) goto returnError;

			error = sPSActionControl->Get(&result, reference);
			// we ignore this error on purpose
			// this document may not have a background layer

			PIUDumpDescriptor(typeID, result, logfilename);

			if (reference) sPSActionReference->Free(reference);
			reference = NULL;
			if (result) sPSActionDescriptor->Free(result);
			result = NULL;
			
		}

returnError:
	if (reference) sPSActionReference->Free(reference);
	if (result) sPSActionDescriptor->Free(result);
	return (error);
}
Ejemplo n.º 6
0
//-------------------------------------------------------------------------------
//
//	GetLayerInfo
//
// get the layer information from each layer of each document
//
//-------------------------------------------------------------------------------
SPErr GetLayerInfo(char* logfilename)
{
	PIActionDescriptor	result = NULL;
	int32				numDocuments, numLayers;
	SPErr				error = kSPNoError;
	DescriptorTypeID	typeID = 0;

	sPSActionControl->StringIDToTypeID("Getting Layer Info", &typeID);

	error = PIUGetInfo(classApplication, 
		               keyNumberOfDocuments, 
					   &numDocuments, 
					   NULL);
	if (error) goto returnError;
	
	if (numDocuments > 0)	
		for (int32 docCounter = 1; docCounter <= numDocuments; docCounter++)
		{
			error = PIUGetInfoByIndex(docCounter, 
				                      classDocument, 
									  keyNumberOfLayers, 
									  &numLayers, 
									  NULL);
			if (error) goto returnError;

			if (numLayers > 0)
				for (int32 layCounter = 1; 
				     layCounter <= numLayers && error == kSPNoError; 
					 layCounter++)
				{
					error = PIUGetInfoByIndexIndex(layCounter, 
						                           docCounter, 
												   classLayer, 
												   classDocument, 
												   0, 
												   &result, 
												   NULL);

					PIUDumpDescriptor(typeID, result, logfilename);

					if (result) sPSActionDescriptor->Free(result);
					result = NULL;
				}
		}

returnError:
	if (result) sPSActionDescriptor->Free(result);

	return (error);
}
SPErr GetPSDName(std::string& result) {
	Handle file_ref = NULL;
	
	SPErr error = PIUGetInfo(classDocument,keyFileReference,&file_ref,NULL);
	if(error) return error;
	
	char buffer[1024];
	int32 length = 1024;
	
	AliasToFullPath(file_ref,buffer,length);
	if(file_ref) sPSHandle->Dispose(file_ref);
	
	result = std::string(buffer);
	return kSPNoError;
}
Ejemplo n.º 8
0
//-------------------------------------------------------------------------------
//
//	GetPathInfo
//
//	Paths are a different beast because they could have a work path that does not
//	show up as a normal path, I will try to pull that information out from the
//	document, they also don't work for referencing the non active document.
//	
//	NOTE: The keyNumberOfPaths counts the work path but does not report it the 
//	normal way so its
//		sPSActionReference->PutIndex(reference, classPath, pathCounter);
//	for normal paths and
//		sPSActionReference->PutProperty(reference, classPath, keyWorkPath);
//	to get the work path.
//
//-------------------------------------------------------------------------------
SPErr	GetPathInfo(char* logfilename)
{
	SPErr				error = kSPNoError;
	PIActionReference	reference = NULL;
	PIActionDescriptor	result = NULL;
	int32				currentLayerID = 0;
	int32				numLayersAvailable = 0;
 	int32				numPathsAvailable = 0;
 	int32				numPathsCollected = 0;
	int32				normalAndWorkCount = 0;
	DescriptorTypeID	normalTypeID = 0;
	DescriptorTypeID	workTypeID = 0;
	DescriptorTypeID	otherPathID[2];
	DescriptorTypeID	textMaskID = 0;
	DescriptorTypeID	vectorMaskID = 0;
	int32				i = 0;
	int32				layerIndex = 0;
	int32				pathTypeIndex = 0;

	(void) sPSActionControl->StringIDToTypeID("Getting Path Info", &normalTypeID);
	(void) sPSActionControl->StringIDToTypeID("Getting Work Path Info", &workTypeID);

	// look for normal paths and a work path for the document
	// these are the same for the entire document
	error = PIUGetInfo(classDocument, keyNumberOfPaths, &numPathsAvailable, NULL);
	if (error) goto returnError;

	for(i = 0; i < numPathsAvailable && !error; i++)
	{
		error = PIUGetInfoByIndex(i + 1, classPath, 0, &result, NULL);
				
		if (!error) 
		{
			PIUDumpDescriptor(normalTypeID, result, logfilename);
			numPathsCollected++;
			normalAndWorkCount++;
		}
	}

	// see if we didn't get all of them and try the work path
	if (numPathsCollected < numPathsAvailable)
	{
		error = sPSActionReference->Make(&reference);
		if (error) goto returnError;
								
		error = sPSActionReference->PutProperty(reference, 
												classPath, 
												keyWorkPath);
		if (error) goto returnError;
								
		error = sPSActionControl->Get(&result, reference);

		if (!error)
		{
			PIUDumpDescriptor(workTypeID, result, logfilename);
			numPathsCollected++;
			normalAndWorkCount++;
		} else {
			error = kSPNoError;
		}

		if (reference != NULL)
		{
			(void) sPSActionReference->Free (reference);
			reference = NULL;
		}
						
		if (result != NULL)
		{
			(void) sPSActionDescriptor->Free(result);
			result = NULL;
		}
	}
	
	(void) sPSActionControl->StringIDToTypeID(kvectorMaskStr, &vectorMaskID);
	(void) sPSActionControl->StringIDToTypeID(ktextShapeStr, &textMaskID);

	otherPathID[0] = vectorMaskID;
	otherPathID[1] = textMaskID;

	error = PIUGetInfo(classDocument, keyNumberOfLayers, &numLayersAvailable, NULL);
	if (error) goto returnError;

	error = PIUGetInfo(classLayer, keyLayerID, &currentLayerID, NULL);
	if (error) goto returnError;

	// now for the rest of them
	// I have to cycle through all the layers because each layer
	// could have a text mask or a vector mask, but not both
	for (layerIndex = 0; layerIndex < numLayersAvailable; layerIndex++)
	{
		// this could error because we are already on that layer, ignore it
		(void) PIUSelectByIndex(classLayer, layerIndex + 1);

		error = PIUGetInfo(classDocument, keyNumberOfPaths, &numPathsAvailable, NULL);
		if (error) goto returnError;

		numPathsCollected = normalAndWorkCount;

		for (pathTypeIndex = 0; (pathTypeIndex < sizeof(otherPathID) / sizeof(otherPathID[0])) &&
			                    (numPathsCollected < numPathsAvailable); pathTypeIndex++)
		{
			error = sPSActionReference->Make(&reference);
			if (error) goto returnError;

			error = sPSActionReference->PutEnumerated(reference, 
													  classPath, 
													  typeOrdinal, 
													  otherPathID[pathTypeIndex]);
			if (error) goto returnError;

			error = sPSActionControl->Get(&result, reference);
					
			if (!error)
			{
				DescriptorTypeID messageID;
				char message[256];
				sprintf(message, "Getting Vector or Text Path Infor for layer %d", layerIndex + 1);
				(void) sPSActionControl->StringIDToTypeID(message, &messageID);
				PIUDumpDescriptor(messageID, result, logfilename);
				numPathsCollected++;
			} else {
				error = kSPNoError;
			}

			if (reference != NULL)
			{
				(void) sPSActionReference->Free (reference);
				reference = NULL;
			}
						
			if (result != NULL)
			{
				(void) sPSActionDescriptor->Free(result);
				result = NULL;
			}
		}
	}

	(void) PIUSelectByID(classLayer, currentLayerID);

returnError:

	if (reference) sPSActionReference->Free(reference);
	if (result) sPSActionDescriptor->Free(result);

	return (error);
}