Apache OpenOffice (AOO) Bugzilla – Issue 31212
Searching the CharEscapement attribute does not work from Basic
Last modified: 2013-02-24 21:07:19 UTC
I created a Writer document and then set some text to have a CharEscapement of 25 (this means that I set it to be superscript). I then ran the following code to verify that the CharEscapement is indeed 25. I verified this in version 1.1.1 and 1.1.2. Sub blech dim mainEnum, para, paraEnum, inpara Dim mainDoc mainDoc = ThisComponent mainEnum = mainDoc.Text.createEnumeration While mainEnum.hasMoreElements para = mainEnum.nextElement If para.supportsService("com.sun.star.text.Paragraph") Then paraEnum = para.createEnumeration While paraEnum.hasMoreElements inpara = paraEnum.nextElement if inpara.CharEscapement=25 then inpara.String="<#>" & inpara.string & "<$>" end if Wend End If Wend End Sub I am able to search for the super script text from the GUI, but I am not able to search for the text from Basic. Note that I can find a CharEscapement of 0, but not 25. Sub ReplaceFormatting() Dim oDocument As Object Dim oReplace As Object Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue Dim ReplAttributes(0) as new com.sun.star.beans.PropertyValue oDocument = ThisComponent oReplace = oDocument.createReplaceDescriptor oReplace.SearchString = ".*" 'Regular expression. Match any text oReplace.ReplaceString = "<#>&<$>" 'Note the & places the found text back oReplace.SearchRegularExpression=True 'Use regular expressions oReplace.searchStyles=True 'We want to search styles oReplace.searchAll=True 'Do the entire document REM This is the attribute to find SrchAttributes(0).Name = "CharEscapement" SrchAttributes(0).Value = 25 REM This is the attribute to replace it with ReplAttributes(0).Name = "CharEscapement" ReplAttributes(0).Value = 0 REM Set the attributes in the replace descriptor oReplace.SetSearchAttributes(SrchAttributes()) 'oReplace.SetReplaceAttributes(ReplAttributes()) REM Now do the work! oDocument.replaceAll(oReplace) End Sub
Hmmm, I thought that I could add a document to demonstrate the problem but I can not <grumble grumble>.... Well, after you no longer require the document at the following link, please let me know so that I can remove it. http://www.pitonyak.org/Bad_Search.sxw Andrew Pitonyak andrew@pitonyak.org
Created attachment 16320 [details] the linked document
SW->pitonyak: I've attached your document so you can remove it from your server :-) SW->TL: eventho the used calls aren't documented ( css.util.XReplaceDescriptor just has the methods set/getReplaceString and css.util.XSearchDescriptor just has the methods set/getSearchString ) they seem to be available and so should also work ;-) ... the idl-documentation should also be adopted when you work on this issue methinks.