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

setStyleNumberWrappedParagraphsAttribute("no-limit") not valid #141

Closed
fschmid opened this issue Dec 11, 2021 · 5 comments
Closed

setStyleNumberWrappedParagraphsAttribute("no-limit") not valid #141

fschmid opened this issue Dec 11, 2021 · 5 comments
Milestone

Comments

@fschmid
Copy link

fschmid commented Dec 11, 2021

I do:

StyleGraphicPropertiesElement gsp =
(StyleGraphicPropertiesElement) OdfXMLFactory.newOdfElement(contentDom,
StyleGraphicPropertiesElement.ELEMENT_NAME);
gsp.setStyleNumberWrappedParagraphsAttribute("no-limit");

and get:
The method setStyleNumberWrappedParagraphsAttribute(Integer) in the type StyleGraphicPropertiesElement is not applicable for the arguments (String)

The odf docs says:
20.318style:number-wrapped-paragraphs
The style:number-wrapped-paragraphs attribute specifies the number of paragraphs that can wrap around a frame if the anchor position of a frame or drawing shape is a paragraph or a character, and the wrap mode specified by the style:wrap attribute is left, right, parallel, or dynamic.
This attribute is only recognized in frames or styles that have a style:wrap attribute attached with a value of left, right, parallel, or dynamic.
The defined values for the style:number-wrapped-paragraphs attribute are:
●no-limit: there is no limit on the number of paragraphs that may wrap around a frame.
●a value of type positiveInteger
The style:number-wrapped-paragraphs attribute is usable with the following element: style:graphic-properties 17.21.
The values of the style:number-wrapped-paragraphs attribute are no-limit or a value of type positiveInteger 18.2.

so how do I set "no-limit" ? Use 0?

@svanteschubert
Copy link
Contributor

Nice catch!

You are right there should not be Integer being generated for this attribute
https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part3-schema/OpenDocument-v1.3-os-part3-schema.html#property-style_number-wrapped-paragraphs at the parent element's class representation StyleGraphicPropertiesElement.java.

The issue is related to code generation therefore dependent on #135
In #135 I have already started to improve the generation of the ODFDOM dom & pkg Java packages.

On the branch odf12-codegen you may find the root problem at the Apache Velocity template in the odfdom project:
https://github.com/tdf/odftoolkit/blob/odf12-codegen/odfdom/src/codegen/resources/dom/template/java-odfdom-element-template.vm#L283

Easy to spot if you compare the generated class and the template side by side in Visual Studio Code with the velocity extension:
image

$valueObject is wrong, we have to go backwards to find out when it was set wrong.
We want at least a String, most typed would be an Enumeration of the possible values, but uncertain if this would not be overengineered (have to think about it).

I won't be able to fix this until the end of January (earliest).
Perhaps someone would like to give it a try. I would love to have a second opinion on code generation.
Apache Velocity is quite fine, has issues but have not found a better alternative so far.
The ODF data model is being extracted from the Multi-Schema-Validator (MSV) via the generator project.
My former colleague wrote some explanation in its package JavaDoc of schema2template, see https://tdf.github.io/odftoolkit/api/schema2template/index.html

I will definitely focus again on the generation part next year and will do improvements in the MSV, see
https://github.com/xmlark/msv/tree/build-refactoring

If someone is interested to help, I am interested to provide guidance by messenger, mail, phone. Anything that helps!

@svanteschubert svanteschubert added the help wanted Extra attention is needed label Dec 11, 2021
@svanteschubert
Copy link
Contributor

From a bit longer look:
The only way Integer could be set at all is
#set ($valueTypes = ${codeModel.getValuetypes($dataTypes)})
see https://github.com/tdf/odftoolkit/blob/odf12-codegen/odfdom/src/codegen/resources/dom/template/java-odfdom-element-template.vm#L242

codeModel is part of the given Java context, see
https://github.com/tdf/odftoolkit/blob/odf12-codegen/generator/schema2template/src/main/java/schema2template/example/odf/SchemaToTemplate.java#L140

codeModel is the SourceCodeModel class and the above function getValueTypes can therefore be found here:
https://github.com/tdf/odftoolkit/blob/odf12-codegen/generator/schema2template/src/main/java/schema2template/example/odf/SourceCodeModel.java#L176

Happy debugging :-)

@svanteschubert
Copy link
Contributor

One last thing, on one side is the generated Java source of ODFDOM and on the other side the ODF XML RelaxNG grammar, which defines all possible ODF documents and is the 'basement' for the code generation.

Of course, we should look at the XML grammar pattern and it is a choice between a positive integer and the "no-limit" string.
http://docs.oasis-open.org/office/OpenDocument/v1.3/os/schemas/OpenDocument-v1.3-schema-rng.html#11617
My bet, the SourceCodeModel omits the mixed return types.

NOTE: Michael and I become last year editors of the OASIS ODF TC and I enhanced the rng file a bit using HTML quite similar as HTML is being used for RFCs - but not automated it generation, yet - see https://github.com/tdf/odftoolkit/blob/master/xslt-runner/src/test/resources/HowTo.md

@svanteschubert
Copy link
Contributor

PS: Velocity is yet-another-syntax and helpful to have syntax highlighted (e.g. in VSCode with extension) the user guide is here:
https://velocity.apache.org/engine/2.3/user-guide.html
Nevertheless, it seemed I was debugging like in old-times only with text output and therefore I suggest to move as much as possible complexity out of the velocity templates into some ODF specific Java classes yet under the example ODF package of schema2template: https://github.com/tdf/odftoolkit/tree/odf12-codegen/generator/schema2template/src/main/java/schema2template/example/odf

The previous mentioned generation of RNG HTML files would be needed in the ODF TC GitHub: https://github.com/oasis-tcs/odf-tc/ I am not a web developer (yet) therefore many of you can do much better in creating something more useable than I did above with the ODF RNG HTML. Any helping hand is most welcome :-)

@svanteschubert svanteschubert removed the help wanted Extra attention is needed label Dec 12, 2022
@svanteschubert svanteschubert added this to the 0.11.0 milestone Dec 12, 2022
@svanteschubert svanteschubert linked a pull request Dec 12, 2022 that will close this issue
@svanteschubert
Copy link
Contributor

Fixed by
The updated generated code allows setting both options:

As a positive integer and "no-limit" is allowed as the attribute value of the ODF XML.

If you got further feedback, please let us know,

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

Successfully merging a pull request may close this issue.

2 participants