Hello everyone,
I need some insight on the following problem.
In Writer, you have the ability to do the following:
- Select several, non-contiguous, text ranges using the Ctrl key.
- Apply a formatting to the selection.
Then, if you undo your last action (ie. going exactly one step backward in the selection history), the entire selected text will be bring back to its previous state.
Now, my question is: how do you achieve the same behavior with an add-on?
Basically, you can select part of the text using for example a XTextCursor. But as far as I now, all XTextRanges could only be expanded to contiguous range (right?).
So, in order to apply formatting on non-contiguous text range, you will actually need to do it segment by segment, by retrieving and modifying each time the XPropertySet of the current selection. In addition to the induced performance cost, at the end, you will have one entry in the undo history for each text segment.
If you have to apply different styles on a relatively big amount of text, the undo history will eventually be overloaded. Which is a big usability issue for an add-on.
Does someone have an idea how we can solve (or mitigate) this issue?
Thanks!
Paul
PS: Actually, the perfect workaround would be to consider all actions triggered by a specific add-on call as a single step in the undo history. There is an actual discussion on the dev ML about the improvement of the undo API that would permit that (among other things): http://www.mail-archive.com/dev@api.ope ... 10649.html
Applying formatting to multiple text ranges at once
Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Return to “Macros and UNO API”
Jump to
- Getting started
- ↳ Survival guide
- ↳ Beginners
- ↳ Getting Started Guide for 4.x
- ↳ Getting Started Guide for 3.x
- ↳ Install, Setup and Troubleshooting
- ↳ Admin Guide
- ↳ MS Windows
- ↳ Linux
- ↳ Mac OSX
- ↳ LibreOffice
- ↳ Tablets
- ↳ Tutorials
- ↳ Writer
- ↳ Calc
- ↳ Base
- Applications
- ↳ Writer
- ↳ Writer Guide for 4.x
- ↳ Writer Guide for 3.x
- ↳ Writer Tutorials
- ↳ Templates
- ↳ Advanced Uses
- ↳ Calc
- ↳ Calc Guide for 4.x
- ↳ Calc Guide for 3.x
- ↳ Calc Functions
- ↳ Calc Tutorials
- ↳ Impress
- ↳ Impress Guide for 4.x
- ↳ Impress Guide for 3.x
- ↳ Draw
- ↳ Draw Guide for 4.x
- ↳ Draw Guide for 3.x
- ↳ Math
- ↳ Math Guide for 4.x
- ↳ Math Guide for 3.x
- ↳ Math Guide for 3.x
- ↳ Base
- ↳ Base Guide for 4.x
- ↳ Wiki
- ↳ Base Tutorials
- ↳ Tables & Queries
- ↳ Forms
- ↳ External Data Sources
- ↳ Reporting
- ↳ Database Examples
- Customizing and Extending
- ↳ Macros and UNO API
- ↳ Basic Guide
- ↳ Code Snippets
- ↳ Extension Repository
- ↳ Macro Repository
- ↳ External Programs
- ↳ Extensions
- ↳ Extensions page
- Community
- ↳ General Discussion
- ↳ Site Feedback
- ↳ Forum Governance
- ↳ User Experience (UX)
- ↳ Announcements
- Business
- ↳ Institutions & Educational
- ↳ Paid support
- ↳ Consultants Directory