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

http://www.oooforum.org/forum/viewtopic.phtml?t=101554&postdays=0&postorder=asc&start=0

To use the com.sun.star.util.TextSearch service for a case-insensitive search,
the search options state that ALL_IGNORE_CASE is deprecated and that
TransliterationModulesNew should be used. See:
http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchFlags.html

First, note that TransliterationModules has a constant for IGNORE_CASE that
works, but, the document specifically names another set of constants.
http://api.openoffice.org/docs/common/ref/com/sun/star/i18n/TransliterationModules.html

You can see the new constants here:
http://api.openoffice.org/docs/common/ref/com/sun/star/i18n/TransliterationModulesNew.html

If I use these constants, I can use UPPERCASE_LOWERCASE or LOWERCASE_UPPERCASE
with no problem. I am not, however, able to use IGNORE_CASE while setting the
transliteration flags.

I expect the following macro to find both aaa and AAA

Sub StringTextSearch
  Dim oTextSearch               ' TextSearch service
  Dim sStrToSearch As String    ' String to serach
  Dim sMatchString As String    ' String that was found
  Dim aSearchResult             '
http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchResult.html
  Dim rank As Long
  Dim iMatchStartPos As Long
  Dim iMatchLen As Long
  Dim aSrcOpt As New com.sun.star.util.SearchOptions
  Dim s$
  Dim enLocale As New com.sun.star.lang.Locale

  enLocale.Language = "en"
  enLocale.Country = "US"

  oTextSearch = CreateUnoService("com.sun.star.util.TextSearch")
  s = ""

  With aSrcOpt
    
'http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchFlags.html
    .searchFlag = com.sun.star.util.SearchFlags.REG_EXTENDED
    .Locale = enLocale
    'Supports ABSOLUTE, REGEXP, and APPROXIMATE
    .algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP
    .searchString = "a+"

    'This does not work.
    .transliterateFlags = 
com.sun.star.i18n.TransliterationModulesNew.IGNORE_CASE

    'This works
    '.transliterateFlags =
com.sun.star.i18n.TransliterationModulesNew.UPPERCASE_LOWERCASE
  End With

  oTextSearch.setOptions(aSrcOpt)

  sStrToSearch = "aaa hello AAA"
  aSearchResult = oTextSearch.searchForward(sStrToSearch, 0,Len(sStrToSearch)-1 
)
  'Print aSearchResult.subRegExpressions

  REM subRegExpressions has value zero if no match...
  Do While aSearchResult.subRegExpressions>  0
    'Print "" + LBound(aSearchResult.startOffset) + ":" +
UBound(aSearchResult.startOffset)
    rank = aSearchResult.subRegExpressions - 1
    iMatchStartPos = aSearchResult.startOffset(rank) + 1
    iMatchLen = aSearchResult.endOffset(rank) - aSearchResult.startOffset(rank)
    sMatchString = Mid(sStrToSearch, iMatchStartPos, iMatchLen)
    s = s&  "(" + LBound(aSearchResult.startOffset)&  ":" +
UBound(aSearchResult.startOffset)&  ") =>  "&  sMatchString&  CHR$(10)

    aSearchResult = oTextSearch.searchForward(sStrToSearch,
aSearchResult.endOffset(rank)+1,Len(sStrToSearch)-1 )
  Loop
  MsgBox s
End Sub




--
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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to