When does suppressLineNumbers not suppress line numbers? - ms-word

I have a Word document with this style:
<w:style w:type="paragraph" w:customStyle="1" w:styleId="myStyle">
<w:name w:val="myStyle"/>
<w:basedOn w:val="ListParagraph"/>
<w:qFormat/>
<w:rsid w:val="005F5C84"/>
<w:pPr>
<w:widowControl/>
<w:numPr>
<w:numId w:val="1"/>
</w:numPr>
<w:suppressLineNumbers/>
<w:spacing w:before="240" w:line="360" w:lineRule="auto"/>
<w:ind w:left="0" w:firstLine="720"/>
<w:contextualSpacing w:val="0"/>
</w:pPr>
</w:style>
Because of the <w:suppressLineNumbers/> tag, I'd expect that Word would not show line numbers, but Word does show the line numbers.
How do I know when <w:suppressLineNumbers/> should take effect? I'm not finding any good documentation on this.
Below is the paragraph in case that helps.
<w:p ...>
<w:pPr>
<w:pStyle w:val="myStyle"/>
</w:pPr>
<w:r w:rsidRPr="00126430">
<w:t xml:space="preserve">Text</w:t>
</w:r>
</w:p>

Word line numbering is per Section, not per Style. Add or remove line numbers
It's possible to drop this into the XML for a paragraph to suppress the line numbering for that paragraph:
<w:pPr>
<w:suppressLineNumbers/>
</w:pPr>
But there's nothing analogous for use in a style. There's no online documentation for using that parameter in a style, either.

Related

Getting the Content of a ContentControl Field as RichText

i am trying to create a Word Template, where Users put in notes with basic formating options (like Bullet List , indentations etc.). But i need that content as Richtext, to display it in a browser.
I thought the RichText ContentControl field would save its content as.. well Richtext. But it turns out to be ooxml.
Is there maybe some converter to convert a richtext field to actual richtext?
Currently its content looks like this:
<w:sdtContent>
<w:p>
<w:pPr>
<w:pStyle w:val="Listenabsatz" />
<w:ind w:left="4320" />
</w:pPr>
<w:proofErr w:type="spellStart" />
<w:r>
<w:t>Ztzjtzj</w:t>
</w:r>
<w:proofErr w:type="spellEnd" />
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Listenabsatz" />
<w:ind w:left="4320" />
</w:pPr>
<w:proofErr w:type="spellStart" />
<w:r>
<w:t>Tzjtzjtzj</w:t>
</w:r>
<w:proofErr w:type="spellEnd" />
</w:p>
</w:sdtContent>

Define tab size in Word document

I would like to calculate tab size in white spaces, that is, roughly how many spaces the tab contains.
Here is a snippet of this Open XML document:
<w:body>
<w:p w14:paraId="606C743E" w14:textId="78B4DBA2" w:rsidR="009322DC" w:rsidRPr="00641B97" w:rsidRDefault="00641B97" w:rsidP="00641B97">
<w:pPr>
<w:pStyle w:val="KNotice"/>
<w:keepNext/>
<w:spacing w:after="0"/>
<w:rPr>
<w:szCs w:val="20"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:szCs w:val="20"/>
</w:rPr>
<w:tab/>
</w:r>
<w:r w:rsidR="00B846CC">
<w:rPr>
<w:szCs w:val="20"/>
</w:rPr>
<w:t>Some text.</w:t>
</w:r>
</w:p>
<w:sectPr w:rsidR="009322DC" w:rsidRPr="00641B97">
<w:pgSz w:w="12240" w:h="15840"/>
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
<w:cols w:space="720"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
I will use Open XML SDK for parsing, but before, trying to find property responsible for this tab size, for example, changing <w:szCs w:val="20"/> does not affect.
I noticed that this size is changed while manipulating First Line Indent or Left Indent, hence I assume there is not some single property that stores value of tab size and maybe I have to manipulate some several properties for that.
Is there such property in document structure? Or it should be calculated in some way?

Word ooxml difference between Mac and Windows

When attempting to get the ooxml from the document I've found a variance.
In Windows, iPad, and Word Online in a document that has a cross reference that will break if you update it, but is not yet broken. (Meaning if you right click it and press update then it will go to to the "Error! Reference source not found." Then the xml will display the text value:
<w:r>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r>
<w:instrText xml:space="preserve"> REF _Ref274197646 \n \h </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="separate"/>
</w:r>
<w:bookmarkStart w:id="39" w:name="_Read0190056i"/>
<w:bookmarkStart w:id="40" w:name="_Read0190047i"/>
<w:r>
<w:t>(i)</w:t>
</w:r>
<w:bookmarkEnd w:id="39"/>
<w:bookmarkEnd w:id="40"/>
<w:r>
<w:fldChar w:fldCharType="end"/>
</w:r>
However in the Mac even though the screen is displaying the text, the xml shows the broken reference text.
<w:r>
<w:rPr>
<w:b/>
<w:bCs/>
</w:rPr>
<w:t>Error! Reference source not found.</w:t>
</w:r>
This feels like a bug, as the different versions of word should report the xml largely the same.

Issue with listnum track changes in OpenXml(Revisions)

I have turned on the track changes(Revisions) option in word and made some changes and found all the track changes were being tracked and found in the openxml content. but i am not seeing the deleted listnum value in openxml content and the listnum values are continued from the next paragraph. so how can I track/get the deleted listnum value in openXml.
More details on the issue - we have 5 paragraphs with listnums (a) to (e). I turned on track changes and deleted listnum value (b) so that second paragraph has no listnum now. I thought I might get the value (b) in openxml since I turned on track changes but I am not able to get the deleted value (b) from openxml.
Thanks,
Manu
A single bulletpoint may use the following xml. It's a single Paragraph containing the text 'Item1' in a Run. The ParagraphProperties applies the style 'ListParagraph' and refers to a numbering:
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph" />
<w:numPr>
<w:ilvl w:val="0" />
<w:numId w:val="1" />
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item1</w:t>
</w:r>
</w:p>
If Track Changes is enabled and I delete the text 'Item1' I get xml like the following:
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph" />
<w:pPrChange w:author="Daniel Brixen" w:date="2017-02-16T09:37:00Z" w:id="0">
<w:pPr>
<w:pStyle w:val="ListParagraph" />
<w:numPr>
<w:numId w:val="1" />
</w:numPr>
<w:ind w:hanging="360" />
</w:pPr>
</w:pPrChange>
</w:pPr>
<w:del w:author="Daniel Brixen" w:date="2017-02-16T09:37:00Z" w:id="2">
<w:r>
<w:delText>Item2</w:delText>
</w:r>
</w:del>
</w:p>
Two things to note:
The deleted text is in a DeletedRun-element
The change in paragraph-properties is recorded by a ParagraphPropertiesChange-element.
So you should be able to find the deleted text by using something like this:
using (var doc = WordprocessingDocument.Open(#"c:\temp\test.docx", true))
{
var deletedText = doc.MainDocumentPart.Document.Body.Descendants<DeletedText>();
Console.WriteLine(String.Join(" ", deletedText.Select(t => t.Text)));
}
Using Open XML Productivity Tool is helpful when debugging stuff like this.

Why isn't this OOXML text bold?

I'm looking at an OOXML WordprocessingML document that has bold enabled in the paragraph style, but no indication in the run level style. No other linked styles make any indications about bold status. I expected that inheritance would dictate the text to be bold, but when I view it in Mac Word 2016 the text ("Trailing Text") is unbolded. Why is that?
Here's the example:
<w:p>
<w:pPr>
<w:pStyle w:val="InconsequentialStyle"/>
<w:jc w:val="both"/>
<w:rPr>
<w:b/>
<w:color w:val="000000" w:themeColor="text1"/>
<w:sz w:val="28"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
<w:color w:val="000000" w:themeColor="text1"/>
<w:sz w:val="28"/>
</w:rPr>
<w:t xml:space="preserve">Leading text: </w:t>
</w:r>
<w:r>
<w:rPr>
<w:color w:val="000000" w:themeColor="text1"/>
<w:sz w:val="28"/>
</w:rPr>
<w:t xml:space="preserve">Trailing Text</w:t>
</w:r>
</w:p>
The text in the first run ("Leading Text:") is bolded by Word, which is my expectation. Does the lack a <w:b/> element turn the style off? If so, then what's the point of allowing the tag in the paragraph's style? FWIW, Word's formatting does appear to be the formatting preference of the document's author. I just can't figure out why this code is producing the desired effect.
If it helps, this text is not in a table, list or anything else. This <w:p> is a child of <w:body> and <w:docDefaults> doesn't specify anything about bold.
I'm seeing the same behavior with the <w:color> style in a different paragraph, so it's not just toggle styles. Please help me understand how Word is interpreting this code.
If you want to apply direct formatting to a run of text you have to specify that formatting in the run properties of that run – and not in the run properties of the paragraph. That means the behavior you see is correct application behavior.
The run properties of the paragraph are used to format the paragraph marker. This formatting is used in Word to format list numbers and bullets: