Date: prev next · Thread: first prev next last


I will give that a go. Thank you.

Regards,
Malte.

On 29 Aug 2021, at 23:02, Svante Schubert <svante.schubert@gmail.com> wrote:

Hello Malte,

Am So., 29. Aug. 2021 um 10:09 Uhr schrieb Malte Stien <malte@stien.de>:

Hi again,

I have progressed a little. Simple things appear to be simple. I have a
question with respect to styles, though.

It appears that OdfTextDocument.newTextDocument(); creates a ODT document
with lots of styles. I would like to be a little more minimalistic and have
as few styles as possible; those default styles are rather confusing.

The template styles the user are those, the user will expect by default in
a LibreOffice (or OpenOffice).
The following ODF documents are bundled in the JAR and one is being loaded
as an empty document:
https://github.com/tdf/odftoolkit/tree/master/odfdom/src/main/resources
^^FYI: the default Maven directory structure
<https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html>
defines that everything beyond "main" will become part of the deliverable.

For instance, the JAR ODT empty template is being loaded here:
https://github.com/tdf/odftoolkit/blob/master/odfdom/src/main/java/org/odftoolkit/odfdom/doc/OdfTextDocument.java#L88



I was thinking of one of the following:

1. The documentation for the above states "ODF text document based on a
default template". That implies that there might be other templates. Is
that the case? Where would I find them? How do I create a newTextDocument()
with one of those?

You might overwrite your newTextDocument() or directly call
OdfDocument.loadTemplate(...)  see
https://github.com/tdf/odftoolkit/blob/8ba9c40ae27284739e54b4f18c26f4796b53a40c/odfdom/src/main/java/org/odftoolkit/odfdom/doc/OdfDocument.java#L202


2. Could I create a styles.xml with, say, LibreOffice, or even an XML
editor and load that somehow? Or an ODT template created with LibreOffice?

When we once created the ODF files for the JARs, I have saved an empty
document in LibreOffice and afterwards opened the XML within the ZIP using
JEDIT with the archive plugin to finetune the XML. You might want to use
the XML plugin of JEdit for indent as well, but the indent is not ODF
conform and might insert space within paragraphs.

One of my future aimed fun projects is to create a Visual Studio Code
extension for ODT, which when an ODT is being opened by VSC opens
content.xml, styles.xml and meta.xml by default using ODFDOM (perhaps
binary compiled using GraalVM to allow ease of use without Java). There the
indent would be ODF conformant and we could do many nice tricks.
If someone on the list had worked on a VSC extension, I would love to get
in contact with you! :-)

Until this project, the JUNIT way is the most elegant to me.



3. Is there a class that represents the styles.xml? I have not found it,
yet. (Does not seem to be OdfStyle). Is there a way I can create a clean
one of those and then attach that to the OdfTextDocument somehow?

The styles.xml file is represented in the DOM folder by
https://github.com/tdf/odftoolkit/blob/8ba9c40ae27284739e54b4f18c26f4796b53a40c/odfdom/src/main/java/org/odftoolkit/odfdom/dom/OdfStylesDom.java




What is the cleverest way to do this?

If your goal is to add your own styles, I would suggest working with
LibreOffice to add/delete the template styles you do not desire.
If there is more manual fine-tuning desired, you might want to use JEdit
with the Archive extension to open, edit & save the XML from within the ODT
document (ZIP).


Thank you,
Malte.


Good luck! :-)
Svante



--
To unsubscribe e-mail to: dev+unsubscribe@odftoolkit.org
Problems?
https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.odftoolkit.org/dev/
Privacy Policy: https://www.documentfoundation.org/privacy



-- 
To unsubscribe e-mail to: dev+unsubscribe@odftoolkit.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.odftoolkit.org/dev/
Privacy Policy: https://www.documentfoundation.org/privacy


-- 
To unsubscribe e-mail to: dev+unsubscribe@odftoolkit.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.odftoolkit.org/dev/
Privacy Policy: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.