OfficeVba/docx/TSDocxRange.tsf

800 lines
26 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Type TSDocxRange = class(TSVbaBase)
Uses TSDocxEnumerations;
public
Function Init(docx, rangeObj);
Function AddParagraph();overload;
Function AddParagraph(direction);overload;
Function AddTable(numRows, numColumns);
Function InsertNewParagraph();
Function Clear(deleteAll);
private
Function CopyRunFormat(sourceRun, destRun);
Function BreakIntoParagraphs(direction);
private
docx_;
range_obj_; // TSWdRange
range_font_; // TSDocxFontRange
range_shading_; // TSDocxShadingRange
paragraph_format_range_; // TSDocxParagraphFormatRange
list_format_range_; // TSDocxListFormatRange
borders_range_; // TSDocxBordersRange
document_; // TSDocxDocument
collapse_;
public
// Methods
Function AutoFormat();
Function Calculate();
Function CheckGrammar();
Function CheckSpelling(CustomDictionary, IgnoreUppercase, AlwaysSuggest, CustomDictionary2, CustomDictionary3, CustomDictionary4, CustomDictionary5, CustomDictionary6, CustomDictionary7, CustomDictionary8, CustomDictionary9, CustomDictionary10);
Function CheckSynonyms();
Function Collapse(Direction);
Function ComputeStatistics(Statistic);
Function ConvertHangulAndHanja(ConversionsMode, FastConversion, CheckHangulEnding, EnableRecentOrdering, CustomDictionary);
Function ConvertToTable(Separator, NumRows, NumColumns, InitialColumnWidth, Format, ApplyBorders, ApplyShading, ApplyFont, ApplyColor, ApplyHeadingRows, ApplyLastRow, ApplyFirstColumn, ApplyLastColumn, AutoFit, AutoFitBehavior, DefaultTableBehavior);
Function Copy();
Function CopyAsPicture();
Function Cut();
Function Delete(_Unit, Count);
Function DetectLanguage();
Function EndOf(_Unit, Extend);
Function Expand(_Unit);
Function ExportAsFixedFormat(OutputFileName, ExportFormat, OpenAfterExport, OptimizeFor, ExportCurrentPage, Item, IncludeDocProps, KeepIRM, CreateBookmarks, DocStructureTags, BitmapMissingFonts, UseISO19005_1, FixedFormatExtClassPtr);
Function ExportAsFixedFormat2(OutputFileName, ExportFormat, OpenAfterExport, OptimizeFor, ExportCurrentPage, Item, IncludeDocProps, KeepIRM, CreateBookmarks, DocStructureTags, BitmapMissingFonts, UseISO19005_1, OptimizeForImageQuality, FixedFormatExtClassPtr);
Function ExportFragment(FileName, Format);
Function GetSpellingSuggestions(CustomDictionary, IgnoreUppercase, MainDictionary, SuggestionMode, CustomDictionary2, CustomDictionary3, CustomDictionary4, CustomDictionary5, CustomDictionary6, CustomDictionary7, CustomDictionary8, CustomDictionary9, CustomDictionary10);
Function GoTo(What, Which, Count, Name);
Function GoToEditableRange(EditorID);
Function GoToNext(What);
Function GoToPrevious(What);
Function ImportFragment(FileName, MatchDestination);
Function InRange(Range);
Function InsertAfter(Text);
Function InsertAlignmentTab(Alignment, RelativeTo);
Function InsertAutoText(Text);
Function InsertBefore(Text);
Function InsertBreak(Type);
Function InsertCaption(_Label, Title, TitleAutoText, Position, ExcludeLabel);
Function InsertCrossReference(ReferenceType, ReferenceKind, ReferenceItem, InsertAsHyperlink, IncludePosition, SeparateNumbers, SeparatorString);
Function InsertDatabase(Format, Style, LinkToSource, Connection, SQLStatement, SQLStatement1, PasswordDocument, PasswordTemplate, WritePasswordDocument, WritePasswordTemplate, DataSource, From_, To_, IncludeFields);
Function InsertDateTime(DateTimeFormat, InsertAsField, InsertAsFullWidth, DateLanguage, CalendarType);
Function InsertFile(FileName, Range, ConfirmConversions, Link, Attachment);
Function InsertParagraph();
Function InsertParagraphAfter();
Function InsertParagraphBefore();
Function InsertSymbol(CharacterNumber, Font, Unicode, Bias);
Function InsertXML(XML, Transform);
Function InStory(Range);
Function IsEqual(Range);
Function LookupNameProperties();
Function ModifyEnclosure(Style, Symbol, EnclosedText);
Function Move(_Unit, Count);
Function MoveEnd(_Unit, Count);
Function MoveEndUntil(Cset, Count);
Function MoveEndWhile(Cset, Count);
Function MoveStart(_Unit, Count);
Function MoveStartUntil(Cset, Count);
Function MoveStartWhile(Cset, Count);
Function MoveUnti(Cset, Count);
Function MoveWhile(Cset, Count);
Function Next(_Unit, Count);
Function NextSubdocument();
Function Paste();
Function PasteAndFormat(Type);
Function PasteAppendTable();
Function PasteAsNestedTable();
Function PasteExcelTable(LinkedToExcel, WordFormatting, RTF);
Function PasteSpecial(IconIndex, Link, Placement, DisplayAsIcon, DataType, IconFileName, IconLabel);
Function PhoneticGuide(Text, Alignment, Raise_, FontSize, FontName);
Function Previous(_Unit, Count);
Function PreviousSubdocument();
Function Relocate(Direction);
Function Select();
Function SetListLevel(Level);
Function SetRange(Start, _End);
Function Sort(ExcludeHeader, FieldNumber, SortFieldType, SortOrder, FieldNumber2, SortFieldType2, SortOrder2, FieldNumber3, SortFieldType3, SortOrder3, SortColumn, Separator, CaseSensitive, BidiSort, IgnoreThe, IgnoreKashida, IgnoreDiacritics, IgnoreHe, LanguageID);
Function SortAscending();
Function SortByHeadings(SortFieldType, SortOrder, CaseSensitive, BidiSort, IgnoreThe, IgnoreKashida, IgnoreDiacritics, IgnoreHe, LanguageID);
Function SortDescending();
Function StartOf(_Unit, Extend);
Function TCSCConverter(WdTCSCConverterDirection, CommonTerms, UseVariants);
Function WholeStory();
// Properties
property Bold read ReadBold write WriteBold;
property BoldBi read ReadBoldBi write WriteBoldBi;
property BookmarkID read ReadBookmarkID;
property Bookmarks read ReadBookmarks;
property Borders read ReadBorders;
property Case_ read ReadCase write WriteCase;
property Cells read ReadCells;
property Characters read ReadCharacters;
property CharacterStyle read ReadCharacterStyle;
property CharacterWidth read ReadCharacterWidth write WriteCharacterWidth;
property Columns read ReadColumns;
property CombineCharacters read ReadCombineCharacters write WriteCombineCharacters;
property Comments read ReadComments;
property Conflicts read ReadConflicts;
property ContentControls read ReadContentControls;
property DisableCharacterSpaceGrid read ReadDisableCharacterSpaceGrid write WriteDisableCharacterSpaceGrid;
property Document read ReadDocument;
property Duplicate read ReadDuplicate;
property Editors read ReadEditors;
property EmphasisMark read ReadEmphasisMark write WriteEmphasisMark;
property _End read ReadEnd write WriteEnd;
property EndnoteOptions read ReadEndnoteOptions;
property Endnotes read ReadEndnotes;
property EnhMetaFileBits read ReadEnhMetaFileBits;
property Fields read ReadFields;
property Find read ReadFind;
property FitTextWidth read ReadFitTextWidth write WriteFitTextWidth;
property Font read ReadFont write WriteFont;
property FootnoteOptions read ReadFootnoteOptions;
property Footnotes read ReadFootnotes;
property FormattedText read ReadFormattedText write WriteFormattedText;
property FormFields read ReadFormFields;
property Frames read ReadFrames;
property GrammarChecked read ReadGrammarChecked write WriteGrammarChecked;
property GrammaticalErrors read ReadGrammaticalErrors;
property HighlightColorIndex read ReadHighlightColorIndex write WriteHighlightColorIndex;
property HorizontalInVertical read ReadHorizontalInVertical write WriteHorizontalInVertical;
property HTMLDivisions read ReadHTMLDivisions;
property Hyperlinks read ReadHyperlinks;
property ID read ReadID write WriteID;
property Information read ReadInformation;
property InlineShapes read ReadInlineShapes;
property IsEndOfRowMark read ReadIsEndOfRowMark;
property Italic read ReadItalic write WriteItalic;
property ItalicBi read ReadItalicBi write WriteItalicBi;
property Kana read ReadKana write WriteKana;
property LanguageDetected read ReadLanguageDetected write WriteLanguageDetected;
property LanguageID read ReadLanguageID write WriteLanguageID;
property LanguageIDFarEast read ReadLanguageIDFarEast write WriteLanguageIDFarEast;
property LanguageIDOther read ReadLanguageIDOther write WriteLanguageIDOther;
property ListFormat read ReadListFormat;
property ListParagraphs read ReadListParagraphs;
property ListStyle read ReadListStyle;
property Locks read ReadLocks;
property NextStoryRange read ReadNextStoryRange;
property NoProofing read ReadNoProofing write WriteNoProofing;
property OMaths read ReadOMaths;
property Orientation read ReadOrientation write WriteOrientation;
property PageSetup read ReadPageSetup;
property ParagraphFormat read ReadParagraphFormat write WriteParagraphFormat;
property Paragraphs read ReadParagraphs;
property ParagraphStyle read ReadParagraphStyle;
property ParentContentControl read ReadParentContentControl;
property PreviousBookmarkID read ReadPreviousBookmarkID;
property ReadabilityStatistics read ReadReadabilityStatistics;
property Revisions read ReadRevisions;
property Rows read ReadRows;
property Scripts read ReadScripts;
property Sections read ReadSections;
property Sentences read ReadSentences;
property Shading read ReadShading;
property ShapeRange read ReadShapeRange;
property ShowAll read ReadShowAll write WriteShowAll;
property SpellingChecked read ReadSpellingChecked write WriteSpellingChecked;
property SpellingErrors read ReadSpellingErrors;
property Start read ReadStart write WriteStart;
property StoryLength read ReadStoryLength;
property StoryType read ReadStoryType;
property Style read ReadStyle write WriteStyle;
property Subdocuments read ReadSubdocuments;
property SynonymInfo read ReadSynonymInfo;
property Tables read ReadTables;
property TableStyle read ReadTableStyle;
property Text read ReadText write WriteText;
property TextRetrievalMode read ReadTextRetrievalMode write WriteTextRetrievalMode;
property TextVisibleOnScreen read ReadTextVisibleOnScreen;
property TopLevelTables read ReadTopLevelTables;
property TwoLinesInOne read ReadTwoLinesInOne write WriteTwoLinesInOne;
property Underline read ReadUnderline write WriteUnderline;
property Updates read ReadUpdates;
property WordOpenXML read ReadWordOpenXML;
property Words read ReadWords;
property XML read ReadXML;
Function ReadXML();
Function ReadWords();
Function ReadWordOpenXML();
Function ReadUpdates();
Function WriteUnderline(value);
Function ReadUnderline();
Function WriteTwoLinesInOne(value);
Function ReadTwoLinesInOne();
Function ReadTopLevelTables();
Function ReadTextVisibleOnScreen();
Function WriteTextRetrievalMode(value);
Function ReadTextRetrievalMode();
Function WriteText(value);
Function ReadText();
Function ReadTableStyle();
Function ReadTables();
Function ReadSynonymInfo();
Function ReadSubdocuments();
Function WriteStyle(value);
Function ReadStyle();
Function ReadStoryType();
Function ReadStoryLength();
Function WriteStart(value);
Function ReadStart();
Function ReadSpellingErrors();
Function WriteSpellingChecked(value);
Function ReadSpellingChecked();
Function WriteShowAll(value);
Function ReadShowAll();
Function ReadShapeRange();
Function ReadShading();
Function ReadSentences();
Function ReadSections();
Function ReadScripts();
Function ReadRows();
Function ReadRevisions();
Function ReadReadabilityStatistics();
Function ReadPreviousBookmarkID();
Function ReadParentContentControl();
Function ReadParagraphStyle();
Function ReadParagraphs();
Function WriteParagraphFormat(value);
Function ReadParagraphFormat();
Function ReadPageSetup();
Function WriteOrientation(value);
Function ReadOrientation();
Function ReadOMaths();
Function WriteNoProofing(value);
Function ReadNoProofing();
Function ReadNextStoryRange();
Function ReadLocks();
Function ReadListStyle();
Function ReadListParagraphs();
Function ReadListFormat();
Function WriteLanguageIDOther(value);
Function ReadLanguageIDOther();
Function WriteLanguageIDFarEast(value);
Function ReadLanguageIDFarEast();
Function WriteLanguageID(value);
Function ReadLanguageID();
Function WriteLanguageDetected(value);
Function ReadLanguageDetected();
Function WriteKana(value);
Function ReadKana();
Function WriteItalicBi(value);
Function ReadItalicBi();
Function WriteItalic(value);
Function ReadItalic();
Function ReadIsEndOfRowMark();
Function ReadInlineShapes();
Function ReadInformation(Type);
Function WriteID(value);
Function ReadID();
Function ReadHyperlinks();
Function ReadHTMLDivisions();
Function WriteHorizontalInVertical(value);
Function ReadHorizontalInVertical();
Function WriteHighlightColorIndex(value);
Function ReadHighlightColorIndex();
Function ReadGrammaticalErrors();
Function WriteGrammarChecked(value);
Function ReadGrammarChecked();
Function ReadFrames();
Function ReadFormFields();
Function WriteFormattedText(value);
Function ReadFormattedText();
Function ReadFootnotes();
Function ReadFootnoteOptions();
Function WriteFont(value);
Function ReadFont();
Function WriteFitTextWidth(value);
Function ReadFitTextWidth();
Function ReadFind();
Function ReadFields();
Function ReadEnhMetaFileBits();
Function ReadEndnotes();
Function ReadEndnoteOptions();
Function WriteEnd(value);
Function ReadEnd();
Function WriteEmphasisMark(value);
Function ReadEmphasisMark();
Function ReadEditors();
Function ReadDuplicate();
Function ReadDocument();
Function WriteDisableCharacterSpaceGrid(value);
Function ReadDisableCharacterSpaceGrid();
Function ReadContentControls();
Function ReadConflicts();
Function ReadComments();
Function WriteCombineCharacters(value);
Function ReadCombineCharacters();
Function ReadColumns();
Function WriteCharacterWidth(value);
Function ReadCharacterWidth();
Function ReadCharacterStyle();
Function ReadCharacters();
Function ReadCells();
Function WriteCase(value);
Function ReadCase();
Function ReadBorders(index);
Function ReadBookmarks();
Function ReadBookmarkID();
Function WriteBoldBi(value);
Function ReadBoldBi();
Function WriteBold(value);
Function ReadBold();
End;
// ============== 实现 ================= //
Function TSDocxRange.Init(docx, rangeObj);
Begin
docx_ := docx;
range_obj_ := rangeObj;
range_font_ := new TSDocxFontRange(self.Application, self.Creator, self);
range_font_.Init(range_obj_);
range_shading_ := new TSDocxShadingRange(self.Application, self.Creator, self);
range_shading_.Init(range_obj_);
paragraph_format_range_ := new TSDocxParagraphFormatRange(self.Application, self.Creator, self);
paragraph_format_range_.Init(docx_, range_obj_);
list_format_range_ := new TSDocxListFormatRange(self.Application, self.Creator, self);
list_format_range_.Init(docx_, range_obj_);
borders_range_ := new TSDocxBordersRange(self.Application, self.Creator, self);
borders_range_.Init(range_obj_);
collapse_ := nil;
document_ := self.Parent;
while not (document_ is class(TSDocxDocument)) do
document_ := document_.Parent;
End;
Function TSDocxRange.AddParagraph();overload;
Begin
if collapse_ = TSDocxEnumerations.wdCollapseEnd() then
return self.AddParagraph("after");
return self.AddParagraph("before");
End;
Function TSDocxRange.AddParagraph(direction);overload;
Begin
[flag, last_node, new_node] := self.BreakIntoParagraphs(direction);
if not flag then
new_node := direction = "before" ? last_node.Parent().InsertBeforeChild(last_node, "element", "w:p")
: last_node.Parent().InsertAfterChild(last_node, "element", "w:p");
pos := document_.Paragraphs.AddParagraph(last_node, new_node, direction);
return document_.Paragraphs.Item(pos + 1);
End;
Function TSDocxRange.InsertNewParagraph();
Begin
case collapse_ of
TSDocxEnumerations.wdCollapseStart():
return self.AddParagraph("before");
TSDocxEnumerations.wdCollapseEnd():
return self.AddParagraph("after");
else begin
self.Clear();
if not range_obj_[0].TParagraph.Empty() then return self.AddParagraph("after");
pos := document_.Paragraphs.FindNewParagraphPosition(range_obj_[0].TParagraph.Root());
return document_.Paragraphs.Item(pos + 1);
end
end;
End;
Function TSDocxRange.AddTable(numRows, numColumns);
Begin
padd_table := function(ttable, node);
begin
if node.Parent().GetName() = "w:tc" then
begin
docx := new TCell();
docx.Create(node);
table := docx.InsertTable(ttable, node);
end
else if node.Parent().GetName() = "w:body" then
begin
table := docx_.InsertTable(ttable, node);
end
return table;
end
psplit := function(direction);
begin
[flag, last_node, new_node] := self.BreakIntoParagraphs(direction);
if flag then
begin
document_.Paragraphs.AddParagraph(last_node, new_node, direction);
end
else begin
index := direction = "before" ? 0 : range_obj_.Size()-1;
new_node := range_obj_[index].TParagraph.Root();
end
return new_node;
end
case collapse_ of
TSDocxEnumerations.wdCollapseStart():
new_node := ##psplit("before");
TSDocxEnumerations.wdCollapseEnd():
new_node := ##psplit("after");
else begin
new_node := range_obj_[range_obj_.Size()-1].TParagraph.Root();
clear_flag := true;
end
end;
data := nils(numRows, numColumns);
ttable := docx_.CreateTable(data);
table := ##padd_table(ttable, new_node);
document_.Paragraphs.AddTableToParagraphs(new_node, table);
if clear_flag then self.Clear(true);
return table;
End;
Function TSDocxRange.Clear(deleteAll);
Begin
arr := range_obj_.Clear(deleteAll);
for i:=0 to length(arr)-1 do
document_.Paragraphs.DeleteParagraph(arr[i]);
End;
Function TSDocxRange.CopyRunFormat(sourceRun, destRun);
Begin
rpr := sourceRun.FirstChildElement("w:rPr");
marshal := rpr.Marshal();
node := class(TSXml).GetNode(destRun, "w:rPr", "first");
class(TSXml).UpdateNode(node, marshal[0]["attribute"], marshal[0]["children"]);
End;
Function TSDocxRange.BreakIntoParagraphs(direction);
Begin
index := direction = "before" ? 0 : range_obj_.Size()-1;
range_obj_.SplitRun(index);
run := range_obj_[index].TRun;
paragraph := range_obj_[index].TParagraph;
root := paragraph.Root();
if not ifObj(run.Root()) or
(not run.Root().NextElement("w:r") and direction = "after") or
(not run.Root().PrevElement("w:r") and direction = "before")
then return array(false, root, nil);
parent_node := root.Parent();
node := direction = "before" ? parent_node.InsertBeforeChild(root, "element", "w:p") : parent_node.InsertAfterChild(root, "element", "w:p");
ppr := root.FirstChildElement("w:pPr");
ppr_node := ppr ? node.InsertFirstChild(string(ppr.Data())) : node.InsertFirstChild("element", "w:rPr");
if direction = "before" then
begin
run_node := root.FirstChildElement("w:r");
while not run_node.Eq(run.Root()) do
begin
node.InsertEndChild(string(run_node.Data()));
delete_node := run_node;
run_node := run_node.NextElement("w:r");
root.DeleteChild(delete_node);
end
end
else begin
run_node := run.Root().NextElement("w:r");
while ifObj(run_node) do
begin
node.InsertEndChild(string(run_node.Data()));
delete_node := run_node;
run_node := run_node.NextElement("w:r");
root.DeleteChild(delete_node);
end
end
return array(true, root, node);
End;
// Methods
Function TSDocxRange.InsertAfter(Text); // 无论range是什么都在段落末尾添加文字
Begin
size := range_obj_.Size();
paragraph := range_obj_[size-1].TParagraph;
if paragraph.Empty() then
begin
run := paragraph.AppendRun();
run.AddText(Text);
paragraph.CopyRunFormat(false, run.Root());
end
else begin
trun := range_obj_[size-1].TRun;
run := paragraph.AppendRun(trun);
run.AddText(Text);
self.CopyRunFormat(trun.Root(), run.Root());
end
range_obj_.Refresh();
End;
Function TSDocxRange.InsertBefore(Text); // 无论range是什么都在段落前添加文字
Begin
paragraph := range_obj_[0].TParagraph;
if paragraph.Empty() then
begin
run := paragraph.AppendRun();
run.AddText(Text);
paragraph.CopyRunFormat(false, run.Root());
end
else begin
trun := range_obj_[0].TRun;
run := paragraph.PrependRun(trun);
run.AddText(Text);
self.CopyRunFormat(trun.Root(), run.Root());
end
range_obj_.Refresh();
End;
Function TSDocxRange.InsertBreak(Type);
Begin
if self.Information(TSDocxEnumerations.wdWithInTable()) then
raise "This method is not supported for the table range and cell range";
pf := function(t, c);
begin
case collapse_ of
TSDocxEnumerations.wdCollapseStart():
index := 0;
TSDocxEnumerations.wdCollapseEnd():
index := range_obj_.Size()-1;
else begin
range_obj_.Clear();
index := 0;
end
end;
range_obj_.SplitRun(index);
tparagraph := range_obj_[index].TParagraph;
run := tparagraph.PrependRun(range_obj_[index].TRun);
run.Br.Type := t;
run.Br.Clear := c;
run.Apply();
end
if ifnil(Type) then Type := TSDocxEnumerations.wdPageBreak();
case Type of
TSDocxEnumerations.wdColumnBreak():
begin
paragraph_obj := self.InsertNewParagraph();
if collapse_ = TSDocxEnumerations.wdCollapseStart() then paragraph_obj := paragraph_obj.Next(1);
obj := paragraph_obj.Object();
run := obj.PrependRun();
run.Br.Type := "column";
run.Apply();
end
TSDocxEnumerations.wdLineBreak():
##pf("textWrapping", nil);
TSDocxEnumerations.wdLineBreakClearLeft():
##pf("textWrapping", "left");
TSDocxEnumerations.wdLineBreakClearRight():
##pf("textWrapping", "right");
TSDocxEnumerations.wdPageBreak():
begin
paragraph_obj := self.InsertNewParagraph();
paragraph_obj := self.InsertNewParagraph();
paragraph_obj.Format.Alignment := TSDocxEnumerations.wdAlignParagraphLeft();
paragraph_obj.Format.WidowControl := true;
paragraph_obj.Format.Apply();
obj := paragraph_obj.Object();
run := obj.AppendRun();
run.Br.Type := "page";
run.Apply();
end
TSDocxEnumerations.wdSectionBreakContinuous(),
TSDocxEnumerations.wdSectionBreakEvenPage(),
TSDocxEnumerations.wdSectionBreakNextPage(),
TSDocxEnumerations.wdSectionBreakOddPage():
raise "This Type is not suppoted";
TSDocxEnumerations.wdTextWrappingBreak():
##pf("textWrapping", "all");
end;
End;
Function TSDocxRange.Collapse(Direction);
Begin
if ifnil(Direction) then Direction := TSDocxEnumerations.wdCollapseStart();
collapse_ := Direction;
End;
Function TSDocxRange.Delete(_Unit, Count);
Begin
self.Clear(true);
End;
Function TSDocxRange.InsertParagraph();
Begin
self.InsertNewParagraph();
End;
Function TSDocxRange.InsertParagraphAfter();
Begin
self.AddParagraph("after");
End;
Function TSDocxRange.InsertParagraphBefore();
Begin
self.AddParagraph("before");
End;
// Properties
Function TSDocxRange.WriteBoldBi(value);
Begin
range_font_.BoldBi := value;
range_font_.Apply();
End;
Function TSDocxRange.ReadBoldBi();
Begin
return range_font_.BoldBi;
End;
Function TSDocxRange.WriteBold(value);
Begin
range_font_.Bold := value;
range_font_.Apply();
End;
Function TSDocxRange.ReadBold();
Begin
return range_font_.Bold;
End;
Function TSDocxRange.WriteFont(value);
Begin
range_font_.ReWrite(value);
End;
Function TSDocxRange.ReadFont();
Begin
return range_font_;
End;
Function TSDocxRange.ReadBorders(index);
Begin
return ifnil(index) ? borders_range_ : borders_range_.Item(index);
End;
Function TSDocxRange.WriteParagraphFormat(value);
Begin
paragraph_format_range_.ReWrite(value);
End;
Function TSDocxRange.ReadParagraphFormat();
Begin
return paragraph_format_range_;
End;
Function TSDocxRange.ReadInformation(Type);
Begin
case Type of
// TSDocxEnumerations.wdActiveEndAdjustedPageNumber():
// TSDocxEnumerations.wdActiveEndPageNumber():
// TSDocxEnumerations.wdActiveEndSectionNumber():
// TSDocxEnumerations.wdAtEndOfRowMarker():
// TSDocxEnumerations.wdCapsLock():
// TSDocxEnumerations.wdEndOfRangeColumnNumber():
// TSDocxEnumerations.wdEndOfRangeRowNumber():
// TSDocxEnumerations.wdFirstCharacterColumnNumber():
// TSDocxEnumerations.wdFirstCharacterLineNumber():
// TSDocxEnumerations.wdFrameIsSelected():
// TSDocxEnumerations.wdHeaderFooterType():
// TSDocxEnumerations.wdHorizontalPositionRelativeToPage():
// TSDocxEnumerations.wdHorizontalPositionRelativeToTextBoundary():
// TSDocxEnumerations.wdInBibliography():
// TSDocxEnumerations.wdInCitation():
// TSDocxEnumerations.wdInClipboard():
// TSDocxEnumerations.wdInCommentPane():
// TSDocxEnumerations.wdInContentControl():
// TSDocxEnumerations.wdInCoverPage():
// TSDocxEnumerations.wdInEndnote():
// TSDocxEnumerations.wdInFieldCode():
// TSDocxEnumerations.wdInFieldResult():
// TSDocxEnumerations.wdInFootnote():
// TSDocxEnumerations.wdInFootnoteEndnotePane():
// TSDocxEnumerations.wdInHeaderFooter():
// TSDocxEnumerations.wdInMasterDocument():
// TSDocxEnumerations.wdInWordMail():
// TSDocxEnumerations.wdMaximumNumberOfColumns():
// TSDocxEnumerations.wdMaximumNumberOfRows():
// TSDocxEnumerations.wdNumberOfPagesInDocument():
// TSDocxEnumerations.wdNumLock():
// TSDocxEnumerations.wdOverType():
// TSDocxEnumerations.wdReferenceOfType():
// TSDocxEnumerations.wdRevisionMarking():
// TSDocxEnumerations.wdSelectionMode():
// TSDocxEnumerations.wdStartOfRangeColumnNumber():
// TSDocxEnumerations.wdStartOfRangeRowNumber():
// TSDocxEnumerations.wdVerticalPositionRelativeToPage():
// TSDocxEnumerations.wdVerticalPositionRelativeToTextBoundary():
TSDocxEnumerations.wdWithInTable():
begin
for i:=0 to range_obj_.Size()-1 do
begin
node := range_obj_[i].TParagraph.Root();
if not (node.Parent().GetName() in array("w:tbl", "w:tc")) then return false;
end
return true;
end
// TSDocxEnumerations.wdZoomPercentage():
else raise "This Type is not suppoted";
end;
End;
Function TSDocxRange.WriteStyle(value);
Begin
paragraph_format_range_.Style := value;
End;
Function TSDocxRange.ReadStyle();
Begin
return paragraph_format_range_.Style;
End;
Function TSDocxRange.WriteText(value);
Begin
range_obj_.SplitRun();
self.Clear();
run := range_obj_[0].TRun;
if ifObj(run.Root()) then run.SetText(value);
else begin
run := range_obj_[0].TParagraph.AppendRun();
run.SetText(value);
range_obj_[0].TRun := run;
end
End;
Function TSDocxRange.ReadText();
Begin
range_obj_.SplitRun();
txt := "";
prev := range_obj_[0].TParagraph;
for i:=0 to range_obj_.Size()-1 do
begin
run := range_obj_[i].TRun;
if not ifObj(run.Root()) then continue;
if prev = range_obj_[i].TParagraph then
begin
txt += run.Text();
end
else begin
txt += "\n" + run.Text();
prev := range_obj_[i].TParagraph;
end
end
return txt;
End;
Function TSDocxRange.ReadListFormat();
Begin
return list_format_range_;
End;
Function TSDocxRange.ReadShading();
Begin
return range_shading_;
End;
Function TSDocxRange.ReadEnd();
Begin
return range_obj_.GetEnd();
End;
Function TSDocxRange.ReadStart();
Begin
return range_obj_.GetStart();
End;
Function TSDocxRange.InsertFile(FileName, Range, ConfirmConversions, Link, Attachment);
Begin
alias := "";
paragraph := self.InsertNewParagraph();
docx_.InsertFile(alias, FileName, paragraph.Root());
paragraph.Range.Delete();
document_.Paragraphs.Init(docx_);
End;