Discussion:
General Mechanism in WXPF Code for Managing CT IDs?
Eliot Kimber
2018-07-20 09:32:50 UTC
Permalink
For footnotes I need to set a unique ID on each newly-created getCTFtnEdn. In my personal code I was maintaining my own global ID counter that I used to set IDs on things.

However, I'm not finding a similar mechanism in the POI code--is there one or is there a reliable technique for constructing new IDs, e.g., based on the size of lists of things? I'm pretty sure footnote IDs only need to be unique across the footnotes but I'm not 100% sure on the general semantics of IDs in OOXML.

Searching for "setId" I'm not finding any hits outside the test cases, so either this is something the current API just doesn't need to do (because it doesn’t automatically create objects that require IDs) or I'm missing where ID setting happens.

Thanks,

Eliot
--
Eliot Kimber
http://contrext.com




---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org
pj.fanning
2018-07-20 13:22:23 UTC
Permalink
We don't seem to have set ids explicitly normally



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org
Mark Murphy
2018-07-20 15:06:34 UTC
Permalink
According to the spec, the id's for footnotes and end notes are unique to
the note type (footnote or end note). You may want to create this so that
it can handle footnotes or end notes as there are only cosmetic differences
between the two. Similar to header/footer. Id's should be handled
internally so the user does not have to concern themselves with them. If
you are looking at header/footer for examples, please do not generate an
empty paragraph when a footnote or end note is created. This is too
limiting because it forces treating the first paragraph differently than
any potential additional paragraphs when adding content.

Maybe for simplicity it would be nice, for someone creating a document, to
simply be able to insert a footnote or end note with some text at the
current location in the paragraph without having to specify anything else.
The InsertFootnote () method would then do all the necessary background
work (create part if necessary, generate the next id, insert the footnote
reference) and insert the footnote text in the footnote part. It could also
return the footnote for additional modification like stylizing or adding
additional paragraphs, tables, images, etc..
Post by Eliot Kimber
For footnotes I need to set a unique ID on each newly-created getCTFtnEdn.
In my personal code I was maintaining my own global ID counter that I used
to set IDs on things.
However, I'm not finding a similar mechanism in the POI code--is there one
or is there a reliable technique for constructing new IDs, e.g., based on
the size of lists of things? I'm pretty sure footnote IDs only need to be
unique across the footnotes but I'm not 100% sure on the general semantics
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the test cases, so
either this is something the current API just doesn't need to do (because
it doesn’t automatically create objects that require IDs) or I'm missing
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
Eliot Kimber
2018-07-20 15:21:56 UTC
Permalink
I agree that having to treat the first paragraph separately is annoying, however, there are already several classes that do that (e.g., XWPFTableRow, which creates a new cell and that cell has a paragraph), so unless we modify them all to not create an initial child object, it seems like consistency of behavior argues for creating the initial paragraph.

What I have working at the moment is footnote creation where the footnote is created with an initial paragraph that contains the required footnote reference in the first run.

As this reference is mandatory and otherwise requires dropping into the CT classes it seemed reasonable to add the paragraph that then contains the reference.

I also added createParagraph() and createTable() (and now that I think about it I also need the insert* methods as well).
I suppose those methods could add the footnoteref if it's not already present.

Here's my real-world code that uses my new methods (it consumes a simple XML structure that mirrors the OOXML structure and constraints):

private void makeFootnote(XWPFParagraph para, XmlCursor cursor) throws DocxGenerationException {
XWPFFootnote note = para.getDocument().createFootnote();

cursor.toFirstChild();
boolean isFirst = true;
do {
String tagName = cursor.getName().getLocalPart();
if ("p".equals(tagName)) {
XWPFParagraph p =
isFirst ? note.getParagraphs().get(0) : note.createParagraph();
isFirst = false;
makeParagraph(p, cursor);
} else if ("table".equals(tagName)) {
makeTable(note, cursor);
} else {
System.out.println("- [WARN] Unexpected element '" + tagName + "' in <fn>. Ignored.");
}
} while (cursor.toNextSibling());

// Add footnote reference to the paragraph:
CTP paraCTP = para.getCTP();
CTR run = paraCTP.addNewR();
run.addNewRPr().addNewRStyle().setVal("FootnoteReference");
run.addNewFootnoteReference().setId(note.getId());

}

Notice the "isFirst" Boolean--in the abstract it would be nice not to have to do that.

I will certainly defer to the direction from the project team on this aspect of the design.

Cheers,

Eliot
--
Eliot Kimber
http://contrext.com


On 7/20/18, 11:06 AM, "Mark Murphy" <***@gmail.com> wrote:

According to the spec, the id's for footnotes and end notes are unique to
the note type (footnote or end note). You may want to create this so that
it can handle footnotes or end notes as there are only cosmetic differences
between the two. Similar to header/footer. Id's should be handled
internally so the user does not have to concern themselves with them. If
you are looking at header/footer for examples, please do not generate an
empty paragraph when a footnote or end note is created. This is too
limiting because it forces treating the first paragraph differently than
any potential additional paragraphs when adding content.

Maybe for simplicity it would be nice, for someone creating a document, to
simply be able to insert a footnote or end note with some text at the
current location in the paragraph without having to specify anything else.
The InsertFootnote () method would then do all the necessary background
work (create part if necessary, generate the next id, insert the footnote
reference) and insert the footnote text in the footnote part. It could also
return the footnote for additional modification like stylizing or adding
additional paragraphs, tables, images, etc..
Post by Eliot Kimber
For footnotes I need to set a unique ID on each newly-created getCTFtnEdn.
In my personal code I was maintaining my own global ID counter that I used
to set IDs on things.
However, I'm not finding a similar mechanism in the POI code--is there one
or is there a reliable technique for constructing new IDs, e.g., based on
the size of lists of things? I'm pretty sure footnote IDs only need to be
unique across the footnotes but I'm not 100% sure on the general semantics
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the test cases, so
either this is something the current API just doesn't need to do (because
it doesn’t automatically create objects that require IDs) or I'm missing
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org
Murphy, Mark
2018-07-20 19:52:11 UTC
Permalink
Those places that have this behavior are being adjusted as I get to them. So let's not create extra work for later.

-----Original Message-----
From: Eliot Kimber [mailto:***@contrext.com]
Sent: Friday, July 20, 2018 11:22 AM
To: POI Users List <***@poi.apache.org>
Subject: Re: General Mechanism in WXPF Code for Managing CT IDs?

I agree that having to treat the first paragraph separately is annoying, however, there are already several classes that do that (e.g., XWPFTableRow, which creates a new cell and that cell has a paragraph), so unless we modify them all to not create an initial child object, it seems like consistency of behavior argues for creating the initial paragraph.

What I have working at the moment is footnote creation where the footnote is created with an initial paragraph that contains the required footnote reference in the first run.

As this reference is mandatory and otherwise requires dropping into the CT classes it seemed reasonable to add the paragraph that then contains the reference.

I also added createParagraph() and createTable() (and now that I think about it I also need the insert* methods as well).
I suppose those methods could add the footnoteref if it's not already present.

Here's my real-world code that uses my new methods (it consumes a simple XML structure that mirrors the OOXML structure and constraints):

private void makeFootnote(XWPFParagraph para, XmlCursor cursor) throws DocxGenerationException {
XWPFFootnote note = para.getDocument().createFootnote();

cursor.toFirstChild();
boolean isFirst = true;
do {
String tagName = cursor.getName().getLocalPart();
if ("p".equals(tagName)) {
XWPFParagraph p =
isFirst ? note.getParagraphs().get(0) : note.createParagraph();
isFirst = false;
makeParagraph(p, cursor);
} else if ("table".equals(tagName)) {
makeTable(note, cursor);
} else {
System.out.println("- [WARN] Unexpected element '" + tagName + "' in <fn>. Ignored.");
}
} while (cursor.toNextSibling());

// Add footnote reference to the paragraph:
CTP paraCTP = para.getCTP();
CTR run = paraCTP.addNewR();
run.addNewRPr().addNewRStyle().setVal("FootnoteReference");
run.addNewFootnoteReference().setId(note.getId());

}

Notice the "isFirst" Boolean--in the abstract it would be nice not to have to do that.

I will certainly defer to the direction from the project team on this aspect of the design.

Cheers,

Eliot
--
Eliot Kimber
http://contrext.com


On 7/20/18, 11:06 AM, "Mark Murphy" <***@gmail.com> wrote:

According to the spec, the id's for footnotes and end notes are unique to
the note type (footnote or end note). You may want to create this so that
it can handle footnotes or end notes as there are only cosmetic differences
between the two. Similar to header/footer. Id's should be handled
internally so the user does not have to concern themselves with them. If
you are looking at header/footer for examples, please do not generate an
empty paragraph when a footnote or end note is created. This is too
limiting because it forces treating the first paragraph differently than
any potential additional paragraphs when adding content.

Maybe for simplicity it would be nice, for someone creating a document, to
simply be able to insert a footnote or end note with some text at the
current location in the paragraph without having to specify anything else.
The InsertFootnote () method would then do all the necessary background
work (create part if necessary, generate the next id, insert the footnote
reference) and insert the footnote text in the footnote part. It could also
return the footnote for additional modification like stylizing or adding
additional paragraphs, tables, images, etc..
Post by Eliot Kimber
For footnotes I need to set a unique ID on each newly-created getCTFtnEdn.
In my personal code I was maintaining my own global ID counter that I used
to set IDs on things.
However, I'm not finding a similar mechanism in the POI code--is there one
or is there a reliable technique for constructing new IDs, e.g., based on
the size of lists of things? I'm pretty sure footnote IDs only need to be
unique across the footnotes but I'm not 100% sure on the general semantics
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the test cases, so
either this is something the current API just doesn't need to do (because
it doesn’t automatically create objects that require IDs) or I'm missing
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org For additional commands, e-mail: user-***@poi.apache.org

B�KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB��[��X��ܚX�KK[XZ[�\�\�][��X��ܚX�P�K�\X�K�ܙ�B��܈Y][ۘ[��[X[��K[XZ[
Murphy, Mark
2018-07-20 19:56:24 UTC
Permalink
In fact, I think it would be good to change the TableCell behavior before 4.0.0 goes live as that is a breaking change.

-----Original Message-----
From: Murphy, Mark [mailto:***@metalexmfg.com]
Sent: Friday, July 20, 2018 3:52 PM
To: 'POI Users List' <***@poi.apache.org>
Subject: RE: General Mechanism in WXPF Code for Managing CT IDs?

Those places that have this behavior are being adjusted as I get to them. So let's not create extra work for later.

-----Original Message-----
From: Eliot Kimber [mailto:***@contrext.com]
Sent: Friday, July 20, 2018 11:22 AM
To: POI Users List <***@poi.apache.org>
Subject: Re: General Mechanism in WXPF Code for Managing CT IDs?

I agree that having to treat the first paragraph separately is annoying, however, there are already several classes that do that (e.g., XWPFTableRow, which creates a new cell and that cell has a paragraph), so unless we modify them all to not create an initial child object, it seems like consistency of behavior argues for creating the initial paragraph.

What I have working at the moment is footnote creation where the footnote is created with an initial paragraph that contains the required footnote reference in the first run.

As this reference is mandatory and otherwise requires dropping into the CT classes it seemed reasonable to add the paragraph that then contains the reference.

I also added createParagraph() and createTable() (and now that I think about it I also need the insert* methods as well).
I suppose those methods could add the footnoteref if it's not already present.

Here's my real-world code that uses my new methods (it consumes a simple XML structure that mirrors the OOXML structure and constraints):

private void makeFootnote(XWPFParagraph para, XmlCursor cursor) throws DocxGenerationException {
XWPFFootnote note = para.getDocument().createFootnote();

cursor.toFirstChild();
boolean isFirst = true;
do {
String tagName = cursor.getName().getLocalPart();
if ("p".equals(tagName)) {
XWPFParagraph p =
isFirst ? note.getParagraphs().get(0) : note.createParagraph();
isFirst = false;
makeParagraph(p, cursor);
} else if ("table".equals(tagName)) {
makeTable(note, cursor);
} else {
System.out.println("- [WARN] Unexpected element '" + tagName + "' in <fn>. Ignored.");
}
} while (cursor.toNextSibling());

// Add footnote reference to the paragraph:
CTP paraCTP = para.getCTP();
CTR run = paraCTP.addNewR();
run.addNewRPr().addNewRStyle().setVal("FootnoteReference");
run.addNewFootnoteReference().setId(note.getId());

}

Notice the "isFirst" Boolean--in the abstract it would be nice not to have to do that.

I will certainly defer to the direction from the project team on this aspect of the design.

Cheers,

Eliot
--
Eliot Kimber
http://contrext.com


On 7/20/18, 11:06 AM, "Mark Murphy" <***@gmail.com> wrote:

According to the spec, the id's for footnotes and end notes are unique to
the note type (footnote or end note). You may want to create this so that
it can handle footnotes or end notes as there are only cosmetic differences
between the two. Similar to header/footer. Id's should be handled
internally so the user does not have to concern themselves with them. If
you are looking at header/footer for examples, please do not generate an
empty paragraph when a footnote or end note is created. This is too
limiting because it forces treating the first paragraph differently than
any potential additional paragraphs when adding content.

Maybe for simplicity it would be nice, for someone creating a document, to
simply be able to insert a footnote or end note with some text at the
current location in the paragraph without having to specify anything else.
The InsertFootnote () method would then do all the necessary background
work (create part if necessary, generate the next id, insert the footnote
reference) and insert the footnote text in the footnote part. It could also
return the footnote for additional modification like stylizing or adding
additional paragraphs, tables, images, etc..
Post by Eliot Kimber
For footnotes I need to set a unique ID on each newly-created getCTFtnEdn.
In my personal code I was maintaining my own global ID counter that I used
to set IDs on things.
However, I'm not finding a similar mechanism in the POI code--is there one
or is there a reliable technique for constructing new IDs, e.g., based on
the size of lists of things? I'm pretty sure footnote IDs only need to be
unique across the footnotes but I'm not 100% sure on the general semantics
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the test cases, so
either this is something the current API just doesn't need to do (because
it doesn’t automatically create objects that require IDs) or I'm missing
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org For additional commands, e-mail: user-***@poi.apache.org

B�KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB��[��X��ܚX�KK[XZ[
�\�\�][��X��ܚX�P�K�\X�K�ܙ�B��܈Y][ۘ[��[X[��K[XZ[
�\�\�Z[�K�\X�K�ܙ�B

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail:
Eliot Kimber
2018-07-20 15:47:41 UTC
Permalink
On IDs, since the ID space is just footnotes, I'm just using the number of footnotes in the Footnotes' footnote list to generate the next available ID. There didn't seem to be a need for more sophistication than that.

Cheers,

E.

--
Eliot Kimber
http://contrext.com


On 7/20/18, 11:06 AM, "Mark Murphy" <***@gmail.com> wrote:

According to the spec, the id's for footnotes and end notes are unique to
the note type (footnote or end note). You may want to create this so that
it can handle footnotes or end notes as there are only cosmetic differences
between the two. Similar to header/footer. Id's should be handled
internally so the user does not have to concern themselves with them. If
you are looking at header/footer for examples, please do not generate an
empty paragraph when a footnote or end note is created. This is too
limiting because it forces treating the first paragraph differently than
any potential additional paragraphs when adding content.

Maybe for simplicity it would be nice, for someone creating a document, to
simply be able to insert a footnote or end note with some text at the
current location in the paragraph without having to specify anything else.
The InsertFootnote () method would then do all the necessary background
work (create part if necessary, generate the next id, insert the footnote
reference) and insert the footnote text in the footnote part. It could also
return the footnote for additional modification like stylizing or adding
additional paragraphs, tables, images, etc..
Post by Eliot Kimber
For footnotes I need to set a unique ID on each newly-created getCTFtnEdn.
In my personal code I was maintaining my own global ID counter that I used
to set IDs on things.
However, I'm not finding a similar mechanism in the POI code--is there one
or is there a reliable technique for constructing new IDs, e.g., based on
the size of lists of things? I'm pretty sure footnote IDs only need to be
unique across the footnotes but I'm not 100% sure on the general semantics
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the test cases, so
either this is something the current API just doesn't need to do (because
it doesn’t automatically create objects that require IDs) or I'm missing
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org
Mark Murphy
2018-07-21 01:13:32 UTC
Permalink
Have you looked through XWPFFootnote and XWPFFootnotes? XWPFDocument has
some code to create footnotes as well, but it appears that endnotes are
incorrectly references without having a class of thier own. Maybe you
should try correcting these.
Post by Eliot Kimber
On IDs, since the ID space is just footnotes, I'm just using the number of
footnotes in the Footnotes' footnote list to generate the next available
ID. There didn't seem to be a need for more sophistication than that.
Cheers,
E.
--
Eliot Kimber
http://contrext.com
According to the spec, the id's for footnotes and end notes are unique to
the note type (footnote or end note). You may want to create this so that
it can handle footnotes or end notes as there are only cosmetic differences
between the two. Similar to header/footer. Id's should be handled
internally so the user does not have to concern themselves with them. If
you are looking at header/footer for examples, please do not generate an
empty paragraph when a footnote or end note is created. This is too
limiting because it forces treating the first paragraph differently than
any potential additional paragraphs when adding content.
Maybe for simplicity it would be nice, for someone creating a document, to
simply be able to insert a footnote or end note with some text at the
current location in the paragraph without having to specify anything else.
The InsertFootnote () method would then do all the necessary background
work (create part if necessary, generate the next id, insert the footnote
reference) and insert the footnote text in the footnote part. It could also
return the footnote for additional modification like stylizing or adding
additional paragraphs, tables, images, etc..
Post by Eliot Kimber
For footnotes I need to set a unique ID on each newly-created
getCTFtnEdn.
Post by Eliot Kimber
In my personal code I was maintaining my own global ID counter that
I used
Post by Eliot Kimber
to set IDs on things.
However, I'm not finding a similar mechanism in the POI code--is
there one
Post by Eliot Kimber
or is there a reliable technique for constructing new IDs, e.g.,
based on
Post by Eliot Kimber
the size of lists of things? I'm pretty sure footnote IDs only need
to be
Post by Eliot Kimber
unique across the footnotes but I'm not 100% sure on the general
semantics
Post by Eliot Kimber
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the test
cases, so
Post by Eliot Kimber
either this is something the current API just doesn't need to do
(because
Post by Eliot Kimber
it doesn’t automatically create objects that require IDs) or I'm
missing
Post by Eliot Kimber
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
---------------------------------------------------------------------
Eliot Kimber
2018-07-21 09:51:44 UTC
Permalink
I'll double check all the relevant methods in the footnote and footnotes classes. At the moment I'm focused on bottom-of-the-page notes because that's what I need to generate in the context of my client work that is motivating these updates but definitely need to make sure end notes are properly handled. I wanted to get a pull request in before I spent to much time just to make sure I wasn’t going off the rails somewhere.

Cheers,

Eliot
--
Eliot Kimber
http://contrext.com


On 7/20/18, 9:13 PM, "Mark Murphy" <***@gmail.com> wrote:

Have you looked through XWPFFootnote and XWPFFootnotes? XWPFDocument has
some code to create footnotes as well, but it appears that endnotes are
incorrectly references without having a class of thier own. Maybe you
should try correcting these.
Post by Eliot Kimber
On IDs, since the ID space is just footnotes, I'm just using the number of
footnotes in the Footnotes' footnote list to generate the next available
ID. There didn't seem to be a need for more sophistication than that.
Cheers,
E.
--
Eliot Kimber
http://contrext.com
According to the spec, the id's for footnotes and end notes are unique to
the note type (footnote or end note). You may want to create this so that
it can handle footnotes or end notes as there are only cosmetic differences
between the two. Similar to header/footer. Id's should be handled
internally so the user does not have to concern themselves with them. If
you are looking at header/footer for examples, please do not generate an
empty paragraph when a footnote or end note is created. This is too
limiting because it forces treating the first paragraph differently than
any potential additional paragraphs when adding content.
Maybe for simplicity it would be nice, for someone creating a document, to
simply be able to insert a footnote or end note with some text at the
current location in the paragraph without having to specify anything else.
The InsertFootnote () method would then do all the necessary background
work (create part if necessary, generate the next id, insert the footnote
reference) and insert the footnote text in the footnote part. It could also
return the footnote for additional modification like stylizing or adding
additional paragraphs, tables, images, etc..
Post by Eliot Kimber
For footnotes I need to set a unique ID on each newly-created
getCTFtnEdn.
Post by Eliot Kimber
In my personal code I was maintaining my own global ID counter that
I used
Post by Eliot Kimber
to set IDs on things.
However, I'm not finding a similar mechanism in the POI code--is
there one
Post by Eliot Kimber
or is there a reliable technique for constructing new IDs, e.g.,
based on
Post by Eliot Kimber
the size of lists of things? I'm pretty sure footnote IDs only need
to be
Post by Eliot Kimber
unique across the footnotes but I'm not 100% sure on the general
semantics
Post by Eliot Kimber
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the test
cases, so
Post by Eliot Kimber
either this is something the current API just doesn't need to do
(because
Post by Eliot Kimber
it doesn’t automatically create objects that require IDs) or I'm
missing
Post by Eliot Kimber
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org
Eliot Kimber
2018-07-21 11:10:18 UTC
Permalink
Reviewing the OOXML specs it is the case that the current XWPF API does not accommodate end notes as it should.

There needs to be separate XWPFEndnotes and XWPFEndnote classes and document- and section-level code to create and manage them.

I can take that on as a separate activity once we're happy with the enhanced bottom-of-the-page API I'm working on now.

I imagine that for most POI users end notes are an edge case--that's definitely the case for my current client, which does not (normally) use end notes. My client is a publisher that manages municipal code for several thousand cities and counties. They need to generate Word documents that reflect the printed code as closely as possible in terms of structure and content (but not necessarily page layout details). All the codes have bottom-of-the-page footnotes but a few might also use end notes (although I haven't seen that yet in any of the samples).

I've had Publishing clients in the past who did use end notes (it's fairly typical for non-fiction books, textbooks, etc.) but none of the those clients needed to generate Word, only read it in order to create XML from it and in that context the end note/footnote distinction is not interesting (because they all become inline footnote markup in the generated XML).

Cheers,

Eliot
--
Eliot Kimber
http://contrext.com


On 7/21/18, 5:51 AM, "Eliot Kimber" <***@contrext.com> wrote:

I'll double check all the relevant methods in the footnote and footnotes classes. At the moment I'm focused on bottom-of-the-page notes because that's what I need to generate in the context of my client work that is motivating these updates but definitely need to make sure end notes are properly handled. I wanted to get a pull request in before I spent to much time just to make sure I wasn’t going off the rails somewhere.

Cheers,

Eliot
--
Eliot Kimber
http://contrext.com


On 7/20/18, 9:13 PM, "Mark Murphy" <***@gmail.com> wrote:

Have you looked through XWPFFootnote and XWPFFootnotes? XWPFDocument has
some code to create footnotes as well, but it appears that endnotes are
incorrectly references without having a class of thier own. Maybe you
should try correcting these.
Post by Eliot Kimber
On IDs, since the ID space is just footnotes, I'm just using the number of
footnotes in the Footnotes' footnote list to generate the next available
ID. There didn't seem to be a need for more sophistication than that.
Cheers,
E.
--
Eliot Kimber
http://contrext.com
According to the spec, the id's for footnotes and end notes are unique to
the note type (footnote or end note). You may want to create this so that
it can handle footnotes or end notes as there are only cosmetic differences
between the two. Similar to header/footer. Id's should be handled
internally so the user does not have to concern themselves with them. If
you are looking at header/footer for examples, please do not generate an
empty paragraph when a footnote or end note is created. This is too
limiting because it forces treating the first paragraph differently than
any potential additional paragraphs when adding content.
Maybe for simplicity it would be nice, for someone creating a document, to
simply be able to insert a footnote or end note with some text at the
current location in the paragraph without having to specify anything else.
The InsertFootnote () method would then do all the necessary background
work (create part if necessary, generate the next id, insert the footnote
reference) and insert the footnote text in the footnote part. It could also
return the footnote for additional modification like stylizing or adding
additional paragraphs, tables, images, etc..
Post by Eliot Kimber
For footnotes I need to set a unique ID on each newly-created
getCTFtnEdn.
Post by Eliot Kimber
In my personal code I was maintaining my own global ID counter that
I used
Post by Eliot Kimber
to set IDs on things.
However, I'm not finding a similar mechanism in the POI code--is
there one
Post by Eliot Kimber
or is there a reliable technique for constructing new IDs, e.g.,
based on
Post by Eliot Kimber
the size of lists of things? I'm pretty sure footnote IDs only need
to be
Post by Eliot Kimber
unique across the footnotes but I'm not 100% sure on the general
semantics
Post by Eliot Kimber
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the test
cases, so
Post by Eliot Kimber
either this is something the current API just doesn't need to do
(because
Post by Eliot Kimber
it doesn’t automatically create objects that require IDs) or I'm
missing
Post by Eliot Kimber
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org






---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org
Mark Murphy
2018-07-21 16:16:26 UTC
Permalink
Since footnotes and endnotes have essentially the same functionality, it
might be good to create a single abstract class that handles the common
bits. Then it should be trivial to extend the process for endnotes.
Post by Eliot Kimber
Reviewing the OOXML specs it is the case that the current XWPF API does
not accommodate end notes as it should.
There needs to be separate XWPFEndnotes and XWPFEndnote classes and
document- and section-level code to create and manage them.
I can take that on as a separate activity once we're happy with the
enhanced bottom-of-the-page API I'm working on now.
I imagine that for most POI users end notes are an edge case--that's
definitely the case for my current client, which does not (normally) use
end notes. My client is a publisher that manages municipal code for several
thousand cities and counties. They need to generate Word documents that
reflect the printed code as closely as possible in terms of structure and
content (but not necessarily page layout details). All the codes have
bottom-of-the-page footnotes but a few might also use end notes (although I
haven't seen that yet in any of the samples).
I've had Publishing clients in the past who did use end notes (it's fairly
typical for non-fiction books, textbooks, etc.) but none of the those
clients needed to generate Word, only read it in order to create XML from
it and in that context the end note/footnote distinction is not interesting
(because they all become inline footnote markup in the generated XML).
Cheers,
Eliot
--
Eliot Kimber
http://contrext.com
I'll double check all the relevant methods in the footnote and
footnotes classes. At the moment I'm focused on bottom-of-the-page notes
because that's what I need to generate in the context of my client work
that is motivating these updates but definitely need to make sure end notes
are properly handled. I wanted to get a pull request in before I spent to
much time just to make sure I wasn’t going off the rails somewhere.
Cheers,
Eliot
--
Eliot Kimber
http://contrext.com
Have you looked through XWPFFootnote and XWPFFootnotes? XWPFDocument has
some code to create footnotes as well, but it appears that endnotes are
incorrectly references without having a class of thier own. Maybe you
should try correcting these.
On Fri, Jul 20, 2018 at 11:47 AM Eliot Kimber <
Post by Eliot Kimber
On IDs, since the ID space is just footnotes, I'm just using the
number of
Post by Eliot Kimber
footnotes in the Footnotes' footnote list to generate the next
available
Post by Eliot Kimber
ID. There didn't seem to be a need for more sophistication than
that.
Post by Eliot Kimber
Cheers,
E.
--
Eliot Kimber
http://contrext.com
According to the spec, the id's for footnotes and end notes
are unique
Post by Eliot Kimber
to
the note type (footnote or end note). You may want to create
this so
Post by Eliot Kimber
that
it can handle footnotes or end notes as there are only
cosmetic
Post by Eliot Kimber
differences
between the two. Similar to header/footer. Id's should be
handled
Post by Eliot Kimber
internally so the user does not have to concern themselves
with them.
Post by Eliot Kimber
If
you are looking at header/footer for examples, please do not
generate
Post by Eliot Kimber
an
empty paragraph when a footnote or end note is created. This
is too
Post by Eliot Kimber
limiting because it forces treating the first paragraph
differently
Post by Eliot Kimber
than
any potential additional paragraphs when adding content.
Maybe for simplicity it would be nice, for someone creating a
document, to
simply be able to insert a footnote or end note with some
text at the
Post by Eliot Kimber
current location in the paragraph without having to specify
anything
Post by Eliot Kimber
else.
The InsertFootnote () method would then do all the necessary
background
Post by Eliot Kimber
work (create part if necessary, generate the next id, insert
the
Post by Eliot Kimber
footnote
reference) and insert the footnote text in the footnote
part. It could
Post by Eliot Kimber
also
return the footnote for additional modification like
stylizing or
Post by Eliot Kimber
adding
additional paragraphs, tables, images, etc..
On Fri, Jul 20, 2018 at 5:33 AM Eliot Kimber <
Post by Eliot Kimber
For footnotes I need to set a unique ID on each
newly-created
Post by Eliot Kimber
getCTFtnEdn.
Post by Eliot Kimber
In my personal code I was maintaining my own global ID
counter that
Post by Eliot Kimber
I used
Post by Eliot Kimber
to set IDs on things.
However, I'm not finding a similar mechanism in the POI
code--is
Post by Eliot Kimber
there one
Post by Eliot Kimber
or is there a reliable technique for constructing new IDs,
e.g.,
Post by Eliot Kimber
based on
Post by Eliot Kimber
the size of lists of things? I'm pretty sure footnote IDs
only need
Post by Eliot Kimber
to be
Post by Eliot Kimber
unique across the footnotes but I'm not 100% sure on the
general
Post by Eliot Kimber
semantics
Post by Eliot Kimber
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the
test
Post by Eliot Kimber
cases, so
Post by Eliot Kimber
either this is something the current API just doesn't need
to do
Post by Eliot Kimber
(because
Post by Eliot Kimber
it doesn’t automatically create objects that require IDs)
or I'm
Post by Eliot Kimber
missing
Post by Eliot Kimber
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
Eliot Kimber
2018-07-22 09:48:45 UTC
Permalink
That was basically my plan as far as I had thought it through--an end note class is probably functionally identical to existing footnote--it's really only the containing part that's different as far as I can tell from my initial (brief) reading of the OOXML spec.

Cheers,

E.

--
Eliot Kimber
http://contrext.com


On 7/21/18, 12:16 PM, "Mark Murphy" <***@gmail.com> wrote:

Since footnotes and endnotes have essentially the same functionality, it
might be good to create a single abstract class that handles the common
bits. Then it should be trivial to extend the process for endnotes.
Post by Eliot Kimber
Reviewing the OOXML specs it is the case that the current XWPF API does
not accommodate end notes as it should.
There needs to be separate XWPFEndnotes and XWPFEndnote classes and
document- and section-level code to create and manage them.
I can take that on as a separate activity once we're happy with the
enhanced bottom-of-the-page API I'm working on now.
I imagine that for most POI users end notes are an edge case--that's
definitely the case for my current client, which does not (normally) use
end notes. My client is a publisher that manages municipal code for several
thousand cities and counties. They need to generate Word documents that
reflect the printed code as closely as possible in terms of structure and
content (but not necessarily page layout details). All the codes have
bottom-of-the-page footnotes but a few might also use end notes (although I
haven't seen that yet in any of the samples).
I've had Publishing clients in the past who did use end notes (it's fairly
typical for non-fiction books, textbooks, etc.) but none of the those
clients needed to generate Word, only read it in order to create XML from
it and in that context the end note/footnote distinction is not interesting
(because they all become inline footnote markup in the generated XML).
Cheers,
Eliot
--
Eliot Kimber
http://contrext.com
I'll double check all the relevant methods in the footnote and
footnotes classes. At the moment I'm focused on bottom-of-the-page notes
because that's what I need to generate in the context of my client work
that is motivating these updates but definitely need to make sure end notes
are properly handled. I wanted to get a pull request in before I spent to
much time just to make sure I wasn’t going off the rails somewhere.
Cheers,
Eliot
--
Eliot Kimber
http://contrext.com
Have you looked through XWPFFootnote and XWPFFootnotes? XWPFDocument has
some code to create footnotes as well, but it appears that endnotes are
incorrectly references without having a class of thier own. Maybe you
should try correcting these.
On Fri, Jul 20, 2018 at 11:47 AM Eliot Kimber <
Post by Eliot Kimber
On IDs, since the ID space is just footnotes, I'm just using the
number of
Post by Eliot Kimber
footnotes in the Footnotes' footnote list to generate the next
available
Post by Eliot Kimber
ID. There didn't seem to be a need for more sophistication than
that.
Post by Eliot Kimber
Cheers,
E.
--
Eliot Kimber
http://contrext.com
According to the spec, the id's for footnotes and end notes
are unique
Post by Eliot Kimber
to
the note type (footnote or end note). You may want to create
this so
Post by Eliot Kimber
that
it can handle footnotes or end notes as there are only
cosmetic
Post by Eliot Kimber
differences
between the two. Similar to header/footer. Id's should be
handled
Post by Eliot Kimber
internally so the user does not have to concern themselves
with them.
Post by Eliot Kimber
If
you are looking at header/footer for examples, please do not
generate
Post by Eliot Kimber
an
empty paragraph when a footnote or end note is created. This
is too
Post by Eliot Kimber
limiting because it forces treating the first paragraph
differently
Post by Eliot Kimber
than
any potential additional paragraphs when adding content.
Maybe for simplicity it would be nice, for someone creating a
document, to
simply be able to insert a footnote or end note with some
text at the
Post by Eliot Kimber
current location in the paragraph without having to specify
anything
Post by Eliot Kimber
else.
The InsertFootnote () method would then do all the necessary
background
Post by Eliot Kimber
work (create part if necessary, generate the next id, insert
the
Post by Eliot Kimber
footnote
reference) and insert the footnote text in the footnote
part. It could
Post by Eliot Kimber
also
return the footnote for additional modification like
stylizing or
Post by Eliot Kimber
adding
additional paragraphs, tables, images, etc..
On Fri, Jul 20, 2018 at 5:33 AM Eliot Kimber <
Post by Eliot Kimber
For footnotes I need to set a unique ID on each
newly-created
Post by Eliot Kimber
getCTFtnEdn.
Post by Eliot Kimber
In my personal code I was maintaining my own global ID
counter that
Post by Eliot Kimber
I used
Post by Eliot Kimber
to set IDs on things.
However, I'm not finding a similar mechanism in the POI
code--is
Post by Eliot Kimber
there one
Post by Eliot Kimber
or is there a reliable technique for constructing new IDs,
e.g.,
Post by Eliot Kimber
based on
Post by Eliot Kimber
the size of lists of things? I'm pretty sure footnote IDs
only need
Post by Eliot Kimber
to be
Post by Eliot Kimber
unique across the footnotes but I'm not 100% sure on the
general
Post by Eliot Kimber
semantics
Post by Eliot Kimber
of IDs in OOXML.
Searching for "setId" I'm not finding any hits outside the
test
Post by Eliot Kimber
cases, so
Post by Eliot Kimber
either this is something the current API just doesn't need
to do
Post by Eliot Kimber
(because
Post by Eliot Kimber
it doesn’t automatically create objects that require IDs)
or I'm
Post by Eliot Kimber
missing
Post by Eliot Kimber
where ID setting happens.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org

Loading...