本文整理汇总了C#中WordprocessingDocument.AddCoreFilePropertiesPart方法的典型用法代码示例。如果您正苦于以下问题:C# WordprocessingDocument.AddCoreFilePropertiesPart方法的具体用法?C# WordprocessingDocument.AddCoreFilePropertiesPart怎么用?C# WordprocessingDocument.AddCoreFilePropertiesPart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WordprocessingDocument
的用法示例。
在下文中一共展示了WordprocessingDocument.AddCoreFilePropertiesPart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyStartingParts
private static void CopyStartingParts(WordprocessingDocument sourceDocument, WordprocessingDocument newDocument,
List<ImageData> images)
{
// A Core File Properties part does not have implicit or explicit relationships to other parts.
CoreFilePropertiesPart corePart = sourceDocument.CoreFilePropertiesPart;
if (corePart != null && corePart.GetXDocument().Root != null)
{
newDocument.AddCoreFilePropertiesPart();
XDocument newXDoc = newDocument.CoreFilePropertiesPart.GetXDocument();
newXDoc.Declaration.Standalone = "yes";
newXDoc.Declaration.Encoding = "UTF-8";
XDocument sourceXDoc = corePart.GetXDocument();
newXDoc.Add(sourceXDoc.Root);
}
// An application attributes part does not have implicit or explicit relationships to other parts.
ExtendedFilePropertiesPart extPart = sourceDocument.ExtendedFilePropertiesPart;
if (extPart != null)
{
OpenXmlPart newPart = newDocument.AddExtendedFilePropertiesPart();
XDocument newXDoc = newDocument.ExtendedFilePropertiesPart.GetXDocument();
newXDoc.Declaration.Standalone = "yes";
newXDoc.Declaration.Encoding = "UTF-8";
newXDoc.Add(extPart.GetXDocument().Root);
}
// An custom file properties part does not have implicit or explicit relationships to other parts.
CustomFilePropertiesPart customPart = sourceDocument.CustomFilePropertiesPart;
if (customPart != null)
{
newDocument.AddCustomFilePropertiesPart();
XDocument newXDoc = newDocument.CustomFilePropertiesPart.GetXDocument();
newXDoc.Declaration.Standalone = "yes";
newXDoc.Declaration.Encoding = "UTF-8";
newXDoc.Add(customPart.GetXDocument().Root);
}
DocumentSettingsPart oldSettingsPart = sourceDocument.MainDocumentPart.DocumentSettingsPart;
if (oldSettingsPart != null)
{
DocumentSettingsPart newSettingsPart = newDocument.MainDocumentPart.AddNewPart<DocumentSettingsPart>();
XDocument settingsXDoc = oldSettingsPart.GetXDocument();
AddRelationships(oldSettingsPart, newSettingsPart, new[] { settingsXDoc.Root });
CopyFootnotesPart(sourceDocument, newDocument, settingsXDoc, images);
CopyEndnotesPart(sourceDocument, newDocument, settingsXDoc, images);
XDocument newXDoc = newDocument.MainDocumentPart.DocumentSettingsPart.GetXDocument();
newXDoc.Declaration.Standalone = "yes";
newXDoc.Declaration.Encoding = "UTF-8";
newXDoc.Add(settingsXDoc.Root);
CopyRelatedPartsForContentParts(oldSettingsPart, newSettingsPart, new[] { newXDoc.Root }, images);
}
WebSettingsPart oldWebSettingsPart = sourceDocument.MainDocumentPart.WebSettingsPart;
if (oldWebSettingsPart != null)
{
WebSettingsPart newWebSettingsPart = newDocument.MainDocumentPart.AddNewPart<WebSettingsPart>();
XDocument settingsXDoc = oldWebSettingsPart.GetXDocument();
AddRelationships(oldWebSettingsPart, newWebSettingsPart, new[] { settingsXDoc.Root });
XDocument newXDoc = newDocument.MainDocumentPart.WebSettingsPart.GetXDocument();
newXDoc.Declaration.Standalone = "yes";
newXDoc.Declaration.Encoding = "UTF-8";
newXDoc.Add(settingsXDoc.Root);
}
ThemePart themePart = sourceDocument.MainDocumentPart.ThemePart;
if (themePart != null)
{
ThemePart newThemePart = newDocument.MainDocumentPart.AddNewPart<ThemePart>();
XDocument newXDoc = newDocument.MainDocumentPart.ThemePart.GetXDocument();
newXDoc.Declaration.Standalone = "yes";
newXDoc.Declaration.Encoding = "UTF-8";
newXDoc.Add(themePart.GetXDocument().Root);
CopyRelatedPartsForContentParts(themePart, newThemePart, new[] { newThemePart.GetXDocument().Root }, images);
}
// If needed to handle GlossaryDocumentPart in the future, then
// this code should handle the following parts:
// MainDocumentPart.GlossaryDocumentPart.StyleDefinitionsPart
// MainDocumentPart.GlossaryDocumentPart.StylesWithEffectsPart
// A Style Definitions part shall not have implicit or explicit relationships to any other part.
StyleDefinitionsPart stylesPart = sourceDocument.MainDocumentPart.StyleDefinitionsPart;
if (stylesPart != null)
{
newDocument.MainDocumentPart.AddNewPart<StyleDefinitionsPart>();
XDocument newXDoc = newDocument.MainDocumentPart.StyleDefinitionsPart.GetXDocument();
newXDoc.Declaration.Standalone = "yes";
newXDoc.Declaration.Encoding = "UTF-8";
newXDoc.Add(stylesPart.GetXDocument().Root);
}
// A StylesWithEffects part shall not have implicit or explicit relationships to any other part.
StylesWithEffectsPart stylesWithEffectsPart = sourceDocument.MainDocumentPart.StylesWithEffectsPart;
if (stylesWithEffectsPart != null)
{
newDocument.MainDocumentPart.AddNewPart<StylesWithEffectsPart>();
XDocument newXDoc = newDocument.MainDocumentPart.StylesWithEffectsPart.GetXDocument();
newXDoc.Declaration.Standalone = "yes";
newXDoc.Declaration.Encoding = "UTF-8";
newXDoc.Add(stylesWithEffectsPart.GetXDocument().Root);
//.........这里部分代码省略.........