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

Navigation/Selection not considering nested paragraphs #82

Open
gtache opened this issue Jan 20, 2021 · 0 comments · May be fixed by #81
Open

Navigation/Selection not considering nested paragraphs #82

gtache opened this issue Jan 20, 2021 · 0 comments · May be fixed by #81

Comments

@gtache
Copy link
Contributor

gtache commented Jan 20, 2021

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.

@gtache gtache linked a pull request Jan 20, 2021 that will close this issue
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 a pull request may close this issue.

1 participant