To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=112431
                 Issue #|112431
                 Summary|com.sun.star.util.TextSearch does not support document
                        |ed options.
               Component|api
                 Version|OOo 3.2.1
                Platform|All
                     URL|
              OS/Version|All
                  Status|NEW
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|code
             Assigned to|jsc
             Reported by|pitonyak





------- Additional comments from piton...@openoffice.org Wed Jun 16 02:05:12 
+0000 2010 -------
Originated here:
http://www.oooforum.org/forum/viewtopic.phtml?t=101554&postdays=0&postorder=asc&start=0&sid=245f48dd73d845f7106cd6e8339de913

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

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

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


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

Reply via email to