bool HTMLLexer::ConsumeMultiLineComment( TokenList *ioTokens, sLONG inType ) { // We have to override the default behavior for multiline comment consumption because we define // a bunch of "special" comment types for 4D. So we will let the default consumer do its job, but // we will look at the comment that was consumed afterwards to see if we have a special comment // type. If we do, we need only modify the token's type accordingly. bool ret = VLexerBase::ConsumeMultiLineComment( ioTokens, inType ); // Look at the last token in the list (it should be a comment or an open comment), and grab its text ILexerToken *token = ioTokens->back(); xbox_assert( token->GetType() == ILexerToken::TT_COMMENT || token->GetType() == ILexerToken::TT_OPEN_COMMENT ); // For right now, we only care about finished comments because it makes the logic easier. We don't have to // worry so much about handling the syntax highlighting aspects of things. VString tokenText = token->GetText(); if (token->GetType() == ILexerToken::TT_COMMENT && tokenText.BeginsWith( CVSTR( "<!--#4D" ) )) { // We probably have one of the special comment types. We're going to remove the old token and create a new // one with the appropriate information, but only after we've verified that this isn't just garbage! if (tokenText.BeginsWith( CVSTR( "<!--#4DVAR" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DHTMLVAR" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DINCLUDE" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DACTION" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DSCRIPT" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DMETHOD" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DIF" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DELSE" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DENDIF" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DLOOP" ) ) || tokenText.BeginsWith( CVSTR( "<!--#4DENDLOOP" ) )) { ioTokens->pop_back(); ioTokens->push_back( new HTMLLexerToken( ILexerToken::TT_SPECIAL_4D_COMMENT, token->GetPosition(), token->GetLength(), tokenText, token->GetValue() ) ); } } return ret; }
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; }
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 ); } }
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; }
virtual VError HandleRequest( IHTTPResponse* inResponse) { if (inResponse == NULL) return VE_INVALID_PARAMETER; VError err = VE_OK; bool done = false; // First, extract the relative path from the url VString path = inResponse->GetRequest().GetURLPath(); VRegexMatcher *matcher = VRegexMatcher::Create( fPattern, &err); if ((matcher != NULL) && (err == VE_OK)) { bool match = matcher->Find( path, 1, false, &err); if (match && (err == VE_OK)) { // Remove the pattern from the path path.Remove( matcher->GetGroupStart(0), matcher->GetGroupLength(0)); // Check whether a namespace is specified VString lNamespaceKey( L"namespace="); VString lNamespace = inResponse->GetRequest().GetURLQuery(); if (lNamespace.BeginsWith( lNamespaceKey)) lNamespace.Remove( 1, lNamespaceKey.GetLength()); else lNamespace.Clear(); // Now, we have a relative module path VString proxy; err = fService->GetProxy( proxy, path, lNamespace, &inResponse->GetRequest(), inResponse); if (err == VE_OK) { VString contentType( L"application/javascript"); err = SetHTTPResponseString( inResponse, proxy, &contentType); done = true; } } } ReleaseRefCountable( &matcher); if (!done) err = inResponse->ReplyWithStatusCode( HTTP_NOT_FOUND); return err; }
XBOX::VError VRPCService::GetProxy( XBOX::VString& outProxy, const XBOX::VString& inModulePath, const XBOX::VString& inNamespace, const IHTTPRequest* inRequest, IHTTPResponse* inResponse) { VError err = VE_OK; outProxy.Clear(); if (fApplication != NULL) { VRIAContext *riaContext = fApplication->RetainNewContext( err); if (err == VE_OK) { VRPCCatalog *catalog = fApplication->RetainRPCCatalog( riaContext, &err, inRequest, inResponse); if (err == VE_OK) { if (catalog != NULL) { MapOfRPCSchema schemas; err = catalog->RetainSchemasByModule( inModulePath, schemas); if (err == VE_OK) { // Build the proxy VFile *bodyFile = NULL, *templateFile = NULL; VFilePath path; VRIAServerApplication::Get()->GetWAFrameworkFolderPath( path); path.ToSubFolder( L"Core").ToSubFolder( L"Runtime").ToSubFolder( L"rpcService"); path.SetFileName( L"proxy-body.js", true); bodyFile = new VFile( path); if (bodyFile == NULL) err = vThrowError( VE_MEMORY_FULL); if (err == VE_OK) { path.SetFileName( L"proxy-template.js", true); templateFile = new VFile( path); if (templateFile == NULL) err = vThrowError( VE_MEMORY_FULL); } if (err == VE_OK && bodyFile->Exists() && templateFile->Exists()) { VString templateString; VFileStream bodyStream( bodyFile); VFileStream templateStream( templateFile); err = bodyStream.OpenReading(); if (err == VE_OK) templateStream.OpenReading(); if (err == VE_OK) err = bodyStream.GetText( outProxy); if (err == VE_OK) { VValueBag bag; bag.SetString( L"rpc-pattern", fPatternForMethods); bag.SetString( L"publishInGlobalNamespace", (fPublishInClientGlobalNamespace) ? L"true" : L"false"); outProxy.Format( &bag); } if (err == VE_OK) err = templateStream.GetText( templateString); if (err == VE_OK) { if (templateString.BeginsWith( L"/*")) { // sc 28/08/2014, remove the copyright VIndex end = templateString.Find( L"*/"); if (end > 0) { templateString.Remove( 1, end + 1); } } for (MapOfRPCSchema::const_iterator iter = schemas.begin() ; iter != schemas.end() ; ++iter) { VValueBag bag; bag.SetString( L"function-name", iter->first.GetMethodName()); bag.SetString( L"namespace", inNamespace); bag.SetString( L"modulePath", inModulePath); VString proxy( templateString); proxy.Format( &bag); outProxy.AppendString( proxy); } } bodyStream.CloseReading(); templateStream.CloseReading(); } else { err = vThrowError( VE_FILE_NOT_FOUND); } QuickReleaseRefCountable( bodyFile); QuickReleaseRefCountable( templateFile); } } else { err = vThrowError( VE_RIA_RPC_CATALOG_NOT_FOUND); } } } ReleaseRefCountable( &riaContext); } return err; }
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; }
bool VHTMLSyntax::IsComment( ICodeEditorDocument* inDocument, const VString& inString ) { return inString.BeginsWith( CVSTR( "<!--" ) ) && inString.EndsWith( CVSTR( "-->" ) ); }