128 Commits
Author SHA1 Message Date
Friedrich W. H. Kossebau 1d24d462c8 In OpAddAnnotation support annotated ranges with 0 length
Before 0 length was assumed to be an annotation without a range
2015-03-26 13:42:23 +01:00
Friedrich W. H. Kossebau 45726eb701 Fix OpMergeParagraph to not remove empty text:p of annotations' text 2015-03-25 11:11:29 +01:00
Philip Peitsch 9fba50ac69 Fix position instability around highlighted annotations
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.
2014-09-30 11:29:33 +10:00
Philip Peitsch 1586b9f36c Add additional tests showing position stability problems 2014-09-30 11:29:33 +10:00
Satvik Kumar a19452ab54 Filter out meaningless text nodes from unit tests
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.
2014-09-11 18:55:03 +10:00
Philip Peitsch 29f228a9f3 Support selection & deletion of more ODF fields
* Includes a tool to help parse the RNG to figure out text containers
* Add demonstration section to visual-tests document

Fixes #772
2014-09-11 15:32:27 +10:00
Philip Peitsch ea0723a6ea Fix preservation of foreign elements on paragraph merge
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.
2014-08-13 00:13:06 +10:00
Philip Peitsch e03940b19b Add test demonstrating foreign elements are discarded on paragraph merge 2014-08-12 22:52:34 +10:00
Philip Peitsch 3141621018 Allow merge paragraph to handle unexpected nodes near paragraph boundaries
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.
2014-08-11 15:08:45 +10:00
Philip Peitsch 72ca4a3b5e Add test showing merge paragraph assert with some exotic odf elements 2014-08-11 14:56:15 +10:00
Philip Peitsch 93f8526849 Don't discard highlighted annotations when merging paragraphs
All text nodes that are children of grouping elements should be counted
as ODF content.

Fixes #666.
2014-06-19 22:36:26 +10:00
Philip Peitsch 80c91eb25f Cleanup leading/trailing insignificant whitespace on paragraph merge
Failing to clean up these empty whitespace blocks will cause them to
unexpectedly become significant whitespace after a merge is performed.
2014-06-17 03:13:01 +10:00
Philip Peitsch 06ecc7d8c8 Implement OpMergeParagraph
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.
2014-06-17 03:13:00 +10:00
Philip Peitsch ff97ac053e Make SplitParagraph op specify the new paragraph style
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.
2014-06-13 22:46:48 +10:00
Friedrich W. H. Kossebau 8c350e927b Add license header also to all CSS and big test data xml files 2014-06-03 12:37:12 +02:00
Philip Peitsch 70f0cbf5dc Apply merged paragraph styles using OpSetParagraphStyle
Reduce the complexity within the remove text operation and push it up to
the controller instead.
2014-05-23 00:34:59 +10:00
Philip Peitsch e5b052c438 Ensure each bookmark is only present ONCE in the step-to-DOM point cache
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.
2014-05-19 23:23:59 +10:00
Philip Peitsch 8ba76d4dd6 Add additional asserts to verify cache integrity
Add asserts to detect cache corruption of the nature experienced here.
These more stringent checks have caused an additional operation test to
fail.
2014-05-19 23:23:58 +10:00
Philip Peitsch 873c3c6fe2 Add operation test showing steps cache update issue
Steps are rather arcane as they were discovered using a fuzzer (Bella).
2014-05-19 23:23:58 +10:00
Philip Peitsch 21f2462dec Re-align downgrade whitespace logic to match upgrade whitespace
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.
2014-05-16 21:40:13 +10:00
Aditya Bhatt f9907179f8 Add property mergedParagraphStyleName to OpRemoveText spec.
* 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.
2014-04-24 23:25:11 +02:00
Philip Peitsch db1dd02731 Allow insert text op to gracefully cope with strange whitespace
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.
2014-04-17 19:36:26 +10:00
Philip Peitsch 6cbd8c4702 Add test showing reproducible crash when using dictation on OSX 10.9
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.
2014-04-17 19:36:26 +10:00
Philip Peitsch 9d9b3be906 Add operations test showing empty spans created on paragraph split 2014-04-12 00:46:10 +10:00
Philip Peitsch f811e1c081 Ensure upgrade whitespace logic always upgrades current and next step
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.
2014-04-12 00:46:09 +10:00
Philip Peitsch fd55cc0677 Add operation test showing issue with split paragraph near spaces 2014-04-12 00:46:09 +10:00
Philip Peitsch 6766a96de3 Update the StepsCache when restoring a bookmarked position
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
2014-04-09 17:05:32 +10:00
Philip Peitsch 289aa5face Add failing operation test showing caching issue 2014-04-09 17:05:31 +10:00
Philip Peitsch cb4a84dd93 Force the entire step cache to be revalidated after operation tests
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.
2014-04-09 17:05:31 +10:00
Philip Peitsch 29fefe65bd Use ranges when applying a style to better handle DOM changes
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.
2014-03-22 17:50:17 +11:00
Philip Peitsch 8ddbc66b43 Add failing test showing crash with apply styles op 2014-03-22 17:50:16 +11:00
Friedrich W. H. Kossebau 071dc4ae91 prefix "annotationHighlight" element classname with "webodf-" 2014-03-10 15:43:48 +01:00
Philip Peitsch 3014631cbc Harden up OpRemoveText to better cope with empty text nodes
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.
2014-03-05 00:32:37 +11:00
Philip Peitsch c7b3fced00 Add failing unit test for crash when removing empty text nodes 2014-03-05 00:32:37 +11:00
Philip Peitsch 93fe54aee7 Ensure damaged bookmarks are never leaked outside of the cache
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.
2014-03-01 00:59:02 +11:00
Friedrich W. H. Kossebau 13068db6d8 Add op tests reproducing issue #417 2014-02-28 21:19:49 +11:00
Philip Peitsch e05974ef21 Stop whitespace upgrade logic from creating empty text nodes 2014-02-28 20:59:45 +11:00
Philip Peitsch ff6e83e6a1 Add checks for empty text nodes in OperationTests
Empty text nodes should never be left behind by an operation. Adding
these extra checks have caused some operations to fail.
2014-02-28 19:00:34 +11:00
Friedrich W. H. Kossebau b9beecaf9f Create direct linking between matching annotation and annotation-end elements 2014-02-06 12:44:44 +01:00
Philip Peitsch 7d5b77ce8f Don't re-order non-ODF children when merging paragraphs
Child order of non-ODF nodes should be preserved when merging
paragraphs.
2014-02-05 17:54:07 +11:00
Philip Peitsch 58ff0da610 Preserve both cursor and anchor nodes when removing an annotation 2014-01-15 23:23:49 +11:00
Philip Peitsch 012f7d98b4 Implemented faster & more robust cursor position fixing logic
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
2014-01-15 11:29:49 +11:00
Philip Peitsch f769e727ec Fix incorrect test expectations (reproducing issue 261) 2014-01-15 11:26:59 +11:00
Philip Peitsch 320e255b36 Exclude any text content inside a cursor node the document text body
A cursor cannot contain valid document text, and should never be returned
in text node or text elements collections.
2014-01-09 21:52:35 +11:00
Friedrich W. H. Kossebau ed4d08a4db Integrate failing operation tests into normal run 2014-01-08 16:08:37 +01:00
Jos van den Oever 26ec905ab2 Add two tests, one of which currently fails.
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.
2013-12-20 18:25:40 +01:00
lli 05f41bac2f Added hyperlink support for text elements 2013-12-13 17:40:21 +11:00
Aditya Bhatt 724fc6951f Adapt tests to work with the new SplitParagraph behavior.
Also add a test to transformationtests.xml to check for
correct behavior whilst splitting at the same position.
2013-12-06 12:37:34 +01:00
Aditya Bhatt 8201188d7b * Use the new isInlineRoot method in OdfUtils, to
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.
2013-12-06 11:13:52 +01:00
Aditya Bhatt 4a14f79bc6 Adapt tests to specify the moveCursor flag
when using OpInsertText.
2013-12-05 17:26:19 +01:00