Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paragraph::has_next "lies" and Paragraph::next returns one non-existing paragraph #50

Open
AlexanderVatov opened this issue Dec 22, 2019 · 0 comments

Comments

@AlexanderVatov
Copy link

Paragraph::has_next returns true if the current paragraph exists in the document, even if there is no next paragraph. next() then returns an empty paragraph which does not exist.

Since that last paragraph is empty, this issue is unnoticeable when reading a document. The problem occurs when the user tries inserting a paragraph after the last paragraph:

Paragraph last = doc.paragraphs();
while(last.has_next()) last = last.next();
last.insert_paragraph_after("This should appear after the last paragraph!");

Since last is actually a non-existing paragraph referring to an pugi::xml_node without a rode, the last paragraph is not written to the file.

I intend to fix this issue myself. I also want to add methods append_paragraph and append_run to Document. This would allow generating a long document without using a while loop to obtain the last paragraph as in the example above, and then working on a new Paragraph object for every new paragraph; instead, one would only use the Document object the entire time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant