115 lines
3.3 KiB
Plaintext
115 lines
3.3 KiB
Plaintext
Type TSDocxListFormat = Class(TSVbaBase)
|
|
Uses TSDocxEnumerations;
|
|
|
|
public
|
|
Function Init(docx, pPr);
|
|
Function Apply();virtual;
|
|
Function GetNumId(type);
|
|
|
|
protected
|
|
docx_;
|
|
pr_; // TOfficeObj("TwpPr")
|
|
document_;
|
|
|
|
public
|
|
// Methods
|
|
Function ApplyBulletDefault(DefaultListBehavior);virtual;
|
|
Function ApplyListTemplate(ListTemplate, ContinuePreviousList, ApplyTo, DefaultListBehavior);virtual;
|
|
Function ApplyListTemplateWithLevel(ListTemplate, ContinuePreviousList, ApplyTo, DefaultListBehavior, ApplyLevel);virtual;
|
|
Function ApplyNumberDefault(DefaultListBehavior);virtual;
|
|
Function ApplyOutlineNumberDefault(DefaultListBehavior);virtual;
|
|
Function CanContinuePreviousList(ListTemplate);virtual;
|
|
Function ConvertNumbersToText();virtual;
|
|
Function ListIndent();virtual;
|
|
Function ListOutdent();virtual;
|
|
Function RemoveNumbers(NumberType);virtual;
|
|
|
|
// Properties
|
|
property List read ReadList;
|
|
property ListLevelNumber read ReadListLevelNumber write WriteListLevelNumber;
|
|
property ListPictureBullet read ReadListPictureBullet;
|
|
property ListString read ReadListString;
|
|
property ListTemplate read ReadListTemplate;
|
|
property ListType read ReadListType;
|
|
property ListValue read ReadListValue;
|
|
property SingleList read ReadSingleList;
|
|
property SingleListTemplate read ReadSingleListTemplate;
|
|
Function ReadSingleListTemplate();virtual;
|
|
Function ReadSingleList();virtual;
|
|
Function ReadListValue();virtual;
|
|
Function ReadListType();virtual;
|
|
Function ReadListTemplate();virtual;
|
|
Function ReadListString();virtual;
|
|
Function ReadListPictureBullet();virtual;
|
|
Function WriteListLevelNumber(value);virtual;
|
|
Function ReadListLevelNumber();virtual;
|
|
Function ReadList();virtual;
|
|
|
|
End;
|
|
|
|
|
|
// ============== 实现 ================= //
|
|
Function TSDocxListFormat.Init(docx, pr);
|
|
Begin
|
|
docx_ := docx;
|
|
pr_ := pr;
|
|
document_ := self.Parent;
|
|
while not (document_ is class(TSDocxDocument)) do
|
|
document_ := document_.Parent;
|
|
End;
|
|
|
|
Function TSDocxListFormat.GetNumId(type);
|
|
Begin
|
|
numid := document_.GetParam(type);
|
|
if not ifnil(numid) then return numid;
|
|
case type of
|
|
"BulletDefault": numid := docx_.NumberingObject().NumberId("bullet", 0);
|
|
"NumberDefault": numid := docx_.NumberingObject().NumberId("singlelevel", "decimal");
|
|
"OutlineNumberDefault": numid := docx_.NumberingObject().NumberId("multilevel", "decimal");
|
|
end;
|
|
document_.SetParam(type, numid);
|
|
return numid;
|
|
End;
|
|
|
|
Function TSDocxListFormat.Apply();virtual;
|
|
Begin
|
|
pr_.Update("first");
|
|
End;
|
|
|
|
Function TSDocxListFormat.ApplyBulletDefault(DefaultListBehavior);
|
|
Begin
|
|
pr_.NumPr.Level := 0;
|
|
pr_.NumPr.NumId := self.GetNumId("BulletDefault");
|
|
pr_.Update("first");
|
|
End;
|
|
|
|
Function TSDocxListFormat.ApplyNumberDefault(DefaultListBehavior);
|
|
Begin
|
|
pr_.NumPr.Level := 0;
|
|
pr_.NumPr.NumId := self.GetNumId("NumberDefault");
|
|
pr_.Update("first");
|
|
End;
|
|
|
|
Function TSDocxListFormat.ApplyOutlineNumberDefault(DefaultListBehavior);virtual;
|
|
Begin
|
|
get_level := function(obj);
|
|
begin
|
|
if not ifObj(obj) then return '';
|
|
level := obj.HeadingLevel();
|
|
if level = "" then
|
|
begin
|
|
id := obj.Value("BasedOn", true);
|
|
return ##get_level(docx_.StyleObject().GetStyleById(id));
|
|
end
|
|
end
|
|
value := pr_.Value("OutlineLevel");
|
|
if ifnil(value) then
|
|
begin
|
|
obj := docx_.StyleObject().GetStyleById(styleid);
|
|
value := ##get_level(obj);
|
|
end
|
|
pr_.NumPr.Level := value;
|
|
pr_.NumPr.NumId := self.GetNumId("OutlineNumberDefault");
|
|
pr_.Update("first");
|
|
End;
|