By checking only nodes that pass the supplied node filter, the position
logic can safely ignore out-of-place cursors near highlighted annotations.
Note, this can't re-use PositionIterator.previousNode, because the logic
requires the previous sibling of the current container's previous sibling.
Some unit tests compare an XML snippet before and after the execution of a
set of operations. For this comparison to pass all the text nodes had to
be exactly the same even if they were not contained in an ODF paragraph.
This imposed a limitation on the tests as they could not have any
whitespace between node structures that were compared in the test files.
Having whitespace is useful to format the test XML data so that it is more
human readable/editable.
This commit filters out any text nodes not contained by an ODF paragraph
so that any test comparisons won't be affected by these text nodes.
This behaviour was working prior to the merge paragraph operation being
introduced. A new edge case was introduced related to cleaning up empty
spans that caused this to regress.
getTextElements may return some unexpected text nodes if the step filters
haven't correctly identified the first/last step in the paragraph. Rather
than failing completely in this case, simply log the unexpected items and
skip them.
getTextElements itself still needs to be fixed in these cases, but the
harm caused by such mistakes is slightly reduced in this instance.
In order to improve the OT-ability of text and paragraph removal
with other operations, the merge behaviour has been extracted.
The logic for building up the necessary remove operations has
been encapsulated in TextController for now as all uses pass
through this point still.
In order to allow convergence between collaborative clients, the split
paragraph op needs to specify what the resulting style of the new
paragraph will be.
Allowing the same bookmark to appear multiple times in this particular cache
causes major headaches when the bookmark is updated, as EACH step-to-DOM (s2D)
entry pointing to the bookmark would also need to be updated.
As there is no real performance benefit from having the same bookmark
appear multiple times, life is made significantly simpler by only allowing
the bookmark to appear a maximum of once in the s2D cache.
Downgrade whitespace now follows the same logic as upgrade, and will
downgrade a whitespace element just to the left of the step, and to the
left of the next step to the right.
Using step iterators instead of position iterators also fixes some failing
operation tests by ensuring one step to the right is checked irrespective
of how many positions there are between steps.
* Make TextController specify the mergedParagraphStyleName
when generating a RemoveText operation. No longer let
OpRemoveText decide the merge order from the context.
* Remove the text:style-name attribute on a paragraph
if the aforementioned property is an empty string.
* Add tests for this.
If an insert text operation is created that contains non-tab non-space
whitespace characters (e.g, \r\n etc.), these will now be treated as if
they were simply space characters and inserted accordingly. A warning
is logged for diagnostics purposes.
This prevents crashing on unexpected behaviour because the number of
inserted steps is consistent with the operation's text length.
Dictation engines enter new data via the same IME mechanism that multi
-language support uses. In this particular instance, the dictation
program supports the phrase "new paragraph" or "new line", which causes
it put a new-line character in the event trap, which the IME handling
happily converts directly into an InsertText op with a new line.
Using step iterators ensures the current and next step are always
upgraded, even if the next step is more than 2 positions away from the
current step.
Additionally, the logic has been corrected to upgrade the character to
the LEFT of the step rather than the right. This better matches the
intended step position as described in README_cursorpositions.txt.
Fixes issues #514.
Whenever any iteration occurs, the cache needs to be updated so damage
can be repaired. This particular change fixes an issue where restoring
from the root bookmark ends up iterating up to the first damaged
paragraph bookmark, which should cause the paragraph bookmark to be
repaired.
This requires consumers to be able to mark ALL current bookmarks as
damaged, which is now achieved by passing in "-1" as the inflection
step to the damageCacheAfter(…) call.
Fixing this bug has exposed another existing issue that potentially
re-orders bookmarks that share the same step. This uncovered problem
will be addressed in a subsequent commit.
Fixes the cache corruption aspect of issue #503
The step cache verification only ensures the cache is valid when step
conversion is requested. Therefore, to force the cache to recheck
after completing the test, the maximum available step is requested.
When first created, the text style applicator used to move nodes around
within the first while loop, often modifying the limiting range in ways
that were not expected.
In 5a86bdd, this behaviour was re-written to gather all the relevant
nodes and migrate them once all siblings in the container were checked.
With this change, it is now best to use the range once again, as this
avoids additional problems (see the modified test) with new children
being added within the range if new styling containers are inserted.
If an auto-collapsing container (e.g., a span) has text with a trailing
empty text node inside the container, the trailing text node is removed
immediately in order to collapse the span. This empty text node may also
appear in the textNodes to be removed, so each subsequent text element
needs to ensure it hasn't already been deleted.
Converting the cache to a damage-based approach improves the per-update
efficiency immensely, but carries some additional risk as invalid
bookmarks are deliberately left behind for performance reasons.
This patch specifically fixes an issue where bookmarks between the
undamaged step and the current iterator position were being treated as
repaired bookmarks, when in fact they were still damaged (as they had
never been seen during iteration in the document). The new logic will
ensure these bookmarks stay in the damaged region until they are
eventually iterated over in an updateCache call.
A happy side effect of this is that all query functions now only ever
return undamaged bookmarks, making the class itself easier to use and
understand.
Existing behaviour was slow if the cursor has a large distance between
the
anchor and focus nodes. It also tended to lose the first letter when
right
near the start of a paragraph or root boundary.
New logic avoids the need for expensive positional lookups, instead
exploiting the fact that the actual step value of the cursor is expected
to be unmoved. This allows the start and end points of the range to be
simply moved to their nearest valid step.
* Re-ordered ambiguous elements in test
"Remove_DeleteLastCharacterInSpan"
Fixes issue #261
The tests test the behavior of a selection. The failing test tests the problem described in issue 261:
When you select some text from the beginning of the first paragraph in a document and try to direct-style it, the left end of the selection creeps to the right by 1 step after the style is applied.
determine walkability around annotations via
the TextPositionFilter.
- In checkLeftRight, now that positions to the left
and right of an annotation are walkable by default,
block the position to the right of an annotation
if there is a grouping element (span, annotation
highlight, etc) to the right.
- Thus, now you can step to both the left and right
of a rangeless annotaiton.
If the annotaiton has a highlighted range, the cursor
won't be able to step between the <office:annotation>
element and it's annotationHighlight, so there
can be no strange text insertion there, and no
rewrapping is required over the newly inserted text
as it goes straight into the highlighted span
like everywhere else.
* Add tests to OdtDocumentTests for cursor positions
around annotations.
* Add tests to operationtests.xml (mostly bumping up
the positions of SplitParagraph operations after
adding annotations, now that 1 new position is exposed.