+1 800 256 3608 (toll-free in North America) or +49 7531 90 60 10| service@combit.com

Finding Chart field with Delphi DOM


(Guest) #1

I could use some help using the Delphi DOM (non .NET) to locate a chart field in a subtotal line of a table.

Using the code below I am able to locate the text, rtf, html, and drawing fields of any subtotal line by testing the base field class against TLlDOMTableFieldText, TLlDOMTableFieldRTF, TLlDOMTableFieldHTML, and TLlDOMTableFieldDrawing respectively. However, I fail to find in the DOM any corresponding class for chart fields, for example TLlDOMTableFieldChart, so I suspect I’m going about it wrong.

One curious fact though, when I step through the code with the IDE’s debugger and come to the line definition with the chart field, the Fields.Count property is set to the correct number of fields. In other words, the value of Fields.Count includes the chart field! However, when the for loop comes to the position in the Fields array where the chart field should be, llFieldBase is nil.

Any suggestions or comments would be much appreciated.

Thanks In Advance,
Chad

CheckTableLineList(TLlDOMSubItemTable(llSubItem).Lines.GroupFooter);

procedure CheckTableLineList(llTableLineList: TLlDOMTableLineBaseList);
var iLine, iField: Integer;
llFieldBase: TLlDOMTableFieldBase;
begin
// Loop through each line definition
for iLine := 0 to llTableLineList.Count - 1 do
begin
// Loop through each field in the line
for iField := 0 to llTableLineList.Items[iLine].Fields.Count - 1 do
begin
llFieldBase := llTableLineList.Items[iLine].Fields.Items[iField];
if llFieldBase is TLlDOMTableFieldText then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldDrawing then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldRTF then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldBarcode then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldDesignerObject then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldHTML then
ShowMessage(llFieldBase.Name);
end;
end;
end;


(Guest) #2
 Service pack 13.007 was released so I pulled it down and installed it right away.  And I see now that l13dom.pas has a TLlDOMTableFieldChart class!

 Now my problem is trying to read/write to the Axis properties.  The TLlDOMObjectChart class has a "Definition" property that returns an object which in turn gives one access to the ChartEngine, and thus the Axis properties.  However, TLlDOMTableFieldChart's Definition property returns an empty string!?!  Perhaps future service packs will update TLlDOMTableFieldChart.Definition to work similiar too TLlDOMObjectChart.Definition. 

In the meantime, instead of calling TLlDOMTableFieldChart.Definition, call TLlDOMTableFieldChart.GetObject('Definition') and use the TLlDOMPropertyChartDefinition class!  

    baseObj := llChartField.GetObject('Definition');
    llDefinition := TLlDOMPropertyChartDefinition.Create(baseObj);

 Once one adds an overriding constructor to the TLlDOMPropertyChartDefinition class so that the dom handle can be passed in. 

    constructor TLlDOMPropertyChartDefinition.Create(oDom: TLlDOMItem);
    begin
      inherited Create(oDom);
    end;

It works! (…though I think I’ll wait for the offical release before sending this code into the field)

procedure CheckTableLineList(llTableLineList: TLlDOMTableLineBaseList);
var iLine, iField, i: Integer;
llFieldBase: TLlDOMTableFieldBase;
llTextField: TLlDOMTableFieldText;
llChartField: TLlDOMTableFieldChart;
baseObj: TLlDOMItem;
llDefinition : TLlDOMPropertyChartDefinition;
llChartEngine : TLlDOMPropertyChartEnginePie3D;
begin
// Loop through each line definition
for iLine := 0 to llTableLineList.Count - 1 do
begin
// Loop through each field in the line
for iField := 0 to llTableLineList.Items[iLine].Fields.Count - 1 do
begin
llFieldBase := llTableLineList.Items[iLine].Fields.Items[iField];
if llFieldBase is TLlDOMTableFieldText then
begin
llTextField := TLlDOMTableFieldText(llFieldBase);
ShowMessage(llTextField.Contents);
end
else if llFieldBase is TLlDOMTableFieldChart then
begin
llChartField := TLlDOMTableFieldChart(llFieldBase);

    //get Definition Object
    baseObj := llChartField.GetObject('Definition');
    llDefinition := TLlDOMPropertyChartDefinition.Create(baseObj); //must add this overriding constructor
    baseObj.Free;

    if llDefinition.ChartEngine is TLlDOMPropertyChartEnginePie3D then
    begin
      llChartEngine := TLlDOMPropertyChartEnginePie3D(llDefinition.ChartEngine);
      for i := 0 to llChartEngine.YAxis.GetSubObjectCount -1 do
        ShowMessage(llChartEngine.YAxis[i].Value);
    end;
  end;
end;

end;
end;

I could use some help using the Delphi DOM (non .NET) to locate a chart field in a subtotal line of a table.

Using the code below I am able to locate the text, rtf, html, and drawing fields of any subtotal line by testing the base field class against TLlDOMTableFieldText, TLlDOMTableFieldRTF, TLlDOMTableFieldHTML, and TLlDOMTableFieldDrawing respectively. However, I fail to find in the DOM any corresponding class for chart fields, for example TLlDOMTableFieldChart, so I suspect I’m going about it wrong.

One curious fact though, when I step through the code with the IDE’s debugger and come to the line definition with the chart field, the Fields.Count property is set to the correct number of fields. In other words, the value of Fields.Count includes the chart field! However, when the for loop comes to the position in the Fields array where the chart field should be, llFieldBase is nil.

Any suggestions or comments would be much appreciated.

Thanks In Advance,
Chad

CheckTableLineList(TLlDOMSubItemTable(llSubItem).Lines.GroupFooter);

procedure CheckTableLineList(llTableLineList: TLlDOMTableLineBaseList);
var iLine, iField: Integer;
llFieldBase: TLlDOMTableFieldBase;
begin
// Loop through each line definition
for iLine := 0 to llTableLineList.Count - 1 do
begin
// Loop through each field in the line
for iField := 0 to llTableLineList.Items[iLine].Fields.Count - 1 do
begin
llFieldBase := llTableLineList.Items[iLine].Fields.Items[iField];
if llFieldBase is TLlDOMTableFieldText then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldDrawing then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldRTF then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldBarcode then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldDesignerObject then
ShowMessage(llFieldBase.Name)
else if llFieldBase is TLlDOMTableFieldHTML then
ShowMessage(llFieldBase.Name);
end;
end;
end;