[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Application default style
From:       Pierre Stirnweiss <pierre.stirnweiss () t-online ! de>
Date:       2009-02-22 19:59:01
Message-ID: 200902222059.02676.pierre.stirnweiss () t-online ! de
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello list,

This mail has got a double purpose. The first is to introduce a new 
possibility, which resulted from my work on fixing 
kotext/opendocument/tests/TestLoading. The second is to offer service/request 
info on how to use this feature throughout Koffice.

A lot of the test failures were due to not having the default properties (font 
and color) set on all the styles. To make it short (and overly simplified), if 
a style defined in the odf file did not set these properties, then there was no 
default to use.
This lead to the implementation of the following.

One can create a file called defaultstyles.xml. In this file, the normal odf 
syntax is used to define application default styles. These application defaults 
are pushed first on the styleStack when loading the styles. This ensures that 
the properties will be set if the odf file does not define them, but also that 
the application default properties are overwritten, should the styles in the 
odf file define them.

This works like this:
- the path to the defaultstyles.xml is added to the KComponentData.
- this KComponentData is passed to the KoOdfLoadingContext on creation, 
together with the KoOdfStyleReader and the KoStore. By default, an invalid 
KComponentData is supplied, so if you don't want this feature, you do not need 
to do anything.
- if the componentData is valid and the file is found, a new styleReader is 
created (called defaultStyleReader) which will contain all the styles defined 
in the defaultstyles.xml file. The same reading/parsing/loading mechanism is 
used than for the "normal" style reader, which means that all styles which are 
handled by KoOdfStyleReader can be used for application default style.
- this defaultStyleReader can be accessed by context->defaultStyleReader().

- after this you can do whatever you want with these styles.

Here is how KWord is using them:

- KoTextSharedLoadingData takes all style elements and calls, for example, 
KoParagraphStyle->loadOdf(styleElement, context). This then calls 
KoOdfLoadingContext->addStyle, to create a styleStack. The properties of this 
styleStack are loaded in the ParagraphStyle. The styleStack is populated first 
with the defaultStyle from the defaultstyles.xml, then by an eventual 
defaultStyle defined in the odf styles, then by all parent styles, and finaly by 
the style being loaded.

So now my proposal: I am offering to implement this in other apps. For this, I 
would need the interested maintainers to first tell me they are interested, and 
secondly to give me some pointers on the style loading/style using mechanism 
and how best to include this in the workflow of the app.

Pierre

[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
"http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" \
content="1" /><style type="text/css">p, li { white-space: pre-wrap; \
}</style></head><body style=" font-family:'DejaVu Sans'; font-size:10pt; \
font-weight:400; font-style:normal;">Hello list,<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><br></p>This mail has got a double purpose. The first is to \
introduce a new possibility, which resulted from my work on fixing \
kotext/opendocument/tests/TestLoading. The second is to offer service/request info on \
how to use this feature throughout Koffice.<br> <p style="-qt-paragraph-type:empty; \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>A lot of the test \
failures were due to not having the default properties (font and color) set on all \
the styles. To make it short (and overly simplified), if a style defined in the odf \
file did not set these properties, then there was no default to use.<br> This lead to \
the implementation of the following.<br> <p style="-qt-paragraph-type:empty; \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>One can create a file \
called defaultstyles.xml. In this file, the normal odf syntax is used to define \
application default styles. These application defaults are pushed first on the \
styleStack when loading the styles. This ensures that the properties will be set if \
the odf file does not define them, but also that the application default properties \
are overwritten, should the styles in the odf file define them.<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; \
                -qt-user-state:0;"><br></p>This works like this:<br>
- the path to the defaultstyles.xml is added to the KComponentData.<br>
- this KComponentData is passed to the KoOdfLoadingContext on creation, together with \
the KoOdfStyleReader and the KoStore. By default, an invalid KComponentData is \
                supplied, so if you don't want this feature, you do not need to do \
                anything.<br>
- if the componentData is valid and the file is found, a new styleReader is created \
(called defaultStyleReader) which will contain all the styles defined in the \
defaultstyles.xml file. The same reading/parsing/loading mechanism is used than for \
the "normal" style reader, which means that all styles which are handled by \
                KoOdfStyleReader can be used for application default style.<br>
- this defaultStyleReader can be accessed by context-&gt;defaultStyleReader().<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><br></p>- after this you can do whatever you want with these \
styles.<br> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><br></p>Here is how KWord is using them:<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>- \
KoTextSharedLoadingData takes all style elements and calls, for example, \
KoParagraphStyle-&gt;loadOdf(styleElement, context). This then calls \
KoOdfLoadingContext-&gt;addStyle, to create a styleStack. The properties of this \
styleStack are loaded in the ParagraphStyle. The styleStack is populated first with \
the defaultStyle from the defaultstyles.xml, then by an eventual defaultStyle defined \
in the odf styles, then by all parent styles, and finaly by the style being \
loaded.<br> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><br></p>So now my proposal: I am offering to implement this in \
other apps. For this, I would need the interested maintainers to first tell me they \
are interested, and secondly to give me some pointers on the style loading/style \
using mechanism and how best to include this in the workflow of the app.<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><br></p>Pierre</p></body></html>



_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic