#include "hbclass.ch" CREATE CLASS TText FROM TObjectBase DATA cText INIT Chr( 34 ) + "Texto" + Chr( 34 ) DATA cFontFamily INIT "Arial" DATA nFontSize INIT 12 DATA nFontOutPrecision INIT 0 DATA nFontPitchAndFamily INIT 0 DATA lFontBold INIT .F. DATA cFontBoldFormula INIT "" DATA lFontItalic INIT .F. DATA cFontItalicFormula INIT "" DATA lFontUnderline INIT .F. DATA cFontUnderlineFormula INIT "" DATA lFontStrikeout INIT .F. DATA cFontStrikeoutFormula INIT "" DATA lTextWrap INIT .T. DATA lAllowPageBreak INIT .F. DATA nLineSpacing INIT 0 DATA nParagraphSpacing INIT 0 DATA lKeepEmptyParagraphs INIT .T. DATA lTextAdjusted INIT .F. DATA lTrimSpaces INIT .F. DATA cTextFlowGroup INIT "" DATA nTextFlowOrder INIT 0 DATA nTextFlowLineHeight INIT 0 DATA cTextColor INIT "#000000" DATA cTextColorFormula INIT "" DATA nTextOpacity INIT 1 DATA cTextAlign INIT "left" DATA nTextDecimalPosition INIT -10 DATA cTextVerticalAlign INIT "top" DATA cLl12SourceType INIT "" DATA cLl12SourceJson INIT "" DATA uTextFormulaPlan INIT NIL DATA cTextFormulaPlanSource INIT "" DATA hStaticRenderPrototype INIT NIL METHOD New( oParent ) CONSTRUCTOR METHOD Init( oParent ) METHOD Create() METHOD End() METHOD Save() METHOD Load( hData ) METHOD GenerarRenderizable( oContextoEjecucion ) HIDDEN: METHOD NormalizarTextColor( uColor ) METHOD NormalizarTextVerticalAlign( uAlign ) METHOD NormalizarOpacity( uValue ) METHOD NormalizarParrafosVacios( cText ) METHOD ContarParrafosVacios( cText ) METHOD HashHasKey( hHash, cKey ) METHOD HashGet( hHash, cKey, uDefault ) METHOD EsHex6( cColor ) METHOD EsHex3( cColor ) METHOD EsHex8Transparente( cColor ) METHOD EsRgbaTransparente( cColor ) METHOD CanUseStaticRenderPrototype() METHOD BuildStaticRenderPrototype() METHOD ApplyDynamicRenderValues( hRender, cTexto, nSuppressedParagraphs ) ENDCLASS METHOD New( oParent ) CLASS TText ::Init( oParent ) RETURN Self METHOD Init( oParent ) CLASS TText ::oParent := oParent ::cName := "Texto" ::cType := "TText" ::cText := Chr( 34 ) + "Texto" + Chr( 34 ) ::cFontFamily := "Arial" ::nFontSize := 12 ::nFontOutPrecision := 0 ::nFontPitchAndFamily := 0 ::lFontBold := .F. ::cFontBoldFormula := "" ::lFontItalic := .F. ::cFontItalicFormula := "" ::lFontUnderline := .F. ::cFontUnderlineFormula := "" ::lFontStrikeout := .F. ::cFontStrikeoutFormula := "" ::lTextWrap := .T. ::lAllowPageBreak := .F. ::nLineSpacing := 0 ::nParagraphSpacing := 0 ::lKeepEmptyParagraphs := .T. ::lTextAdjusted := .F. ::lTrimSpaces := .F. ::cTextFlowGroup := "" ::nTextFlowOrder := 0 ::nTextFlowLineHeight := 0 ::cTextColor := "#000000" ::cTextColorFormula := "" ::nTextOpacity := 1 ::cTextAlign := "left" ::nTextDecimalPosition := -10 ::cTextVerticalAlign := "top" ::cLl12SourceType := "" ::cLl12SourceJson := "" ::uTextFormulaPlan := NIL ::cTextFormulaPlanSource := "" ::hStaticRenderPrototype := NIL ::lBorderTop := .F. ::lBorderRight := .F. ::lBorderBottom := .F. ::lBorderLeft := .F. RETURN Self METHOD Create() CLASS TText RETURN Self METHOD End() CLASS TText ::oParent := NIL ::uTextFormulaPlan := NIL ::cTextFormulaPlanSource := "" ::hStaticRenderPrototype := NIL RETURN NIL METHOD Save() CLASS TText LOCAL hData := ::Super:Save() hData[ "cText" ] := ::cText hData[ "cFontFamily" ] := ::cFontFamily hData[ "nFontSize" ] := ::nFontSize hData[ "nFontOutPrecision" ] := ::nFontOutPrecision hData[ "nFontPitchAndFamily" ] := ::nFontPitchAndFamily hData[ "lFontBold" ] := ::lFontBold hData[ "cFontBoldFormula" ] := ::cFontBoldFormula hData[ "lFontItalic" ] := ::lFontItalic hData[ "cFontItalicFormula" ] := ::cFontItalicFormula hData[ "lFontUnderline" ] := ::lFontUnderline hData[ "cFontUnderlineFormula" ] := ::cFontUnderlineFormula hData[ "lFontStrikeout" ] := ::lFontStrikeout hData[ "cFontStrikeoutFormula" ] := ::cFontStrikeoutFormula hData[ "lTextWrap" ] := ::lTextWrap hData[ "lAllowPageBreak" ] := ::lAllowPageBreak hData[ "nLineSpacing" ] := ::nLineSpacing hData[ "nParagraphSpacing" ] := ::nParagraphSpacing hData[ "lKeepEmptyParagraphs" ] := ::lKeepEmptyParagraphs hData[ "lTextAdjusted" ] := ::lTextAdjusted hData[ "lTrimSpaces" ] := ::lTrimSpaces hData[ "cTextFlowGroup" ] := ::cTextFlowGroup hData[ "nTextFlowOrder" ] := ::nTextFlowOrder hData[ "nTextFlowLineHeight" ] := ::nTextFlowLineHeight hData[ "cTextColor" ] := ::NormalizarTextColor( ::cTextColor ) hData[ "cTextColorFormula" ] := ::cTextColorFormula hData[ "nTextOpacity" ] := ::NormalizarOpacity( ::nTextOpacity ) hData[ "cTextAlign" ] := ::cTextAlign hData[ "nTextDecimalPosition" ] := ::nTextDecimalPosition hData[ "cTextVerticalAlign" ] := ::NormalizarTextVerticalAlign( ::cTextVerticalAlign ) hData[ "cLl12SourceType" ] := ::cLl12SourceType hData[ "cLl12SourceJson" ] := ::cLl12SourceJson RETURN hData METHOD Load( hData ) CLASS TText LOCAL cFormula := "" LOCAL cFormulaValue := "" IF HB_ISHASH( hData ) .AND. hb_HHasKey( hData, "cFormula" ) cFormulaValue := ::ValorAString( hData[ "cFormula" ] ) cFormula := AllTrim( cFormulaValue ) ENDIF ::Super:Load( hData ) IF HB_ISHASH( hData ) IF ! Empty( cFormula ) ::cText := cFormulaValue ELSEIF ::HashHasKey( hData, "cText" ) ::cText := ::ValorAString( ::HashGet( hData, "cText", ::cText ) ) ENDIF IF ::HashHasKey( hData, "cFontFamily" ) ::cFontFamily := ::ValorAString( ::HashGet( hData, "cFontFamily", ::cFontFamily ) ) ELSEIF ::HashHasKey( hData, "cFontName" ) ::cFontFamily := ::ValorAString( ::HashGet( hData, "cFontName", ::cFontFamily ) ) ENDIF IF ::HashHasKey( hData, "nFontSize" ) ::nFontSize := ::HashGet( hData, "nFontSize", ::nFontSize ) ENDIF ::nFontOutPrecision := ::ValorAEntero( ::HashGet( hData, "nFontOutPrecision", 0 ) ) ::nFontPitchAndFamily := ::ValorAEntero( ::HashGet( hData, "nFontPitchAndFamily", 0 ) ) IF ::HashHasKey( hData, "lFontBold" ) ::lFontBold := ::ValorALogico( ::HashGet( hData, "lFontBold", ::lFontBold ) ) ENDIF ::cFontBoldFormula := ::ValorAString( ::HashGet( hData, "cFontBoldFormula", "" ) ) IF ::HashHasKey( hData, "lFontItalic" ) ::lFontItalic := ::ValorALogico( ::HashGet( hData, "lFontItalic", ::lFontItalic ) ) ENDIF ::cFontItalicFormula := ::ValorAString( ::HashGet( hData, "cFontItalicFormula", "" ) ) IF ::HashHasKey( hData, "lFontUnderline" ) ::lFontUnderline := ::ValorALogico( ::HashGet( hData, "lFontUnderline", ::lFontUnderline ) ) ENDIF ::cFontUnderlineFormula := ::ValorAString( ::HashGet( hData, "cFontUnderlineFormula", "" ) ) IF ::HashHasKey( hData, "lFontStrikeout" ) ::lFontStrikeout := ::ValorALogico( ::HashGet( hData, "lFontStrikeout", ::lFontStrikeout ) ) ENDIF ::cFontStrikeoutFormula := ::ValorAString( ::HashGet( hData, "cFontStrikeoutFormula", "" ) ) IF ::HashHasKey( hData, "lTextWrap" ) ::lTextWrap := HB_ISLOGICAL( ::HashGet( hData, "lTextWrap", NIL ) ) .AND. ::HashGet( hData, "lTextWrap", NIL ) ENDIF IF ::HashHasKey( hData, "lAllowPageBreak" ) ::lAllowPageBreak := ::ValorALogico( ::HashGet( hData, "lAllowPageBreak", .F. ) ) ENDIF IF ::HashHasKey( hData, "nLineSpacing" ) ::nLineSpacing := ::ValorANumero( ::HashGet( hData, "nLineSpacing", 0 ) ) ENDIF IF ::HashHasKey( hData, "nParagraphSpacing" ) ::nParagraphSpacing := ::ValorANumero( ::HashGet( hData, "nParagraphSpacing", 0 ) ) ENDIF IF ::HashHasKey( hData, "lKeepEmptyParagraphs" ) ::lKeepEmptyParagraphs := ::ValorALogico( ::HashGet( hData, "lKeepEmptyParagraphs", .T. ) ) ENDIF IF ::HashHasKey( hData, "lTextAdjusted" ) ::lTextAdjusted := ::ValorALogico( ::HashGet( hData, "lTextAdjusted", .F. ) ) ENDIF IF ::HashHasKey( hData, "lTrimSpaces" ) ::lTrimSpaces := ::ValorALogico( ::HashGet( hData, "lTrimSpaces", .F. ) ) ENDIF IF ::HashHasKey( hData, "cTextFlowGroup" ) ::cTextFlowGroup := ::ValorAString( ::HashGet( hData, "cTextFlowGroup", "" ) ) ENDIF IF ::HashHasKey( hData, "nTextFlowOrder" ) ::nTextFlowOrder := Int( ::ValorANumero( ::HashGet( hData, "nTextFlowOrder", 0 ) ) ) ENDIF IF ::HashHasKey( hData, "nTextFlowLineHeight" ) ::nTextFlowLineHeight := ::ValorANumero( ::HashGet( hData, "nTextFlowLineHeight", 0 ) ) ENDIF IF ::HashHasKey( hData, "cTextColor" ) ::cTextColor := ::NormalizarTextColor( ::HashGet( hData, "cTextColor", ::cTextColor ) ) ENDIF IF ::HashHasKey( hData, "cTextColorFormula" ) ::cTextColorFormula := ::ValorAString( ::HashGet( hData, "cTextColorFormula", ::cTextColorFormula ) ) ENDIF IF ::HashHasKey( hData, "nTextOpacity" ) ::nTextOpacity := ::NormalizarOpacity( ::HashGet( hData, "nTextOpacity", ::nTextOpacity ) ) ENDIF IF ::HashHasKey( hData, "cTextAlign" ) ::cTextAlign := ::ValorAString( ::HashGet( hData, "cTextAlign", ::cTextAlign ) ) ENDIF IF ::HashHasKey( hData, "nTextDecimalPosition" ) ::nTextDecimalPosition := ::ValorANumero( ::HashGet( hData, "nTextDecimalPosition", ::nTextDecimalPosition ) ) ENDIF IF ::HashHasKey( hData, "cTextVerticalAlign" ) ::cTextVerticalAlign := ::NormalizarTextVerticalAlign( ::HashGet( hData, "cTextVerticalAlign", ::cTextVerticalAlign ) ) ELSEIF ::HashHasKey( hData, "cVerticalAlign" ) ::cTextVerticalAlign := ::NormalizarTextVerticalAlign( ::HashGet( hData, "cVerticalAlign", ::cTextVerticalAlign ) ) ENDIF ::cLl12SourceType := ::ValorAString( ::HashGet( hData, "cLl12SourceType", "" ) ) ::cLl12SourceJson := ::ValorAString( ::HashGet( hData, "cLl12SourceJson", "" ) ) ENDIF ::uTextFormulaPlan := NIL ::cTextFormulaPlanSource := "" ::hStaticRenderPrototype := NIL RETURN Self METHOD GenerarRenderizable( oContextoEjecucion ) CLASS TText LOCAL cTexto LOCAL cTextColor LOCAL cBackgroundColor LOCAL cBorderColor LOCAL cShadowColor LOCAL hPadding LOCAL hRender LOCAL nSuppressedParagraphs := 0 LOCAL lFontBold LOCAL lFontItalic LOCAL lFontUnderline LOCAL lFontStrikeout IF ! ::EsVisibleEnEjecucion( oContextoEjecucion ) RETURN NIL ENDIF IF !( ::cTextFormulaPlanSource == ::cText ) IF __objHasMsg( oContextoEjecucion, "COMPILARPLANFORMULA" ) ::uTextFormulaPlan := oContextoEjecucion:CompilarPlanFormula( ::cText ) ELSE ::uTextFormulaPlan := NIL ENDIF IF ! HB_ISHASH( ::uTextFormulaPlan ) ::uTextFormulaPlan := .F. ENDIF ::cTextFormulaPlanSource := ::cText ENDIF IF HB_ISHASH( ::uTextFormulaPlan ) .AND. ; hb_HHasKey( ::uTextFormulaPlan, "tipo" ) .AND. ; ::uTextFormulaPlan[ "tipo" ] == "value" cTexto := ::ValorAString( ::HashGet( ::uTextFormulaPlan, "valor", "" ) ) ELSEIF __objHasMsg( oContextoEjecucion, "EVALUARPLANFORMULA" ) cTexto := ::ValorAString( oContextoEjecucion:EvaluarPlanFormula( ::uTextFormulaPlan, ::cText ) ) ELSE cTexto := ::ValorAString( oContextoEjecucion:EvaluarFormula( ::cText ) ) ENDIF IF ::lTrimSpaces cTexto := AllTrim( cTexto ) ENDIF IF Len( ::cTextFlowGroup ) > 0 .AND. ! ::lKeepEmptyParagraphs nSuppressedParagraphs := ::ContarParrafosVacios( cTexto ) ENDIF cTexto := ::NormalizarParrafosVacios( cTexto ) IF ::CanUseStaticRenderPrototype() IF ! HB_ISHASH( ::hStaticRenderPrototype ) ::hStaticRenderPrototype := ::BuildStaticRenderPrototype() ENDIF hRender := hb_HClone( ::hStaticRenderPrototype ) ::ApplyDynamicRenderValues( hRender, cTexto, nSuppressedParagraphs ) RETURN hRender ENDIF cTextColor := ::EvaluarColor( oContextoEjecucion, ::cTextColorFormula, ::cTextColor, .T. ) cBackgroundColor := ::EvaluarColor( oContextoEjecucion, ::cBackgroundColorFormula, ::cBackgroundColor ) cBorderColor := ::EvaluarColor( oContextoEjecucion, ::cBorderColorFormula, ::cBorderColor ) cShadowColor := ::EvaluarColor( oContextoEjecucion, ::cShadowColorFormula, ::cShadowColor ) hPadding := ::PaddingRenderizable() lFontBold := iif( Empty( AllTrim( ::cFontBoldFormula ) ), ::lFontBold, ::ValorALogico( oContextoEjecucion:EvaluarFormula( ::cFontBoldFormula ) ) ) lFontItalic := iif( Empty( AllTrim( ::cFontItalicFormula ) ), ::lFontItalic, ::ValorALogico( oContextoEjecucion:EvaluarFormula( ::cFontItalicFormula ) ) ) lFontUnderline := iif( Empty( AllTrim( ::cFontUnderlineFormula ) ), ::lFontUnderline, ::ValorALogico( oContextoEjecucion:EvaluarFormula( ::cFontUnderlineFormula ) ) ) lFontStrikeout := iif( Empty( AllTrim( ::cFontStrikeoutFormula ) ), ::lFontStrikeout, ::ValorALogico( oContextoEjecucion:EvaluarFormula( ::cFontStrikeoutFormula ) ) ) hRender := { ; "id" => ::cId, ; "tipo" => "texto", ; "x" => ::nLeft, ; "y" => ::nTop, ; "ancho" => ::nWidth, ; "alto" => ::nHeight, ; "texto" => cTexto, ; "formula" => ::cText, ; "fuente" => ::cFontFamily, ; "tamano" => ::nFontSize, ; "precisionFuente" => ::nFontOutPrecision, ; "familiaPitchFuente" => ::nFontPitchAndFamily, ; "color" => ::NormalizarTextColor( cTextColor ), ; "opacidadTexto" => ::NormalizarOpacity( ::nTextOpacity ), ; "alineacion" => ::cTextAlign, ; "posicionDecimal" => ::nTextDecimalPosition, ; "alineacionVertical" => ::NormalizarTextVerticalAlign( ::cTextVerticalAlign ), ; "negrita" => lFontBold, ; "cursiva" => lFontItalic, ; "subrayado" => lFontUnderline, ; "tachado" => lFontStrikeout, ; "ajusteLinea" => ::lTextWrap, ; "permiteSaltoPagina" => ::lAllowPageBreak, ; "interlineado" => ::nLineSpacing, ; "espaciadoParrafo" => ::nParagraphSpacing, ; "conservarParrafosVacios" => ::lKeepEmptyParagraphs, ; "ajustado" => ::lTextAdjusted, ; "optimizarEspacios" => ::lTrimSpaces, ; "grupoFlujoTexto" => ::cTextFlowGroup, ; "ordenFlujoTexto" => ::nTextFlowOrder, ; "alturaLineaFlujoTexto" => ::nTextFlowLineHeight, ; "alturaSuprimidaFlujoTexto" => Min( ::nHeight, nSuppressedParagraphs * Max( 0, ::nTextFlowLineHeight ) ), ; "colorFondo" => cBackgroundColor, ; "colorBorde" => cBorderColor, ; "grosorBorde" => ::nBorderWidth, ; "bordeSuperior" => ::lBorderTop, ; "bordeDerecho" => ::lBorderRight, ; "bordeInferior" => ::lBorderBottom, ; "bordeIzquierdo" => ::lBorderLeft, ; "redondeo" => ::nRounded, ; "rotacionOriginal" => ::nRotation, ; "rotacion" => ::nRotation, ; "opacidad" => ::nOpacity, ; "sombraTamano" => ::nShadowSize, ; "sombraTransparencia" => ::nShadowTransparency, ; "sombraColor" => cShadowColor, ; "ordenOriginal" => ::nZIndex, ; "capa" => ::nZIndex, ; "zIndex" => ::nZIndex } hRender[ "paddingSuperior" ] := hPadding[ "paddingSuperior" ] hRender[ "paddingDerecho" ] := hPadding[ "paddingDerecho" ] hRender[ "paddingInferior" ] := hPadding[ "paddingInferior" ] hRender[ "paddingIzquierdo" ] := hPadding[ "paddingIzquierdo" ] RETURN hRender METHOD CanUseStaticRenderPrototype() CLASS TText IF ! HB_ISOBJECT( ::oParent ) .OR. ! __objHasMsg( ::oParent, "CTYPE" ) .OR. !( ::oParent:cType == "TTable" ) RETURN .F. ENDIF RETURN Empty( AllTrim( ::cTextColorFormula ) ) .AND. ; Empty( AllTrim( ::cBackgroundColorFormula ) ) .AND. ; Empty( AllTrim( ::cBorderColorFormula ) ) .AND. ; Empty( AllTrim( ::cShadowColorFormula ) ) .AND. ; Empty( AllTrim( ::cFontBoldFormula ) ) .AND. ; Empty( AllTrim( ::cFontItalicFormula ) ) .AND. ; Empty( AllTrim( ::cFontUnderlineFormula ) ) .AND. ; Empty( AllTrim( ::cFontStrikeoutFormula ) ) METHOD BuildStaticRenderPrototype() CLASS TText LOCAL hPadding := ::PaddingRenderizable() LOCAL hRender := { ; "id" => "", ; "tipo" => "texto", ; "x" => 0, ; "y" => 0, ; "ancho" => 0, ; "alto" => 0, ; "texto" => "", ; "formula" => "", ; "fuente" => ::cFontFamily, ; "tamano" => ::nFontSize, ; "precisionFuente" => ::nFontOutPrecision, ; "familiaPitchFuente" => ::nFontPitchAndFamily, ; "color" => ::NormalizarTextColor( ::EvaluarColor( NIL, "", ::cTextColor, .T. ) ), ; "opacidadTexto" => ::NormalizarOpacity( ::nTextOpacity ), ; "alineacion" => ::cTextAlign, ; "posicionDecimal" => ::nTextDecimalPosition, ; "alineacionVertical" => ::NormalizarTextVerticalAlign( ::cTextVerticalAlign ), ; "negrita" => ::lFontBold, ; "cursiva" => ::lFontItalic, ; "subrayado" => ::lFontUnderline, ; "tachado" => ::lFontStrikeout, ; "ajusteLinea" => ::lTextWrap, ; "permiteSaltoPagina" => ::lAllowPageBreak, ; "interlineado" => ::nLineSpacing, ; "espaciadoParrafo" => ::nParagraphSpacing, ; "conservarParrafosVacios" => ::lKeepEmptyParagraphs, ; "ajustado" => ::lTextAdjusted, ; "optimizarEspacios" => ::lTrimSpaces, ; "grupoFlujoTexto" => ::cTextFlowGroup, ; "ordenFlujoTexto" => ::nTextFlowOrder, ; "alturaLineaFlujoTexto" => ::nTextFlowLineHeight, ; "alturaSuprimidaFlujoTexto" => 0, ; "colorFondo" => ::EvaluarColor( NIL, "", ::cBackgroundColor ), ; "colorBorde" => ::EvaluarColor( NIL, "", ::cBorderColor ), ; "grosorBorde" => ::nBorderWidth, ; "bordeSuperior" => ::lBorderTop, ; "bordeDerecho" => ::lBorderRight, ; "bordeInferior" => ::lBorderBottom, ; "bordeIzquierdo" => ::lBorderLeft, ; "redondeo" => ::nRounded, ; "rotacionOriginal" => ::nRotation, ; "rotacion" => ::nRotation, ; "opacidad" => ::nOpacity, ; "sombraTamano" => ::nShadowSize, ; "sombraTransparencia" => ::nShadowTransparency, ; "sombraColor" => ::EvaluarColor( NIL, "", ::cShadowColor ), ; "ordenOriginal" => 0, ; "capa" => 0, ; "zIndex" => 0, ; "paddingSuperior" => hPadding[ "paddingSuperior" ], ; "paddingDerecho" => hPadding[ "paddingDerecho" ], ; "paddingInferior" => hPadding[ "paddingInferior" ], ; "paddingIzquierdo" => hPadding[ "paddingIzquierdo" ] } RETURN hRender METHOD ApplyDynamicRenderValues( hRender, cTexto, nSuppressedParagraphs ) CLASS TText hRender[ "id" ] := ::cId hRender[ "x" ] := ::nLeft hRender[ "y" ] := ::nTop hRender[ "ancho" ] := ::nWidth hRender[ "alto" ] := ::nHeight hRender[ "texto" ] := cTexto hRender[ "formula" ] := ::cText hRender[ "alturaSuprimidaFlujoTexto" ] := Min( ::nHeight, nSuppressedParagraphs * Max( 0, ::nTextFlowLineHeight ) ) hRender[ "ordenOriginal" ] := ::nZIndex hRender[ "capa" ] := ::nZIndex hRender[ "zIndex" ] := ::nZIndex RETURN NIL METHOD NormalizarTextColor( uColor ) CLASS TText LOCAL cColor := Lower( AllTrim( ::ValorAString( uColor ) ) ) IF cColor == "" .OR. cColor == "transparent" RETURN "#000000" ENDIF IF ::EsHex8Transparente( cColor ) .OR. ::EsRgbaTransparente( cColor ) RETURN "#000000" ENDIF IF ::EsHex6( cColor ) RETURN cColor ENDIF IF ::EsHex3( cColor ) RETURN "#" + SubStr( cColor, 2, 1 ) + SubStr( cColor, 2, 1 ) + ; SubStr( cColor, 3, 1 ) + SubStr( cColor, 3, 1 ) + ; SubStr( cColor, 4, 1 ) + SubStr( cColor, 4, 1 ) ENDIF RETURN "#000000" METHOD NormalizarTextVerticalAlign( uAlign ) CLASS TText LOCAL cAlign := Lower( AllTrim( ::ValorAString( uAlign ) ) ) IF cAlign == "bottom" .OR. cAlign == "inferior" RETURN "bottom" ENDIF IF cAlign == "center" .OR. cAlign == "middle" .OR. cAlign == "centro" RETURN "center" ENDIF RETURN "top" METHOD NormalizarOpacity( uValue ) CLASS TText LOCAL nValue IF HB_ISSTRING( uValue ) uValue := StrTran( uValue, ",", "." ) ENDIF nValue := iif( HB_ISNUMERIC( uValue ), uValue, Val( ::ValorAString( uValue ) ) ) RETURN Max( 0.0, Min( 1.0, nValue ) ) METHOD NormalizarParrafosVacios( cText ) CLASS TText LOCAL cNormalized LOCAL cRemaining LOCAL cParagraph LOCAL cResult := "" LOCAL nBreak IF ::lKeepEmptyParagraphs RETURN cText ENDIF cNormalized := StrTran( StrTran( cText, Chr( 13 ) + Chr( 10 ), Chr( 10 ) ), Chr( 13 ), Chr( 10 ) ) cRemaining := cNormalized DO WHILE .T. nBreak := At( Chr( 10 ), cRemaining ) IF nBreak > 0 cParagraph := Left( cRemaining, nBreak - 1 ) cRemaining := SubStr( cRemaining, nBreak + 1 ) ELSE cParagraph := cRemaining ENDIF IF ! Empty( AllTrim( cParagraph ) ) cResult += iif( cResult == "", "", Chr( 10 ) ) + cParagraph ENDIF IF nBreak == 0 EXIT ENDIF ENDDO RETURN cResult METHOD ContarParrafosVacios( cText ) CLASS TText LOCAL cNormalized := StrTran( StrTran( cText, Chr( 13 ) + Chr( 10 ), Chr( 10 ) ), Chr( 13 ), Chr( 10 ) ) LOCAL cRemaining := cNormalized LOCAL cParagraph LOCAL nBreak LOCAL nEmpty := 0 DO WHILE .T. nBreak := At( Chr( 10 ), cRemaining ) IF nBreak > 0 cParagraph := Left( cRemaining, nBreak - 1 ) cRemaining := SubStr( cRemaining, nBreak + 1 ) ELSE cParagraph := cRemaining ENDIF IF Empty( AllTrim( cParagraph ) ) nEmpty++ ENDIF IF nBreak == 0 EXIT ENDIF ENDDO RETURN nEmpty METHOD HashHasKey( hHash, cKey ) CLASS TText LOCAL cHashKey IF ! HB_ISHASH( hHash ) RETURN .F. ENDIF IF hb_HHasKey( hHash, cKey ) .OR. hb_HHasKey( hHash, Upper( cKey ) ) RETURN .T. ENDIF FOR EACH cHashKey IN hb_HKeys( hHash ) IF Lower( ::ValorAString( cHashKey ) ) == Lower( cKey ) RETURN .T. ENDIF NEXT RETURN .F. METHOD HashGet( hHash, cKey, uDefault ) CLASS TText LOCAL cHashKey IF HB_ISHASH( hHash ) IF hb_HHasKey( hHash, cKey ) RETURN hHash[ cKey ] ENDIF IF hb_HHasKey( hHash, Upper( cKey ) ) RETURN hHash[ Upper( cKey ) ] ENDIF FOR EACH cHashKey IN hb_HKeys( hHash ) IF Lower( ::ValorAString( cHashKey ) ) == Lower( cKey ) RETURN hHash[ cHashKey ] ENDIF NEXT ENDIF RETURN uDefault METHOD EsHex6( cColor ) CLASS TText LOCAL nIndex LOCAL nChar IF Len( cColor ) != 7 .OR. Left( cColor, 1 ) != "#" RETURN .F. ENDIF FOR nIndex := 2 TO 7 nChar := Asc( SubStr( cColor, nIndex, 1 ) ) IF !( ( nChar >= 48 .AND. nChar <= 57 ) .OR. ; ( nChar >= 97 .AND. nChar <= 102 ) ) RETURN .F. ENDIF NEXT RETURN .T. METHOD EsHex3( cColor ) CLASS TText LOCAL nIndex LOCAL nChar IF Len( cColor ) != 4 .OR. Left( cColor, 1 ) != "#" RETURN .F. ENDIF FOR nIndex := 2 TO 4 nChar := Asc( SubStr( cColor, nIndex, 1 ) ) IF !( ( nChar >= 48 .AND. nChar <= 57 ) .OR. ; ( nChar >= 97 .AND. nChar <= 102 ) ) RETURN .F. ENDIF NEXT RETURN .T. METHOD EsHex8Transparente( cColor ) CLASS TText RETURN Len( cColor ) == 9 .AND. Right( cColor, 2 ) == "00" .AND. ::EsHex6( Left( cColor, 7 ) ) METHOD EsRgbaTransparente( cColor ) CLASS TText LOCAL nComa := RAt( ",", cColor ) LOCAL cAlpha IF Left( cColor, 5 ) != "rgba(" .OR. Right( cColor, 1 ) != ")" .OR. nComa <= 0 RETURN .F. ENDIF cAlpha := AllTrim( SubStr( cColor, nComa + 1, Len( cColor ) - nComa - 1 ) ) RETURN cAlpha == "0" .OR. cAlpha == "0.0" .OR. cAlpha == ".0" .OR. cAlpha == "0.00" .OR. cAlpha == ".00"