Bug 138380 - Basic-IDE - Missing feature to export COLORIZED basic code in a WRITER document + Workaround
Summary: Basic-IDE - Missing feature to export COLORIZED basic code in a WRITER docume...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.4.7.2 release
Hardware: All All
: low enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 138379 (view as bug list)
Depends on:
Blocks: BASIC-IDE
  Show dependency treegraph
 
Reported: 2020-11-20 19:49 UTC by Hans-Werner
Modified: 2023-05-13 17:00 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
CodeColorizerBasic.bas (15.92 KB, application/octet-stream)
2020-11-20 19:50 UTC, Hans-Werner
Details
CodeColorizerBasic.odt (21.73 KB, application/vnd.oasis.opendocument.text)
2020-11-20 19:50 UTC, Hans-Werner
Details
CodeColorizerBasic - ReferenceData.odt (19.35 KB, application/vnd.oasis.opendocument.text)
2020-11-20 19:51 UTC, Hans-Werner
Details
CodeColorizerBasic - Info ENG.odt (29.39 KB, application/vnd.oasis.opendocument.text)
2020-11-20 19:52 UTC, Hans-Werner
Details
CodeColorizerBasic - Info ENG.odt (29.54 KB, application/vnd.oasis.opendocument.text)
2020-11-23 07:04 UTC, Hans-Werner
Details
CodeColorizerBasic.bas (16.73 KB, text/plain)
2021-01-07 15:42 UTC, Hans-Werner
Details
CodeColorizerBasic.odt (21.97 KB, application/vnd.oasis.opendocument.text)
2021-01-07 15:44 UTC, Hans-Werner
Details
CodeColorizerBasic - Info ENG.odt (28.10 KB, application/vnd.oasis.opendocument.text)
2021-01-07 15:46 UTC, Hans-Werner
Details
CodeColorizerBasic - Info DEU.odt (28.97 KB, application/vnd.oasis.opendocument.text)
2021-01-07 15:46 UTC, Hans-Werner
Details
CodeColorizerBasic - Info ENG.odt (28.27 KB, application/vnd.oasis.opendocument.text)
2021-01-07 15:53 UTC, Hans-Werner
Details
CodeColorizerBasic - Info DEU.odt (28.99 KB, application/vnd.oasis.opendocument.text)
2021-01-07 16:41 UTC, Hans-Werner
Details
TestData (5.11 KB, text/plain)
2022-06-06 13:49 UTC, Hans-Werner
Details
TestData - LO Basic IDE - ScreenPrint Part 1 (39.78 KB, image/png)
2022-06-06 13:50 UTC, Hans-Werner
Details
TestData - LO Basic IDE - ScreenPrint Part 2 (25.90 KB, image/png)
2022-06-06 13:50 UTC, Hans-Werner
Details
TestData - LO Basic IDE - ScreenPrint Part 3 (22.63 KB, image/png)
2022-06-06 13:51 UTC, Hans-Werner
Details
TestData - coooder - basic4gl (17.65 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:51 UTC, Hans-Werner
Details
TestData - coooder - blitzbasic (17.25 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:52 UTC, Hans-Werner
Details
TestData - coooder - freebasic (17.49 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:52 UTC, Hans-Werner
Details
TestData - coooder - qbasic (17.48 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:53 UTC, Hans-Werner
Details
TestData - coooder - vb (17.36 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:54 UTC, Hans-Werner
Details
TestData - coooder - vbnet (17.63 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:54 UTC, Hans-Werner
Details
TestData - Code Colorizer Formatter (17.62 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:55 UTC, Hans-Werner
Details
TestData - CodeColorizerBasic (17.38 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:56 UTC, Hans-Werner
Details
CCB (23.00 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:57 UTC, Hans-Werner
Details
CCB - User Manual ENG (27.07 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:58 UTC, Hans-Werner
Details
CCB - User Manual DEU (27.50 KB, application/vnd.oasis.opendocument.text)
2022-06-06 13:58 UTC, Hans-Werner
Details
LO 7.3.4.2 (x64) - Basic IDE - ScreenPrint (110.45 KB, image/png)
2022-06-17 08:55 UTC, Hans-Werner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Werner 2020-11-20 19:49:31 UTC
Description:
In regard to Basic-IDE I'm missing a feature to export COLORIZED basic code in a WRITER document for furthermore usage.

Therefore I wrote a little basic macro to do this job. The macro uses the basic function "replaceAll" and some "regular expressions" to colorize basic code the same way as to be seen when displayed by the Basic-IDE.

It's just a workaround. If this workaround could be useful for the LO community feel free to use the macro as you like, e.g., as a workaround for the  above mentioned missing feature.

The better way surely would be to use the Basic-IDE display data while the basic code is displayed by the Basic-IDE, but this would be a big job to be realized and - in my opinion - not be done by LO developers next time because of other more important work to be  done.

Greetings
Hans-Werner

Actual Results:
There's no Basic-IDE feature to export COLORIZED basic code in a WRITER document for furthermore usage.

Expected Results:
n/a


Reproducible: Always


User Profile Reset: No



Additional Info:
There should be a Basic-IDE feature to export COLORIZED basic code in a WRITER document for furthermore usage.
Comment 1 Hans-Werner 2020-11-20 19:50:22 UTC Comment hidden (obsolete)
Comment 2 Hans-Werner 2020-11-20 19:50:57 UTC Comment hidden (obsolete)
Comment 3 Hans-Werner 2020-11-20 19:51:30 UTC Comment hidden (obsolete)
Comment 4 Hans-Werner 2020-11-20 19:52:10 UTC Comment hidden (obsolete)
Comment 5 Hans-Werner 2020-11-23 07:04:57 UTC Comment hidden (obsolete)
Comment 6 Justin L 2020-11-30 17:48:29 UTC
*** Bug 138379 has been marked as a duplicate of this bug. ***
Comment 7 Hans-Werner 2021-01-07 15:42:58 UTC Comment hidden (obsolete)
Comment 8 Hans-Werner 2021-01-07 15:44:56 UTC Comment hidden (obsolete)
Comment 9 Hans-Werner 2021-01-07 15:46:06 UTC Comment hidden (obsolete)
Comment 10 Hans-Werner 2021-01-07 15:46:58 UTC Comment hidden (obsolete)
Comment 11 Hans-Werner 2021-01-07 15:53:16 UTC Comment hidden (obsolete)
Comment 12 Hans-Werner 2021-01-07 16:41:58 UTC
Created attachment 168754 [details]
CodeColorizerBasic - Info DEU.odt

Updated CodeColorizerBasic - Info DEU.odt
Comment 14 QA Administrators 2022-05-26 03:43:27 UTC Comment hidden (obsolete)
Comment 15 Hans-Werner 2022-06-06 13:47:22 UTC
OS: Windows 10 Home (21H2 - 19044.1741)
LO: 7.2.7.2 (x64) + 7.3.3.2 (x64) (LibreOffice Community)

T e s t D a t a

Used for testing the macro basic code colorizing extensions:

Attachment: "TestData.txt"

TestData as to be seen in the LO Basic IDE:

Attachment: "TestData - LO Basic IDE - ScreenPrint Part 1.png"
Attachment: "TestData - LO Basic IDE - ScreenPrint Part 2.png"
Attachment: "TestData - LO Basic IDE - ScreenPrint Part 3.png"

Colors: Blue, Green, Red, Grey (only for comments) and Black (only for # @).

E x t e n s i o n s

[1] Code Highlighter

https://extensions.libreoffice.org/en/extensions/show/code-highlighter

Not working, only error message:

Ein Scripting Framework Fehler trat während der Ausführung vom Python Skript vnd.sun.star.script:codehighlighter.oxt|python|highlight.py$highlight_qbasic_default?language=Python&location=user:uno_packages auf.
Meldung: <class 'KeyError'>: 'codehighlighter.oxt'
File "C:\Program Files\LibreOffice\program\pythonscript.py", line 1046, in getScript
storageUri = self.provCtx.getStorageUrlFromPersistentUrl(
File "C:\Program Files\LibreOffice\program\pythonscript.py", line 417, in getStorageUrlFromPersistentUrl
package = self.mapPackageName2Path[ packageName ]"

[2] coooder

https://extensions.libreoffice.org/en/extensions/show/coooder

No basic dialect found were basic macro code is colorized similar to the colorizing of the LO Basic IDE:

Attachment: "TestData - coooder - basic4gl.odt"
Attachment: "TestData - coooder - blitzbasic.odt"
Attachment: "TestData - coooder - freebasic.odt"
Attachment: "TestData - coooder - qbasic.odt"
Attachment: "TestData - coooder - vb.odt"
Attachment: "TestData - coooder - vbnet.odt"

[3] Code Colorizer Formatter (Pitonyak)

https://extensions.libreoffice.org/en/extensions/show/71

Very good colorizing, but not exactly like "LO Basic IDE" colorizing:

+ All special characters (outside strings) "( ) [ ] % ! $ : = - + &" are colorized "black", but should be colorized "dark blue". Only "@ #" should be colorized "black".
+ Variable names enclosed by square brackets are mixed colorized ("dark green" and "dark blue"), but should be colorized "dark green".
+ "Chr()", "InStr()" and "MsgBox()" are colorized "dark blue", but should be colorized "dark green".
+ "HEX" and "OCT" numbers are mixed colorized ("black" and "dark green") but should be colorized "red".
+ "REM", "REm", "Rem" and "rem" are colorized "dark blue", but should be colorized "grey".

Attachment: "TestData - Code Colorizer Formatter.odt"

[4] CodeColorizerBasic (no extension, basic macro)

Uses for colorizing only regular expressions. No errors to be found. But this does not mean, that errors could never be found ...

Attachment: "TestData - CodeColorizerBasic.odt"

C o r e   f e a t u r e   ?

[1] The Basic IDE is part of the core and therefore the Basic IDE printing feature [File]>[Print] is part of the core too. Isn't it ?

[2] The Basic IDE printing feature seems to be a little bit old-fashioned, only black-and-white printing is possible contrary to the colorized basic macro code displayed by the Basic IDE. There's no "What You See Is What You Get" ... 

[3] Why not to replace the printing feature by an export-to-writer feature ? Colorizing basic macro code outside LO in the same way as is displayed by the Basic IDE is complex, difficult and error-prone. What's about to use directly or indirectly the already existing code colorizer of the Basic-IDE. For example, could it be possible to code some software that exports the displayed basic macro code in a writer document and replaces the SCREEN-color-tags by WRITER-color tags ?

[4] The language of the descriptions of the (most) extensions is English. What's about LO users, that don't speak English ? If [3] could be realized, the language would be automatically the language of the LO version the user is using.
Comment 16 Hans-Werner 2022-06-06 13:49:25 UTC
Created attachment 180588 [details]
TestData
Comment 17 Hans-Werner 2022-06-06 13:50:12 UTC
Created attachment 180589 [details]
TestData - LO Basic IDE - ScreenPrint Part 1
Comment 18 Hans-Werner 2022-06-06 13:50:39 UTC
Created attachment 180590 [details]
TestData - LO Basic IDE - ScreenPrint Part 2
Comment 19 Hans-Werner 2022-06-06 13:51:07 UTC
Created attachment 180591 [details]
TestData - LO Basic IDE - ScreenPrint Part 3
Comment 20 Hans-Werner 2022-06-06 13:51:41 UTC
Created attachment 180592 [details]
TestData - coooder - basic4gl
Comment 21 Hans-Werner 2022-06-06 13:52:18 UTC
Created attachment 180593 [details]
TestData - coooder - blitzbasic
Comment 22 Hans-Werner 2022-06-06 13:52:57 UTC
Created attachment 180594 [details]
TestData - coooder - freebasic
Comment 23 Hans-Werner 2022-06-06 13:53:30 UTC
Created attachment 180595 [details]
TestData - coooder - qbasic
Comment 24 Hans-Werner 2022-06-06 13:54:00 UTC
Created attachment 180596 [details]
TestData - coooder - vb
Comment 25 Hans-Werner 2022-06-06 13:54:34 UTC
Created attachment 180597 [details]
TestData - coooder - vbnet
Comment 26 Hans-Werner 2022-06-06 13:55:24 UTC
Created attachment 180598 [details]
TestData - Code Colorizer Formatter
Comment 27 Hans-Werner 2022-06-06 13:56:26 UTC
Created attachment 180599 [details]
TestData - CodeColorizerBasic
Comment 28 Buovjaga 2022-06-06 13:57:07 UTC
(In reply to Hans-Werner from comment #15)
> C o r e   f e a t u r e   ?
> 
> [1] The Basic IDE is part of the core and therefore the Basic IDE printing
> feature [File]>[Print] is part of the core too. Isn't it ?
> 
> [2] The Basic IDE printing feature seems to be a little bit old-fashioned,
> only black-and-white printing is possible contrary to the colorized basic
> macro code displayed by the Basic IDE. There's no "What You See Is What You
> Get" ... 
> 
> [3] Why not to replace the printing feature by an export-to-writer feature ?
> Colorizing basic macro code outside LO in the same way as is displayed by
> the Basic IDE is complex, difficult and error-prone. What's about to use
> directly or indirectly the already existing code colorizer of the Basic-IDE.
> For example, could it be possible to code some software that exports the
> displayed basic macro code in a writer document and replaces the
> SCREEN-color-tags by WRITER-color tags ?
> 
> [4] The language of the descriptions of the (most) extensions is English.
> What's about LO users, that don't speak English ? If [3] could be realized,
> the language would be automatically the language of the LO version the user
> is using.

Let's ask UX team
Comment 29 Hans-Werner 2022-06-06 13:57:38 UTC
Created attachment 180600 [details]
CCB
Comment 30 Hans-Werner 2022-06-06 13:58:13 UTC
Created attachment 180601 [details]
CCB - User Manual ENG
Comment 31 Hans-Werner 2022-06-06 13:58:45 UTC
Created attachment 180602 [details]
CCB - User Manual DEU
Comment 32 Heiko Tietze 2022-06-07 08:42:34 UTC
(In reply to Hans-Werner from comment #0)
> The better way surely would be to use the Basic-IDE display data while the
> basic code is displayed by the Basic-IDE, but this would be a big job to be
> realized and - in my opinion - not be done by LO developers next time
> because of other more important work to be  done.

I fully agree- the desire for source code (actually only sbasic) as OLE object is clear. But there are more important things to do. And I appreciate features that are maintained in parallel - in other words extensions. Therefore I would upload the extension to our site and not implement this into core. Other opinions?
Comment 33 Hans-Werner 2022-06-07 10:35:07 UTC
(In reply to Heiko Tietze from comment #32)
> (In reply to Hans-Werner from comment #0)
> > The better way surely would be to use the Basic-IDE display data while the
> > basic code is displayed by the Basic-IDE, but this would be a big job to be
> > realized and - in my opinion - not be done by LO developers next time
> > because of other more important work to be  done.
> 
> I fully agree- the desire for source code (actually only sbasic) as OLE
> object is clear. But there are more important things to do. And I appreciate
> features that are maintained in parallel - in other words extensions.
> Therefore I would upload the extension to our site and not implement this
> into core. Other opinions?

The "Let's ask UX team" questions are to be found in "Comment 28" (2022-06-06) and not in "Comment 0" (2020-11-20) ...
Comment 34 Heiko Tietze 2022-06-16 15:04:39 UTC
(In reply to Hans-Werner from comment #15)
> [3] Code Colorizer Formatter (Pitonyak)
> https://extensions.libreoffice.org/en/extensions/show/71 
> Very good colorizing, but not exactly like "LO Basic IDE" colorizing:
Code highlighting is a can of worms and better suited for a macro. If this one isn't working it might be good to fix the issues there. Andrew Pitonyak (CC) is an experienced and active macro developer.
 
> C o r e   f e a t u r e   ?
> [1] The Basic IDE is part of the core and therefore the Basic IDE printing
> feature [File]>[Print] is part of the core too. Isn't it ?
It's a module and likely using different code.

> [2] The Basic IDE printing feature seems to be a little bit old-fashioned,
> only black-and-white printing is possible contrary to the colorized basic
> macro code displayed by the Basic IDE. There's no "What You See Is What You
> Get" ... 
Agreed on the need to improve, if true (haven't tested myself). And if you can print/export it would be possible to insert the PDF. I suggest to check if we have a ticket about this aspect and file one otherwise.

> [4] The language of the descriptions of the (most) extensions is English.
> What's about LO users, that don't speak English ? If [3] could be realized,
> the language would be automatically the language of the LO version the user
> is using.
Valid argument for a core feature but not a strong one. So in a nutshell no objection for a core implementation - if someone volunteers. Guess it's quite some effort for a limited benefit resp. some benefit for only a few users.
Comment 35 Hans-Werner 2022-06-17 08:55:41 UTC
Created attachment 180810 [details]
LO 7.3.4.2 (x64) - Basic IDE - ScreenPrint
Comment 36 Hans-Werner 2022-06-17 08:56:41 UTC
(In reply to Heiko Tietze from comment #34)

Many thanks for answering the questions [1],[2] and [4] of "Comment 28" :-))

But what's about the question [3] of "Comment 28" ?

Code colorizing is already part of the core, because the basic macro code browsed by the "LO Basic IDE" (Integrated Development Environment) is colorized (Attachment: LO 7.3.4.2 (x64) - Basic IDE - ScreenPrint.png).

Therefore ("Comment 28"):

"[...]  [3] Why not to replace the printing feature by an export-to-writer feature ? [...] What's about to use directly or indirectly the already existing code colorizer of the Basic-IDE. For example, could it be possible to code some software that exports the displayed basic macro code in a writer document and replaces the SCREEN-color-tags by WRITER-color tags ? [...]"
Comment 37 Heiko Tietze 2022-06-17 11:17:57 UTC
(In reply to Hans-Werner from comment #36)
> But what's about the question [3] of "Comment 28" ?

Writer document is preferably style-oriented text. You would have to create for each line a special paragraph style per code style (Basic, Python, Java...) plus numerous character styles to make parts in bold, italic, colored etc. Printing and exporting to PDF / bitmap formats is a more character-oriented procedure since you never reuse the content anywhere else. 
And as I commented before, the Basic colorization is likely not available at different modules.
In other words, you don't write/modify code in Writer (nor you want to reuse the formatting) but want to share a static result - a screenshot.
And again my disclaimer: the desire is clear and valuable from the UX POV (my expertise here). Volunteers who want to do the effort are very welcome. But I would not steer resources, if there was any, into it.
Comment 38 Andrew Pitonyak 2022-06-17 13:38:22 UTC
Copying to the clipboard using a rich text format as one of the formats would probably suffice and might be easier to implement. I have not attempted to read the IDE implementation code, so I could be wrong.
Comment 39 Buovjaga 2022-07-02 10:09:09 UTC
(In reply to Hans-Werner from comment #15)
> E x t e n s i o n s
> 
> [1] Code Highlighter
> 
> https://extensions.libreoffice.org/en/extensions/show/code-highlighter
> 
> Not working, only error message:
> 
> Ein Scripting Framework Fehler trat während der Ausführung vom Python Skript
> vnd.sun.star.script:codehighlighter.oxt|python|highlight.
> py$highlight_qbasic_default?language=Python&location=user:uno_packages auf.
> Meldung: <class 'KeyError'>: 'codehighlighter.oxt'
> File "C:\Program Files\LibreOffice\program\pythonscript.py", line 1046, in
> getScript
> storageUri = self.provCtx.getStorageUrlFromPersistentUrl(
> File "C:\Program Files\LibreOffice\program\pythonscript.py", line 417, in
> getStorageUrlFromPersistentUrl
> package = self.mapPackageName2Path[ packageName ]"

Good news: Jean-Marc Zambon has picked up the maintenance of this extension. You can try it by downloading the "source code" in the releases, inside the archive you will find the .oxt extension file:
https://github.com/jmzambon/libreoffice-code-highlighter/releases