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;
}
Esempio n. 2
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;
	}	
}