Problem with the default background colour in TDBWPRichText

  • Delphi 2007/XE
    WPTools 6.13.3

    Selecting the default background colour (first white colour at the top of the colour palette) in TDBWPRichText adds cb0 code to the rtf:

    Code
    {\rtf1\ansi\deff0\uc1\ansicpg1252\deftab2440{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset2 Wingdings;}{\f2\fnil\fcharset2 Symbol;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;}\wpprheadfoot1\paperw11906\paperh16838\margl760\margr1880\margt760\margb760\headery254\footery254\endnhere\sectdefaultcl{\*\generator WPTools_6.060;}{\plain\f0\fs22\cb0 testing text background colour\par  }}

    which seems to be incorrect as cb0 is \colortbl\red0\green0\blue0 which is black colour. Therefore on opening the document like this in other rtf components, the text is highlighted with black colour.

    Opening the same rtf on MS Word or WordPad won't show the problem as they both ignore \cb code. Instead they use \highlight. Starting from WPTools 6.06 there was a new option introduced "-writehighlight" to use \highlight instead of \cb. Setting this option and creating the rtf document in TDBWPRichText will generate:

    Code
    {\rtf1\ansi\deff0\uc1\ansicpg1252\deftab2440{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset2 Wingdings;}{\f2\fnil\fcharset2 Symbol;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;}\wpprheadfoot1\paperw11906\paperh16838\margl760\margr1880\margt760\margb760\headery254\footery254\endnhere\sectdefaultcl{\*\generator WPTools_6.060;}{\plain\f0\fs22\highlight0 testing text background colour\par  }}

    Opening this rtf in MS Word & WordPad will show the text highlighted with black colour.

    Einmal editiert, zuletzt von Chys (12. November 2010 um 03:59)

    • Offizieller Beitrag

    This is rather a problem with the GUI. It should know that the first color is neutral.

    I guess it can be fiexed by adding one in in WPCtrRich:

    procedure TWPSetModeControl.SetBKColor(x: Integer);
    begin

    if n then n := -1; //<----

    if Cursor.IsSelected then
    Cursor.SelectedTextAttr.SetBGColorNr(x)
    else Cursor.WritingTextAttr.SetBGColorNr(x);
    end;

  • I apologies. Version is 6.13.3.

    Zitat von wpsupport

    if n then n := -1; //<----


    Did you mean x instead of n? :)

    Zitat

    It should know that the first color is neutral.


    Same for procedure TWPSetModeControl.SetColor(x: Integer); as it sets cf0 when the default is selected? It works fine as \colortbl\red0\green0\blue0 which is black, but to be consistent perhaps the same change needs to be applied to SetColor?