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

Issue #245: HTML Text Styling is not retaining source font size and formatting #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Tatskaari
Copy link

Added some prost processing that will apply styles to elements generated by the HTML -> ODF. These new styles inherit from the elements parent style but have all the style rules of the XDocReport style.

Added post processing in order to set the parent style name of the
XDocreport styles to the style of the parent element. This means that
child elements now inherit style rules from their parent elements.
@Tatskaari
Copy link
Author

Seems this broke an integration test. If you're interested in merging this pull request I can look at fixing it.

@angelozerr
Copy link
Member

Thanks @Tatskaari for your PR!

At first I suggest to you to use XDocReport preprocessor like https://github.com/opensagres/xdocreport/blob/master/document/fr.opensagres.xdocreport.document.docx/src/main/java/fr/opensagres/xdocreport/document/docx/preprocessor/dom/DOMFontsPreprocessor.java instead developping your own preprocessor.

I tell me too if your fix can be done when XDocReport styles are generated?

@Tatskaari
Copy link
Author

Tatskaari commented Oct 11, 2017

@angelozerr I had a look at how the styles are generated and it looks like quite the endeavor to apply this fix when the styles then. The ODTDocumentHandler has methods for translating each HTML styling tag into ODF format. The problem with the DocumentHandler interface is that there's no way to pass the parent element/style to these methods. The DocumentHandler interface is used quite extensively throughout XDocReport so changing it would have a high impact.

    public void startItalics()
        throws IOException
    {
        internalStartSpan( styleGen.getItalicStyleName(), true );
    }

As you can see there's an internal version of a lot of these methods that applies the XDocReport styles. Perhaps there's a way to get the parent style name here but I can't see any easy way. The fix above works for me and I need to move onto another project however if you know of a better way to do this, I might be able to look into it later.

@Tatskaari
Copy link
Author

Tatskaari commented Oct 11, 2017

Regarding the preprocessor stuff: the preprocessors are applied before the template engine is run. Because the XDocReport styles are applied when the template engine mail merges in HTML, I have to apply my fix in post-processing. Perhaps we should create a postprocessor list similar to the preprocessor list.

Edit: I also need access to the styles.xml in order to see the XDocReport styles. The preprocessor only has access to the main content dom.

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 this pull request may close these issues.

None yet

2 participants