Re: Search with attributes erases text

Andrew Douglas Pitonyak <[email protected]>
Newsgroups gmane.comp.openoffice.devel.api
Message-ID <[email protected]>
  OK, I guess it is a bug

http://qa.openoffice.org/issues/show_bug.cgi?id=114662



On 09/15/2010 11:49 AM, Andrew Douglas Pitonyak wrote:
>
>
> Consider this small program, looks innocent... Find something that 
> matches an attribute (no replacing).
>
> Sub SearchTest(oProps())
>   Dim oFind
>   Dim oFound
>   Dim oDoc
>
>   oDoc = ThisComponent
>
>   oFind = oDoc.createSearchDescriptor()
>   With oFind
>    .SearchString  = ".*"
>    .SearchRegularExpression = True
>    .SearchAll = True
>   End With
>   oFind.setSearchAttributes(oProps)
>
>
>   oFound = oDoc.FindAll(oFind)
>   print "" & oFound.count & " for " & oProps(0).Name
> End Sub
>
> Now, call it as follows:
>
> Sub FindCharStyle
>   Dim SearchProps(0) as new com.sun.star.beans.PropertyValue
>
>   'Matches everything, and erases everything that it finds.
>   searchProps(0).name = "CharStyleName"
>   searchProps(0).value = "_OOoComputerLiteral"
>   searchProps(0).value = "xyzzy"
>   '??SearchTest(searchProps)
>
>   'This finds things as expected
>   searchProps(0).name = "CharWeight"
>   searchProps(0).value = 100
>   SearchTest(searchProps)
>
>   'Fails
>   searchProps(0).Name = "CharFontName"
>   searchProps(0).Value = "Times New Roman"
>   searchProps(0).Value = "Albany"
>   SearchTest(searchProps)
>
>   'Finds stuff, but erases everything that it finds.
>   searchProps(0).Name = "CharFontNameAsian"
>   searchProps(0).Value = "HG Mincho Light J"
>   '??SearchTest(searchProps)
>
>   'Works
>   searchProps(0).Name = "CharFontPitch"
>   searchProps(0).Value = 2
>   SearchTest(searchProps)
>
>   'Works
>   searchProps(0).Name = "CharNoHyphenation"
>   searchProps(0).Value = True
>   SearchTest(searchProps)
> End Sub
>
> Searching on CharStyle name always matches, and then it erases all the 
> text that it finds (well, it replaces it with an empty string). The 
> same for CharFontNameAsian.
>
> Searching on CharFontName simply never matches.
>
>

-- 
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.