Skip to content

Commit da68a69

Browse files
authored
Use xref (#308)
1 parent 228bdd7 commit da68a69

25 files changed

+110
-118
lines changed

.openpublishing.publish.config.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,42 @@
66
"build_output_subfolder": "open-xml-docs",
77
"locale": "en-us",
88
"monikers": [],
9-
"moniker_ranges": [],
9+
"moniker_ranges": [
10+
"openxml-2.7.1",
11+
"openxml-2.7.2",
12+
"openxml-2.8.0",
13+
"openxml-2.8.1",
14+
"openxml-2.9.0",
15+
"openxml-2.9.1",
16+
"openxml-2.10.0",
17+
"openxml-2.10.1",
18+
"openxml-2.11.0",
19+
"openxml-2.11.1",
20+
"openxml-2.11.2",
21+
"openxml-2.11.3",
22+
"openxml-2.12.0",
23+
"openxml-2.12.1",
24+
"openxml-2.12.2",
25+
"openxml-2.12.3",
26+
"openxml-2.13.0",
27+
"openxml-2.13.1",
28+
"openxml-2.14.0",
29+
"openxml-2.15.0",
30+
"openxml-2.16.0",
31+
"openxml-2.17.1",
32+
"openxml-2.18.0",
33+
"openxml-2.19.0",
34+
"openxml-2.20.0",
35+
"openxml-3.0.0",
36+
"openxml-3.0.1"
37+
],
1038
"open_to_public_contributors": true,
1139
"customized_tasks": {
1240
"docset_prebuild": [
1341
"_dependentPackages/CommonPlugins/tools/JoinTOC.ps1"
1442
]
1543
},
44+
"xref_query_tags": [ "/dotnet" ],
1645
"type_mapping": {
1746
"Conceptual": "Content",
1847
"ManagedReference": "Content",

docs/general/features.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,21 @@ private sealed class PrivateFeature
3838
{
3939
}
4040
```
41+
4142
> [!NOTE]
4243
> The feature collection on elements is readonly. This is due to memory issues if it is made writeable. If this is needed, please engage on https://github.com/dotnet/open-xml-sdk to let us know your scenario.
4344
4445
## Visualizing Registered Features
4546

46-
The in-box implementations of the `IFeatureCollection` provide a helpful debug view so you can see what features are available and what their properties/fields are:
47+
The in-box implementations of the <xref:DocumentFormat.OpenXml.Features.IFeatureCollection> provide a helpful debug view so you can see what features are available and what their properties/fields are:
4748

4849
![Features Debug View](../media/feature-debug-view.png)
4950

5051
## Available Features
5152

5253
The features that are currently available are described below and at what scope they are available:
5354

54-
### IDisposableFeature
55+
### <xref:DocumentFormat.OpenXml.Features.IDisposableFeature>
5556

5657
This feature allows for registering actions that need to run when a package or a part is destroyed or disposed:
5758

@@ -65,7 +66,7 @@ part.Features.Get<IDisposableFeature>().Register(() => /* Some action that is ca
6566

6667
Packages and parts will have their own implementations of this feature. Elements will retrieve the feature for their containing part if available.
6768

68-
### IPackageEventsFeature
69+
### <xref:DocumentFormat.OpenXml.Features.IPackageEventsFeature>
6970

7071
This feature allows getting event notifications of when a package is changed:
7172

@@ -79,7 +80,7 @@ var feature = package.Features.GetRequired<IPackageEventsFeature>();
7980
> [!NOTE]
8081
> There may be times when the package is changed but an event is not fired. Not all areas have been identified where it would make sense to raise an event. Please file an issue if you find one.
8182
82-
### IPartEventsFeature
83+
### <xref:DocumentFormat.OpenXml.Features.IPartEventsFeature>
8384

8485
This feature allows getting event notifications of when an event is being created. This is a feature that is added to the part or package:
8586

@@ -95,7 +96,7 @@ Generally, assume that there may be a singleton implementation for the events an
9596
> [!NOTE]
9697
> There may be times when the part is changed but an event is not fired. Not all areas have been identified where it would make sense to raise an event. Please file an issue if you find one.
9798
98-
### IPartRootEventsFeature
99+
### <xref:DocumentFormat.OpenXml.Features.IPartRootEventsFeature>
99100

100101
This feature allows getting event notifications of when a part root is being modified/loaded/created/etc. This is a feature that is added to the part level feature:
101102

@@ -111,11 +112,11 @@ Generally, assume that there may be a singleton implementation for the events an
111112
> [!NOTE]
112113
> There may be times when the part root is changed but an event is not fired. Not all areas have been identified where it would make sense to raise an event. Please file an issue if you find one.
113114
114-
### IRandomNumberGeneratorFeature
115+
### <xref:DocumentFormat.OpenXml.Features.IRandomNumberGeneratorFeature>
115116

116117
This feature allows for a shared service to generate random numbers and fill an array.
117118

118-
### IParagraphIdGeneratorFeature
119+
### <xref:DocumentFormat.OpenXml.Features.IParagraphIdGeneratorFeature>
119120

120121
This feature allows for population and tracking of elements that contain paragraph ids. By default, this will ensure uniqueness of values and ensure that values that do exist are valid per the constraints of the standard. To use this feature:
121122

@@ -159,21 +160,3 @@ body2.AddChild(p2);
159160
Assert.NotEqual(p1.ParagraphId, p2.ParagraphId);
160161
Assert.Equal(2, shared.Count);
161162
```
162-
163-
### IPartRootXElementFeature
164-
165-
This feature allows operating on an `OpenXmlPart` by using XLinq features and directly manipulating `XElement` nodes.
166-
167-
```csharp
168-
OpenXmlPart part = GetSomePart();
169-
170-
var node = new(W.document, new XAttribute(XNamespace.Xmlns + "w", W.w),
171-
new XElement(W.body,
172-
new XElement(W.p,
173-
new XElement(W.r,
174-
new XElement(W.t, "Hello World!")))));
175-
176-
part.SetXElement(node);
177-
```
178-
179-
This `XElement` is cached but will be kept in sync with the underlying part if it were to change.

docs/general/how-to-add-a-new-document-part-to-a-package.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This topic shows how to use the classes in the Open XML SDK for Office to add a
2121

2222
## Get a WordprocessingDocument object
2323

24-
The code starts with opening a package file by passing a file name to one of the overloaded **[Open()](/dotnet/api/documentformat.openxml.packaging.wordprocessingdocument.open)** methods of the **[DocumentFormat.OpenXml.Packaging.WordprocessingDocument](/dotnet/api/documentformat.openxml.packaging.wordprocessingdocument)** that takes a string and a Boolean value that specifies whether the file should be opened for editing or for read-only access. In this case, the Boolean value is **true** specifying that the file should be opened in read/write mode.
24+
The code starts with opening a package file by passing a file name to one of the overloaded <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open%2A> methods of the <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> that takes a string and a Boolean value that specifies whether the file should be opened for editing or for read-only access. In this case, the Boolean value is `true` specifying that the file should be opened in read/write mode.
2525

2626
### [C#](#tab/cs-0)
2727
```csharp
@@ -40,14 +40,14 @@ The code starts with opening a package file by passing a file name to one of the
4040
***
4141

4242

43-
The **using** statement provides a recommended alternative to the typical .Create, .Save, .Close sequence. It ensures that the **Dispose** method (internal method used by the Open XML SDK to clean up resources) is automatically called when the closing brace is reached. The block that follows the **using** statement establishes a scope for the object that is created or named in the **using** statement, in this case **wordDoc**. Because the **WordprocessingDocument** class in the Open XML SDK
43+
The **using** statement provides a recommended alternative to the typical .Create, .Save, .Close sequence. It ensures that the **Dispose** method (internal method used by the Open XML SDK to clean up resources) is automatically called when the closing brace is reached. The block that follows the **using** statement establishes a scope for the object that is created or named in the **using** statement, in this case **wordDoc**. Because the <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> class in the Open XML SDK
4444
automatically saves and closes the object as part of its **System.IDisposable** implementation, and because the **Dispose** method is automatically called when you exit the block; you do not have to explicitly call **Save** and **Close**, as long as you use **using**.
4545

4646
[!include[Structure](../includes/word/structure.md)]
4747

4848
## How the sample code works
4949

50-
After opening the document for editing, in the **using** statement, as a **WordprocessingDocument** object, the code creates a reference to the **MainDocumentPart** part and adds a new custom XML part. It then reads the contents of the external
50+
After opening the document for editing, in the **using** statement, as a <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> object, the code creates a reference to the **MainDocumentPart** part and adds a new custom XML part. It then reads the contents of the external
5151
file that contains the custom XML and writes it to the **CustomXmlPart** part.
5252

5353
> [!NOTE]

docs/general/how-to-copy-the-contents-of-an-open-xml-package-part-to-a-document-part-in-a-dif.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ programmatically.
3030

3131
--------------------------------------------------------------------------------
3232
## Getting a WordprocessingDocument Object
33-
To open an existing document, instantiate the [WordprocessingDocument](/dotnet/api/documentformat.openxml.packaging.wordprocessingdocument) class as shown in
33+
To open an existing document, instantiate the <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> class as shown in
3434
the following two **using** statements. In the
3535
same statement, you open the word processing file with the specified
3636
file name by using the [Open](/dotnet/api/documentformat.openxml.packaging.wordprocessingdocument.open) method, with the Boolean parameter.
@@ -57,19 +57,16 @@ order to enable editing the document.
5757
```
5858
***
5959

60-
61-
The **using** statement provides a recommended
60+
The `using` statement provides a recommended
6261
alternative to the typical .Create, .Save, .Close sequence. It ensures
63-
that the **Dispose** method (internal method
62+
that the <xref:System.IDisposable.Dispose> method (internal method
6463
used by the Open XML SDK to clean up resources) is automatically called
6564
when the closing brace is reached. The block that follows the using
6665
statement establishes a scope for the object that is created or named in
67-
the **using** statement. Because the **WordprocessingDocument** class in the Open XML SDK
68-
automatically saves and closes the object as part of its **System.IDisposable** implementation, and because
69-
**Dispose** is automatically called when you
70-
exit the block, you do not have to explicitly call **Save** and **Close**─as
71-
long as you use **using**.
72-
66+
the `using` statement. Because the <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> class in the Open XML SDK
67+
automatically saves and closes the object as part of its <xref:System.IDisposable> implementation, and because
68+
<xref:System.IDisposable.Dispose> is automatically called when you
69+
exit the block, you do not have to explicitly call <xref:DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Save%2A>.
7370

7471
--------------------------------------------------------------------------------
7572

@@ -117,9 +114,9 @@ is stored in the ZIP item theme/theme1.xml:
117114
## How the Sample Code Works
118115
To copy the contents of a document part in an Open XML package to a
119116
document part in a different package, the full path of the each word
120-
processing document is passed in as a parameter to the **CopyThemeContent** method. The code then opens both
121-
documents as **WordprocessingDocument**
122-
objects, and creates variables that reference the **ThemePart** parts in each of the packages.
117+
processing document is passed in as a parameter to the `CopyThemeContent` method. The code then opens both
118+
documents as <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument>
119+
objects, and creates variables that reference the <xref:DocumentFormat.OpenXml.Packaging.ThemePart> parts in each of the packages.
123120

124121
### [C#](#tab/cs-1)
125122
```csharp
@@ -144,8 +141,8 @@ objects, and creates variables that reference the **ThemePart** parts in each of
144141
***
145142

146143

147-
The code then reads the contents of the source **ThemePart** part by using a **StreamReader** object and writes to the target
148-
**ThemePart** part by using a **StreamWriter** object.
144+
The code then reads the contents of the source <xref:DocumentFormat.OpenXml.Packaging.ThemePart> part by using a **StreamReader** object and writes to the target
145+
<xref:DocumentFormat.OpenXml.Packaging.ThemePart> part by using a <xref:System.IO.StreamWriter>.
149146

150147
### [C#](#tab/cs-2)
151148
```csharp
@@ -170,7 +167,7 @@ The code then reads the contents of the source **ThemePart** part by using a **S
170167
--------------------------------------------------------------------------------
171168
## Sample Code
172169
The following code copies the contents of one document part in an Open
173-
XML package to a document part in a different package. To call the **CopyThemeContent** method, you can use the
170+
XML package to a document part in a different package. To call the `CopyThemeContent`` method, you can use the
174171
following example, which copies the theme part from "MyPkg4.docx" to
175172
"MyPkg3.docx."
176173

@@ -207,9 +204,4 @@ Following is the complete sample code in both C\# and Visual Basic.
207204
--------------------------------------------------------------------------------
208205
## See also
209206

210-
211207
- [Open XML SDK class library reference](/office/open-xml/open-xml-sdk)
212-
213-
214-
215-

docs/general/how-to-create-a-package.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,25 @@ from content in the form of **WordprocessingML** XML markup.
2323

2424
[!include[Structure](../includes/word/packages-and-document-parts.md)]
2525

26-
2726
## Getting a WordprocessingDocument Object
2827

29-
In the Open XML SDK, the [WordprocessingDocument](/dotnet/api/documentformat.openxml.packaging.wordprocessingdocument) class represents a Word document package. To create a Word document, you create an instance
30-
of the **WordprocessingDocument** class and
28+
In the Open XML SDK, the <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> class represents a Word document package. To create a Word document, you create an instance
29+
of the <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> class and
3130
populate it with parts. At a minimum, the document must have a main
3231
document part that serves as a container for the main text of the
3332
document. The text is represented in the package as XML using **WordprocessingML** markup.
3433

35-
To create the class instance you call the [Create(String, WordprocessingDocumentType)](/dotnet/api/documentformat.openxml.packaging.wordprocessingdocument.create)
36-
method. Several **Create** methods are
37-
provided, each with a different signature. The sample code in this topic
38-
uses the **Create** method with a signature
39-
that requires two parameters. The first parameter takes a full path
34+
To create the class instance you call <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Create(System.String,DocumentFormat.OpenXml.WordprocessingDocumentType)>. Several <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Create%2A> methods are
35+
provided, each with a different signature. The first parameter takes a full path
4036
string that represents the document that you want to create. The second
41-
parameter is a member of the [WordprocessingDocumentType](/dotnet/api/documentformat.openxml.wordprocessingdocumenttype) enumeration.
37+
parameter is a member of the <xref:DocumentFormat.OpenXml.WordprocessingDocumentType> enumeration.
4238
This parameter represents the type of document. For example, there is a
43-
different member of the [WordProcessingDocumentType](/dotnet/api/documentformat.openxml.wordprocessingdocumenttype) enumeration for each
39+
different member of the <xref:DocumentFormat.OpenXml.WordprocessingDocumentType> enumeration for each
4440
of document, template, and the macro enabled variety of document and
4541
template.
4642

4743
> [!NOTE]
48-
> Carefully select the appropriate **WordProcessingDocumentType** and verify that the persisted file has the correct, matching file extension. If the **WordProcessingDocumentType** does not match the file extension, an error occurs when you open the file in Microsoft Word. The code that calls the **Create** method is part of a **using** statement followed by a bracketed block, as shown in the following code example.
44+
> Carefully select the appropriate <xref:DocumentFormat.OpenXml.WordprocessingDocumentType> and verify that the persisted file has the correct, matching file extension. If the <xref:DocumentFormat.OpenXml.WordprocessingDocumentType> does not match the file extension, an error occurs when you open the file in Microsoft Word.
4945
5046
### [C#](#tab/cs-0)
5147
```csharp
@@ -63,19 +59,18 @@ template.
6359
```
6460
***
6561

66-
6762
The **using** statement provides a recommended
6863
alternative to the typical .Create, .Save, .Close sequence. It ensures
6964
that the **Dispose** () method (internal method
7065
used by the Open XML SDK to clean up resources) is automatically called
7166
when the closing bracket is reached. The block that follows the **using** statement establishes a scope for the
72-
object that is created or named in the **using** statement, in this case **wordDoc**. Because the **WordprocessingDocument** class in the Open XML SDK
67+
object that is created or named in the **using** statement, in this case **wordDoc**. Because the <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> class in the Open XML SDK
7368
automatically saves and closes the object as part of its **System.IDisposable** implementation, and because
7469
**Dispose** is automatically called when you exit the bracketed block, you do not have to explicitly call **Save** and **Close**─as
7570
long as you use **using**.
7671

7772
Once you have created the Word document package, you can add parts to
78-
it. To add the main document part you call the [AddMainDocumentPart()](/dotnet/api/documentformat.openxml.packaging.wordprocessingdocument.addmaindocumentpart) method of the **WordprocessingDocument** class. Having done that,
73+
it. To add the main document part you call <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument.AddMainDocumentPart%2A>. Having done that,
7974
you can set about adding the document structure and text.
8075

8176
[!include[Structure](../includes/word/structure.md)]
@@ -99,7 +94,6 @@ call:
9994
```
10095
***
10196

102-
10397
After you run the program, open the created file "myPkg4.docx" and
10498
examine its content; it should be one paragraph that contains the phrase
10599
"Hello world!"
@@ -114,9 +108,4 @@ Following is the complete sample code in both C\# and Visual Basic.
114108

115109
## See also
116110

117-
118-
119111
- [Open XML SDK class library reference](/office/open-xml/open-xml-sdk)
120-
121-
122-

docs/general/how-to-get-the-contents-of-a-document-part-from-a-package.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ document programmatically.
3030
## Getting a WordprocessingDocument Object
3131
The code starts with opening a package file by passing a file name to
3232
one of the overloaded [Open()](/dotnet/api/documentformat.openxml.packaging.wordprocessingdocument.open) methods (Visual Basic .NET Shared
33-
method or C\# static method) of the [WordprocessingDocument](/dotnet/api/documentformat.openxml.packaging.wordprocessingdocument) class that takes a
33+
method or C\# static method) of the <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> class that takes a
3434
string and a Boolean value that specifies whether the file should be
3535
opened in read/write mode or not. In this case, the Boolean value is
3636
**false** specifying that the file should be
@@ -60,7 +60,7 @@ alternative to the typical .Create, .Save, .Close sequence. It ensures
6060
that the **Dispose** method (internal method
6161
used by the Open XML SDK to clean up resources) is automatically called
6262
when the closing brace is reached. The block that follows the **using** statement establishes a scope for the
63-
object that is created or named in the **using** statement, in this case **wordDoc**. Because the **WordprocessingDocument** class in the Open XML SDK
63+
object that is created or named in the **using** statement, in this case **wordDoc**. Because the <xref:DocumentFormat.OpenXml.Packaging.WordprocessingDocument> class in the Open XML SDK
6464
automatically saves and closes the object as part of its **System.IDisposable** implementation, and because
6565
the **Dispose** method is automatically called
6666
when you exit the block; you do not have to explicitly call **Save** and **Close**─as

0 commit comments

Comments
 (0)