[WebODF] RFC: Making OpApplyStyle and OpUpdateParagraphStyle more consistent

Philip Peitsch P.Peitsch at qsrinternational.com
Thu Jul 25 02:38:40 CEST 2013


On 25/07/2013, at 5:38 AM, Friedrich W. H. Kossebau wrote:

> Hi,
> 
> OpApplyStyle and OpUpdateParagraphStyle are currently quite different:
> a) how they encode the style attributes to change
> b) OpApplyStyle does not really support unsetting of attributes
> c) OpApplyStyle and related code only does textstyle properties
> d) OpApplyStyle does not directly modify existing styles, but create any 
> needed automatic styles to have the given styling
> e) OpApplyStyle has a too generic name
> 
> 
> Before I start to write anything for OT of OpApplyStyle things needs to be 
> cleaned up a little, to reduce the complexity due to the different behaviour.
> 
> 
> For a) OpApplyStyle takes some "info" payload that are actually directly the 
> ODF element names and properties+values that should be set to the direct 
> formatting. The names of the property and attributes use the usual prefix to 
> indicate the namespace. OpUpdateParagraphStyle instead has a "setProperties" 
> payload that carries the properties+values to set, with an own id scheme that 
> first needs to be mapped to the ODF values.

+1 I'm happy for this standardisation

> Q: anyone would mind to rename that "info" property to "setProperties", for 
> some more entropy in the name?
> Okay to remove the custom property names and mapping in OpUpdateParagraphStyle 
> and use directly the ODF attribute names as well?

+1 for this as well. I don't think the custom mapping adds any benefit in reality, as that
would put the onus on us to write documentation for this custom mapping. At least
ODF styles are (fairly) well documented

> In matters of b), OpUpdateParagraphStyle has a payload "removedProperties" 
> which stores the names of all attributes that should be removed. That was done 
> like that instead of listing the attribute with value >null<, >undefined< or 
> "" in the "setProperties" to express that is should be removed, because >null< 
> and >undefined< might not exist in other languages and "" could be an actual 
> valid value.
> 
> Q: does it make sense to add something similar like "removedProperties" to 
> OpApplyStyle? I guess it does.

This concept doesn't really make any sense for direct formatting.

For example:

<p style="font-weight: bold"><span>hi</span> there!</p>

I might accidentally think that to make the "hi" text non-bold, I should OpApplyStyle with 
removedProperties =[font-weight]. This doesn't make any real sense though, as the
element I'm formatting (the styling of the span) doesn't have a property to remove.

If I remove it off the paragraph element, I'll incorrectly unbold " there!" as well.

The end user intent is never to remove formatting (with the exception of a specific
OpRemoveDirectFormatting option or similar). Rather, when they say "unbold this",
they really mean "make this range font-weight=normal".

> For c) I wonder what the plans are for paragraph styling. There is no TODO or 
> anything else mentioned. And I am only thinking of the op spec, not of the 
> actual implementation how to execute this op.

> Q: Should the same op be used for direct paragraph styling? So should there 
> be, like in OpUpdateParagraphStyle, another section "paragraphProperties", 
> next to "textProperties"? 

I wrote OpApplyStyle to allow the possibility of that taking care of paragraph
and text properties if desired. But, I'm not particularly attached to that approach.

I like OpApplyStyle's range-based operation. It makes translation from the cursor
easier, and the operation is still quite straightforward. But… I am worried about
whether inverse operations (i.e., proper undo) can be created for range-based
operations .


> The difference mentioned in d) seems wanted, as this op is rather a direct 
> mapping of some UI action, like we have with OpRemoveText or OpSplitParagraph. 
> So no question about that issue.
> 
> 
> WRT e), I propose the name "OpApplyDirectStyling"

+1 I'm happy for that!


Thanks again for your work maintaining the technical integrity of webodf :).
The codebase is a pleasure to work in (apart from CMakeFiles.txt that I keep
forgetting how to update properly…)



More information about the WebODF mailing list