v2.1.1 大量更新,功能性更新见readme

This commit is contained in:
csh
2025-05-30 14:44:32 +08:00
parent f816e8b6e3
commit b7a7b983b3
20 changed files with 25299 additions and 13986 deletions
+9 -3
View File
@@ -3,12 +3,14 @@ public
function Create();
function Init();virtual;
function InitZip(zip: ZipFile);
function NewFile(): tableArray;
function Open(alias: string; file: string; password: string): tableArray;
function Save(): array of info; // array(err, errmsg)
function SaveAs(alias: string; file: string): array of info;
function Zip(): ZipFile;
protected
function DefaultBinaryData(): binary;virtual;
function GetProp(_variable: tslobj; _name: string): tslobj;
function GetPropArr(_variable: tslobj; _name: string; _index: integer): tslobj;
function NewObject(_name: string): tslobj;virtual;
@@ -16,22 +18,26 @@ protected
protected
zipfile_: ZipFile;
conf_: tableArray;
end;
function TSComponentsBase.Create();
begin
{self.}Init();
end;
function TSComponentsBase.InitZip(zip: ZipFile);
begin
{self.}Init();
zipfile_ := zip;
end;
function TSComponentsBase.NewFile(): tableArray;
begin
zipfile_ := new ZipFile();
return zipfile_.LoadFromMem({self.}DefaultBinaryData());
end;
function TSComponentsBase.Open(alias: string; file: string; password: string): tableArray;
begin
{self.}Init();
zipfile_ := new ZipFile();
return zipfile_.Open(alias, file, password);
end;
+103 -15
View File
@@ -1,7 +1,8 @@
type TSOfficeContainer = class
public
function Create(arr: array of string);
function Set(data: any): boolean; // 设置data数据
function Set(data: any): boolean;overload; // 设置data数据
function Set(name: string; index: integer; data: any): boolean;overload;
function Add(data: any): boolean;
function Append(data: any): boolean;
function Insert(data: any): boolean;
@@ -16,7 +17,8 @@ private
bucket_: array of LinkList;
child_: array of string;
current_index_: integer;
last_index_: integer;
min_index_; integer;
max_index_: integer;
end;
type LinkList = class
@@ -47,22 +49,88 @@ function TSOfficeContainer.Create(arr: array of string);
begin
bucket_ := array();
child_ := array();
min_index_ := 0;
max_index_ := 0;
for str,v in arr do
begin
child_[str] := v[0];
last_index_ := v[0];
if v[0] > max_index_ then max_index_ := v[0];
if v[0] < min_index_ then min_index_ := v[0];
end
current_index_ := -1;
current_index_ := -INF;
end;
function TSOfficeContainer.Set(data: any): boolean;
function TSOfficeContainer.Set(data: any): boolean;overload;
begin
obj := {self.}GetBucketObj(data.ElementName);
if ifnil(obj) then return false;
obj.Add(data);
obj.Set(data);
return true;
end;
function TSOfficeContainer.Set(name: string; index: integer; data: any): boolean;overload;
begin
ind := child_[name];
obj := bucket_[ind];
if ifObj(obj) and obj.Name() = name then
begin
node := obj.First();
while ifObj(node) do
begin
if node.data.Removed then
begin
node := node.next;
continue;
end
index--;
if index = -1 then
begin
new_node := new Node();
new_node.data := data;
new_node.next := node.next;
node.data.Removed := true;
node.next := new_node;
if tail_ = node then
tail_ := new_node;
return true;
end
node := node.next;
end
end
i := max_index_ + 1;
for i:=max_index_+1 to current_index_ do
begin
if i = ind then continue;
obj := bucket_[i];
if ifObj(obj) and obj.Name() = name then
begin
node := obj.First();
while ifObj(node) do
begin
if node.data.Remove then
begin
node := node.next;
continue;
end
index--;
if index = -1 then
begin
new_node := new Node();
new_node.data := data;
new_node.next := node.next;
node.data.Removed := true;
node.next := new_node;
if tail_ = node then
tail_ := new_node;
return true;
end
node := node.next;
end
end
end
return false;
end;
function TSOfficeContainer.Add(data: any): boolean;
begin
obj := {self.}GetBucketObj(data.ElementName);
@@ -80,7 +148,7 @@ begin
if ifObj(obj) and obj.Name() = data.ElementName then obj.Add(data);
else begin
obj := new LinkList(data.ElementName);
current_index_ := current_index_ > last_index_ ? current_index_ + 1 : last_index_ + 1;
current_index_ := current_index_ > max_index_ ? current_index_ + 1 : max_index_ + 1;
bucket_[current_index_] := obj;
obj.Add(data);
end
@@ -102,7 +170,7 @@ end;
function TSOfficeContainer.Insert(data: any): boolean;
begin
i := last_index_ + 1;
i := max_index_ + 1;
while i <= current_index_ do
begin
obj := bucket_[i];
@@ -129,7 +197,7 @@ end;
function TSOfficeContainer.GetElements(include_removed: boolean = true): array of tslobj;
begin
arr := array();
for i:=0 to current_index_ do
for i:=min_index_ to current_index_ do
begin
obj := bucket_[i];
if ifObj(obj) then
@@ -151,33 +219,43 @@ begin
ind := child_[name];
arr := array();
obj := bucket_[ind];
if ifObj(obj) then
if ifObj(obj) and obj.Name() = name then
begin
node := obj.First();
while ifObj(node) do
begin
if node.data.Removed then
begin
node := node.next;
continue;
end
arr[length(arr)] := node.data;
index--;
if index = -1 then return node.data;
node := node.next;
end
end
i := last_index_ + 1;
while i <= current_index_ do
i := max_index_ + 1;
for i:=max_index_+1 to current_index_ do
begin
if i = ind then continue;
obj := bucket_[i];
if ifObj(obj) and obj.Name() = name then
begin
node := obj.First();
while ifObj(node) do
begin
if node.data.Removed then
begin
node := node.next;
continue;
end
arr[length(arr)] := node.data;
index--;
if index = -1 then return node.data;
node := node.next;
end
end
i++;
end
return arr;
end;
@@ -208,8 +286,18 @@ function LinkList.Set(data: any)
begin
node := new Node();
node.data := data;
head_.next := node;
tail_ := node;
if tail_ <> head_ then
begin
tail_.data.Removed := true;
tail_.next := node;
tail_ := node;
size_++;
end
else begin
head_.next := node;
tail_ := node;
size_ := 1;
end
end;
function LinkList.Add(data: any)
+17 -2
View File
@@ -1,16 +1,24 @@
unit TSSafeUnitConverter;
interface
function PointsToTwips(value): real;
function TwipsToPoints(value): real;
function EmusToPoints(value): real;
function HalfPointToPoints(value): real;
function PercentToNumber(value): real;
function NumberToPercent(value): real;
function ToInt(value): integer;
function EighthPointToPoints(value): real;
implementation
uses TSUnitConverter;
function PointsToTwips(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.PointsToTwips(new_value);
end;
function TwipsToPoints(value): real;
begin
if ifNil(value) then return 0;
@@ -39,10 +47,17 @@ uses TSUnitConverter;
return TSUnitConverter.PercentToNumber(new_value);
end;
function NumberToPercent(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.NumberToPercent(new_value);
end;
function ToInt(value): integer;
begin
if ifNil(value) then return 0;
return tryStrtoInt(value, r) ? r : 0;
return strtoIntDef(value, 0);
end;
function EighthPointToPoints(value): real;
+12
View File
@@ -1,13 +1,20 @@
unit TSUnitConverter;
interface
function PointsToTwips(value): real;
function TwipsToPoints(value: real): real;
function EmusToPoints(value: real): real;
function HalfPointToPoints(value: real): real;
function EighthPointToPoints(value: real): real;
function PercentToNumber(value: real): real;
function NumberToPercent(value: real): real;
implementation
function PointsToTwips(value): real;
begin
return value * 20;
end;
function TwipsToPoints(value: real): real;
begin
return value / 20;
@@ -28,6 +35,11 @@ implementation
return value / 100;
end;
function NumberToPercent(value: real): real;
begin
return value * 100;
end;
function EighthPointToPoints(value: real): real;
begin
return value / 8;
+7 -7
View File
@@ -1,6 +1,6 @@
type VBABase = class
public
function Create(Par: tslobj; App: Application; Cre: integer);
function Create(_parent: tslobj; _application: Application; _creator: integer);
public
property Application read ReadApplication;
@@ -9,19 +9,19 @@ public
function ReadApplication();
function ReadParent();
function ReadCreator();
private
[weakref]parent_: tslobj;
[weakref]application_: Application;
creator_: integer;
End;
end;
// ============== 实现 ================= //
function VBABase.Create(Par: tslobj; App: Application; Cre: integer);
function VBABase.Create(_parent: tslobj; _application: Application; _creator: integer);
begin
parent_ := Par;
application_ := App;
creator_ := Cre;
parent_ := _parent;
application_ := _application;
creator_ := _creator;
end;
// properties