简体   繁体   English

MS Word,DOCX,开放XML-通过更改XML应用主题

[英]MS Word, DOCX, Open XML - Apply themes by changing XMLs

Need to apply theme from one word document (DOCX) to another via manipulating the XMLs. 需要通过处理XML将主题从一个Word文档(DOCX)应用于另一个。

The road I'm going through is - 我要走的路是-
word/themes folder contains at least one theme#.xml and could have the rels folder containg relationship files. word / themes文件夹至少包含一个theme#.xml,并且rels文件夹可能包含关系文件。 I decided not to touch the rels folder and copy all theme#.xmls (as could be more than one) present in word/theme folder. 我决定不触摸rels文件夹,并复制word / theme文件夹中存在的所有theme#.xmls(可能不止一个)。 This is working for me. 这对我有用。

I have two concerns over it: 我对此有两个担忧:
1. Do I need to add theme1.xml.rels file present in word\\theme_rels as well? 1.是否还需要添加word \\ theme_rels中存在的theme1.xml.rels文件? It contains mapping to one image in word\\media folder. 它包含映射到word \\ media文件夹中的一张图像。 Do I need to add the image mapping too? 我也需要添加图像映射吗?
2. For few themes such as "Quotable", the theme1.xml contains one reference in 'a:fmtScheme' node to relationship id, probably for DrawingML and shapes. 2.对于诸如“ Quotable”之类的少数主题,theme1.xml在'a:fmtScheme'节点中包含一个对关系ID的引用,可能是对DrawingML和形状的引用。

for ex: 例如:

<a:blipFill rotWithShape="1">
<a:blip xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:embed="rId1">

As the "rId1" here refers to styles.xml and maintained in word_rels\\document.xml.rels, my concern is the word_rels\\document.xml.rels mapping to styles.xml could not be rId1 in the document to which theme is getting applied (for instance this could be rId5 for styles.xml). 由于这里的“ rId1”指的是styles.xml并保存在word_rels \\ document.xml.rels中,因此我担心的是映射到styles.xml的word_rels \\ document.xml.rels在主题所在的文档中不能是rId1应用(例如,对于styles.xml,它可以是rId5)。 So, Do I need to change this in theme1.xml while copying to work it properly. 因此,在复制以使其正常工作时,是否需要在theme1.xml中进行更改。

Any help would be greatly appreciated. 任何帮助将不胜感激。

If this XML appears in theme1.xml, 'rId1' is a key in theme1.xml.rels, not the document.xml.rels. 如果此XML出现在theme1.xml中,则“ rId1”是theme1.xml.rels中的键,而不是document.xml.rels中的键。 The relationship ids (rId#) are unique within a 'source' XML document but are not unique within the overall package (.docx file). 关系ID(rId#)在“源” XML文档中是唯一的,但在整个包(.docx文件)中不是唯一的。

Since this one is a <a:blip> element, the relationship will be to an image part, eg image1.jpg. 由于这是一个<a:blip>元素,因此关系将与图像部分有关,例如image1.jpg。 I suspect this one is a large-ish quotation mark image that appears in front of a pull-out quote. 我怀疑这是一个很大的引号图像,出现在拉出式引号的前面。

If you want it to show up properly, you'll want to make sure those relationships and their target parts are reconstructed in your target package. 如果希望它正确显示,则需要确保在目标包中重构了这些关系及其目标部分。 That would mean "yes", you would want to add the theme1.xml.rels file in the right place, as well as the image file it refers to. 这意味着“是”,您需要在正确的位置添加theme1.xml.rels文件及其引用的图像文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM