Analysis
Overview
- After the task the saving and loading books feature should be fixed.
Task requirements
After this task the following results will be visible:
- Saving and loading books will be available.
- Backward compatibility with the older books (books using the old text model) will be available.
- Copy/Paste of (styled) text will be available.
- Drag/Drop of (styled) text will be available
- Rtf/Html import/export will be available.
- The server collaboration will be available with the text resources.
This features will work not worse than the existing ones in the trunk.
Task result
The result will be code.
Implementation idea
- Create persisters for the new classes and fix the old ones.
Related
(Add links to related tasks that could be useful or helpful.)
How to demo
- Create a new book in sophie. Save the book. Close the book. Load the book again.
- Create a new book in sophie. Create text frame, type text. Copy the text, paste the text.
- Create a new book in sophie. Create a text resource. Drag and drop the resource in sophie.
- Create a new book in sophie. Import html or rtf document.
Design
--------BASE_PERSISTER_PART--------------------
In order to achieve this functionallity the following changes have been made:
- In TextRun class add new function : public HotStyleDef getRunStyles() - retrieves the styles that the run contains and returns the styles of the TextRun. This is needed in the persister class of the TextRun (TextRunPersister).
- In HotStyleDef class add new function : public ImmMap<HotAttr<?>, Object> getValues() - getter for all attributes that the current HotStyleDef consists of, returns the current HotStyleDef values for the contained attributes. This is needed while persisting the HotStyleDef objects(in HotStyleDefPersister class).
- In ImmMap interface add new function: Map<K, V> toMap() - gets the Map for the current ImmMap and returns a Map view of the ImmMap. This is needed because HotStyleDef#derive
(Map<HotAttr<?>, Object> styleValues) takes Map and while persisting the HotStyleDef
we have only ImmMap available.
- Implement the toMap() function in ImmTreeMap class.
- In org.sophie2.base.model.text.persistence add new classes:
- public class HotStyleDefPersister extends RefToStoragePersister<HotStyleDef> - persister for
HotStyleDef class. It persists the Map of the HotAttr<?> -> Object of the HotStyleDef objects.
- public class TextRunPersister extends RefToStoragePersister<TextRun> - persister for TextRun class. It persists the text of the TextRun as string and it's HotStyleDef.
- public class ImmHotTextPersister extends RefToStoragePersister<ImmHotText> - persister for ImmHotText class. It persists the ImmHotText as follows: gets the TextRun-s of the text and persists them.
- Rename the HotTextIntervalPersister to ImmTextIntervalPersister.
--------CONVERT_PERSISTER_PART--------------
Implementation
(Describe and link the implementation results here (from the wiki or the repository).)
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)