textsearch.cxx (16b8677b) textsearch.cxx (03c97e34)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 706 unchanged lines hidden (view full) ---

715 // REG_NOSUB is not used anywhere => not implemented
716 // NORM_WORD_ONLY is only used for SearchAlgorithm==Absolute
717 // LEV_RELAXED is only used for SearchAlgorithm==Approximate
718 // why is even ALL_IGNORE_CASE deprecated in UNO? because of transliteration taking care of it???
719 if( (rOptions.searchFlag & com::sun::star::util::SearchFlags::ALL_IGNORE_CASE) != 0)
720 nIcuSearchFlags |= UREGEX_CASE_INSENSITIVE;
721 UErrorCode nIcuErr = U_ZERO_ERROR;
722 // assumption: transliteration didn't mangle regexp control chars
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 706 unchanged lines hidden (view full) ---

715 // REG_NOSUB is not used anywhere => not implemented
716 // NORM_WORD_ONLY is only used for SearchAlgorithm==Absolute
717 // LEV_RELAXED is only used for SearchAlgorithm==Approximate
718 // why is even ALL_IGNORE_CASE deprecated in UNO? because of transliteration taking care of it???
719 if( (rOptions.searchFlag & com::sun::star::util::SearchFlags::ALL_IGNORE_CASE) != 0)
720 nIcuSearchFlags |= UREGEX_CASE_INSENSITIVE;
721 UErrorCode nIcuErr = U_ZERO_ERROR;
722 // assumption: transliteration didn't mangle regexp control chars
723#ifdef OS2
724 IcuUniString aIcuSearchPatStr( (const UChar*)rPatternStr.getStr(), rPatternStr.getLength());
725#else
723 IcuUniString aIcuSearchPatStr( rPatternStr.getStr(), rPatternStr.getLength());
726 IcuUniString aIcuSearchPatStr( rPatternStr.getStr(), rPatternStr.getLength());
727#endif
724#if 1
725 // for conveniance specific syntax elements of the old regex engine are emulated
726 // by using regular word boundary matching \b to replace \< and \>
727 static const IcuUniString aChevronPattern( "\\<|\\>", -1, IcuUniString::kInvariant);
728 static const IcuUniString aChevronReplace( "\\b", -1, IcuUniString::kInvariant);
729 static RegexMatcher aChevronMatcher( aChevronPattern, 0, nIcuErr);
730 aChevronMatcher.reset( aIcuSearchPatStr);
731 aIcuSearchPatStr = aChevronMatcher.replaceAll( aChevronReplace, nIcuErr);

--- 15 unchanged lines hidden (view full) ---

747 if( !pRegexMatcher)
748 return aRet;
749
750 if( endPos > searchStr.getLength())
751 endPos = searchStr.getLength();
752
753 // use the ICU RegexMatcher to find the matches
754 UErrorCode nIcuErr = U_ZERO_ERROR;
728#if 1
729 // for conveniance specific syntax elements of the old regex engine are emulated
730 // by using regular word boundary matching \b to replace \< and \>
731 static const IcuUniString aChevronPattern( "\\<|\\>", -1, IcuUniString::kInvariant);
732 static const IcuUniString aChevronReplace( "\\b", -1, IcuUniString::kInvariant);
733 static RegexMatcher aChevronMatcher( aChevronPattern, 0, nIcuErr);
734 aChevronMatcher.reset( aIcuSearchPatStr);
735 aIcuSearchPatStr = aChevronMatcher.replaceAll( aChevronReplace, nIcuErr);

--- 15 unchanged lines hidden (view full) ---

751 if( !pRegexMatcher)
752 return aRet;
753
754 if( endPos > searchStr.getLength())
755 endPos = searchStr.getLength();
756
757 // use the ICU RegexMatcher to find the matches
758 UErrorCode nIcuErr = U_ZERO_ERROR;
759#ifdef OS2
760 const IcuUniString aSearchTargetStr( (const UChar*)searchStr.getStr(), endPos);
761#else
755 const IcuUniString aSearchTargetStr( searchStr.getStr(), endPos);
762 const IcuUniString aSearchTargetStr( searchStr.getStr(), endPos);
763#endif
756 pRegexMatcher->reset( aSearchTargetStr);
757 // search until there is a valid match
758 for(;;)
759 {
760 if( !pRegexMatcher->find( startPos, nIcuErr))
761 return aRet;
762
763 // #i118887# ignore zero-length matches e.g. "a*" in "bc"

--- 33 unchanged lines hidden (view full) ---

797
798 if( startPos > searchStr.getLength())
799 startPos = searchStr.getLength();
800
801 // use the ICU RegexMatcher to find the matches
802 // TODO: use ICU's backward searching once it becomes available
803 // as its replacement using forward search is not as good as the real thing
804 UErrorCode nIcuErr = U_ZERO_ERROR;
764 pRegexMatcher->reset( aSearchTargetStr);
765 // search until there is a valid match
766 for(;;)
767 {
768 if( !pRegexMatcher->find( startPos, nIcuErr))
769 return aRet;
770
771 // #i118887# ignore zero-length matches e.g. "a*" in "bc"

--- 33 unchanged lines hidden (view full) ---

805
806 if( startPos > searchStr.getLength())
807 startPos = searchStr.getLength();
808
809 // use the ICU RegexMatcher to find the matches
810 // TODO: use ICU's backward searching once it becomes available
811 // as its replacement using forward search is not as good as the real thing
812 UErrorCode nIcuErr = U_ZERO_ERROR;
813#ifdef OS2
814 const IcuUniString aSearchTargetStr( (const UChar*)searchStr.getStr(), startPos);
815#else
805 const IcuUniString aSearchTargetStr( searchStr.getStr(), startPos);
816 const IcuUniString aSearchTargetStr( searchStr.getStr(), startPos);
817#endif
806 pRegexMatcher->reset( aSearchTargetStr);
807 if( !pRegexMatcher->find( endPos, nIcuErr))
808 return aRet;
809
810 // find the last match
811 int nLastPos = 0;
812 do {
813 nLastPos = pRegexMatcher->start( nIcuErr);

--- 200 unchanged lines hidden ---
818 pRegexMatcher->reset( aSearchTargetStr);
819 if( !pRegexMatcher->find( endPos, nIcuErr))
820 return aRet;
821
822 // find the last match
823 int nLastPos = 0;
824 do {
825 nLastPos = pRegexMatcher->start( nIcuErr);

--- 200 unchanged lines hidden ---