本文整理汇总了C#中OpenXmlPart.GetXDocument方法的典型用法代码示例。如果您正苦于以下问题:C# OpenXmlPart.GetXDocument方法的具体用法?C# OpenXmlPart.GetXDocument怎么用?C# OpenXmlPart.GetXDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenXmlPart
的用法示例。
在下文中一共展示了OpenXmlPart.GetXDocument方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessTemplatePart
private static void ProcessTemplatePart(XElement data, TemplateError te, OpenXmlPart part)
{
XDocument xDoc = part.GetXDocument();
XElement newRootElementWithMetadata = (XElement)TransformToMetadata(xDoc.Root, data, te);
NormalizeTablesRepeatAndConditional(newRootElementWithMetadata, te);
XElement newRootElement = newRootElementWithMetadata;
// do the actual content replacement
newRootElement = (XElement)ContentReplacementTransform(newRootElement, data, te);
xDoc.Elements().First().ReplaceWith(newRootElement);
part.PutXDocument();
return;
}
示例2: AcceptRevisionsForPart
public static void AcceptRevisionsForPart(OpenXmlPart part)
{
XElement documentElement = part.GetXDocument().Root;
documentElement = (XElement)AcceptMoveFromMoveToTransform(documentElement);
documentElement = AcceptMoveFromRanges(documentElement);
// AcceptParagraphEndTagsInMoveFromTransform needs rewritten similar to AcceptDeletedAndMoveFromParagraphMarks
documentElement = (XElement)AcceptParagraphEndTagsInMoveFromTransform(documentElement);
documentElement = AcceptDeletedAndMovedFromContentControls(documentElement);
documentElement = AcceptDeletedAndMoveFromParagraphMarks(documentElement);
documentElement = (XElement)RemoveRowsLeftEmptyByMoveFrom(documentElement);
documentElement = (XElement)AcceptAllOtherRevisionsTransform(documentElement);
documentElement = (XElement)AcceptDeletedCellsTransform(documentElement);
documentElement = (XElement)MergeAdjacentTablesTransform(documentElement);
documentElement.Descendants().Attributes().Where(a => a.Name == PT.UniqueId || a.Name == PT.RunIds).Remove();
documentElement.Descendants(W.numPr).Where(np => !np.HasElements).Remove();
XDocument newXDoc = new XDocument(documentElement);
part.PutXDocument(newXDoc);
}
示例3: FixIdsInPart
// todo are there any other elements that need ids fixed? see children of paragraph, run
private static void FixIdsInPart(OpenXmlPart part, int nextCommentId, int nextBookmarkId)
{
if (part == null)
return;
foreach (var element in part.GetXDocument().Root.Descendants()
.Where(e => e.Name == W.commentRangeStart ||
e.Name == W.commentRangeEnd ||
e.Name == W.commentReference))
element.Attribute(W.id).Value = ((int)element.Attribute(W.id) + nextCommentId).ToString();
foreach (var element in part.GetXDocument().Root.Descendants()
.Where(e => e.Name == W.bookmarkStart || e.Name == W.bookmarkEnd))
element.Attribute(W.id).Value = ((int)element.Attribute(W.id) + nextBookmarkId).ToString();
}
示例4: MergeCommentsInPart
private static void MergeCommentsInPart(OpenXmlPart part1, OpenXmlPart part2,
OpenXmlPart destinationPart, XDocument commentsPartXDoc)
{
XDocument xdoc1 = part1.GetXDocument();
XDocument xdoc2 = part2.GetXDocument();
XElement newRootElement = (XElement)MergeElementTransform(xdoc1.Root, xdoc2.Root,
commentsPartXDoc);
destinationPart.PutXDocument(new XDocument(newRootElement));
}
示例5: TestPartForUnsupportedContent
private static void TestPartForUnsupportedContent(OpenXmlPart part, int sourceNumber)
{
XNamespace[] obsoleteNamespaces = new[]
{
XNamespace.Get("http://schemas.microsoft.com/office/word/2007/5/30/wordml"),
XNamespace.Get("http://schemas.microsoft.com/office/word/2008/9/16/wordprocessingDrawing"),
XNamespace.Get("http://schemas.microsoft.com/office/word/2009/2/wordml"),
};
XDocument xDoc = part.GetXDocument();
XElement invalidElement = xDoc.Descendants()
.FirstOrDefault(d =>
{
bool b = d.Name == W.subDoc ||
d.Name == W.control ||
d.Name == W.altChunk ||
d.Name.LocalName == "contentPart" ||
obsoleteNamespaces.Contains(d.Name.Namespace);
bool b2 = b ||
d.Attributes().Any(a => obsoleteNamespaces.Contains(a.Name.Namespace));
return b2;
});
if (invalidElement != null)
{
if (invalidElement.Name == W.subDoc)
throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains sub document",
sourceNumber));
if (invalidElement.Name == W.control)
throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains ActiveX controls",
sourceNumber));
if (invalidElement.Name == W.altChunk)
throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains altChunk",
sourceNumber));
if (invalidElement.Name.LocalName == "contentPart")
throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains contentPart content",
sourceNumber));
if (obsoleteNamespaces.Contains(invalidElement.Name.Namespace) ||
invalidElement.Attributes().Any(a => obsoleteNamespaces.Contains(a.Name.Namespace)))
throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains obsolete namespace",
sourceNumber));
}
}
示例6: PartHasTrackedRevisions
public static bool PartHasTrackedRevisions(OpenXmlPart part)
{
return part.GetXDocument()
.Descendants()
.Any(e => TrackedRevisionsElements.Contains(e.Name));
}
示例7: SimplifyMarkupForPart
private static void SimplifyMarkupForPart(
OpenXmlPart part,
SimplifyMarkupSettings settings)
{
SimplifyMarkupParameters parameters = new SimplifyMarkupParameters();
if (part.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml")
{
WordprocessingDocument doc = (WordprocessingDocument)part.OpenXmlPackage;
if (settings.RemoveGoBackBookmark == true)
{
var goBackBookmark = doc
.MainDocumentPart
.GetXDocument()
.Root
.Descendants(W.bookmarkStart)
.FirstOrDefault(bm => (string)bm.Attribute(W.name) == "_GoBack");
if (goBackBookmark != null)
parameters.GoBackId = (int)goBackBookmark.Attribute(W.id);
}
}
XDocument xdoc = part.GetXDocument();
XElement newRoot = xdoc.Root;
// Need to do this first to enable simplifying hyperlinks.
if (settings.RemoveContentControls ||
settings.RemoveSmartTags)
newRoot = (XElement)
RemoveCustomXmlAndContentControlsTransform(
newRoot, settings);
// This may touch many elements, so needs to be its own
// transform.
if (settings.RemoveRsidInfo)
newRoot = (XElement)RemoveRsidTransform(newRoot);
XDocument prevNewRoot = new XDocument(newRoot);
while (true)
{
if (settings.RemoveComments ||
settings.RemoveEndAndFootNotes ||
settings.ReplaceTabsWithSpaces ||
settings.RemoveFieldCodes ||
settings.RemovePermissions ||
settings.RemoveProof ||
settings.RemoveBookmarks ||
settings.RemoveWebHidden ||
settings.RemoveGoBackBookmark)
newRoot = (XElement)SimplifyMarkupTransform(newRoot,
settings, parameters);
// Remove runs and run properties that have become empty due to previous
// transforms.
newRoot = (XElement)
RemoveEmptyRunsAndRunPropertiesTransform(newRoot);
// Merge adjacent runs that have identical run properties.
newRoot = (XElement)MergeAdjacentRunsTransform(newRoot);
// Merge adjacent instrText elements.
newRoot = (XElement)MergeAdjacentInstrText(newRoot);
// Separate run children into separate runs
newRoot = (XElement)SeparateRunChildrenIntoSeparateRuns(newRoot);
if (XNode.DeepEquals(prevNewRoot.Root, newRoot))
break;
prevNewRoot = new XDocument(newRoot);
}
if (settings.NormalizeXml)
{
XAttribute[] ns_attrs =
{
new XAttribute(XNamespace.Xmlns + "wpc", WPC.wpc),
new XAttribute(XNamespace.Xmlns + "mc", MC.mc),
new XAttribute(XNamespace.Xmlns + "o", O.o),
new XAttribute(XNamespace.Xmlns + "r", R.r),
new XAttribute(XNamespace.Xmlns + "m", M.m),
new XAttribute(XNamespace.Xmlns + "v", VML.vml),
new XAttribute(XNamespace.Xmlns + "wp14", WP14.wp14),
new XAttribute(XNamespace.Xmlns + "wp", WP.wp),
new XAttribute(XNamespace.Xmlns + "w10", W10.w10),
new XAttribute(XNamespace.Xmlns + "w", W.w),
new XAttribute(XNamespace.Xmlns + "w14", W14.w14),
new XAttribute(XNamespace.Xmlns + "wpg", WPG.wpg),
new XAttribute(XNamespace.Xmlns + "wpi", WPI.wpi),
new XAttribute(XNamespace.Xmlns + "wne", WNE.wne),
new XAttribute(XNamespace.Xmlns + "wps", WPS.wps),
new XAttribute(MC.Ignorable, "w14 wp14"),
};
XDocument newXDoc = Normalize(new XDocument(newRoot), null);
foreach (var nsatt in ns_attrs)
{
if (newXDoc.Root.Attribute(nsatt.Name) == null)
newXDoc.Root.Add(nsatt);
}
//.........这里部分代码省略.........
示例8: SimplifyMarkupForPart
private static void SimplifyMarkupForPart(
OpenXmlPart part,
SimplifyMarkupSettings settings)
{
XDocument xdoc = part.GetXDocument();
XElement newRoot = xdoc.Root;
// Need to do this first to enable simplifying hyperlinks.
if (settings.RemoveContentControls ||
settings.RemoveSmartTags)
newRoot = (XElement)
RemoveCustomXmlAndContentControlsTransform(
newRoot, settings);
// This may touch many elements, so needs to be its own
// transform.
if (settings.RemoveRsidInfo)
newRoot = (XElement)RemoveRsidTransform(newRoot);
if (settings.RemoveComments ||
settings.RemoveEndAndFootNotes ||
settings.ReplaceTabsWithSpaces ||
settings.RemoveFieldCodes ||
settings.RemovePermissions ||
settings.RemoveProof ||
settings.RemoveBookmarks ||
settings.RemoveWebHidden)
newRoot = (XElement)SimplifyMarkupTransform(newRoot,
settings);
// Remove runs and run properties that have become empty due to previous
// transforms.
newRoot = (XElement)
RemoveEmptyRunsAndRunPropertiesTransform(newRoot);
// Merge adjacent runs that have identical run properties.
newRoot = (XElement)RemoveSuperfluousRunsTransform(newRoot);
// Merge adjacent instrText elements.
newRoot = (XElement)MergeAdjacentInstrText(newRoot);
// The last thing to do is to again remove runs and run properties
// that have become empty due to previous transforms.
newRoot = (XElement)
RemoveEmptyRunsAndRunPropertiesTransform(newRoot);
if (settings.NormalizeXml)
{
XAttribute[] ns_attrs =
{
new XAttribute(XNamespace.Xmlns + "wpc", WPC.wpc),
new XAttribute(XNamespace.Xmlns + "mc", MC.mc),
new XAttribute(XNamespace.Xmlns + "o", O.o),
new XAttribute(XNamespace.Xmlns + "r", R.r),
new XAttribute(XNamespace.Xmlns + "m", M.m),
new XAttribute(XNamespace.Xmlns + "v", VML.vml),
new XAttribute(XNamespace.Xmlns + "wp14", WP14.wp14),
new XAttribute(XNamespace.Xmlns + "wp", WP.wp),
new XAttribute(XNamespace.Xmlns + "w10", W10.w10),
new XAttribute(XNamespace.Xmlns + "w", W.w),
new XAttribute(XNamespace.Xmlns + "w14", W14.w14),
new XAttribute(XNamespace.Xmlns + "wpg", WPG.wpg),
new XAttribute(XNamespace.Xmlns + "wpi", WPI.wpi),
new XAttribute(XNamespace.Xmlns + "wne", WNE.wne),
new XAttribute(XNamespace.Xmlns + "wps", WPS.wps),
new XAttribute(MC.Ignorable, "w14 wp14"),
};
XDocument newXDoc = Normalize(new XDocument(newRoot), null);
newXDoc.Root.Add(ns_attrs);
part.PutXDocument(newXDoc);
}
else
{
part.PutXDocument(new XDocument(newRoot));
}
}
示例9: AnnotateWithFieldInfo
public static void AnnotateWithFieldInfo(OpenXmlPart part)
{
XNamespace w = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
XElement root = part.GetXDocument().Root;
var r = root.DescendantsAndSelf()
.Rollup(
new FieldElementTypeStack
{
Id = 0,
FiStack = null,
},
(e, s) =>
{
if (e.Name == w + "fldChar")
{
if (e.Attribute(w + "fldCharType").Value == "begin")
{
Stack<FieldElementTypeInfo> fis;
if (s.FiStack == null)
fis = new Stack<FieldElementTypeInfo>();
else
fis = new Stack<FieldElementTypeInfo>(s.FiStack.Reverse());
fis.Push(
new FieldElementTypeInfo
{
Id = s.Id + 1,
FieldElementType = FieldElementTypeEnum.Begin,
});
return new FieldElementTypeStack
{
Id = s.Id + 1,
FiStack = fis,
};
};
if (e.Attribute(w + "fldCharType").Value == "separate")
{
Stack<FieldElementTypeInfo> fis = new Stack<FieldElementTypeInfo>(s.FiStack.Reverse());
FieldElementTypeInfo wfi = fis.Pop();
fis.Push(
new FieldElementTypeInfo
{
Id = wfi.Id,
FieldElementType = FieldElementTypeEnum.Separate,
});
return new FieldElementTypeStack
{
Id = s.Id,
FiStack = fis,
};
}
if (e.Attribute(w + "fldCharType").Value == "end")
{
Stack<FieldElementTypeInfo> fis = new Stack<FieldElementTypeInfo>(s.FiStack.Reverse());
FieldElementTypeInfo wfi = fis.Pop();
return new FieldElementTypeStack
{
Id = s.Id,
FiStack = fis,
};
}
}
if (s.FiStack == null || s.FiStack.Count() == 0)
return s;
FieldElementTypeInfo wfi3 = s.FiStack.Peek();
if (wfi3.FieldElementType == FieldElementTypeEnum.Begin)
{
Stack<FieldElementTypeInfo> fis = new Stack<FieldElementTypeInfo>(s.FiStack.Reverse());
FieldElementTypeInfo wfi2 = fis.Pop();
fis.Push(
new FieldElementTypeInfo
{
Id = wfi2.Id,
FieldElementType = FieldElementTypeEnum.InstrText,
});
return new FieldElementTypeStack
{
Id = s.Id,
FiStack = fis,
};
}
if (wfi3.FieldElementType == FieldElementTypeEnum.Separate)
{
Stack<FieldElementTypeInfo> fis = new Stack<FieldElementTypeInfo>(s.FiStack.Reverse());
FieldElementTypeInfo wfi2 = fis.Pop();
fis.Push(
new FieldElementTypeInfo
{
Id = wfi2.Id,
FieldElementType = FieldElementTypeEnum.Result,
});
return new FieldElementTypeStack
{
Id = s.Id,
FiStack = fis,
};
}
if (wfi3.FieldElementType == FieldElementTypeEnum.End)
{
Stack<FieldElementTypeInfo> fis = new Stack<FieldElementTypeInfo>(s.FiStack.Reverse());
//.........这里部分代码省略.........
示例10: UpdatePartForToa
private static void UpdatePartForToa(OpenXmlPart part)
{
XDocument xDoc = part.GetXDocument();
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "paragraph" && (string)e.Attribute(W.styleId) == "TableofAuthorities")
.FirstOrDefault(),
@"<w:style w:type='paragraph'
w:styleId='TableofAuthorities'
xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
<w:name w:val='table of authorities'/>
<w:basedOn w:val='Normal'/>
<w:next w:val='Normal'/>
<w:uiPriority w:val='99'/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:rsid w:val='0090569D'/>
<w:pPr>
<w:spacing w:after='0'/>
<w:ind w:left='220'
w:hanging='220'/>
</w:pPr>
</w:style>");
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "paragraph" && (string)e.Attribute(W.styleId) == "TOAHeading")
.FirstOrDefault(),
@"<w:style w:type='paragraph'
w:styleId='TOAHeading'
xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
<w:name w:val='toa heading'/>
<w:basedOn w:val='Normal'/>
<w:next w:val='Normal'/>
<w:uiPriority w:val='99'/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:rsid w:val='0090569D'/>
<w:pPr>
<w:spacing w:before='120'/>
</w:pPr>
<w:rPr>
<w:rFonts w:asciiTheme='majorHAnsi'
w:eastAsiaTheme='majorEastAsia'
w:hAnsiTheme='majorHAnsi'
w:cstheme='majorBidi'/>
<w:b/>
<w:bCs/>
<w:sz w:val='24'/>
<w:szCs w:val='24'/>
</w:rPr>
</w:style>");
part.PutXDocument();
}
示例11: UpdatePartForTof
private static void UpdatePartForTof(OpenXmlPart part)
{
XDocument xDoc = part.GetXDocument();
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "paragraph" && (string)e.Attribute(W.styleId) == "TableofFigures")
.FirstOrDefault(),
@"<w:style w:type='paragraph' w:styleId='TableofFigures' xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
<w:name w:val='table of figures'/>
<w:basedOn w:val='Normal'/>
<w:next w:val='Normal'/>
<w:uiPriority w:val='99'/>
<w:unhideWhenUsed/>
<w:pPr>
<w:spacing w:after='0'/>
</w:pPr>
</w:style>");
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "character" && (string)e.Attribute(W.styleId) == "Hyperlink")
.FirstOrDefault(),
@"<w:style w:type='character' w:styleId='Hyperlink' xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
<w:name w:val='Hyperlink'/>
<w:basedOn w:val='DefaultParagraphFont'/>
<w:uiPriority w:val='99'/>
<w:unhideWhenUsed/>
<w:rPr>
<w:color w:val='0000FF' w:themeColor='hyperlink'/>
<w:u w:val='single'/>
</w:rPr>
</w:style>");
part.PutXDocument();
}
示例12: UpdatePartForToc
private static void UpdatePartForToc(OpenXmlPart part)
{
XDocument xDoc = part.GetXDocument();
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "paragraph" && (string)e.Attribute(W.styleId) == "TOCHeading")
.FirstOrDefault(),
@"<w:style w:type='paragraph' w:styleId='TOCHeading' xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
<w:name w:val='TOC Heading'/>
<w:basedOn w:val='Heading1'/>
<w:next w:val='Normal'/>
<w:uiPriority w:val='39'/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:qFormat/>
<w:pPr>
<w:outlineLvl w:val='9'/>
</w:pPr>
<w:rPr>
<w:lang w:eastAsia='ja-JP'/>
</w:rPr>
</w:style>");
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "paragraph" && (string)e.Attribute(W.styleId) == "TOC1")
.FirstOrDefault(),
@"<w:style w:type='paragraph' w:styleId='TOC1' xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
<w:name w:val='toc 1'/>
<w:basedOn w:val='Normal'/>
<w:next w:val='Normal'/>
<w:autoRedefine/>
<w:uiPriority w:val='39'/>
<w:unhideWhenUsed/>
<w:pPr>
<w:spacing w:after='100'/>
</w:pPr>
</w:style>");
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "paragraph" && (string)e.Attribute(W.styleId) == "TOC2")
.FirstOrDefault(),
@"<w:style w:type='paragraph' w:styleId='TOC2' xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
<w:name w:val='toc 2'/>
<w:basedOn w:val='Normal'/>
<w:next w:val='Normal'/>
<w:autoRedefine/>
<w:uiPriority w:val='39'/>
<w:unhideWhenUsed/>
<w:pPr>
<w:spacing w:after='100'/>
<w:ind w:left='220'/>
</w:pPr>
</w:style>");
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "paragraph" && (string)e.Attribute(W.styleId) == "TOC3")
.FirstOrDefault(),
@"<w:style w:type='paragraph' w:styleId='TOC3' xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
<w:name w:val='toc 3'/>
<w:basedOn w:val='Normal'/>
<w:next w:val='Normal'/>
<w:autoRedefine/>
<w:uiPriority w:val='39'/>
<w:unhideWhenUsed/>
<w:pPr>
<w:spacing w:after='100'/>
<w:ind w:left='440'/>
</w:pPr>
</w:style>");
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "paragraph" && (string)e.Attribute(W.styleId) == "TOC4")
.FirstOrDefault(),
@"<w:style w:type='paragraph' w:styleId='TOC4' xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
<w:name w:val='toc 4'/>
<w:basedOn w:val='Normal'/>
<w:next w:val='Normal'/>
<w:autoRedefine/>
<w:uiPriority w:val='39'/>
<w:unhideWhenUsed/>
<w:pPr>
<w:spacing w:after='100'/>
<w:ind w:left='660'/>
</w:pPr>
</w:style>");
AddElementIfMissing(
xDoc,
xDoc.Root.Elements(W.style)
.Where(e => (string)e.Attribute(W.type) == "character" && (string)e.Attribute(W.styleId) == "Hyperlink")
//.........这里部分代码省略.........
示例13: InitializeListItemRetrieverForPart
private static void InitializeListItemRetrieverForPart(WordprocessingDocument wordDoc, OpenXmlPart part, ListItemRetrieverSettings settings)
{
var mainXDoc = part.GetXDocument();
var numPart = wordDoc.MainDocumentPart.NumberingDefinitionsPart;
if (numPart == null)
return;
var numXDoc = numPart.GetXDocument();
var stylesPart = wordDoc.MainDocumentPart.StyleDefinitionsPart;
if (stylesPart == null)
return;
var stylesXDoc = stylesPart.GetXDocument();
var rootNode = mainXDoc.Root;
InitializeListItemRetrieverForStory(numXDoc, stylesXDoc, rootNode);
var textBoxes = mainXDoc
.Root
.Descendants(W.txbxContent);
foreach (var textBox in textBoxes)
InitializeListItemRetrieverForStory(numXDoc, stylesXDoc, textBox);
}
示例14: TransformPartToSingleCharacterRuns
public static void TransformPartToSingleCharacterRuns(OpenXmlPart part)
{
// After transforming to single character runs, Rsid info will be invalid, so
// remove from the part.
XDocument xDoc = part.GetXDocument();
XElement newRoot = (XElement)RemoveRsidTransform(xDoc.Root);
newRoot = (XElement)SingleCharacterRunTransform(newRoot);
xDoc.Elements().First().ReplaceWith(newRoot);
part.PutXDocument();
}