ASBoolean SnpSelectionHelper::IsTextRangeSelected(void)
{
	ASBoolean result = false;
	if (this->IsDocumentSelected()) {
		ATE::TextRangesRef rangesRef = NULL;
		AIErr error = sAIDocument->GetTextSelection(&rangesRef);
		aisdk::check_ai_error(error);

		ATE::ITextRanges ranges(rangesRef); 
		if (ranges.GetSize() > 0) {
			AIBoolean textFocus = false;
			error = sAIDocument->HasTextFocus(&textFocus);
			aisdk::check_ai_error(error);

			if (textFocus) {
				ATE::ITextRange textRange = ranges.Item(0);
				if (textRange.GetSize() > 0)
					result = true;
			}
			else
				result = true;
		}
	}
	return result;
}
Exemplo n.º 2
0
void AddTextToRange(ATE::ITextRange sourceRange, ATE::ITextRange& targetRange, int beforeAfter)
{
    //Put the new text in the targetRange
    if (beforeAfter == 1)
    {
        targetRange.InsertAfter(sourceRange);
    } else
    {
        targetRange.InsertBefore(sourceRange);
    }
}
Exemplo n.º 3
0
bool IsAllWhitespace(ATE::ITextRange theRange) {

	ASInt32 size = theRange.GetSize();
	char *buffer = new char[size+1];
	
	theRange.GetContents(buffer, size);
	
	//Check if there is not whitespace
	if ( string::npos == string(buffer).find_first_not_of(WHITESPACES) ) {
		delete[] buffer;
		return TRUE;
	} else {
		delete[] buffer;
		return FALSE;
	}	
}
Exemplo n.º 4
0
ai::UnicodeString GetNameFromATETextRange(ATE::ITextRange targetRange) {
	ATE::ITextFramesIterator itemFrameIterator = targetRange.GetTextFramesIterator();
	AIArtHandle itemArtHandle = NULL;
	ATE::ITextFrame itemTextFrame = itemFrameIterator.Item();
	ATE::TextFrameRef itemTextFrameRef = itemTextFrame.GetRef();
	sAITextFrame->GetAITextFrame(itemTextFrameRef, &itemArtHandle);
	ai::UnicodeString itemName;
	sAIArt->GetArtName(itemArtHandle, itemName, NULL);

	return itemName;
}
Exemplo n.º 5
0
bool ListFonts::GetFontFromITextRange(ATE::ITextRange currRange)
{
    ATE::ITextRunsIterator iter = currRange.GetTextRunsIterator();
    while (iter.IsNotDone())
    {
        BtAteTextFeatures features(iter.Item().GetUniqueCharFeatures());
        
        featuresList.push_back(features);
        
        iter.Next();
    }
    return true;
}
Exemplo n.º 6
0
void SetAIColorForATETextRange(ATE::ITextRange theRange, AIColor theColor, bool fillOrStroke /*DEFAULT 0*/) {

	ATE::ICharFeatures targetICharFeatures;
	
	//Change the AIColor to the ATE Color
	ATE::ApplicationPaintRef ateApplicationPaintRef = NULL;
	sAIATEPaint->CreateATEApplicationPaint(&theColor, &ateApplicationPaintRef);
	ATE::IApplicationPaint targetIApplicationPaint(ateApplicationPaintRef);
	
	//Change the fill or stroke
	if (fillOrStroke == 0) { //FILL
		targetICharFeatures.SetFillColor(targetIApplicationPaint);	
		targetICharFeatures.SetFill(TRUE);
	} else { //STROKE
		targetICharFeatures.SetStrokeColor(targetIApplicationPaint);
		targetICharFeatures.SetStroke(TRUE);		
	}
	
	//Add the features back to the range
	theRange.ReplaceOrAddLocalCharFeatures(targetICharFeatures);
}
Exemplo n.º 7
0
AIColor GetAIColorFromATETextRange(ATE::ITextRange theRange, bool fillOrStroke /*DEFAULT 0*/) {
	
	bool isAssigned = FALSE;
	AIColor theColor;
	AIColor *ptheColor = &theColor;
	
	ATE::ICharFeatures targetICharFeatures = theRange.GetUniqueCharFeatures();
	
	ATE::IApplicationPaint targetIApplicationPaint;
	if (fillOrStroke == 0) { //FILL
		targetIApplicationPaint = targetICharFeatures.GetFillColor(&isAssigned);
		theColor.kind = kNoneColor;
	} else { //STROKE
		targetIApplicationPaint = targetICharFeatures.GetStrokeColor(&isAssigned);
		theColor.kind = kNoneColor;
	}
	
	if(isAssigned) {
		sAIATEPaint->GetAIColor(targetIApplicationPaint.GetRef(), &theColor);
	}
	
	return *ptheColor;

}
Exemplo n.º 8
0
bool FixTextAttributes(ATE::ITextRange theRange, ASReal firstRunBaselineShift) {
	bool isAssigned = FALSE;
	ATE::ITextRunsIterator it = theRange.GetTextRunsIterator();
	
	//If there is stuff to iterate through
	if ( !it.IsEmpty() ) {
		
		bool isFirst = TRUE;
		bool foundGoodFeatures = FALSE;
		ATE::ICharFeatures knownGoodCharFeatures;
		
		ATE::ICharFeatures currCharFeatures;
		
		while (it.IsNotDone()) {
			
			//Loop through all the ranges in the run
			while (it.IsNotDone()) {
				
				//If this is the first range, we need to go through the run and find the first good fill or stroke color
				if (isFirst) {
					while ( foundGoodFeatures == FALSE ) {
						if (it.IsNotDone()) {
							knownGoodCharFeatures = it.Item().GetUniqueCharFeatures();
							
							bool fillAssigned = FALSE;
							bool strokeAssigned = FALSE;
							knownGoodCharFeatures.GetFillColor(&fillAssigned);
							knownGoodCharFeatures.GetStrokeColor(&strokeAssigned);
							
							if (fillAssigned || strokeAssigned) {
								foundGoodFeatures = TRUE;
							}
						}
						it.Next();
					}
					//Put our iterator back to the beginning again
					it.MoveToFirst();
				}
				
				//Now we'll check the color of our current range
				currCharFeatures = it.Item().GetUniqueCharFeatures();
				bool currFillAssigned = FALSE;
				bool currStrokeAssigned = FALSE;
				currCharFeatures.GetFillColor(&currFillAssigned);
				currCharFeatures.GetStrokeColor(&currStrokeAssigned);
								
				//If it has a valid color, we'll store that for the next time
				
				if ( currFillAssigned || currStrokeAssigned) {
					knownGoodCharFeatures = currCharFeatures;
									
					isFirst = FALSE;
				} else {
					//Otherwise, we'll set the color of the range to the known good color
					it.Item().SetLocalCharFeatures(knownGoodCharFeatures);
				}
				
				//Also, we need to adjust the baselineshift here
				ATE::ICharFeatures baselineShiftFeatures(knownGoodCharFeatures);
				ASReal currBaselineShift = currCharFeatures.GetBaselineShift(&isAssigned);
				currBaselineShift -= firstRunBaselineShift;
				baselineShiftFeatures.SetBaselineShift(currBaselineShift);
				it.Item().SetLocalCharFeatures(baselineShiftFeatures);
				
				//Move to the next run
				it.Next();
			}
		}
	}
}