Text Twirler

Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This section is not for asking questions about writing your own macros.
Post Reply
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Text Twirler

Post by Villeroy »

Uncle Jazzbeau’s Gallimaufrey wrote: Aoccdrnig to a rscheearch at an Elingsh uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht frist and lsat ltteer is at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae we do not raed ervey lteter by it slef but the wrod as a wlohe.

[...]

Randomising letters in the middle of words [has] little or no effect on the ability of skilled readers to understand the text. This is easy to denmtrasote. In a pubiltacion of New Scnieitst you could ramdinose all the letetrs, keipeng the first two and last two the same, and reibadailty would hadrly be aftcfeed. My ansaylis did not come to much beucase the thoery at the time was for shape and senqeuce retigcionon. Saberi's work sugsegts we may have some pofrweul palrlael prsooscers at work. The resaon for this is suerly that idnetiyfing coentnt by paarllel prseocsing speeds up regnicoiton. We only need the first and last two letetrs to spot chganes in meniang.
http://www.bisso.com/ujg_archives/000227.html

Code: Select all

REM  *****  BASIC  *****
Sub obfuscateSelection()
Const sRegex = "\<[:alpha:]{4,}\>"
on error goto exitErr
	XDocText = thisComponent.getText()
	if MsgBox("Reverting the following procedure may require (too) many undo-steps. Continue?", 308, "macro:obfuscateSelection") = 7 then exit sub
	desc = thisComponent.createSearchDescriptor()
	desc.SearchRegularExpression = True
	desc.setSearchString(sRegex)
	sel = thisComponent.getCurrentSelection()
	For i = 0 to sel.getCount() -1
		XRange = sel.getByIndex(i)
		'xray XRange
		XStart = XRange.getStart()
		XEnd = XRange.getEnd()
		Do
			word = thisComponent.findNext(XStart, desc)
			if XDocText.compareRegionEnds(word.getEnd(), XEnd) < 0 then exit do
			sReplace = otsfucabeWrod(word.getString())
			word.setString(sReplace)
			XStart = word.getEnd()
		Loop
	next
exitErr:
end sub

Function otsfucabeWrod(sWord$)
Static oFA
	if not isObject(oFA) then oFA = createUnoService("com.sun.star.sheet.FunctionAccess")
	s = mid(sWord, 2, len(sWord) -2)
	l = len(s)
	Randomize()
	dim a(0 to l -1)
	for i = 0 to l -1
		a(i) = Rnd
	next
	b() = oFA.callFunction("RANK", Array(Array(a()), Array(a())))
	b() = b(0)
	for i = 0 to l -1
		b(i) = Mid(s, b(i), 1)
	next
	Mid(sWord, 2, l, join(b(), ""))
	otsfucabeWrod = sWord
End Function
 Edit: Still beeing quite an ignorant as far as Writer is concerned I did not handle all the possible types of objects which may be nested within a user's selection. The macro seems to fail with certain objects and tables. It works pretty well with a (multiple) selection of text portions, including TOCs and hyperlinks. 
Last edited by Villeroy on Wed Apr 09, 2008 12:43 pm, edited 1 time in total.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Text Twirler

Post by huw »

Looks fun. Is Xray third party code, not part of default OpenOffice / StarOffice installation? When I try to run your macro I get the Yes / No Undo warning, but nothing happens regardless of my answer or current selection.
User avatar
Hagar Delest
Moderator
Posts: 32594
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Text Twirler

Post by Hagar Delest »

huw wrote:Is Xray third party code
If you're talking about the X-Ray macro, yes, it's from Bernard Marcelly (B Marcelly in this forum).
-> X - Ray Tool on sourceforge (was formerly on ooomacros web site)
-> Patch of Xray 5.2 for OOo 2.4.0
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Text Twirler

Post by huw »

Okay, I've installed Xray and the library is loaded, but still nothing...
User avatar
Hagar Delest
Moderator
Posts: 32594
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Text Twirler

Post by Hagar Delest »

Well it works fine for me (OOo 2.4 under W2k). Have you selected some text before running the macro?

Note that XRay is not necessary to run the macro, XRay is only an analysis tool (I thought your question was off topic).

The strange thing is that a scrambled English text is still easily readable (even for me, a non native English speaker) but a scrambled French text is far more difficult to read!
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Text Twirler

Post by huw »

Hagar de l'Est wrote:Have you selected some text before running the macro?
Yes.
Hagar de l'Est wrote:Note that XRay is not necessary to run the macro, XRay is only an analysis tool (I thought your question was off topic).
A comment in Villeroy's code refers to Xray - that's why I asked.
Hagar de l'Est wrote:The strange thing is that a scrambled English text is still easily readable (even for me, a non native English speaker) but a scrambled French text is far more difficult to read!
Strange indeed, if you are French (which I assume from the "de l'Est" in your name). Not at all strange if you are actually German, or Spanish, or...
User avatar
Hagar Delest
Moderator
Posts: 32594
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Text Twirler

Post by Hagar Delest »

huw wrote:A comment in Villeroy's code refers to Xray - that's why I asked.
I guess he's forgotten to remove it. It's often used to debug a macro when receiving error messages to check what's wrong with the parameters put in the code.
huw wrote:Strange indeed, if you are French (which I assume from the "de l'Est" in your name).
Yes, I am indeed. So I made some tests to check if I was somehow brain disabled or not.

Here are the scrambled translations of the text above. NB: I've modified the macro for second paragraph to keep also first and last 2 letters of each word:
D'apèrs une éutde dnas une urtivneisé asiganle, peu irptome l'orrde dnas leuqel se tvrnueot les lerttes d'un mot, la selue cshoe itpnoarmte est que la pirrèmee et dnèeirre lrttee sneoit à leur place. Le rtsee peut êrte tmaoeltent ménlgaé, vous pvuoez qnaud mmêe le lrie snas dlificufté. Ceci est pbossile car nous ne lonsis pas caqhue lttere en elle-mmêe mais le mot dnas son emlesnbe.

[...]

Méglaner les lerttes au miileu d'un mot n'a que très peu d'effet sur la capaicté d'un bon lecetur à codmnprere un texte. Ceci se déomtnre famceilent. Dans une pulciabtion du New Scnietist, vous poiuvez méanlger totues les lerttes, tout en gaardnt les deux prrèmeies et les deux deèrinres inéachgnes, la liblisiité n'en était qu'à peine affcetée. Mon anlyase n'abutoit pas à grand chose car à cette épqoue, ma thréoie se baasit sur les formes et la reoainncnsasce de sécneuqes. Le traavil de Saberi suèggre que nous ayons de punassits precsosus d'anlyase paallèrles. La raison est ceemenaitrnt que l'idtaectfiinion d'un cotennu par des presscous paallrèles acècélre la rencanoaissnce. Nous avons juste beosin des deux preèrimes et deux derinères letrtes pour détiernmer les chnaegmnets de siacgifntiion.
Then, I made some quick mathematics:

First §:
English -> 68 words and 340 characters -> 5.0 char/word
French -> 66 words and 385 characters -> 5.8 char/word
Second §:
English -> 114 words and 668 characters -> 5.9 char/word
French -> 124 words and 802 characters -> 6.5 char/word
=> As French has slightly longer words, the text is more scrambled than the English one.

First § (I manually counted the unchanged words, so the count may contain small errors):
English -> 34 words out of 68 unchanged (less than 3 char) -> 36.4%
French -> 24 words out of 66 unchanged (less than 3 char) -> 50.0%
=> As English has more short words as French, less words are scrambled, hence a better readability.

OK, I'm not that brain disabled actually.

I'd like to see the same analysis with... German :mrgreen:
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Text Twirler

Post by huw »

Hagar de l'Est wrote:
huw wrote:A comment in Villeroy's code refers to Xray - that's why I asked.
I guess he's forgotten to remove it. It's often used to debug a macro when receiving error messages to check what's wrong with the parameters put in the code.
Right. I wonder why it doesn't work for me then.

Hagar de l'Est wrote:=> As English has more short words as French, less words are scrambled, hence a better readability.
There is a further English example in the comments at the link Villeroy provided. It uses lots of longer English words and is a bit harder to read.
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Text Twirler

Post by Villeroy »

Yep, forgot to remove the last remaining xray comment. I'm interested why it fails to do it's work for huw. Comment out "on error goto exitErr", which basicly means: "fail silently on any kind of error", since execution will directly jump to mark "exitErr:" at the end of the routine. Without this error-handler (or "non-handler") the code should show a error-message and jump to the offending line in the Basic-IDE.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Text Twirler

Post by huw »

Villeroy wrote:Comment out "on error goto exitErr", which basicly means: "fail silently on any kind of error", since execution will directly jump to mark "exitErr:" at the end of the routine. Without this error-handler (or "non-handler") the code should show a error-message and jump to the offending line in the Basic-IDE.
Gives me:
BASIC runtime error. Property or method not found.
if XDocText.compareRegionEnds(word.getEnd(), XEnd) < 0
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Text Twirler

Post by Villeroy »

BASIC runtime error. Property or method not found.
if XDocText.compareRegionEnds(word.getEnd(), XEnd) < 0
Well, I can confirm that the code fails when it encounters a table. In this case it raises an illegal argument exception on the same line. I added a remark to my initial post and apologise for my ignorance towards the Writer API. There are too many different things selectable at once.
I'd like to see the same analysis with... German
At least I can confirm that some "features" of German language include scrambler macros already. German allows composed word constructs resulting in extremely long concatenations.
Just found English streetcar, tramway, trolley-car, trolley line, cable car as rough synonyms for German "Straßenbahn", which is a composed noun of two nouns "Straße"(street) and "Bahn"(track, railway). "Straßenbahn" is a noun of it's own right, describing a track on a street. The person who drives such a thing may be refered to as "Straßenbahnfahrer" (Fahrer=driver). This would be more common than valid expression "Fahrer einer Straßenbahn" (like "driver of a streetcar").
A native speaker may have some difficulties with the following variations of "Straßenbahnfahrer" although special char "ß" may be of some help:
Sreheßatnfnhaabrr
Srarßehfannbtaher
Srehaftnaßnbaehrr
Sethaaßnefbharnrr
Sßfatanhhernbaerr
Srßfebnthaearnhar
Seahbßrtfanehranr
Snanbraeßfhharter
Shnnehatbrfareßar
Sebannfßtrhaeharr
Sßhtafreebhrananr
Snßfabthharreeanr
Srhahenfßtabraenr
Snrafhernebßaathr
Seraßfnehrbtahnar
Stßbfneaarrnhhear
Sanßfterrnehhabar
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Text Twirler

Post by huw »

Villeroy wrote:
BASIC runtime error. Property or method not found.
if XDocText.compareRegionEnds(word.getEnd(), XEnd) < 0
Well, I can confirm that the code fails when it encounters a table. In this case it raises an illegal argument exception on the same line. I added a remark to my initial post and apologise for my ignorance towards the Writer API. There are too many different things selectable at once.
No tables, just a new document containing only standard dummy text (type "dt", press F3). I am using StarOffice 8.5, without Python. I haven't come across a macro before which doesn't work, except one which called Python.
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Text Twirler

Post by Villeroy »

...(type "dt", press F3)...
Did not even know that one ;)
Tools>Macros>Orgaize>Basic... [+]<my library>[+]<my module>, obfuscateSelection, [Run]
He haerd qiuet steps bneihd him. Taht didn't bdoe well. Who colud be fwoolilng him this late at night and in tihs ddabaeet part of twon? And at tihs pauratlcir mmoent, jsut atfer he pluled off the big time and was mnkiag off wtih the gerakbcens. Was tehre athoenr crook who'd had the same ...
Could it be an issue with StarOffice? Today we got this rather unspecific complaint about SO failing to do "complex spreadsheet editing" (some users describe macros this way) http://user.services.openoffice.org/en/ ... =49&t=4506
This is hard to track down without StarOffice.
"BASIC runtime error. Property or method not found." means that we have some object and try to let it do something inapropriate (call "Look!" to a blind person).
The offending line contains two nested method calls from two objects: XDocText.compareRegionEnds(...) and word.getEnd()
(Yes, the whole thing is sloppy. I know that)

Splitting up into 2 lines gives us a hint which method call raises the error actually:

Code: Select all

...
wdEnd = word.getEnd()
if XDocText.compareRegionEnds(wdEnd, XEnd) < 0 then exit do
...
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Text Twirler

Post by huw »

Villeroy wrote:Today we got this rather unspecific complaint about SO failing to do "complex spreadsheet editing" (some users describe macros this way) http://user.services.openoffice.org/en/ ... =49&t=4506
I took that one to be purely an issue with Sun's server(s) for downloading updates.

Villeroy wrote:"BASIC runtime error. Property or method not found." means that we have some object and try to let it do something inapropriate (call "Look!" to a blind person).
The offending line contains two nested method calls from two objects: XDocText.compareRegionEnds(...) and word.getEnd()
(Yes, the whole thing is sloppy. I know that)

Splitting up into 2 lines gives us a hint which method call raises the error actually:

Code: Select all

...
wdEnd = word.getEnd()
if XDocText.compareRegionEnds(wdEnd, XEnd) < 0 then exit do
...
That narrows it down to
wdEnd = word.getEnd()
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Text Twirler

Post by Villeroy »

Before that line:

Code: Select all

print word.getImplementationName()
In case you have xray installed you could ask anything from the word object:

Code: Select all

GlobalScope.BasicLibraries.loadLibrary("XrayTool")
xray word
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Text Twirler

Post by huw »

Villeroy wrote:Before that line:

Code: Select all

print word.getImplementationName()
Returns "com.sun.star.helper.writer.WriterImpl"

Villeroy wrote:In case you have xray installed you could ask anything from the word object:

Code: Select all

GlobalScope.BasicLibraries.loadLibrary("XrayTool")
xray word
This is new to me, I don't know anything about writing macros, and I don't know what is of use here and what isn't. If you want me to drill down into any of them, just say.
Properties:

Code: Select all

Creator                   long                                1400204879  pseudo-prop, read-only 
Parent                    com.sun.star.helper.XHelperInterface            pseudo-prop, read-only 
Documents                 com.sun.star.helper.writer.XDocuments           pseudo-prop, read-only 
ActiveDocument            com.sun.star.helper.writer.XDocument            pseudo-prop, read-only 
ActiveWindow              com.sun.star.helper.writer.XWindow              pseudo-prop, read-only 
Windows                   com.sun.star.helper.writer.XWindows             pseudo-prop, read-only 
Options                   com.sun.star.helper.writer.XOptions             pseudo-prop, read-only 
MailSystem                long                                         0  pseudo-prop, read-only 
Width                     long                                      1280  pseudo-prop 
Height                    long                                       977  pseudo-prop 
Top                       long                                        19  pseudo-prop 
Left                      long                                         0  pseudo-prop 
Version                   string                                     "8"  pseudo-prop, read-only 
PathSeparator             string                                     "\"  pseudo-prop, read-only 
ScreenUpdating            boolean                                   True  pseudo-prop 
DefaultSaveFormat         string                                      ""  pseudo-prop 
Build                     string                                      ""  pseudo-prop, read-only 
Caption                   string                     "StarOffice Writer"  pseudo-prop 
MAPIAvailable             boolean                                   True  pseudo-prop, read-only 
Path                      string                                   <...>  pseudo-prop, read-only 
UserName                  string                                      ""  pseudo-prop, read-only 
Visible                   boolean                                   True  pseudo-prop 
UserControl               boolean                                   True  pseudo-prop, read-only 
CheckLanguage             boolean                                   True  pseudo-prop 
Name                      string                     "StarOffice Writer"  pseudo-prop, read-only 
DisplayStatusBar          boolean                                   True  pseudo-prop 
DisplayAlerts             long                                        -1  pseudo-prop 
StartupPath               string                                          pseudo-prop 
StatusBar                 string                                          pseudo-prop, write-only 
ActivePrinter             string                 "HP LaserJet 2100 PCL6"  pseudo-prop 
ImplementationName        string                                   <...>  pseudo-prop, read-only 
SupportedServiceNames     []string                                        pseudo-prop, read-only 
Types                     []type                                          pseudo-prop, read-only 
ImplementationId          []byte                                          pseudo-prop, read-only 
Dbg_Properties            string                                   <...>  basic prop, read-only 
Dbg_Methods               string                                   <...>  basic prop, read-only 
Dbg_SupportedInterfaces   string                                   <...>  basic prop, read-only 
Methods:

Code: Select all

queryInterface            ( aType as type )                AS any                                                      com.sun.star.uno.XInterface 
acquire                   (  )                                                                                         com.sun.star.uno.XInterface 
release                   (  )                                                                                         com.sun.star.uno.XInterface 
getCreator                (  )                             AS long                                                     com.sun.star.helper.XHelperInterface 
getParent                 (  )                             AS com.sun.star.helper.XHelperInterface                     com.sun.star.helper.XHelperInterface 
Application               (  )                             AS any                                                      com.sun.star.helper.XHelperInterface 
CommonApplication         (  )                             AS com.sun.star.helper.XApplication                         com.sun.star.helper.XHelperInterface 
Writer                    (  )                             AS com.sun.star.helper.writer.XWriter                       com.sun.star.helper.writer.XWriter 
getDocuments              (  )                             AS com.sun.star.helper.writer.XDocuments                    com.sun.star.helper.writer.XWriter 
getActiveDocument         (  )                             AS com.sun.star.helper.writer.XDocument                     com.sun.star.helper.writer.XWriter 
getActiveWindow           (  )                             AS com.sun.star.helper.writer.XWindow                       com.sun.star.helper.writer.XWriter 
getWindows                (  )                             AS com.sun.star.helper.writer.XWindows                      com.sun.star.helper.writer.XWriter 
getOptions                (  )                             AS com.sun.star.helper.writer.XOptions                      com.sun.star.helper.writer.XWriter 
Exit                      ( SaveChanges as any, OriginalFormat as any, RouteDocument as any )                          com.sun.star.helper.writer.XWriter 
Quit                      ( SaveChanges as any, OriginalFormat as any, RouteDocument as any )                          com.sun.star.helper.writer.XWriter 
getMailSystem             (  )                             AS long                                                     com.sun.star.helper.writer.XWriter 
setWidth                  ( Width as long )                                                                            com.sun.star.helper.writer.XWriter 
getWidth                  (  )                             AS long                                                     com.sun.star.helper.writer.XWriter 
setHeight                 ( Height as long )                                                                           com.sun.star.helper.writer.XWriter 
getHeight                 (  )                             AS long                                                     com.sun.star.helper.writer.XWriter 
setTop                    ( Top as long )                                                                              com.sun.star.helper.writer.XWriter 
getTop                    (  )                             AS long                                                     com.sun.star.helper.writer.XWriter 
setLeft                   ( Left as long )                                                                             com.sun.star.helper.writer.XWriter 
getLeft                   (  )                             AS long                                                     com.sun.star.helper.writer.XWriter 
getVersion                (  )                             AS string                                                   com.sun.star.helper.writer.XWriter 
getPathSeparator          (  )                             AS string                                                   com.sun.star.helper.writer.XWriter 
setScreenUpdating         ( updatescreen as boolean )                                                                  com.sun.star.helper.writer.XWriter 
getScreenUpdating         (  )                             AS boolean                                                  com.sun.star.helper.writer.XWriter 
setDefaultSaveFormat      ( SaveFormat as string )                                                                     com.sun.star.helper.writer.XWriter 
getDefaultSaveFormat      (  )                             AS string                                                   com.sun.star.helper.writer.XWriter 
Templates                 (  )                             AS com.sun.star.helper.writer.XTemplates                    com.sun.star.helper.writer.XWriter 
Activate                  (  )                                                                                         com.sun.star.helper.writer.XWriter 
getBuild                  (  )                             AS string                                                   com.sun.star.helper.writer.XWriter 
getCaption                (  )                             AS string                                                   com.sun.star.helper.writer.XWriter 
setCaption                ( Caption as string )                                                                        com.sun.star.helper.writer.XWriter 
getMAPIAvailable          (  )                             AS boolean                                                  com.sun.star.helper.writer.XWriter 
getPath                   (  )                             AS string                                                   com.sun.star.helper.writer.XWriter 
getUserName               (  )                             AS string                                                   com.sun.star.helper.writer.XWriter 
setVisible                ( Visible as boolean )                                                                       com.sun.star.helper.writer.XWriter 
getVisible                (  )                             AS boolean                                                  com.sun.star.helper.writer.XWriter 
getUserControl            (  )                             AS boolean                                                  com.sun.star.helper.writer.XWriter 
setCheckLanguage          ( CheckLanguage as boolean )                                                                 com.sun.star.helper.writer.XWriter 
getCheckLanguage          (  )                             AS boolean                                                  com.sun.star.helper.writer.XWriter 
getName                   (  )                             AS string                                                   com.sun.star.helper.writer.XWriter 
getDisplayStatusBar       (  )                             AS boolean                                                  com.sun.star.helper.writer.XWriter 
setDisplayStatusBar       ( DisplayStatusBar as boolean )                                                              com.sun.star.helper.writer.XWriter 
CheckSpelling             ( Word as any, CustomDictionary as any, IgnoreUppercase as any, MainDictionary as any, CustomDictionary2 as any, CustomDictionary3 as any, CustomDictionary4 as any, CustomDictionary5 as any, CustomDictionary6 as any, CustomDictionary7 as any, CustomDictionary8 as any, CustomDictionary9 as any, CustomDictionary10 as any ) AS boolean  com.sun.star.helper.writer.XWriter 
Run                       ( MacroName as string, varg1 as any, varg2 as any, varg3 as any, varg4 as any, varg5 as any, varg6 as any, varg7 as any, varg8 as any, varg9 as any, varg10 as any, varg11 as any, varg12 as any, varg13 as any, varg14 as any, varg15 as any, varg16 as any, varg17 as any, varg18 as any, varg19 as any, varg20 as any, varg21 as any, varg22 as any, varg23 as any, varg24 as any, varg25 as any, varg26 as any, varg27 as any, varg28 as any, varg29 as any, varg30 as any ) AS any  com.sun.star.helper.writer.XWriter 
getDisplayAlerts          (  )                             AS long                                                     com.sun.star.helper.writer.XWriter 
setDisplayAlerts          ( displayAlerts as long )                                                                    com.sun.star.helper.writer.XWriter 
Dialogs                   (  )                             AS com.sun.star.helper.writer.XDialogs                      com.sun.star.helper.writer.XWriter 
FontNames                 (  )                             AS com.sun.star.helper.writer.XFontNames                    com.sun.star.helper.writer.XWriter 
ListGalleries             (  )                             AS com.sun.star.helper.writer.XListGalleries                com.sun.star.helper.writer.XWriter 
GetSpellingSuggestions    ( Word as string, CustomDictionary as any, IgnoreUppercase as any, MainDictionary as any, SuggestionMode as any, CustomDictionary2 as any, CustomDictionary3 as any, CustomDictionary4 as any, CustomDictionary5 as any, CustomDictionary6 as any, CustomDictionary7 as any, CustomDictionary8 as any, CustomDictionary9 as any, CustomDictionary10 as any ) AS com.sun.star.helper.writer.XSpellingSuggestions  com.sun.star.helper.writer.XWriter 
ScreenRefresh             (  )                                                                                         com.sun.star.helper.writer.XWriter 
ChangeFileOpenDirectory   ( Path as string )                                                                           com.sun.star.helper.writer.XWriter 
InchesToPoints            ( inches as double )             AS double                                                   com.sun.star.helper.writer.XWriter 
CentimetersToPoints       ( centimeters as double )        AS double                                                   com.sun.star.helper.writer.XWriter 
MillimetersToPoints       ( millimeters as double )        AS double                                                   com.sun.star.helper.writer.XWriter 
PointsToInches            ( points as double )             AS double                                                   com.sun.star.helper.writer.XWriter 
PointsToCentimeters       ( points as double )             AS double                                                   com.sun.star.helper.writer.XWriter 
PointsToMillimeters       ( points as double )             AS double                                                   com.sun.star.helper.writer.XWriter 
PointsToPixels            ( Points as double, fVertical as any ) AS double                                             com.sun.star.helper.writer.XWriter 
PixelsToPoints            ( Pixels as double, fVertical as any ) AS double                                             com.sun.star.helper.writer.XWriter 
FileSearch                (  )                             AS com.sun.star.helper.common.XFileSearch                   com.sun.star.helper.writer.XWriter 
setStartupPath            ( StartupPath as string )                                                                    com.sun.star.helper.writer.XWriter 
getStartupPath            (  )                             AS string                                                   com.sun.star.helper.writer.XWriter 
setStatusBar              ( ShowString as string )                                                                     com.sun.star.helper.writer.XWriter 
Assistant                 (  )                             AS com.sun.star.helper.common.ui.dialog.XAssistant          com.sun.star.helper.writer.XWriter 
Selection                 (  )                             AS any                                                      com.sun.star.helper.writer.XWriter 
System                    (  )                             AS com.sun.star.helper.XSystem                              com.sun.star.helper.writer.XWriter 
CommandBars               (  )                             AS com.sun.star.helper.common.ui.XCommandBars               com.sun.star.helper.writer.XWriter 
getActivePrinter          (  )                             AS string                                                   com.sun.star.helper.writer.XPrintable 
setActivePrinter          ( aPrinterName as string )                                                                   com.sun.star.helper.writer.XPrintable 
PrintOut                  ( Background as any, Append as any, Range as any, OutputFileName as any, From as any, To as any, Item as any, Copies as any, Pages as any, PageType as any, PrintToFile as any, Collate as any, FileName as any, ActivePrinterMacGX as any, ManualDuplexPrint as any, PrintZoomColumn as any, PrintZoomRow as any, PrintZoomPaperWidth as any, PrintZoomPaperHeight as any )  com.sun.star.helper.writer.XPrintable 
getImplementationName     (  )                             AS string                                                   com.sun.star.lang.XServiceInfo 
supportsService           ( ServiceName as string )        AS boolean                                                  com.sun.star.lang.XServiceInfo 
getSupportedServiceNames  (  )                             AS []string                                                 com.sun.star.lang.XServiceInfo 
dispose                   (  )                                                                                         com.sun.star.lang.XComponent 
addEventListener          ( xListener as com.sun.star.lang.XEventListener )                                            com.sun.star.lang.XComponent 
removeEventListener       ( aListener as com.sun.star.lang.XEventListener )                                            com.sun.star.lang.XComponent 
queryAdapter              (  )                             AS com.sun.star.uno.XAdapter                                com.sun.star.uno.XWeak 
getTypes                  (  )                             AS []type                                                   com.sun.star.lang.XTypeProvider 
getImplementationId       (  )                             AS []byte                                                   com.sun.star.lang.XTypeProvider 
Services:

Code: Select all

  --- List of supported services ---
com.sun.star.helper.HelperServiceBase 
com.sun.star.helper.writer.Writer 
   
  --- List of available services ---
   ( no service )
Interfaces:

Code: Select all

  --- List of supported interfaces ---
com.sun.star.helper.writer.XPrintable 
com.sun.star.helper.writer.XWriter 
com.sun.star.helper.XHelperInterface 
com.sun.star.lang.XComponent 
com.sun.star.lang.XServiceInfo 
com.sun.star.lang.XTypeProvider 
com.sun.star.uno.XInterface 
com.sun.star.uno.XWeak 
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Text Twirler

Post by Villeroy »

print word.getImplementationName()


Returns "com.sun.star.helper.writer.WriterImpl"
Here it returns "SwTextCursor", so your variable "word" is a different animal than mine.
Xraying my "word" reveals a method "getEnd()". With my variable "word" the following makes sense:

Code: Select all

wdEnd = word.getEnd()
Your variable "word" provides no method to get some end out of it. Your "word" raises an error, stating that some method could not be found for the object represented by variable "word".

My wdEnd is a thingy with implementation name "SwXTextRange", which can be compared with another SwXTextRange by means of

Code: Select all

XDocText.compareRegionEnds(wdEnd, XEnd)
OK, I'll investigate further. I have never seen a "com.sun.star.helper.writer.WriterImpl". "com.sun.star.helper" is not even documented in the ususal references.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Text Twirler

Post by Villeroy »

Got a reply from Ariel Constenla-Haile on list comp.openoffice.api.devel.
Huw, would you mind to file the issue, since you can provide all the details of your setup. Not shure if SO has it's own submission channel.
Ariel wrote:something may be working wrong with your StarOffice: com.sun.star.helper.writer.WriterImpl is from Sun's VBA support

http://api.openoffice.org/source/browse ... iew=markup

why this with OOo Basic macro? sounds like an issue.
AFAIK this is an extension in StarOffice, see if removing/disabling fixes the problem.


Regards
Ariel.

--
Ariel Constenla-Haile
La Plata, Argentina
Off topic: Did I ever mention that VBA support is a bad thing? Yes, I did. Now it interferes even with plain StarBasic code.
Ah, does your Basic module contain a line "Option VBASupport" or similar on top? If so, what happens when you comment out the statement?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Text Twirler

Post by huw »

Sun does have a bug report form, but it is for Java. Bugs in StarOffice can be discussed on Sun's StarOffice forums, or a support request can be made. In my case I go through my organisation's IT support, who have a contract with Sun. They are currently testing a newer version of StarOffice anyway, so this may well be fixed when that is rolled out.

I don't have any VBA reference anywhere in any macros at all (other than in some commented out code), and have tried your code again with my only extension disabled - still no luck. Don't worry, it's not exactly mission critical.
User avatar
mariakatosvich
Banned
Posts: 5
Joined: Fri Jul 29, 2016 3:03 pm

Re: Text Twirler

Post by mariakatosvich »

Text Twirler lets you twirl letters within words.but i dint get it what does it mean to twirl the text ,,,can anyone explain me plz
Last edited by floris v on Wed Aug 03, 2016 9:58 am, edited 1 time in total.
Reason: Hid signature, floris v, moderator
User avatar
Hagar Delest
Moderator
Posts: 32594
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Text Twirler

Post by Hagar Delest »

Sometimes when you take studies out of their context, they appear as just fun from scientists who should focus on more important topics.
However, it is certainly part of something of a wider scope. I guess that it deals initially with the ability of the brain to adapt. It was not a given fact that we could decipher scrambled words (under certain conditions) so easily. It means that the brain has a visual memory of the words so good that it can grasp their meaning simply by seeing the letters (even if not in the right order) and with the help of the context (the short words not scrambled) which shall trigger some guessing.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Post Reply