From 36a750c5734e3fbf7915dd5bf6bbad4a01d712db Mon Sep 17 00:00:00 2001 From: maxim Date: Sun, 3 Jan 2016 12:33:35 +0000 Subject: [PATCH] Merged revision(s) 51086 #170279af46, 51100 #871641c688 from trunk: ipro: Fix non-breaking space character given by numerical value instead of " "; fixes issue #28174. ........ TurboPower_iPro: Fix bgcolor attribute of tables, rows and cells ........ git-svn-id: branches/fixes_1_6@51149 - --- components/turbopower_ipro/iphtml.pas | 47 +++++++++++++------ .../turbopower_ipro/iphtmlblocklayout.pas | 3 +- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/components/turbopower_ipro/iphtml.pas b/components/turbopower_ipro/iphtml.pas index d441b38db6..a693ba8f44 100644 --- a/components/turbopower_ipro/iphtml.pas +++ b/components/turbopower_ipro/iphtml.pas @@ -2718,6 +2718,7 @@ const MaxElements = 1024*1024; ShyChar = #1; {character used to represent soft-hyphen in strings} NbspChar = #2; {character used to represent no-break space in strings} + NbspUtf8 = #194#160; {utf8 code of no-break space character} WheelDelta = 8; const @@ -3229,7 +3230,10 @@ begin {'Complete boolean eval' must be off} if not OnUTF8 and (Index1 >= 32) and (Index1 <= 255) then Result := Chr(Index1) else + begin Result := UnicodeToUTF8(Index1); + if Result = NbspUTF8 then Result := NbspChar; + end; end; end else begin @@ -3316,12 +3320,25 @@ end; function NoBreakToSpace(const S: string): string; var - P : Integer; + P, n : Integer; begin - Result := S; - for P := length(Result) downto 1 do - if Result[P] = NbspChar then - Result[P] := ' '; + SetLength(Result, Length(S)); + n := 0; + P := 1; + while P <= Length(S) do + begin + inc(n); + if S[P] = NbspChar then + Result[n] := ' ' + else if (P < Length(S)) and (S[P] = NbspUtf8[1]) and (S[P+1] = NbspUtf8[2]) then + begin + Result[n] := ' '; + inc(P); + end else + Result[n] := S[P]; + inc(P); + end; + SetLength(Result, n); end; procedure SetRawWordValue(Entry: PIpHtmlElement; const Value: string); @@ -6318,6 +6335,7 @@ begin FixupPercentages(CurRow); CurRow := TIpHtmlNodeTR.Create(Parent); CurRow.ParseBaseProps(Self); + CurRow.BgColor := ColorFromString(FindAttribute(htmlAttrBGCOLOR)); CurRow.Align := ParseAlignment; CurRow.VAlign := ParseVAlignment; CurRow.LoadAndApplyCSSProps; @@ -6443,11 +6461,11 @@ begin Border := ParseInteger(htmlAttrBORDER, 0); CellSpacing := ParseInteger(htmlAttrCELLSPACING, 2); CellPadding := ParseInteger(htmlAttrCELLPADDING, 2); + BgColor := ColorFromString(FindAttribute(htmlAttrBGCOLOR)); ParseBaseProps(Self); Summary := FindAttribute(htmlAttrSUMMARY); Frame := ParseFrameProp(Frame); Rules := ParseRules(Rules); - BgColor := ColorFromString(FindAttribute(htmlAttrBGCOLOR)); end; repeat @@ -9259,7 +9277,7 @@ begin case CurElem.ElementType of etWord : - begin + if CurElem.AnsiWord <> NAnchorChar then begin S := S + NoBreakToSpace(CurElem.AnsiWord); LFDone := False; end; @@ -10096,10 +10114,14 @@ var aCanvas : TCanvas; begin aCanvas := Owner.Target; + + Props.BGColor := BGColor; if (Props.BGColor <> -1) and PageRectToScreen(BorderRect, R) then begin - aCanvas.Brush.Color := Props.BGColor; + aCanvas.Brush.Color :=Props.BGColor; aCanvas.FillRect(R); - end; + end + else if (Props.BGColor = -1) then + aCanvas.Brush.Style := bsClear; aCanvas.Pen.Color := clBlack; Al := Props.VAlignment; @@ -10138,11 +10160,8 @@ begin end; // set TR color, Render override them anyway if TD/TH have own settings - if TrBgColor <> -1 then - Props.BGColor := TrBgColor; - - if TrTextColor <> -1 then - Props.FontColor := TrTextColor; + Props.BGColor := TrBgColor; + Props.FontColor := TrTextColor; Props.VAlignment := Al; Render(Props); diff --git a/components/turbopower_ipro/iphtmlblocklayout.pas b/components/turbopower_ipro/iphtmlblocklayout.pas index b2db7ea91b..2ef317a738 100644 --- a/components/turbopower_ipro/iphtmlblocklayout.pas +++ b/components/turbopower_ipro/iphtmlblocklayout.pas @@ -1480,7 +1480,8 @@ begin begin FIpHtml.Target.Brush.Color := Props.BGColor; FIpHtml.Target.FillRect(R); - end; + end else + FIpHtml.Target.Brush.Style := bsClear; end; Props.DelayCache:=False; inherited Render(Props);