HotXLS Docs

XlsGetDrawingThemeColor function

Unit: lxHandle
Recovers the theme idx + tint a caller previously passed into XlsApplyThemeColorToDrawing for a given drawing color slot. Returns True with both out values populated when the workbook's in-memory side-table has an entry for the slot; returns False otherwise so the caller can fall through to ColorFormat.RGB. Available since v2.64.0 (chart backlog wave D phase 7).

Syntax

function XlsGetDrawingThemeColor(
  ColorFormat : TXLSColorFormat;
  Workbook    : TXLSWorkbook;
  out ThemeIdx: Word;
  out Tint    : Double): Boolean;

Parameters

ColorFormat — the drawing color slot to query (same handle that was passed to XlsApplyThemeColorToDrawing).
Workbook — the host TXLSWorkbook — the side-table lives on the workbook instance, not the color slot.
ThemeIdx (out) — the recorded 0-based theme slot when the function returns True; 0 otherwise.
Tint (out) — the recorded tint in the range -1.0 .. +1.0 when the function returns True; 0 otherwise.

Remarks

The side-table is keyed by (ColorFormat._Container, ColorFormat._Pid) — the same key the setter uses. Same shape + same property id always lands on the same entry, so successive XlsApplyThemeColorToDrawing calls overwrite each other rather than accumulating history.
Single-process scope. The side-table is not serialised to disk — BIFF8 OfficeArt has no theme color slot in its on-disk format, so the theme intent itself cannot be persisted, only the resolved RGB is. After SaveAs or Open, the workbook is a fresh TXLSWorkbook instance whose side-table is empty, and this getter returns False for every query. Application code that needs persistent intent should keep its own state alongside the workbook.
Calling the getter with a slot that was set via plain ColorFormat.RGB (instead of XlsApplyThemeColorToDrawing) also returns False — there was no theme intent to remember, the RGB is the source of truth.

Example

Walks the first worksheet's shapes and writes the theme idx + tint to the log when one is present, falling back to the raw RGB otherwise.

var
  i        : Integer;
  Shape    : TXLSShape;
  ThemeIdx : Word;
  Tint     : Double;
begin
  for i := 0 to Workbook.Worksheets[1].Shapes.Count - 1 do
  begin
    Shape := Workbook.Worksheets[1].Shapes.Items[i];

    if XlsGetDrawingThemeColor(Shape.Fill.ForeColor, Workbook, ThemeIdx, Tint)
    then
      LogLine(Format('shape %d: theme=%d tint=%.2f', [i, ThemeIdx, Tint]))
    else
      LogLine(Format('shape %d: rgb=%.8x',         [i, Shape.Fill.ForeColor.RGB]));
  end;
end;

See also