LibreOffice Macro that works only on Selected Cells in LibreOffice Writer Table or Selected Cells in Calc Spreadsheet

I have created a macro with the help of Ask Libreoffice that is useful to convert text written in Kruti Dev Font to Unicode and vice versa. The limitation with the macro is it works only with selected text, it do not work with selected cells in table or it do not work in calc spreadsheet. I wish the macro should run with selected cells in libreoffice writer table and selected cells in calc spreadsheet.
Kruti Dev to Unicode Macro Code.odt (60.8 KB)
Uploading: Unicode to Kruti Dev Macro Code.odt…

What font to install to see all Kruti Dev characters? I tried Kruti Dev 010 but there weren’t all characters and there is too much fonts named Kruti Dev on internet.

It isn’t easy task, I made 1st prototype but it was too much slow, so I try faster variant.

Hello, @KamilLanda.
I think we should look into Python codecs.

Might this kruti_replacement_deva.ods (23.4 KB) also do?
Such a table can be maintained (corrections, additions, deletions, ...) by the user regarding possibly specific needs.
The questioner chose inapt means, but he colleted the replacements as he may need them.
BTW: What about a sequence like the actually occurring

LF
LFk
LFkk
LFkkZ

?
If consecutive transliterating replacements are performed in this order “in situ”, LFk and consecutive will never apply. In what way am I wrong?

Kruti Dev 055

A Telegram bot @krutiunicodebot is available for this purpose.

Although this is not what you asked, thought it might be useful to someone else.

1 Like

I also need one unicode to kruti dev

These are two Telegram bots that you may find useful:

@krutiunicodebot – KrutiDev to Unicode
@unicodekrutibot – Unicode to KrutiDev

This is off-topic. Please email me for more information (address in my profile).

This isn’t about any cells, but about te conversion:

Yes. Of course.
We got many pages of code containing a kind of conversion table.
But we did not get a simple plain text file (“ascii” style) with an example of a short (not too short) text coded in Kruti Dev.
I don’t understand this.

In spreadsheets you can select any SheetCellRanges (plural!) which includes the case of many single cells. You then can apply a converting macro to the string of every selected cell, and you can preselect cells by assigning a specific cell style.

TextTables don’t allow the selection of non-contiguous ranges, and there are no cell styles. How to preselect cells needing to get processed: Study the attached example.

(This is independent of whatever macro you want to apply to the mentioned cells.)
disask_127582_PreselectTTcells.odt (19.2 KB)

1st prototype for Writer, test it dutifully because it wasn’t easy to made it. It uses com.sun.star.util.TextSearch and there was also some problem with move of TextCursor (method .goLeft) in cells for Kruti Dev (Latin script was ok) - it need more tests because it seems as bug in Libre and I probably will test it in next days.

Last is 3rd version,
!!! But bug occured !!!

@sokol92 maybe it could be faster with next (and not so easy) modification of TreeSort that should does only one pass of replaced string for all replacements. I deleted TreeSort from Github, but actual documentation is on my web with examples in Python - but only in Czech, I still hadn’t time to translate one to English. But I was more dutiful before some years than I remember :-), and it seems I have the functional extended version on disk also in LibreBasic.

3 Likes

I tried it. Very useful. I think the OP should provide a test document.

It is working for Writer. Now please provide for Calc

There are some problems in Calc to keep the formatting in cells, algorithm from Writer tables failed. It seems it will take more days to solve it.

Take your time.

Your table conversion code has been made available as an extension

But this extension is unreliable now, because the arrays OriginalStrings and TargetStrings aren’t sorted according to length(s)

And it is problem! Because the replacements in arrays have different lengths, so for Kruti2Unicode it need the length-sorting according to lengths in TargetStrings, but for Unicode2Kruti according to lengths in OriginalStrings. Really good IQ test :-)! And really convenient for TreeSort, I will try to solve it with TreeSort.

What did I miss?
Is there ONE realistic short example typed/created in kruti dev?
I still also can’t find resonable explanations. There are “online services” and all sorts of suggestions or recommendations, but neither the examples nor the information.
Is kruti dev the secret of the ages?

2nd prototype for Writer, it should be functional also for normal selections in normal text and also for multiselections.
ind-find-replace-in-cells-KL2.odt (49.0 kB)

I removed duplicities from F&R arrays and sorted ones according to lengths, but the conversion still isn’t 100% reliable now :frowning:.


F&R in Calc are still problematic :frowning:

Not working at all.