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

Various list numbering improvements #565

Merged
merged 6 commits into from
Jul 11, 2014
Merged

Conversation

satsuper
Copy link
Contributor

This PR adds support for displaying multi level list numbering. The approach used was to use a different counter for each level instead of using nested CSS counters. This was because you can limit the levels of numbering displayed to a subset of the current level e.g. displaying two levels

  1. Level 1
        1.1. Level 2
            1.1. Level 3
                1.1. Level 4

The nested counter approach was not compatible with the above option of list numbering.

Also added was continuing the numbering of previous lists in the document. This approach was intially modeled off existing code in OdfCanvas that partially implemented this feature but due to a regression this code was not being reached anymore.

The new approach assigns unique counters to all text:list elements regardless of whether they need to be continued or not. This allows us to circumvent CSS scoping rules that prevent using the same counter across different lists which was how the old approach worked. If a list continues another list in the document it can simply be assigned the unique counters from the list it continues from. This is a cleaner approach overall as it reduces the amount of overridden CSS rules.

Lists can either continue the list directly preceding them in document or they can continue a list anywhere in the document by referencing its xml:id. Both these cases are handled in this PR.

To better illustrate the three main improvements made in this PR I have included a comparison screenshot of WebODF rendering the updated visual-tests.fodt.

comparison

@kogmbh-ci
Copy link

Build failed.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1547/

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1552/

while (displayLevels > 0) {
content += " counter(" + listCounterName + (textLevel - displayLevels + 1) + "," + stylemap[style] + ")";
if(displayLevels > 1) {
content += '"' + suffix + '"';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should suffix use the escapeCSSString function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, is this expected to add a suffix char after each individual list item? I can't find anything in the ODT specs around how this should work, but from playing with LibreOffice, this seems to be purely a suffix (i.e., after the complete counter). The joining character looks like it's always a decimal.

If this isn't the case, it'd be good to make sure your test document contains a list definition showing the behaviour you expect from this loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had assumed that suffix was also the list separator but your analysis is correct and supported by this helpful link https://wiki.openoffice.org/wiki/Number_labels

@peitschie
Copy link
Contributor

Due to the difficulties with getting the actual rendered text from a pseudo element, I'd suggest additional tests be added to webodf/tests/visual-tests.fodt for these new list behaviours. This allows a document that can be loaded and manually verified by a human to ensure WebODF behaviour remains correct.

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1558/

// check the previous list to be continued has the same list style
if (styleName === previousStyleName) {
list.setAttributeNS(helperns, "reset-none", "true");
rule = 'text|list[webodfhelper|reset-none="true"] ';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is now a general rule that can be placed in webodf.css.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this but this doesn't seem to work as this rule needs to override an existing dynamic rule for the list counter reset.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably would need to be { counter-reset: none !important; }

@kogmbh-ci
Copy link

Build failed.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1562/

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1577/

} else if (node.localName === "list-level-style-bullet") {
contentRule = getBulletRule(node);
}
return contentRule + ';';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The surrounding \n's and the comments above should be kept together with the content rule creation.

@satsuper satsuper changed the title List numbering Various list numbering improvements May 7, 2014
@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1581/

@thz
Copy link
Member

thz commented May 8, 2014

May I propose to also update the welcome.odt file to feature the improvements with this PR?

@peitschie
Copy link
Contributor

@thz we would definitely be open to that. Do you have any suggestions?

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1584/

* Assigns a unique identifier to this list element and gives it a list counter
* using CSS rules that target the unique identifier
* @param {!string} id
* @param {!Element} listElement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note in the API dox that this could be a list or a list-item. Ideally the name of the argument would hint to that as well, because I initially with just listElement understood that this could be just a text:list element and was puzzled by the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have changed some of this code around now, the rule generation method only takes text:list elements while the recursive tree traversal deals with all elements.

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1838/

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1839/

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1916/

@satsuper
Copy link
Contributor Author

satsuper commented Jul 8, 2014

Just pushed up a rebase so that this can be looked at again soon :bowtie:

@kossebau
Copy link
Contributor

On my schedule for tomorrow/this friday. Really looking forward to get this finally in.

* <office:document>
* <text:list>
* <text:list-item/> counter: level1 value: 1
* <text:list>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the detailed explanation, helps a lot!
One nitpick: the example does not match the ODF spec, <text:list> elements can be only childs of <text:list-item> elements, not <text:list>directly, so the example should be something like

<text:list>
    <text:list-item>  counter: level1 value: 1
        <text:list>
            <text:list-item/> counter: level2 value: 1
        </text:list>
    </text:list-item>

etc.

@kossebau
Copy link
Contributor

Cool 🍦 ! Might be that my eyes got tired by looking at it a third(?) time, but could only find those minor problems :) So please work on those, then rebase, for the final testing. I put the "Ship it" stamp already on my desk, to be able to quickly apply it :)

Satvik Kumar added 6 commits July 12, 2014 02:58
Moved the processing of the list style to get the content rule into a
separate method so it can be re used for continue list styles. Also
ensured that the new getContentRule function returns a complete rule with
the semicolon on the end.
Implemented a changed list counter setup where each list level has its own
counter. This is to support behaviour defined where you can display only a
subset of the list numbers.

This is defined here:
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1418890_253892949
Giving each list a unique counter allows us to implement continued
numbering functionality while avoiding unexpected numbering due to how CSS
counter values are scoped to an elements sibilings or children.
This adds support for the text:continue-numbering and text:continue-list
attributes. The text:continue-numbering attribute specifies whether to
continue the immediately preceding list if it has the same style.

http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#attribute-text_continue-numbering

The text:continue-list attribute specifes the unique identifier of a list
to continue numbering from in the document. These must also have the same
style.

http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#attribute-text_continue-list

https://tools.oasis-open.org/issues/browse/OFFICE-3558
The removed code was intended to implement continue list functionality.
However this code no longer worked due to a regression introduced in commit 3ae9e0c.

As I have refactored this area and implemented the continue list
functionality in the new list styles class this old code is no longer
required.

The removed code in OdfCanvas also made use of the
getFirstNonWhitespaceChild function in OdfUtils and the removed code was
the last remaining usage of it. As it is preferable to make use of DOM API
calls which give us the desired behaviour such as
element.firstElementChild I have removed this function.
Added unit tests for the continue lists and added some examples of
continued and multi level lists to visual-tests.fodt
@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/1939/

@kossebau
Copy link
Contributor

Really good work! Let's have it in master. Please merge!

satsuper added a commit that referenced this pull request Jul 11, 2014
Various list numbering improvements
@satsuper satsuper merged commit 85fff61 into webodf:master Jul 11, 2014
@satsuper satsuper deleted the list-numbering branch August 8, 2014 01:12
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.

6 participants