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 Expand viewCollapse view
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. |