- The XSearchable interface provides the createSearchDescriptor() method. This interface can only be created with a DrawPage (not the Draw document). After creation of the search descriptor:
- if the findFirst method is called and the created search string is not found, the application crashes.
- If the findFirst method is called and the created search string is found, the application returns not the string, but the interface: ::com::sun::uno::XInterface of the object found. If one were to xray this object, (mine are just text boxes) then the following string is found: "resent=" (because I have "Mitigated{CR}Ipresent=$LEVkA" as my string and {CR} is actually a newline or carriage return). I would have expected the string to be "present" and not "resent=".... note this for the next comment
- The XReplaceable interface provides the createReplaceDescriptor() method. This interface is created with the DrawPage as well. After creation of both the replaceDescriptor and the searchDescriptor:
- The replaceAll method can be called. I have not checked if it crashes on not finding anything yet.
- The replaceAll method replaces the text SHIFTED by one character to the right for me. That is, it replaces the "resent=" text with "myreplace". For example, if I'm replacing "Mitigated" with "Unmitigated" in the text box string "Mitigated{CR}Ipresent=$LEVkA", the result is UnmitigatedIpresent=$LEVkA"... the {CR} gets overwritten!!!! not good!
The following code snips are the drivers used to test these bugs:
make sure you have the following text in a textbox and replace the {CR} with a return on your keyboard:
here is the code for the replaceAll method callMitigated{CR}Ipresent=$LEVkA
Code: Select all
sub driveSearch1
Dim oDoc As Object
Dim oDrawPages As Object
Dim oDrawPage As Object
Dim oReplaceDesc As Object
oDoc = thisComponent
oDrawPages = oDoc.getDrawPages()
oDrawPage = oDrawPages.getByIndex(0)
oReplaceDesc = oDrawPage.createReplaceDescriptor
oReplaceDesc.searchString = "Mitigated"
oReplaceDesc.replaceString = "Unmitigated"
oReplaceDesc.SearchCaseSensitive = false
oReplaceDesc.SearchWords = true
oDrawPage.replaceAll(oReplaceDesc)
end sub
Finally the ugly crash one:
Code: Select all
sub driveSearch2
Dim oDoc As Object
Dim oDrawPages As Object
Dim oDrawPage As Object
Dim sMyResult As Object
Dim oFound As Object ' object which was found to test
oDoc = thisComponent
oDrawPages = oDoc.getDrawPages()
oDrawPage = oDrawPages.getByIndex(0)
oSearchDesc = oDrawPage.createSearchDescriptor
oSearchDesc.searchString = "Present"
' crash here at this next line. put a stop on this line and step into it.
oFound = oDrawPage.findFirst(oSearchDesc)
end sub