Skip to content

Navigation/Selection not considering nested paragraphs #82

Description

@gtache

Consider the following odt xml:

...
<text:p text:style-name="parent_style">
    <draw:frame draw:style-name="frame_style" draw:name="frame" text:anchor-type="paragraph" svg:x="2.589cm" svg:width="5.198cm" draw:z-index="4">
        <draw:text-box fo:min-height="0.665cm">
            <text:p text:style-name="paragraph_draw_style">Testing frame</text:p>
        </draw:text-box>
    </draw:frame>
    <text:span text:style-name="P1">Te</text:span>
    <text:span text:style-name="P2">sting</text:span>
    <text:span text:style-name="P3"> parent</text:span>
</text:p>
...

If we search for Testing, the first match will be in the sub paragraph in the frame. The next match in the parent paragraph won't be found though, as the Navigation#getNextMatchElementInTree method automatically calls nextSibling on the parent (note that it'd also be true if Testing was in a single span).
Checking in the parent if it is a paragraph shouldn't be difficult by adding a simple condition, but the tricky part would probably be avoiding re-matching the sub-paragraphs.

The other problem (due to the same assumption) appears when refreshing the selections: Assuming we currently have a selection on parent and one one frame; if we replace frame by, for example, something, the Selection#refresh static method won't refresh the parent selection, as it only considers selections that are in the same element. If we then try to replace parent, we'll get an exception.
The solution would be to also check for selections in parent elements when refreshing (which should be pretty easy), but again, the tricky part is to know if we have to refresh the parent selection or not, depending on where the child selection is regarding to the parent one.

I made a basic PR #81, but it still needs some work on the tricky parts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions