Code Monkey home page Code Monkey logo

Comments (4)

tbaliance avatar tbaliance commented on July 25, 2024

Yup, I'll add it. I think the second part (NumId) is incorrect in your example though, it's a reference to a numbering definition defined in numbering.xml

from unioffice.

freb avatar freb commented on July 25, 2024

A reference to number.xml seems a little more legit than choosing a random int :).

Thanks, yet again.

from unioffice.

tbaliance avatar tbaliance commented on July 25, 2024

@freb Done, check out _examples/document/simple for example usage.

To mimic what you were doing, you can do this instead:

para.SetNumberingLevel(level)
para.SetNumberingDefinitionByID(defnID)

from unioffice.

freb avatar freb commented on July 25, 2024

I think there might be an error in the implementation. I also might be wrong.

In document.xml, paragraphs look like look like this (second indented item):

<w:p w14:paraId="1D8F95A7" w14:textId="294F4857" w:rsidP="00BD6BD9" w:rsidR="00BD6BD9" w:rsidRDefault="00BD6BD9">
	<w:pPr>
		<w:pStyle w:val="ListOrdered"/>
		<w:numPr>
			<w:ilvl w:val="1"/>
			<w:numId w:val="2"/>
		</w:numPr>
	</w:pPr>
	<w:r>
		<w:t>List Item Text Here</w:t>
	</w:r>
</w:p>

In numbering.xml, there are num's and abstractNum's. Mine looks like this:

<w:abstractNum w15:restartNumberingAfterBreak="0" w:abstractNumId="0">
	...
</w:abstractNum>
<w:abstractNum w15:restartNumberingAfterBreak="0" w:abstractNumId="1">
	...
</w:abstractNum>
<w:num w:numId="1">
	<w:abstractNumId w:val="0"/>
</w:num>
<w:num w:numId="2">
	<w:abstractNumId w:val="1"/>
</w:num>

The numId value in the paragraph looks like it points to a <w:num>, not an abstractNum.

The helper methods on the paragraph, SetNumberingDefinition and SetNumberingDefinitionByID both essentially operate on a NumberingDefinition which is a CT_AbstractNum. This sets the NumId on the NumPr of the paragraph properties PPr.NumPr.NumId, but they set it equal to the id of the abstractNum that is passed in.

I believe the PPr.NumPr.NumId should point to a CT_Num.NumIdAttrwhich is an entry in doc.Numbering.X().Num. CT_Num then contains the reference to the AbstractNumId that you want to use.

I don't think the function signatures for the paragraph helpers needs to change since any lookups or creations would take place against the abstractNum, but the CT_Num would probably need to be looked up or created based on the abstractNum so that the CT_Num could then be referenced.

I noticed in my XML there are two abstractNums with ids 0 and 1, but the paragraph references use IDs 1 and 2 which match the <w:num> tags. The naming also seems to line up.

Let me know if I have something wrong.

from unioffice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.