From koffice-devel Sun Feb 22 19:59:01 2009 From: Pierre Stirnweiss Date: Sun, 22 Feb 2009 19:59:01 +0000 To: koffice-devel Subject: Application default style Message-Id: <200902222059.02676.pierre.stirnweiss () t-online ! de> X-MARC-Message: https://marc.info/?l=koffice-devel&m=123533235806452 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============0302718017==" --===============0302718017== Content-Type: multipart/alternative; boundary="Boundary-00=_G6aoJPts1zSU9OT" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-00=_G6aoJPts1zSU9OT Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --Boundary-00=_G6aoJPts1zSU9OT Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit 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

--Boundary-00=_G6aoJPts1zSU9OT-- --===============0302718017== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ koffice-devel mailing list koffice-devel@kde.org https://mail.kde.org/mailman/listinfo/koffice-devel --===============0302718017==--