コード例 #1
0
/*
	static
*/
VError VFolder::ResolveAliasFolder( VFolder **ioFolder, bool inDeleteInvalidAlias)
{
	VError err = VE_OK;
	if ( (*ioFolder != NULL) && (*ioFolder)->fPath.IsFolder() && !(*ioFolder)->fFolder.Exists( false /* doesn't check alias */) )
	{
		// the folder doesn't exists
		// maybe is it an alias file?
		VString path = (*ioFolder)->fPath.GetPath();
		if (testAssert( path[path.GetLength()-1] == FOLDER_SEPARATOR))
		{
			path.Truncate( path.GetLength()-1);
			#if VERSIONWIN
			path += ".lnk";
			#endif
			VFile file( path);
			if (file.IsAliasFile() && file.Exists())
			{
				VFilePath resolvedPath;
				err = file.GetImpl()->ResolveAlias( resolvedPath);	// nothrow
				if (err == VE_OK)
				{
					if (resolvedPath.IsFolder())
					{
						(*ioFolder)->Release();
						*ioFolder = new VFolder( resolvedPath);
					}
					else if (inDeleteInvalidAlias)
					{
						err = file.Delete();
					}
					else
					{
						StThrowFileError errThrow( *ioFolder, VE_FILE_CANNOT_RESOLVE_ALIAS_TO_FOLDER);
						err = errThrow.GetError();
					}
				}
				else if (inDeleteInvalidAlias)
				{
					err = file.Delete();
				}
				else
				{
					if (IS_NATIVE_VERROR( err))
					{
						StThrowFileError errThrow( &file, VE_FILE_CANNOT_RESOLVE_ALIAS, err);
						err = errThrow.GetError();
					}
				}
			}
		}
	}
	return err;
}
コード例 #2
0
/*
	IMPORTANT:	the build version is created on the compilation machine. It requires that (1) perl is installed and (2) an external file contains the number.
				That's why if you compile 4D on your computer, you'll probably always get a build version of 0 (if the external file is not found, "00000" is used)
*/
sLONG VProcess::GetChangeListNumber() const
{
	sLONG changeListNumber = 0;
	VString s;
	GetBuildNumber( s);
	VIndex pos = s.FindUniChar( '.', s.GetLength(), true);
	if (pos > 0)
	{
		s.SubString( pos + 1, s.GetLength() - pos);
		changeListNumber = s.GetLong();
	}
	return changeListNumber;
}
コード例 #3
0
bool ScriptDocLexer::ConsumeName( VString &outName, bool &outIsOptional, bool &outDoFurtherProcessing )
{
	outIsOptional = false;
	outDoFurtherProcessing = true;
	while (true) {
		if (!fLexerInput->HasMoreChars())	return false;
		UniChar ch = fLexerInput->MoveToNextChar();

		if (CHAR_LEFT_SQUARE_BRACKET == ch) {
			// If the name is enclosed in [], then it's considered to be an optional
			// parameter.
			if (outName.GetLength() == 0) {
				outIsOptional = true;
			} else {
				return false;
			}
		} else if (IsLineEnding( ch )) {
			// We've reached the end of the tag, and the user has not specified a comment, which
			// is fine.  We'll just break out now and not do any further processing.
			ConsumeLineEnding( ch );
			outDoFurtherProcessing = false;
			break;
		} else if (IsWhitespace( ch ) || (outIsOptional && CHAR_RIGHT_SQUARE_BRACKET == ch)) {
			break;
		} else {
			outName.AppendUniChar( ch );
		}
	}
	return true; 
}
コード例 #4
0
void VXMLSyntax::parseOneLineByLex(ICodeEditorDocument *&inDocument, sLONG inLineNumber,struct xmlLexStyleInfo *&inputstruct)
{
	VString xstr;
	inDocument->GetLine(inLineNumber,xstr);
	const UniChar * unistring  = xstr.GetCPointer();
	char *lexinput;
	sLONG len = xstr.GetLength();
	lexinput = new char[len+1];
	lexinput[len] = '\0';

	for(int i = 0 ; i < len ; i++)     //to change unicode to char
	{
		if ( unistring[i] == 9 )
		{
			lexinput[i] = ' ';
		}
		else if (unistring[i] > 127)
		{	
			lexinput[i] = 'X';
		}
		else
		{	
			lexinput[i] = (char)unistring[i];
		}			
	}
	inputstruct = startxmlParse(lexinput);  
	delete lexinput;
}
コード例 #5
0
void VSpanHandler::EndElement( const VString& inElementName)
{
	xbox_assert(inElementName == fElementName);

	VTextStyle *style = fStyles->GetData();
	if (style)
	{
		sLONG vbegin, vend;
		style->GetRange(vbegin,vend);
		vend = fText->GetLength();
		style->SetRange(vbegin,vend);

	}
	if (!fParseSpanOnly)
	{
		//HTML parsing:

		if (inElementName.EqualToString("q"))
			//end of quote
			*fText += "\"";

		//add break lines for elements which need it
		if (VTaggedTextSAXHandler::NeedBreakLine(inElementName))
			*fText += "\r";
	}
}
コード例 #6
0
void XPosixProcessLauncher::_BuildArrayArguments(char **&outArrayArg)
{	
	sLONG nbArguments = (sLONG) fArrayArg.size();
	
	// Dispose the previous array of arguments if not NULL
	_Free2DCharArray(outArrayArg);
	
	if(nbArguments < 1)
		return;
	
	size_t outArrayArgLength = (nbArguments + 1 ) * sizeof(char*);
	outArrayArg = (char **) gMemory->NewPtr(outArrayArgLength, 0);
	
	if(testAssert(outArrayArg != NULL))
	{
		for(sLONG i = 0; i < nbArguments; ++i)
		{
			VString		*currentArgPtr = &fArrayArg[i];
			size_t		argFullLength = currentArgPtr->GetLength() * 2;// + 1;
			char		*newArgPtr = new char[argFullLength];
			
			if(newArgPtr != NULL)
				currentArgPtr->ToCString(newArgPtr, argFullLength);
			
			outArrayArg[i] = newArgPtr;
		}
		outArrayArg[nbArguments] = NULL;
	}
}
コード例 #7
0
ファイル: VValueBag.cpp プロジェクト: StephaneH/core-XToolbox
/*
	static
*/
void VValueBag::GetKeysFromPath( const VString& inPath, StKeyPath& outKeys)
{
	VFromUnicodeConverter_UTF8 converter;

	char buffer[256];
	VIndex charsConsumed;
	VSize bytesProduced;
	const UniChar *begin = inPath.GetCPointer();
	const UniChar *end = begin + inPath.GetLength();
	for( const UniChar *pos = begin ; pos != end ; ++pos)
	{
		if (*pos == '/')
		{
			bool ok = converter.Convert( begin, (VIndex) (pos - begin), &charsConsumed, buffer, sizeof( buffer), &bytesProduced);
			if (ok)
			{
				outKeys.push_back( StKey( buffer, bytesProduced));
			}
			begin = pos + 1;
		}
	}
	if (begin != end)
	{
		bool ok = converter.Convert( begin, (VIndex) (end - begin), &charsConsumed, buffer, sizeof( buffer), &bytesProduced);
		if (ok)
		{
			outKeys.push_back( StKey( buffer, bytesProduced));
		}
	}
}
コード例 #8
0
int VXMLSyntax::findStopLoc(ICodeEditorDocument* inDocument,int inLineNumber,int commenttype)
{
	VString xstr;
	inDocument->GetLine(inLineNumber,xstr);
	const UniChar * unistringtemp  = xstr.GetCPointer();
	int stoploc = 0;


	if ( commenttype == ordinarycomment)
	{
		for (int i = 0;i < xstr.GetLength()-1;i++)
		{
			if (unistringtemp[i] == '*' && unistringtemp[i+1] == '/')
			{  
				stoploc = i+1;
				break;
			}
			if (unistringtemp[i] == '/' && unistringtemp[i+1] == '*')
			{
				stoploc = i +1;
				break;
			}
		}
	}
	else if ( commenttype == htmlsytlecomment )
	{
		for (int i = 0;i < xstr.GetLength()-3;i++)
		{ 
			//		char c = unistringtemp[i];
			if (unistringtemp[i+1] == '-' && unistringtemp[i+2] == '-' && unistringtemp[i+3] == '>')
			{  
				stoploc = i+2;
				break;
			}
			if (unistringtemp[i] == '<' && unistringtemp[i+1] == '!' && unistringtemp[i+2] == '-'&& unistringtemp[i+3] == '-')
			{
				stoploc = i + 3;
				break;
			}
		}

	}

	return stoploc;
}
コード例 #9
0
JS4D::ValueRef JS4D::VStringToValue( ContextRef inContext, const VString& inString)
{
	if (inString.IsNull())
		return JSValueMakeNull( inContext);

	JSStringRef jsString = JSStringCreateWithCharacters( inString.GetCPointer(), inString.GetLength());
	ValueRef value = JSValueMakeString( inContext, jsString);
	JSStringRelease( jsString);
	return value;
}
コード例 #10
0
bool VXMLParser::Parse( const VString& inText, IXMLHandler *inHandler, XMLParsingOptions inOptions)
{
	xercesc::MemBufInputSource source( (const XMLByte *) inText.GetCPointer(), inText.GetLength() * sizeof( UniChar), "frommem");
	#if BIGENDIAN
	source.setEncoding( xercesc::XMLUni::fgUTF16BEncodingString);
	#else
	source.setEncoding( xercesc::XMLUni::fgUTF16LEncodingString);
	#endif

	return SAXParse( this, source, inHandler, inOptions);
}
コード例 #11
0
void VTaggedTextSAXHandler::SetAttribute(const VString& inName, const VString& inValue)
{
	if( inName == "STYLE")
	{
		if (*fStyles == NULL)
		{
			*fStyles = new VTreeTextStyle();
			VTextStyle* style = new VTextStyle();
			style->SetRange(0,fText->GetLength());
			(*fStyles)->SetData(style);
		}

		VCSSParserInlineDeclarations cssParser;

		VSpanHandler *handler = new VSpanHandler(VString("body"), *fStyles, fText, fParseSpanOnly);	
		cssParser.Start(inValue);
		VString attribut, value;
		while(cssParser.GetNextAttribute(attribut, value))
		{
			handler->TraiteCSS(attribut, value);
		}
		handler->Release();
	} else if (!fParseSpanOnly)
	{
		if (*fStyles == NULL)
		{
			*fStyles = new VTreeTextStyle();
			VTextStyle* style = new VTextStyle();
			style->SetRange(0,fText->GetLength());
			(*fStyles)->SetData(style);
		}
		VSpanHandler *handler = new VSpanHandler(VString("body"), *fStyles, fText, fParseSpanOnly);	
		handler->SetHTMLAttribute( inName, inValue);
		handler->Release();
	}
}
コード例 #12
0
VError VFolder::GetRelativeURL(VFolder* inBaseFolder, VString& outURL, bool inEncoded)
{
	VString folderURL;
	VError err = GetURL(outURL, inEncoded);
	if (inBaseFolder != NULL)
	{
		inBaseFolder->GetURL(folderURL, inEncoded);
		if (outURL.BeginsWith(folderURL))
		{
			outURL.Remove(1, folderURL.GetLength());
		}

	}
	return err;
}
コード例 #13
0
void VHTMLSyntax::SwapComment( ICodeEditorDocument* inDocument, VString& ioString, bool inComment )
{
	if ( inComment )
	{
		ioString.Insert( CVSTR( "<!--" ), 1 );
		ioString += CVSTR( "-->" );
	}
	else
	{
		if ( ioString.BeginsWith( CVSTR( "<!--" ) ) )
			ioString.Remove( 1, 4 );

		if ( ioString.EndsWith( CVSTR( "-->" ) ) )
			ioString.Truncate( ioString.GetLength() - 3 );
	}
}
コード例 #14
0
void ColorToValue(const RGBAColor inColor, VString& outValue)
{
	outValue.FromHexLong(inColor);
	sLONG len = outValue.GetLength();
	//ignorer le canal alpha
	if(len==8 && outValue.BeginsWith("FF"))
	{
		outValue.Replace("",1,2);
	}

	for(int i=0; i < 6-len;i++)
	{
		outValue = "0" + outValue;
	}

	outValue = "#" + outValue;
}
コード例 #15
0
void VSpanHandler::SetFontSize(const VString& inValue, float inDPI)
{
	Real size = 0;
	VTextStyle* TheStyle = fStyles->GetData();
	if(!TheStyle)
		return;
	if(inValue.EndsWith("pt", true))
	{
		VString textsize = inValue;
		textsize.Truncate( inValue.GetLength()-2);
		size = textsize.GetReal();
		//we need convert from format dpi to 72 dpi
#if VERSIONWIN
		TheStyle->SetFontSize(floor(size*(inDPI ? inDPI : VSpanTextParser::Get()->GetDPI())/72.0f+0.5f));
#else
		TheStyle->SetFontSize(size);
#endif
	}
}
コード例 #16
0
ファイル: VUUID.cpp プロジェクト: sanyaade-iot/core-XToolbox
void VUUID::FromString(const VString& inValue)
{
	sLONG	destIndex = 0;

	// Don't care if it finds non Hexa characters, so you can parse
	// strings like "{19D215C0-3884-45af-A173-14F5CCD73C49}"
	for (sLONG srcIndex = 0; srcIndex < inValue.GetLength(); srcIndex++)
	{
		UniChar	digit = inValue[srcIndex];
		UniChar	nibble;

		if (digit >= CHAR_DIGIT_ZERO && digit <= CHAR_DIGIT_NINE)
			nibble = (UniChar) (digit - CHAR_DIGIT_ZERO);
		else if (digit >= CHAR_LATIN_CAPITAL_LETTER_A && digit <= CHAR_LATIN_CAPITAL_LETTER_F)
			nibble = (UniChar) (10 + digit - CHAR_LATIN_CAPITAL_LETTER_A);
		else if (digit >= CHAR_LATIN_SMALL_LETTER_A && digit <= CHAR_LATIN_SMALL_LETTER_F)
			nibble = (UniChar) (10 + digit - CHAR_LATIN_SMALL_LETTER_A);
		else
			continue;

		if ((destIndex & 1) != 0)
		{
			fData.fBytes[destIndex/2] += nibble;
		}
		else
		{
			fData.fBytes[destIndex/2] = (uBYTE) (nibble * 16);
		}
		if (++destIndex > 31)
			break;
	}
	
	if (destIndex == 32)
		_GotValue(false);
	else
	{
		BuildFromAnsiString(inValue);
		//SetNull();
	}
}
コード例 #17
0
void VHTMLSyntax::SetLine( ICodeEditorDocument *inDocument, sLONG inLineNumber, bool inLoading )
{
#if 0
	VString source;
	inDocument->GetLine( inLineNumber, source );
	
	HTMLParser parser;
	HTMLParser::State *state = NULL;
	HTMLParser::State *prevLineState = NULL;
	if (inLineNumber > 0)	prevLineState = GetStateForLine( inDocument, inLineNumber - 1 );
	ParsingCookie *cookie = new ParsingCookie( inDocument, inLineNumber );
	parser.Parse( source, prevLineState, &state, this, (const void *)cookie );
	SetStateForLine( inDocument, inLineNumber, state );
	cookie->Release();
#else
	// Get the params for the current line so that we can set them up properly
	VLineSyntaxParams *currentLineParams = static_cast< VLineSyntaxParams * >( inDocument->GetLineSyntaxParams( inLineNumber ) );
	if (!currentLineParams) {
		currentLineParams = new VLineSyntaxParams();
		inDocument->AssignLineSyntaxParams( inLineNumber, currentLineParams );
	}
	bool previousOpenCommentState = currentLineParams->IsOpenComment();

	// We also want the params for the preceeding line, in case we're the continuation of
	// a comment.
	VLineSyntaxParams *previousLineParams = NULL;
	if (inLineNumber > 0) {
		previousLineParams = static_cast< VLineSyntaxParams * >( inDocument->GetLineSyntaxParams( inLineNumber - 1 ) );
	}

	VString xstr;
	inDocument->GetLine(inLineNumber,xstr);
	inDocument->SetLineStyle(inLineNumber,0,xstr.GetLength(),0);		//initiate the line

	char *lexinput = CreateUTF8String( xstr );
	struct htmlLexeme *list = parseHTML( lexinput );

	// If we used to be in comment continuation mode, the assumption is that we're still in 
	// comment continuation mode.  We'll switch this off if the comment ends though
	currentLineParams->CopyState( previousLineParams );

	// We are going to keep track of which open and close tags we've seen on the line.  This allows
	// us to determine which unmatched open and close tags exist so we can associate that data with
	// the line.  As we find open tags, we'll push them onto the open tag list.  As we find close tags,
	// we will scan the open tag list and *remove* any that match.  If there's no match, then we'll add
	// the tag to the close list.
	std::vector< VString > openList, closeList;

	// Given the list of HTML tokens, let's walk over the list and try to make some sense
	// of them.  Walk over the list one token at a time, and see if we can make sense of 
	// what we've got.
	struct htmlLexeme *cur = list;
	while (cur) {
		// There are only three types of comments we need to worry about.  Full comments, 
		// open comments and close comments.  We'll get a token representing any one of the
		// three.  However, we need to pay special attention to multi-line comments, since
		// they won't lex out entirely correct.  If the previous line was part of an open
		// comment, then we want to keep walking over the tokens, marking them as part of
		// the comment, until we run out of tokens, or we find a kCommentClose token.
		if (currentLineParams->IsOpenComment()) {
			if (kCommentClose == cur->fStyle) {
				// We found the end of the comment, so we can highlight it appropriately, 
				// and go back to our regularly scheduled lexing
				inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ comment_col ] );

				// We're also done being a part of the comment continuation train
				currentLineParams->SetIsOpenComment( false );
			} else {
				// This is just another part of the comment
				inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ comment_col ] );
			}
			// Advance
			cur = cur->fNext;
			continue;
		}
		if (kCompleteComment == cur->fStyle) {
			// A complete comment is the easiest of the three cases.  Just highlight it
			inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ comment_col ] );
		} else if (kCommentOpen == cur->fStyle) {
			// An open comment must be the last token in the list
			xbox_assert( !cur->fNext );

			// We want to highlight from here to the end of the line
			inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ comment_col ] );
			// We also want to flag that this line ends with an open comment
			currentLineParams->SetIsOpenComment( true );
		} else if (kCommentClose == cur->fStyle) {
			// If we got a close comment token, then something's off.  That means the user put in a close comment
			// token, but they never opened it.  We're going to ignore that state, and flag this as being normal
			inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ scommentend_col ] );
		} else if (kString == cur->fStyle) {
			inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ string_col ] );
		} else if (kKeyword == cur->fStyle) {
			// Keywords a bit trickier than you might think because we need to be sure they're actually part of a
			// tag.  If the user types something like: <b>This table rocks</b>, we only want to highlight the b in the
			// begin and end tag, and not the "table" in the user's text.  To deal with this, we have an "in tag" flag
			// that basically turns keyword highlighting on and off.
			if (currentLineParams->IsProcessingTag()) {
				inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ keyword_col ] );

				// If we're processing an opening tag, then we want to push the keyword onto the tag stack.  But if we're
				// processing a closing tag, then we want to pop the last keyword off the tag stack and try to match it up
				// to what we just processed.  If they match, we're golden.  If not, we just assume the user's mismatching
				// their tags because they're an idiot.
				VString tagName;
				xstr.GetSubString( cur->fOffset + 1, cur->fLength, tagName );

				if (currentLineParams->IsProcessingStartTag()) {
					if (!IsTagWithoutClose( tagName )) {
						openList.push_back( tagName );
					}
					currentLineParams->PushTag( tagName );

					// Note that we are no longer processing the start of a tag.  This allows us to handle attributes
					// separately from the tag itself.
					currentLineParams->SetIsProcessingStartTag( false );
				} else {
					// Check to see if this closed tag is on the open list.  If it is, we want to remove it from the
					// list.  Otherwise, we want to add it to the close list.
					bool bAddToClose = true;
					for (std::vector< VString >::iterator iter = openList.begin(); bAddToClose && iter != openList.end();) {
						if (tagName.EqualTo( *iter, false )) {
							iter = openList.erase( iter );
							bAddToClose = false;
						} else {
							++iter;
						}
					}
					if (bAddToClose)	closeList.push_back( tagName );

					VString lastTag;
					currentLineParams->PopTag( lastTag );

					if (!lastTag.EqualTo( tagName, false )) {
						// The tags don't match, so we're just going to ignore the issue
						// TODO: do something more sensible here
					}
				}
			}
		} else if (kNumber == cur->fStyle) {
			inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ allnum_col ] );
		} else if (kTagOpen == cur->fStyle || kEndTagOpen == cur->fStyle) {
			currentLineParams->SetIsProcessingTag( true );
			currentLineParams->SetIsProcessingStartTag( kTagOpen == cur->fStyle );
		} else if (kTagClose == cur->fStyle || kTagSelfClose == cur->fStyle) {
			currentLineParams->SetIsProcessingTag( false );

			// If we just handled a self-closing tag (like <br />), then we want to pop it from the stack
			VString lastTag;
			currentLineParams->LastTag( lastTag );
			if (kTagSelfClose == cur->fStyle || IsTagWithoutClose( lastTag )) {
				VString toss;
				currentLineParams->PopTag( toss );

				// We also do not want to add it to our list of open tags for the line, since it's self-closed
				for (std::vector< VString >::iterator iter = openList.begin(); iter != openList.end(); ++iter) {
					if (lastTag.EqualTo( *iter, false )) {
						iter = openList.erase( iter );
						break;
					}
				}
			}
		}

		cur = cur->fNext;
	}
	FreeLexemeList( list );

	// Now that we have an open and a close list, we want to associate them with the line.
	for (std::vector< VString >::iterator iter = openList.begin(); iter != openList.end(); ++iter) {
		currentLineParams->AddUnmatchedOpenTag( *iter );
	}
	for (std::vector< VString >::iterator iter = closeList.begin(); iter != closeList.end(); ++iter) {
		currentLineParams->AddUnmatchedCloseTag( *iter );
	}

	// There are two cases we really need to care about.  If the line now ends in
	// an open comment (and didn't used to), we want to colorize down the document.
	// Also, if the line no longer ends in an open comment (but used to), we want to
	// colorize down the document.  In either case, we want to keep colorizing subsequent
	// lines until the comment is ended or the end of the document is reached.
	if ((!previousOpenCommentState && currentLineParams->IsOpenComment() ||		// Now ends with open comment, didn't used to
		previousOpenCommentState && !currentLineParams->IsOpenComment()) &&		// Used to end with an open comment, but no longer does
		inLineNumber + 1 < inDocument->GetNbLines()) {
		SetLine( inDocument, inLineNumber + 1, inLoading );
	}
#endif // old code
}
コード例 #18
0
void VLocalizationTransUnitHandler::EndElement( const XBOX::VString&)
{
	//DebugMsg( "VLocalizationTransUnitHandler::EndElement: %S\n", &fElementName);
	if (fElementName.EqualToUSASCIICString( "source"))
	{
		fElementName.Clear();
	}
	else if (fElementName.EqualToUSASCIICString( "target"))
	{
		fElementName.Clear();
	}
	//The last _should_ be the trans-unit element.
	else
	{
		fElementName.Clear();
		
		if (!fExcluded)
		{
			VString translatedString;
			if (!fTarget.IsNull())
				translatedString = fTarget;
			else if (!fSource.IsNull())
				translatedString = fSource;

			if (fTransUnitBag != NULL)
			{
				fTransUnitBag->SetString( "target", translatedString);
				fGroupBag->AddElement( "trans-unit", fTransUnitBag);
			}
			
			//As soon as the conditions are fulfilled, we record it in the Localization Manager and we won't record it another time. It implies that if the trans-unit has two <target> tags for example, the first <target> tag is the one we take in account.
			if (!fIsEntryRecorded)
			{
				// Value Insertion (STR#-like pattern)
				if (fStringID > 0 && fGroupID != 0)
				{			
					STRSharpCodes theSTRSharpCodes = STRSharpCodes(fGroupID, fStringID);
					fIsEntryRecorded = fLocalizationManager->InsertSTRSharpCodeAndString(theSTRSharpCodes, translatedString, fShouldOverwriteAnyExistentLocalizationValue);
				}

				// Value Insertion (resname value)
				if (!translatedString.IsEmpty())
				{
					VString resourceURL;
					if (fGroupResnamesStack.size() >= 2 && !fResName.IsEmpty())
					{
						std::stack<XBOX::VString> groupResnamesStackCopy = fGroupResnamesStack;
						VString lastGroupResname = groupResnamesStackCopy.top();
						groupResnamesStackCopy.pop();
						VString penultimateGroupResname = groupResnamesStackCopy.top();
						if (!lastGroupResname.IsEmpty() && !penultimateGroupResname.IsEmpty() && penultimateGroupResname[0] == CHAR_LEFT_SQUARE_BRACKET && penultimateGroupResname[penultimateGroupResname.GetLength()-1] == CHAR_RIGHT_SQUARE_BRACKET)
						{
							VString divider = VString(OO_SYNTAX_INTERNAL_DIVIDER);
							resourceURL += penultimateGroupResname;
							resourceURL += divider;
							resourceURL += lastGroupResname;
							resourceURL += divider;
							resourceURL += fResName;
						}
					}
					
					if (!resourceURL.IsEmpty())
					{
						if (fLocalizationManager->InsertObjectURLAndString(resourceURL, translatedString, fShouldOverwriteAnyExistentLocalizationValue))
							fIsEntryRecorded = true;
					}
					else
					{
						if (!fResName.IsEmpty())
						{
							if (fLocalizationManager->InsertObjectURLAndString(fResName, translatedString, fShouldOverwriteAnyExistentLocalizationValue))
								fIsEntryRecorded = true;
						}
						if (fGroupResnamesStack.size() >= 1)
						{
							std::stack<XBOX::VString> groupResnamesStackCopy = fGroupResnamesStack;
							while(groupResnamesStackCopy.size() > 0)
							{
								VString groupResname;
								groupResname = groupResnamesStackCopy.top();
								groupResnamesStackCopy.pop();
								if (fLocalizationManager->InsertIDAndStringInAGroup(fStringID, translatedString, groupResname, fShouldOverwriteAnyExistentLocalizationValue))
									fIsEntryRecorded = true;
							}
						}
					}
				}
			}
		}
	}
}
コード例 #19
0
void AddStyleToListUniformStyle(const VTreeTextStyle* inUniformStyles, VTreeTextStyle* ioListUniformStyles, sLONG inBegin, sLONG inEnd)
{
	if(inUniformStyles->GetParent())
	{
		StyleProperties vStyle;
		sLONG isbold, isunderline, isitalic, istrikeout;
		Real vfontsize = -1;
		RGBAColor forecolor;
		VString vfontname;
		bool hasForeColor, istransparent;
		justificationStyle vjust = JST_Left;
		bool doit = false;
		
		memset(&vStyle,0, sizeof(StyleProperties));
		vStyle.bold = &isbold;
		vStyle.italic = &isitalic;
		vStyle.underline = &isunderline;
		vStyle.fontSize = &vfontsize;
		vStyle.fontName = &vfontname;
		vStyle.just = &vjust;
		vStyle.foreColor = &forecolor;
		vStyle.strikeout = &istrikeout;
		
		GetPropertiesValue(inUniformStyles, vStyle);
		
		VTextStyle* uniformStyle = new VTextStyle();
		uniformStyle->SetRange(inBegin, inEnd);
		if(vfontname.GetLength() > 0)
		{
			uniformStyle->SetFontName(vfontname);
		}
		
		if(vfontsize != -1)
		{
			uniformStyle->SetFontSize(vfontsize);
		}
		
		if(isbold != -1)
		{
			uniformStyle->SetBold(isbold);
		}
		
		if(isitalic != -1)
		{
			uniformStyle->SetItalic(isitalic);
		}
		
		if(isunderline != -1)
		{
			uniformStyle->SetUnderline(isunderline);
		}
		
		if(istrikeout != -1)
		{
			uniformStyle->SetStrikeout(istrikeout);
		}
		
		uniformStyle->SetHasForeColor(true);
		uniformStyle->SetColor(forecolor);
		
		if(vjust != JST_Notset)
		{
			uniformStyle->SetJustification(vjust);
		}
		
		//if(doit)
		{
			VTreeTextStyle* child = new VTreeTextStyle(uniformStyle);	
			//ioListUniformStyles->AddChild(child);
			//[MI] le 24/11/2011 : les element de la liste doivent etre rang par ordre croissant de debut de selection
			sLONG vbegin, vend; 
			sLONG vcount = ioListUniformStyles->GetChildCount();
			sLONG index = vcount;
			child->GetData()->GetRange(vbegin,vend);
			//recherche dichotomique de l index ou le child  doit etre inser
			if(vcount)
			{
				sLONG bornsup = vcount;
				sLONG borninf = 1;
				sLONG b,e,b1,e1;
				index = bornsup;
				VTreeTextStyle* thechild = ioListUniformStyles->GetNthChild(bornsup);
				thechild->GetData()->GetRange(b,e);
				thechild = ioListUniformStyles->GetNthChild(borninf);
				thechild->GetData()->GetRange(b1,e1);
				if(vbegin >=  b)
					index = bornsup;
				else if(vbegin <  b1)
					index = 0;
				else
				{
					//fixed ACI0073686: c'était n'importe quoi cette recherche dicho...??
					bool found = false;
					while(!found && (borninf<= bornsup))
					{
						index = (borninf+bornsup)/2;

						thechild = ioListUniformStyles->GetNthChild(index);
						thechild->GetData()->GetRange(b,e);
						if(vbegin >=  b)
							borninf = index; //ensure we insert after index
						else
							bornsup = index-1; //ensure we insert before index
						if(bornsup == (borninf+1) || bornsup == borninf)
						{
							index = borninf;
							found = true;
						}
					}
				}
			}
			ioListUniformStyles->InsertChild(child,index+1);	
		}
	}
}
コード例 #20
0
ファイル: VFont.cpp プロジェクト: sanyaade-iot/core-XToolbox
/** return true if font with the specified font family name, style and size exists on the current system */
bool VFont::FontExists(const VString& inFontFamilyName, const VFontFace& inFace, GReal inSize, const GReal inDPI, const VGraphicContext *inGC)
{
#if VERSIONWIN
	bool exists = false;
	//JQ 21/06/2010: fixed and optimized FontExists (was not coherent with font creation)
	VFont *font = RetainFont( inFontFamilyName, inFace, inSize, inDPI, true);
	if (font)
	{
		if (!font->IsTrueTypeFont())
		{
			//not TrueType fonts are drawed with GDI
			//so return true if a valid HFONT is set

			HFONT hFont = font->GetFontRef();
			exists = hFont != NULL;
			font->Release();
			return exists;
		}
#if ENABLE_D2D
		if (inGC && inGC->IsD2DImpl())
		{
			//if DWrite font family name is not equal to inFontFamilyName
			//DWrite has returned a compatible font 
			//so return true only if DWrite font family name matches inFontFamilyName

			VTaskLock lock(&VWinD2DGraphicContext::GetMutexDWriteFactory());
			exists = false;
			if (font->GetImpl().GetDWriteTextFormat() != NULL)
			{
				UINT32 nameLength = font->GetImpl().GetDWriteTextFormat()->GetFontFamilyNameLength();
				if (nameLength+1 <= 80)
				{
					WCHAR familyName[80];
					HRESULT hr = font->GetImpl().GetDWriteTextFormat()->GetFontFamilyName( familyName, nameLength+1);
					exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
				}
				else
				{
					WCHAR *familyName = new WCHAR[nameLength+1];
					font->GetImpl().GetDWriteTextFormat()->GetFontFamilyName( familyName, nameLength+1);
					exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
					delete [] familyName;
				}
			}
			font->Release();
			return exists;
		}
#endif
		//if gdiplus font family name is not equal to inFontFamilyName
		//gdiplus has returned a compatible font 
		//so return true only if gdiplus font family name matches inFontFamilyName
		Gdiplus::FontFamily *family = new Gdiplus::FontFamily();
		Gdiplus::Status status = font->GetImpl().GetGDIPlusFont()->GetFamily(family);
		WCHAR familyName[LF_FACESIZE];
		family->GetFamilyName( familyName);
		exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
		delete family;

		font->Release();
	}
	return exists;
#else
	bool exists = false;
	VFont *font = RetainFont( inFontFamilyName, inFace, inSize, inDPI, true);
	if (font)
	{
		//ensure returned font has the requested family name (here we check only the family name but not the full name)
		//otherwise it is a font substitute
		CTFontRef ctfont = font->GetFontRef();
		CFStringRef name = CTFontCopyFamilyName(ctfont);
		VString xname;
		xname.MAC_FromCFString( name);
		CFRelease(name);
		VString inname( inFontFamilyName);
		inname.Truncate( xname.GetLength());
		return inname.EqualToString( xname);
	}
	return exists;
#endif
}
コード例 #21
0
JS4D::StringRef JS4D::VStringToString( const VString& inString)
{
	JSStringRef jsString = JSStringCreateWithCharacters( inString.GetCPointer(), inString.GetLength());
	return jsString;
}
コード例 #22
0
VError VServiceDiscoveryServer::_HandlePacket (VUDPEndPoint *inEndPoint, uBYTE *inPacket, uLONG inPacketSize, uLONG inBufferSize)
{
	xbox_assert(inEndPoint != NULL);
	xbox_assert(inPacket != NULL);
		
	uLONG									numberQuestions, size, i, offset;
	VError									error;
	const uBYTE								*p;
	VString									vString;
	std::list<VServiceRecord>::iterator		j;
	std::map<VString, bool>					queriedServices, queriedAddresses;
	std::map<VString, bool>::iterator		k;		
		
	if (inPacketSize < 12) 
		
		return VE_SRVR_BONJOUR_MALFORMED_PACKET;
	
	if ((inPacket[2] & 0x80)
	|| (inPacket[3] & 0x0f)
	|| !(numberQuestions = Bonjour::Read2Bytes(&inPacket[4])))
		
		return VE_OK;
	
	p = &inPacket[12];
	for (i = 0; i < numberQuestions; i++) {
		
		uWORD	questionType, questionClass;
		
		size = inPacketSize;
		if ((error = Bonjour::ParseDNSName(inPacket, &size, p - inPacket, &vString)) != VE_OK) 

			return error;

		p += size;	
		questionType = Bonjour::Read2Bytes(p);
		questionClass = Bonjour::Read2Bytes(p + 2);		
		p += 4;
		
		if (questionClass != 1)
			
			continue;
		
		if (questionType == Bonjour::kTypePTR) {

			if (vString.EndsWith(".local", true)) {
			
				vString.Truncate(vString.GetLength() - 6);
				
				for (j = fServiceRecords.begin(); j != fServiceRecords.end(); j++)

					if (j->fServiceName.EqualToString(vString, true)) {

						queriedServices[vString] = true;
						break;

					} else if (vString.EqualToString("_services._dns-sd._udp", true)) {
						
						queriedServices[vString] = true;
						break;
				
					}
				
			}
			
		} else if (questionType == Bonjour::kTypeA) 
			
			queriedAddresses[vString] = true;

		// Ignore all other types of queries.

	}	
	
	error = VE_OK;
	offset = p - inPacket;
	for (k = queriedServices.begin(); k != queriedServices.end(); k++) 

		if (k->first.EqualToString("_services._dns-sd._udp", true))

			error = _SendServiceList(inEndPoint, inPacket, inBufferSize, offset);

		else
		
			error = _AnswerQuery(inEndPoint, inPacket, inBufferSize, offset, k->first);

	// Note that a hostname can have several network address(es).

	for (k = queriedAddresses.begin(); k != queriedAddresses.end(); k++) 
		
		for (j = fServiceRecords.begin(); j != fServiceRecords.end(); j++)
		
			if (j->fHostName.EqualToString(k->first, false)) 
				
				error = _SendAddressAnswer(inEndPoint, inPacket, inBufferSize, offset, *j);

	return error;
}
コード例 #23
0
VError XWinFolder::RetainSystemFolder( ESystemFolderKind inFolderKind, bool inCreateFolder, VFolder **outFolder )
{
	VString folderPath;
	UniChar path[4096];
	size_t maxLength = sizeof( path)/sizeof( UniChar);
	path[maxLength-2]=0;
	VFolder* sysFolder = NULL;
	DWORD winErr = ERROR_PATH_NOT_FOUND;
	switch( inFolderKind)
	{
		case eFK_Executable:
			{
				DWORD pathLength = ::GetModuleFileNameW( NULL, path, (DWORD) maxLength);
				if (testAssert( pathLength != 0 && !path[maxLength-2])) 
				{
					folderPath.FromUniCString( path );
					VFile exeFile( folderPath );
					sysFolder = exeFile.RetainParentFolder();
					winErr = 0;
				}
				break;
			}

		case eFK_Temporary:
			{
				DWORD length = ::GetTempPathW( (DWORD) maxLength, path);
				if ( (length > 0) && (length <= maxLength) && !path[maxLength-2])
				{
					DWORD size = ::GetLongPathNameW( path, NULL, 0);
					if (size > 0)
					{
						UniChar *p = folderPath.GetCPointerForWrite( size-1);
						if (p != NULL)
						{
							DWORD result = ::GetLongPathNameW( path, p, size);
							if (result == 0)
								winErr = GetLastError();
							else
								winErr = 0;
							folderPath.Validate( result);
							sysFolder = new VFolder( folderPath );
						}
					}
				}
				break;
			}

		default:
			{
				int type;
				switch( inFolderKind)
				{
					case eFK_UserDocuments:			type = CSIDL_PERSONAL; break;
					case eFK_CommonPreferences:		type = CSIDL_COMMON_APPDATA; break;
					case eFK_UserPreferences:		type = CSIDL_APPDATA; break;
					case eFK_CommonApplicationData:	type = CSIDL_COMMON_APPDATA; break;
					case eFK_UserApplicationData:	type = CSIDL_APPDATA; break;
					case eFK_CommonCache:			type = CSIDL_COMMON_APPDATA; break;
					case eFK_UserCache:				type = CSIDL_LOCAL_APPDATA; break;
					default: xbox_assert( false);	type = CSIDL_APPDATA; break;
				}
				HRESULT result = ::SHGetFolderPathW( NULL, type, NULL, SHGFP_TYPE_CURRENT, path);
				if ( result == S_OK || result == S_FALSE )	// S_FALSE means The CSIDL is valid, but the folder does not exist.
				{
					folderPath.FromUniCString( path);
					if (folderPath[folderPath.GetLength()-1] != FOLDER_SEPARATOR)
						folderPath += FOLDER_SEPARATOR;
					sysFolder = new VFolder( folderPath );
					winErr = 0;
				}
				break;
			}
	}

	if ( (sysFolder != NULL) && !sysFolder->Exists() )
	{
		if (inCreateFolder)
		{
			if (sysFolder->CreateRecursive() != VE_OK)
				ReleaseRefCountable( &sysFolder);
		}
		else
		{
			ReleaseRefCountable( &sysFolder);
		}
	}

	*outFolder = sysFolder;
	return MAKE_NATIVE_VERROR( winErr);
}
コード例 #24
0
void VXMLSyntax::SetLine( ICodeEditorDocument* inDocument, sLONG inLineNumber, bool inLoading )
{

	int linekind_comment_aboveline      = 0;
	int linekind_comment_curline_cur    = 0;
	int linekind_comment_curline_former = 0;


	bool NeedTocheckCommet  = false;	//use as a flag whether we should check scommet 
	int checkType	        = 0;                  //check in which situation of the scomment



	if ( inLineNumber > 0 )
	{
		linekind_comment_aboveline = getFullLindKind_Comment(inDocument,inLineNumber-1);
	}
	linekind_comment_curline_former = getFullLindKind_Comment(inDocument,inLineNumber);





	//begin parsing
	struct xmlLexStyleInfo * lexstrptr = 0;
	VString xstr;
	inDocument->GetLine(inLineNumber,xstr);
	const UniChar * unistring  = xstr.GetCPointer();
	char *lexinput;
	sLONG len = xstr.GetLength();
	lexinput = new char[len+1];
	lexinput[len] = '\0';
	for(int i = 0 ; i < len; i++)     //to change unicode to char
	{
		if (unistring[i] == 9)
			lexinput[i] = ' ';
		else if (unistring[i] > 127)
			lexinput[i] = 'X';
		else
			lexinput[i] = (char)unistring[i];			
	}
	lexstrptr = startxmlParse(lexinput); 

	linekind_comment_curline_cur = getxmlLinetype();
	setLineKind_Lex(inDocument,inLineNumber,linekind_comment_curline_cur);
	linekind_comment_curline_cur = linekind_comment_curline_cur%100;






	if ( (inDocument->GetLineKind(inLineNumber)%1000)/100 > common )       //if the line tag begin or tagend
	{

		if ( getLindKind_Tagnameloc(inDocument,inLineNumber) == 0 )
		{
			allxmltags.Push(getxmlTagName());

			setLindKind_Tagnameloc(inDocument,inLineNumber,allxmltags.GetCount());	
		}
		else
		{
			int line_i_tag_loc = getLindKind_Tagnameloc(inDocument,inLineNumber);		
			allxmltags[line_i_tag_loc-1] = getxmlTagName();
		}

	}




	inDocument->SetLineStyle(inLineNumber,0,len,0);		//initiate the line
	for (int j = 0; j < getxmlKeywordNum(); j++ )						//set the keywords color	
	{      
		inDocument->SetLineStyle(inLineNumber,lexstrptr->indent,(lexstrptr->indent)+(lexstrptr->length),xmlcolorShadow[lexstrptr->style]);							
		lexstrptr++;
	}	




	/************************************************************************/
	/* the following code to                                                                     */
	/************************************************************************/



	for (int commenttypei = 0; commenttypei <= htmlsytlecomment ; commenttypei++  )
	{	

		int linekind_comment_specific_cur    = 0;
		int linekind_comment_specific_fomer  = 0;

		int	linkkind_comment_specific_above  = 0; 


		if ( commenttypei == ordinarycomment )
		{
			linekind_comment_specific_cur   = linekind_comment_curline_cur%10;                     //both ..cur and ..former >= 0
			linekind_comment_specific_fomer = linekind_comment_curline_former%10;
			linkkind_comment_specific_above = linekind_comment_aboveline%10;
		}
		else if ( commenttypei == htmlsytlecomment )
		{
			linekind_comment_specific_cur   = linekind_comment_curline_cur/10;                     //both ..cur and ..former >= 0
			linekind_comment_specific_fomer = linekind_comment_curline_former/10;
			linkkind_comment_specific_above = linekind_comment_aboveline/10;
		}



		if ( linekind_comment_curline_former != linekind_comment_curline_cur)		    //if current linekind is changed, we need to check comment folding
		{  

			NeedTocheckCommet = true;

			linekind_comment_specific_fomer = linekind_comment_specific_fomer*10 + linekind_comment_specific_cur;     //getLineKind_Comment(inDocument,inLineNumber);		

			switch(linekind_comment_specific_fomer)
			{

			case 1:  checkType = enterCreateCommon;break;
			case 2:  checkType = enterCreateOnlyStart;break;
			case 3:  checkType = enterCreateOnlyEnd;break;
			case 4:  checkType = enterCreateBoth;break;
			case 12: checkType = commonAddStart;break;                     
			case 21: checkType = onlyStartDeleteStart;break;
			case 23: checkType = endStartDeleteStart;break;
			case 24: checkType = onlyStartAddEnd;	break;
			case 31: checkType = onlyEndDeleteEnd; break;
			case 32: checkType = onlyEndRightAddStart;break;
			case 34: checkType = onlyEndAddStart;break; 
			case 41: checkType = bothToCommon;break;
			case 42: checkType = bothDeleteEnd;break;
			case 43: checkType = bothDeleteStart;break;
			case 51: checkType = insideType;break;
			case 52: checkType = insideAddStart;break;
			case 53: checkType = insideAddEnd;break;
			case 54: checkType = insideCommentToBoth;break;

			default: checkType = 99;

			}
		}
		else																			  // the line kind comment is unchanged
		{
			if (inLineNumber > 0)
			{      
				if ( linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd )
				{	  	
					switch (linekind_comment_specific_cur)
					{
					case common:           inDocument->SetLineStyle(inLineNumber,0,len,0);setLineKind_Comment(inDocument,inLineNumber,insideComment,commenttypei);linekind_comment_specific_cur = insideComment;break;
					case insideComment:    inDocument->SetLineStyle(inLineNumber,0,len,4);break;
					case startWithoutEnd : inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
					default:               inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
					}
				}	  
			}
		}



		if (NeedTocheckCommet)				 //need to handle comment 
		{
			int line_i_type = 0;         
			int totallinenum = 0;

			totallinenum = inDocument->GetNbLines();


			//----------------------------------------------------------------------------------------------------------------


			if (checkType == enterCreateCommon || checkType == bothToCommon)
			{
				if (inLineNumber > 0 &&  (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd ))
				{
					inDocument->SetLineStyle(inLineNumber,0,len,4);	
					setLineKind_Comment(inDocument,inLineNumber,insideComment,commenttypei);
				}
			}


			//-----------------------------------------------------------------------------------------------------------------


			else if (checkType == commonAddStart || checkType == onlyEndRightAddStart  || checkType == bothDeleteEnd || checkType == enterCreateOnlyStart)     //case 12,42:  comment add a start     AAAAA  ->  AAA /* AAA
			{      
				if (checkType != commonAddStart)
				{	
					if (inLineNumber > 0 &&  (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd ))
					{	
						inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
					}

				}

				for (int i = inLineNumber+1; i < totallinenum; i++)
				{
					line_i_type = getLineKind_Comment(inDocument,i,commenttypei);
					inDocument->GetLine(i,xstr);
					if (line_i_type == endWithoutStart || line_i_type == startWithEnd ||line_i_type == startWithoutEnd)
					{			
						inDocument->SetLineStyle(i,0, findStopLoc(inDocument,i,commenttypei),4);						
						break;
					}
					else
					{
						inDocument->SetLineStyle(i,0,xstr.GetLength(),4);
						if (line_i_type == common)
						{
							setLineKind_Comment(inDocument,i,insideComment,commenttypei);
						}
					}
				}
			}



			//-----------------------------------------------------------------------------------------------------------------


			else if (checkType == onlyStartDeleteStart )   //case 21:       AAA /*  AA  ->  AAAAAA
			{
				if (inLineNumber > 0 && (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above ==startWithoutEnd))
				{
					inDocument->SetLineStyle(inLineNumber,0,len,4);
					setLineKind_Comment(inDocument,inLineNumber,insideComment,commenttypei);
				}
				else
				{
					for (int i = inLineNumber+1;i < inDocument->GetNbLines();i++)
					{
						line_i_type = getLineKind_Comment(inDocument,i,commenttypei);
						inDocument->GetLine(i,xstr);					
						const UniChar * unistringtemp = xstr.GetCPointer();
						sLONG len = xstr.GetLength();
						lexinput = new char[len+1];
						lexinput[len] = '\0';
						for(int j = 0 ; j < len ; j++)     //to change unicode to char
						{
							if (unistringtemp[j] == 9)
								lexinput[j] = ' ';
							else if (unistringtemp[j] > 127)
								lexinput[j] = 'X';
							else
								lexinput[j] = (char)unistringtemp[j];			
						}
						lexstrptr = startxmlParse(lexinput);  
						setLineKind_Lex(inDocument,i,getxmlLinetype());
						inDocument->SetLineStyle(i,0,len,4);  //initate the line
						for (int j = 0; j < getxmlKeywordNum(); j++ )
						{      
							inDocument->SetLineStyle(i,lexstrptr->indent,(lexstrptr->indent)+(lexstrptr->length),xmlcolorShadow[lexstrptr->style]);				
							lexstrptr++;
						}	

						if (line_i_type == startWithEnd || line_i_type == startWithoutEnd || line_i_type == endWithoutStart)
						{

							break;
						}

					}
				}
			}



			//--------------------------------------------------------------------------------------------------------------------------------------------



			else if (checkType == endStartDeleteStart || checkType == onlyStartAddEnd || checkType == insideAddEnd || checkType == enterCreateOnlyEnd || checkType == enterCreateBoth)    //23  24
			{

				if (inLineNumber > 0 && (linkkind_comment_specific_above == startWithoutEnd || linkkind_comment_specific_above == insideComment))
				{ 
					inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
				}

				for (int i = inLineNumber +1; i < totallinenum; i++)
				{
					line_i_type = getLineKind_Comment(inDocument,i,commenttypei);

					inDocument->GetLine(i,xstr);					
					const UniChar * unistringtemp = xstr.GetCPointer();
					sLONG len = xstr.GetLength();
					lexinput = new char[len+1];
					lexinput[len] = '\0';
					for(int j = 0 ; j < len ; j++)     //to change unicode to char
					{
						if (unistringtemp[j] == 9)
							lexinput[j] = ' ';
						else if (unistringtemp[j] > 127)
							lexinput[j] = 'X';
						else
							lexinput[j] = (char)unistringtemp[j];				
					}
					lexstrptr = startxmlParse(lexinput);  
					setLineKind_Lex(inDocument,i,getxmlLinetype());
					inDocument->SetLineStyle(i,0,len,0);  //initate the line
					for (int j = 0; j < getxmlKeywordNum(); j++ )
					{      
						inDocument->SetLineStyle(i,lexstrptr->indent,(lexstrptr->indent)+(lexstrptr->length),xmlcolorShadow[lexstrptr->style]);						
						lexstrptr++;
					}	

					if (line_i_type == startWithEnd || line_i_type == startWithoutEnd || line_i_type == endWithoutStart)
					{
						break;
					}			 
				}		
			}



			//---------------------------------------------------------------------------------------------------------------------------------------------


			else if (checkType == onlyEndDeleteEnd)      //31
			{
				if (inLineNumber > 0 &&  (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd ))
				{
					for (int i =inLineNumber; i < totallinenum ;i++)
					{
						line_i_type = getLineKind_Comment(inDocument,i,commenttypei);
						inDocument->GetLine(i,xstr);
						if (line_i_type == startWithEnd || line_i_type == endWithoutStart)
						{							
							inDocument->SetLineStyle(i,0,findStopLoc(inDocument,i,commenttypei),4);
							break;
						}
						else
						{
							inDocument->SetLineStyle(i,0,xstr.GetLength(),4);
							if (line_i_type == common)
							{
								setLineKind_Comment(inDocument,i,insideComment,commenttypei);
							}
						}
					}
				}
			}



			//---------------------------------------------------------------------------------------------------------------------------------------------



			else if (checkType == insideType || checkType == insideAddStart || checkType == bothDeleteStart)     //51
			{
				if (checkType == insideType)
				{
					inDocument->SetLineStyle(inLineNumber,0,len,4);
				}
				else
				{
					if (inLineNumber > 0 &&  (linkkind_comment_specific_above == insideComment || linkkind_comment_specific_above == startWithoutEnd ))
					{		
						inDocument->SetLineStyle(inLineNumber,0,findStopLoc(inDocument,inLineNumber,commenttypei),4);
					}
				}

				if (checkType == insideType)
				{	
					setLineKind_Comment(inDocument,inLineNumber,insideComment,commenttypei);
				}

			}

			//---------------------------------------------------------------------------------------------------------------------------------------------
		}
	}

	delete lexinput;



	
}
コード例 #25
0
bool HTMLLexer::AdvanceOneToken( int &outToken, TokenList *outTokens )
{
	outToken = -1;

	if (!fLexerInput)
		return false;

	// There can be any combination of newlines and whitespaces preceeding semantic tokens,
	// so we're going to loop until we don't find either.
	while (fLexerInput->HasMoreChars())
	{
		bool consumedWhitespace = false;
		bool consumedNewLine = false;
		if (!SkipWhitespaces( consumedWhitespace, outTokens ))
			return false;

		// HTML also treats newlines as a whitespace
		while (fLexerInput->HasMoreChars() && IsLineEnding( fLexerInput->PeekAtNextChar() ))
		{
			// Eat the line ending
			ConsumeLineEnding( fLexerInput->MoveToNextChar() );
			consumedNewLine = true;
		}

		// If we're done consuming newlines and whitespaces, then we're done with this loop
		if (!consumedWhitespace && !consumedNewLine)
			break;
	}
	if (!fLexerInput->HasMoreChars())
		return false;

	// Take a peek at what sort of token we're about to deal with. 
	UniChar	uChar = fLexerInput->PeekAtNextChar();
	sLONG stringType;
	sLONG stringValue;

	if( (outToken = ConsumePossiblePunctuation(uChar, outTokens)) != 0 )
	{
	}
	else if (IsStringStart( uChar, stringType, stringValue ))
	{
		VString	vstrQuoted;
		if (!ConsumeString( &vstrQuoted, outTokens, stringType, stringValue ))
		{
			return false;
		}
		outToken = stringValue;
		fLastTokenText = vstrQuoted;
	}
	else if (IsIdentifierStart( uChar ))
	{
		// The base class assumes we've consumed the first character already for this call.  We should
		// rectify this some day, as it's very confusing.
		fLexerInput->MoveToNextChar();
		VString *vstrNAME = ConsumeIdentifier();
		if (!vstrNAME)
		{
			return false;
		}

		outToken = HTMLLexemes::TEXT;
		if (outTokens)	outTokens->push_back( new HTMLLexerToken( ILexerToken::TT_NAME, fLexerInput->GetCurrentPosition() - vstrNAME->GetLength(), vstrNAME->GetLength(), *vstrNAME, outToken ) );

		fLastTokenText = *vstrNAME;
		delete vstrNAME;
	}
	else
	{
		return false;
	}
	
	SetLastToken( outToken );
	return true;
}
コード例 #26
0
void XWinIntlMgr::FormatDate( const VTime& inDate, VString& outDate, EOSFormats inFormat, bool inUseGMTTimeZoneForDisplay)
{
	// Prepare SYSTEMTIME for windows.
	sWORD YY = 0;
	sWORD MM = 0;
	sWORD DD = 0;
	sWORD hh = 0;
	sWORD mm = 0;
	sWORD ss = 0;
	sWORD ms = 0;
	if (inUseGMTTimeZoneForDisplay)
		inDate.GetUTCTime (YY,MM,DD,hh,mm,ss,ms);
	else
		inDate.GetLocalTime (YY,MM,DD,hh,mm,ss,ms);

	// Verify if date >1st Jan 1601 (GetDateFormat doesn't support earlier dates.
	if (YY>=1601)
	{
		// Let the OS do it's job.
		UniChar acBuffer[256];

		SYSTEMTIME osDate={0};
		osDate.wYear=YY;
		osDate.wMonth=MM;
		osDate.wDay=DD;
		osDate.wHour=hh;
		osDate.wMinute=mm;
		osDate.wSecond=ss;
		osDate.wMilliseconds=ms;

		if (inFormat == eOS_MEDIUM_FORMAT)
		{
			VString pattern;
			if (GetLocaleInfo( LOCALE_SLONGDATE, pattern))
			{
				// replace long month and date by medium ones
				pattern.ExchangeRawString( CVSTR( "MMMM"), CVSTR( "MMM"));
				pattern.ExchangeRawString( CVSTR( "dddd"), CVSTR( "ddd"));
				if (::GetDateFormatW( fDialect, 0, &osDate, pattern.GetCPointer(), acBuffer, sizeof(acBuffer)))
					outDate = acBuffer;
			}
		}
		else
		{
			// Let the OS do the stuff.
			DWORD dateFormat = (inFormat == eOS_SHORT_FORMAT) ? DATE_SHORTDATE : DATE_LONGDATE;
			if (::GetDateFormatW(fDialect,dateFormat,&osDate,NULL,acBuffer,sizeof(acBuffer)))
				outDate = acBuffer;
		}
	}
	else
	{
		// Get the date pattern
		VString pattern;
		if (GetLocaleInfo( (inFormat == eOS_LONG_FORMAT) ? LOCALE_SLONGDATE : LOCALE_SSHORTDATE, pattern))
		{
			XBOX::VString tokens="gyMd";
			UniChar oldToken=0;
			sLONG count=0;
			pattern.AppendChar(' ');
			sLONG YY2=YY%100;
			XBOX::VString oneName;
			for (int pos=0;pos<pattern.GetLength();pos++)
			{
				UniChar token=pattern[pos];
				if (tokens.FindUniChar(token)>=1)
				{
					if (token==oldToken)
						count++;
					else
					{
						if (!count)
						{
							count=1;
							oldToken=token;
						}
					}
				}

				if (count && token!=oldToken)
				{
					switch(oldToken)
					{
					case 'g':
						if (count==2)
						{
							// TODO: ERA will be added if really wanted.
						}
						else
						{
							for (int i=0;i<count;i++)
								outDate.AppendUniChar(oldToken);
						}
						break;

					case 'y':	// YEAR
						switch(count)
						{
						case 5:
						case 4:		// 4 or more digits date
							outDate.AppendLong(YY);
							break;

						case 2:		// 2 digits with starting 0.
							if (YY2<=9)
								outDate.AppendLong(0);
						case 1:		// 1 or 2 digits
							outDate.AppendLong(YY2);
							break;

						default:
							for (int i=0;i<count;i++)
								outDate.AppendUniChar(oldToken);
							break;
						}
						break;

					case 'M':	// MONTH
						switch(count)
						{
						case 4:	// Long name
						case 3:	// Abbreviated name
							if (GetLocaleInfo( ((count==4) ? LOCALE_SMONTHNAME1 : LOCALE_SABBREVMONTHNAME1) + MM - 1, oneName))
								outDate += oneName;
							break;

						case 2:	// 2 digits number (leading 0)
							if (MM<=9)
								outDate.AppendLong(0);
						case 1:	// 1 or 2 digits number
							outDate.AppendLong(MM);
							break;

						default:
							for (int i=0;i<count;i++)
								outDate.AppendUniChar(oldToken);
							break;
						}
						break;

					case 'd':	// DAY
						switch(count)
						{
						case 4:	// Weekday long name
						case 3:	// Weekday abbreviated name
							if (GetLocaleInfo( ((count==4) ? LOCALE_SDAYNAME1 : LOCALE_SABBREVDAYNAME1) + (inDate.GetWeekDay() + 6) % 7, oneName))
								outDate += oneName;
							break;

						case 2:	// Month day on 2 digits (leading 0)
							if (DD<=9)
								outDate.AppendLong(0);
						case 1:	// Month day on 1 or 2 digits.
							outDate.AppendLong(DD);
							break;

						default:
							for (int i=0;i<count;i++)
								outDate.AppendUniChar(oldToken);
							break;
						}
						break;

					}
					count=0;
				}

				if (!count)
					outDate.AppendUniChar(token);
				oldToken=token;
			}

			// Remove the extra space at end of pattern.
			if (outDate.GetLength()>1)
				outDate.SubString(1,outDate.GetLength()-1);
		}
	}
}
コード例 #27
0
int HTMLLexer::ConsumePossiblePunctuation( UniChar inChar, TokenList *outTokens )
{
	VIndex nStartingPosition = fLexerInput->GetCurrentPosition();
	int tk = 0;
	VString tokenStr;
	switch (inChar) {
		case CHAR_AMPERSAND: {
			VString entity;
			UniChar ch;
			if (ConsumePossibleEntity( entity, ch )) {
				tk = HTMLLexemes::TEXT;
				if (outTokens) {
					outTokens->push_back( new HTMLLexerToken( ILexerToken::TT_HTML_ENTITY, nStartingPosition, entity.GetLength(), entity, ch ) );
				}
				return tk;
			}
		} break;
		case CHAR_EQUALS_SIGN: {
			tokenStr.AppendUniChar( fLexerInput->MoveToNextChar() );
			tk = (int)inChar;
		} break;
		case CHAR_SOLIDUS: {
			fLexerInput->MoveToNextChar();
			if (fLexerInput->HasMoreChars()) {
				if (fLexerInput->PeekAtNextChar() == CHAR_GREATER_THAN_SIGN) {
					tk = HTMLLexemes::SELF_CLOSE;
					tokenStr = "/>";
					fLexerInput->MoveToNextChar();	// Eat the >
				}
			}
			if (!tk)	fLexerInput->MoveToPreviousChar();
		} break;
		case CHAR_LESS_THAN_SIGN: {
			tokenStr.AppendUniChar( fLexerInput->MoveToNextChar() );
			tk = (int)inChar;
			if (fLexerInput->HasMoreChars()) {
				if (fLexerInput->PeekAtNextChar() == CHAR_SOLIDUS) {
					tk = HTMLLexemes::START_OF_CLOSE_TAG;
					tokenStr = "</";
					fLexerInput->MoveToNextChar();	// Eat the /
				} else if (fLexerInput->PeekAtNextChar() == CHAR_EXCLAMATION_MARK) {
					tk = HTMLLexemes::BANG_START;
					tokenStr = "<!";
					fLexerInput->MoveToNextChar();
				} else if (fLexerInput->PeekAtNextChar() == CHAR_QUESTION_MARK) {
					tk = HTMLLexemes::QUESTION_START;
					tokenStr = "<?";
					fLexerInput->MoveToNextChar();
				}
			} 
		} break;
		case CHAR_GREATER_THAN_SIGN: {
			tokenStr.AppendUniChar( fLexerInput->MoveToNextChar() );
			tk = (int)inChar;
		} break;
	}

	if (tk && outTokens) {
		outTokens->push_back( new HTMLLexerToken( ILexerToken::TT_PUNCTUATION, 
									nStartingPosition, tokenStr.GetLength(), tokenStr, tk ) );
	}
	return tk;
}
コード例 #28
0
/** parse span text element or XHTML fragment 
@param inTaggedText
	tagged text to parse (span element text only if inParseSpanOnly == true, XHTML fragment otherwise)
@param outStyles
	parsed styles
@param outPlainText
	parsed plain text
@param inParseSpanOnly
	true (default): only <span> element(s) with CSS styles are parsed
	false: all XHTML text fragment is parsed (parse also mandatory HTML text styles)
*/
void VSpanTextParser::ParseSpanText( const VString& inTaggedText, VTreeTextStyle*& outStyles, VString& outPlainText, bool inParseSpanOnly)
{
	outPlainText = "";
	if(outStyles)
		outStyles->Release();
	outStyles = NULL;
	if (inTaggedText.IsEmpty())
		return;
	//fixed ACI0076343: for compatibility with older bases which do not have support for multistyle var or field
	//					we need to convert to xml text the text which is not bracketed with SPAN 
	//					otherwise parser would fail
	VString vtext;
	sLONG posStartSPAN = 1; //pos of first SPAN tag
	sLONG posEndSPAN = inTaggedText.GetLength()+1; //pos of character following ending SPAN tag
	if (inParseSpanOnly)
	{
		//search for opening SPAN tag
		posStartSPAN = inTaggedText.Find("<SPAN", 1, false);
		if (!posStartSPAN)
		{
			//convert full text to xml
			inTaggedText.GetXMLString( vtext, XSO_Default); 
			vtext = VString("<SPAN>")+vtext+"</SPAN>";
		}
		else 
		{
			VString before, after;
			if (posStartSPAN > 1)
			{
				//convert to XML text preceeding first SPAN 
				VString temp;
				inTaggedText.GetSubString( 1, posStartSPAN-1, temp);
				temp.GetXMLString( before, XSO_Default);
			}
			//search for ending SPAN tag
			const UniChar *c = inTaggedText.GetCPointer()+inTaggedText.GetLength()-1;
			sLONG pos = inTaggedText.GetLength()-1;
			VString spanEndTag = "</SPAN>";
			VString spanEndTag2 = "</span>";
			do
			{
				while (pos >= 0 && *c != '>')
				{
					pos--;
					if (pos >= 0)
						c--;
				}
				if (pos >= 0)
				{
					if (memcmp( (void*)(c+1-spanEndTag.GetLength()), spanEndTag.GetCPointer(), spanEndTag.GetLength()*sizeof(UniChar)) == 0
						||
						memcmp( (void*)(c+1-spanEndTag2.GetLength()), spanEndTag2.GetCPointer(), spanEndTag2.GetLength()*sizeof(UniChar)) == 0)
					{
						posEndSPAN = pos+2;
						break;
					}	
					else
					{
						pos--;
						if (pos >= 0)
							c--;
					}
				}
			} while (pos >= 0);
			if (posEndSPAN <= inTaggedText.GetLength())
			{
				//convert to XML text following ending SPAN tag
				VString temp;
				inTaggedText.GetSubString( posEndSPAN, inTaggedText.GetLength()-posEndSPAN+1, temp);
				temp.GetXMLString( after, XSO_Default);
			}
			if (!before.IsEmpty() || !after.IsEmpty())
			{
				inTaggedText.GetSubString( posStartSPAN, posEndSPAN-posStartSPAN, vtext);
				vtext = VString("<SPAN>")+before+vtext+after+"</SPAN>";
			}
			else
				vtext = VString("<SPAN>")+inTaggedText+"</SPAN>";
		}
	}
	else
		vtext = inTaggedText;

	vtext.ExchangeAll(0x0B,0x0D);//[MI] le 28/12/2010 ACI0069253
#if VERSIONWIN
	vtext.ConvertCarriageReturns(eCRM_CR); //important here on Windows before parsing because styles are assumed to use one character size for line ending on any platform 
										   //and so pair of 0x0D 0x0A should be treated as a single 0x0D character
#endif											
	VTaggedTextSAXHandler vsaxhandler(outStyles, &outPlainText, inParseSpanOnly);
	VXMLParser vSAXParser;

	vSAXParser.Parse(vtext, &vsaxhandler, XML_ValidateNever);

#if VERSIONWIN
	outPlainText.ConvertCarriageReturns(eCRM_CR); //we need to convert to CR (on any platform but Linux here) because xerces parser has converted all line endings to LF (cf W3C XML line ending uniformization while parsing)
#elif VERSIONMAC
	outPlainText.ConvertCarriageReturns(eCRM_CR); //we need to convert to CR (on any platform but Linux here) because xerces parser has converted all line endings to LF (cf W3C XML line ending uniformization while parsing)
#endif
}
コード例 #29
0
VError VArchiveUnStream::ProceedCatalog()
{
	VError result = VE_OK;
	VStr8 dotSlash("./");
	VStr8 slash("/");
	VStr8 extra("::");
	VStr8 folderSep(XBOX::FOLDER_SEPARATOR);

	if ( fStream->GetLong() == 'FPBK' )
	{
		VString filePath;
		VString fileExtra;
		VString storedPath;
		uLONG kind = 0;
		uLONG creator = 0;
		sLONG8 dataFileSize = 0;
		sLONG8 resFileSize = 0;
		uBYTE version = fStream->GetByte();
		uLONG8 fileCount = fStream->GetLong8();
		fTotalByteCount = 0;


		if ( fStream->GetLong() == 'LIST' )
		{
			for ( uLONG i = 0; i < fileCount && result == VE_OK; i++ )
			{
				if ( fStream->GetLong() == 'file' )
				{
					result = filePath.ReadFromStream(fStream);
					if ( result == VE_OK )
					{
						VIndex index = filePath.Find(extra);
						fileExtra = filePath;
						fileExtra.Remove(1,index+1);
						filePath.Remove(index,filePath.GetLength()-index+1);
						storedPath = filePath;
						if ( filePath.Find( dotSlash ) > 0 )
						{
							// some archives have bogous file paths such as ./Z:/folder
							filePath.Exchange( (UniChar) ':', (UniChar) '_');
							filePath.Replace(fDestinationFolder.GetPath(),1,2);
						}
						filePath.Exchange(slash ,folderSep, 1, 255);
					
						dataFileSize = fStream->GetLong8();
						fTotalByteCount += dataFileSize;
						resFileSize = fStream->GetLong8();
						fTotalByteCount += resFileSize;

						kind = fStream->GetLong();
						creator = fStream->GetLong();

						VFile *file = new VFile(filePath);
						fFileCatalog.push_back(new VArchiveCatalog(file,dataFileSize,resFileSize,storedPath,fileExtra,kind,creator));
						ReleaseRefCountable( &file);
					}
				}
				else
					result = VE_STREAM_BAD_SIGNATURE;
			}
		}
		else
			result = VE_STREAM_BAD_SIGNATURE;
	}
	return result;
}
コード例 #30
0
void VSpanTextParser::GenerateSpanText( const VTreeTextStyle& inStyles, const VString& inPlainText, VString& outTaggedText, VTextStyle* inDefaultStyle)
{
	sLONG begin, end;
	bool vhasForecolore, vistransparent;
	VString fontName, defaultfontName;
	sLONG vbold,vitalic,vunderline, vstrikeout, vdefaultbold,vdefaultitalic,vdefaultunderline,vdefaultstrikeout;
	Real fontSize, defaultfontSize;
	RGBAColor vforecolor, vdefaultforecolor, vbackcolor, vdefaultbackcolor;
	justificationStyle justification, defaultjustification;
	VTextStyle* uniformStyle = inStyles.GetData();
	
	justification = defaultjustification = JST_Left;

	uniformStyle->GetRange(begin, end);
	fontName = uniformStyle->GetFontName();
	fontSize = uniformStyle->GetFontSize();
	vbold = uniformStyle->GetBold();
	vitalic = uniformStyle->GetItalic();
	vunderline = uniformStyle->GetUnderline();
	vstrikeout = uniformStyle->GetStrikeout();
	vhasForecolore = uniformStyle->GetHasForeColor();
	vistransparent = uniformStyle->GetTransparent();
	vforecolor = uniformStyle->GetColor();
	vbackcolor = uniformStyle->GetBackGroundColor();
	justification = uniformStyle->GetJustification();
	VTreeTextStyle* parenttree = inStyles.GetParent();
	bool hasDefaultForeColor = false;
	bool hasDefaultBackColor = false;

	if(inDefaultStyle)
	{
		defaultfontName = inDefaultStyle->GetFontName();
		defaultfontSize = inDefaultStyle->GetFontSize();
		defaultjustification = inDefaultStyle->GetJustification();
		vdefaultbold = inDefaultStyle->GetBold();
		vdefaultitalic = inDefaultStyle->GetItalic();
		vdefaultunderline = inDefaultStyle->GetUnderline();
		vdefaultstrikeout = inDefaultStyle->GetStrikeout();
		hasDefaultForeColor = inDefaultStyle->GetHasForeColor();
		hasDefaultBackColor = !inDefaultStyle->GetTransparent();
		vdefaultforecolor = inDefaultStyle->GetColor();
		vdefaultbackcolor = inDefaultStyle->GetBackGroundColor();
	}
	else
	{
		defaultfontName = "";
		defaultfontSize = -1;
		vdefaultbold = 0;
		vdefaultitalic = 0;
		vdefaultunderline = 0;
		vdefaultstrikeout = 0;
		defaultjustification = JST_Notset;
	}

	//as we inherit styles from parent, -1 or default value should be assumed equal (otherwise comparison would trigger a useless tag)
	if (vdefaultbold < 0)
		vdefaultbold = 0;
	if (vdefaultitalic < 0)
		vdefaultitalic = 0;
	if (vdefaultunderline < 0)
		vdefaultunderline = 0;
	if (vdefaultstrikeout < 0)
		vdefaultstrikeout = 0;
	if (defaultjustification < 0)
		defaultjustification = JST_Default;

	bool addfontag, addfonsizetag, addboldtag, additalictag, addunderlinetag, addstrikeouttag, addforecolortag, addbackcolortag, addjustificationtag;
	addfontag = addfonsizetag = addboldtag = additalictag = addunderlinetag = addstrikeouttag =  addforecolortag = addbackcolortag = addjustificationtag = false;

	//we pass inherited default style to children to avoid to redefine style already defined by parent node:
	//so current inDefaultStyle always inherits parent styles
	VTextStyle *defaultStyleInherit = inStyles.GetChildCount() > 0 ? new VTextStyle( inDefaultStyle) : NULL;
	if( fontName.GetLength() > 0 && fontName != defaultfontName)
	{
		addfontag = true;
		if (defaultStyleInherit)
			defaultStyleInherit->SetFontName( fontName);
	}
	if( fontSize != -1 && fontSize != defaultfontSize)
	{
		addfonsizetag = true;
		if (defaultStyleInherit)
			defaultStyleInherit->SetFontSize( fontSize);
	}
	if( justification != JST_Notset && justification != defaultjustification)
	{
		addjustificationtag = true;
		if (defaultStyleInherit)
			defaultStyleInherit->SetJustification( justification);
	}
	if( vbold != UNDEFINED_STYLE && vbold != vdefaultbold)
	{
		addboldtag = true;
		if (defaultStyleInherit)
			defaultStyleInherit->SetBold( vbold);
	}

	if( vitalic != UNDEFINED_STYLE  && vitalic != vdefaultitalic)
	{
		additalictag = true;
		if (defaultStyleInherit)
			defaultStyleInherit->SetItalic( vitalic);
	}

	if( vunderline != UNDEFINED_STYLE && vunderline != vdefaultunderline)
	{
		addunderlinetag = true;
		if (defaultStyleInherit)
			defaultStyleInherit->SetUnderline( vunderline);
	}

	if( vstrikeout != UNDEFINED_STYLE && vstrikeout != vdefaultstrikeout)
	{
		addstrikeouttag = true;
		if (defaultStyleInherit)
			defaultStyleInherit->SetStrikeout( vstrikeout);
	}

	if( vhasForecolore && ((!hasDefaultForeColor) || vforecolor != vdefaultforecolor))
	{
		addforecolortag = true;
		if (defaultStyleInherit)
		{
			defaultStyleInherit->SetHasForeColor( vhasForecolore);
			defaultStyleInherit->SetColor( vforecolor);
		}
	}

	if( !vistransparent && ((!hasDefaultBackColor) || vbackcolor != vdefaultbackcolor))
	{
		addbackcolortag = true;
		if (defaultStyleInherit)
		{
			defaultStyleInherit->SetTransparent( false);
			defaultStyleInherit->SetBackGroundColor( vbackcolor);
		}
	}

	bool addtag = addfontag || addfonsizetag || addboldtag || additalictag || addunderlinetag || addstrikeouttag || addforecolortag || addbackcolortag || addjustificationtag;

	bool isInitialEmpty = outTaggedText.IsEmpty();
	if(addtag)
	{
		bool addcoma = false;
		outTaggedText += "<SPAN STYLE=\"";
	
		if(addfontag)
		{
			outTaggedText += MS_FONT_NAME;
			outTaggedText += ":'";
			outTaggedText += fontName + "'";
			addcoma = true;
		}

		if(addfonsizetag)
		{
			VString strFontSize;
			//we need to convert from 72dpi font size to the desired dpi (screen dpi for v12 compatibility)
#if VERSIONWIN
			strFontSize.FromReal(floor(fontSize*72.0f/VSpanTextParser::Get()->GetDPI()+0.5f));
#else
			strFontSize.FromReal(fontSize);
#endif
			if(addcoma)
				outTaggedText+=";";
			outTaggedText += MS_FONT_SIZE ;
			outTaggedText += ":";
			outTaggedText += strFontSize;
			outTaggedText += "pt";
			addcoma = true;
		}
		
		if(addjustificationtag)
		{
			VString value;
			JustificationToString(justification,value);
			if(addcoma)
				outTaggedText+=";";
			outTaggedText += MS_JUSTIFICATION;
			outTaggedText += ":";
			outTaggedText += value;
			addcoma = true;
		}

		if(addboldtag)
		{
			VString value;
			if(addcoma)
				outTaggedText+=";";
			vbold ? value = "bold" : value = "normal";
			outTaggedText += MS_BOLD ;
			outTaggedText += ":" + value;
			addcoma = true;
		}

		if(additalictag)
		{
			VString value;
			if(addcoma)
				outTaggedText+=";";
			vitalic ? value = "italic" : value = "normal";
			outTaggedText += MS_ITALIC ;
			outTaggedText += ":"+ value;
			addcoma = true;
		}

		if(addunderlinetag && addstrikeouttag)
		{
			VString value;
			if(addcoma)
				outTaggedText+=";";
			if(!vunderline && !vstrikeout)
				value = "none";
			if(vunderline && vstrikeout)
				value = "underline line-through";
			else if(vunderline)
				value = "underline";
			else if(vstrikeout)
				value = "line-through";				
			outTaggedText += MS_UNDERLINE ;
			outTaggedText += ":"+ value;
			addcoma = true;
		}
		else
		{
			if(addunderlinetag)
			{
				VString value;
				if(addcoma)
					outTaggedText+=";";
				vunderline ? value = "underline" : value = "none";
				outTaggedText += MS_UNDERLINE ;
				outTaggedText += ":"+ value;
				addcoma = true;
			}
					
			if(addstrikeouttag)
			{
				VString value;
				if(addcoma)
					outTaggedText+=";";
				vstrikeout ? value = "line-through" : value = "none";
				outTaggedText += MS_UNDERLINE ;
				outTaggedText += ":"+ value;
				addcoma = true;
			}
		}

		if(addforecolortag)
		{
			VString value;
			if(addcoma)
				outTaggedText+=";";
			ColorToValue(vforecolor,value);
			outTaggedText += MS_COLOR;
			outTaggedText += ":"+ value;
			addcoma = true;
		}

		if(addbackcolortag)
		{
			VString value;
			if(addcoma)
				outTaggedText+=";";
			ColorToValue(vbackcolor,value);
			outTaggedText += MS_BACKGROUND;
			outTaggedText += ":"+ value;
			addcoma = true;
		}

		outTaggedText +="\">";				

	}

	
	VString text;
	VString tmp;

	sLONG count = inStyles.GetChildCount();

	//prevent assert in GetSubString
	if (end > inPlainText.GetLength())
		end = inPlainText.GetLength();
	if (begin > inPlainText.GetLength())
		begin = inPlainText.GetLength();

	if(count == 0)
	{
		if(end>begin)
		{
			inPlainText.GetSubString(begin+1, end-begin, text);
			ToXMLCompatibleText(text, tmp);
			outTaggedText += tmp;
		}
	}
	else
	{
		sLONG start = begin;
		for(sLONG i = 1; i <= count; i++)
		{
			VTreeTextStyle* child = inStyles.GetNthChild(i);
			sLONG b,e;
			child->GetData()->GetRange(b,e);

			//prevent assert in GetSubString
			if (e > inPlainText.GetLength())
				e = inPlainText.GetLength();
			if (b > inPlainText.GetLength())
				b = inPlainText.GetLength();

			//if(start < b-1)
			if(start < b)
			{
				inPlainText.GetSubString(start+1, b-start, text);
				ToXMLCompatibleText(text, tmp);
				outTaggedText += tmp;
			}
			
			GenerateSpanText(*child, inPlainText, outTaggedText, defaultStyleInherit);
			start = e;
		}
		
		if(start < end)
		{
			inPlainText.GetSubString(start+1, end-start, text);
			ToXMLCompatibleText(text, tmp);
			outTaggedText += tmp;
		}

	}

	if (addtag)
		outTaggedText +="</SPAN>";
	//JQ 24/12/2012: ensure tagged text is bracketed with SPAN tag
	else if (isInitialEmpty)
	{
		if (!outTaggedText.BeginsWith(CVSTR("<SPAN"), true))
			outTaggedText = CVSTR("<SPAN>")+outTaggedText+CVSTR("</SPAN>");
	}

	if (defaultStyleInherit)
		delete defaultStyleInherit;
}