[Libreoffice-commits] core.git: 9 commits - oox/source sc/inc sc/source sc/uiconfig

Eike Rathke erack at redhat.com
Mon Feb 22 20:31:04 UTC 2016


 oox/source/token/properties.txt           |    1 
 sc/inc/queryentry.hxx                     |   14 ++---
 sc/source/core/data/dociter.cxx           |    6 +-
 sc/source/core/data/dpcache.cxx           |   12 ++--
 sc/source/core/data/table3.cxx            |   74 +++++++++++++++---------------
 sc/source/core/tool/compare.cxx           |    4 -
 sc/source/core/tool/interpr1.cxx          |   11 ++--
 sc/source/core/tool/queryentry.cxx        |    4 -
 sc/source/filter/excel/impop.cxx          |    1 
 sc/source/filter/oox/workbooksettings.cxx |    1 
 sc/source/ui/inc/tpcalc.hxx               |    1 
 sc/source/ui/optdlg/tpcalc.cxx            |   22 ++++++++
 sc/uiconfig/scalc/ui/optcalculatepage.ui  |   24 ++++++++-
 13 files changed, 106 insertions(+), 69 deletions(-)

New commits:
commit 4eea29f79eca05e76bfe90aaa176f39dd0fd80ea
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 22 21:06:45 2016 +0100

    enable wildcards when importing .xlsx|.xlsb, tdf#72196
    
    Change-Id: I6fbc8926d10d9028287c154a2e933d2de847cc12

diff --git a/sc/source/filter/oox/workbooksettings.cxx b/sc/source/filter/oox/workbooksettings.cxx
index b61885e6..831314f 100644
--- a/sc/source/filter/oox/workbooksettings.cxx
+++ b/sc/source/filter/oox/workbooksettings.cxx
@@ -186,6 +186,7 @@ void WorkbookSettings::finalizeImport()
         case FILTER_BIFF:
             aPropSet.setProperty( PROP_IgnoreCase,          true );     // always in Excel
             aPropSet.setProperty( PROP_RegularExpressions,  false );    // not supported in Excel
+            aPropSet.setProperty( PROP_Wildcards,           true );     // always in Excel
         break;
         case FILTER_UNKNOWN:
         break;
commit 5eaab67daa3dc6e18fa3b901a9ec57b509733905
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 22 21:01:15 2016 +0100

    add Wildcards / PROP_Wildcards, tdf#72196
    
    Change-Id: I7045042cba991a834f24f237d983ac3693f4b93d

diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index dfef4dc..5290914 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -561,6 +561,7 @@ VisualEffect
 Weight
 WhiteDay
 Width
+Wildcards
 WritingMode
 XLA1Representation
 ZoomType
commit faf7979144203d110111a2a4e80c7688a45cd538
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 22 20:50:15 2016 +0100

    enable wildcards when importing .xls, tdf#72196
    
    Change-Id: Ice014ef31c9962a2d77496236712b59cd147b6e8

diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index 470c315..c4e2717 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -148,6 +148,7 @@ ImportExcel::ImportExcel( XclImpRootData& rImpData, SvStream& rStrm ):
     ScDocOptions aDocOpt( pD->GetDocOptions() );
     aDocOpt.SetIgnoreCase( true );              // always in Excel
     aDocOpt.SetFormulaRegexEnabled( false );    // regular expressions? what's that?
+    aDocOpt.SetFormulaWildcardsEnabled( true ); // Excel uses wildcard expressions
     aDocOpt.SetLookUpColRowNames( false );      // default: no natural language refs
     pD->SetDocOptions( aDocOpt );
 }
commit 20b5917966d931fc9cbb8dd24a957f80f95e64bc
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 22 20:43:50 2016 +0100

    add wildcards to Tools->Options->Calc->Calculate dialog, tdf#72196
    
    Maybe this should be a radio button instead (wildcards/regex/literal),
    on the other hand it reflects the two API bool values. Also only two
    checkbox lines are needed instead of three radio button lines.
    
    Change-Id: I3fa74e19c838e10dc0cffd6c0ad6329017e10e56

diff --git a/sc/source/ui/inc/tpcalc.hxx b/sc/source/ui/inc/tpcalc.hxx
index 9476ac1..1d99e1e 100644
--- a/sc/source/ui/inc/tpcalc.hxx
+++ b/sc/source/ui/inc/tpcalc.hxx
@@ -60,6 +60,7 @@ private:
     VclPtr<CheckBox>       m_pBtnCase;
     VclPtr<CheckBox>       m_pBtnCalc;
     VclPtr<CheckBox>       m_pBtnMatch;
+    VclPtr<CheckBox>       m_pBtnWildcards;
     VclPtr<CheckBox>       m_pBtnRegex;
     VclPtr<CheckBox>       m_pBtnLookUp;
     VclPtr<CheckBox>       m_pBtnGeneralPrec;
diff --git a/sc/source/ui/optdlg/tpcalc.cxx b/sc/source/ui/optdlg/tpcalc.cxx
index 8073d37..b3fcfb7 100644
--- a/sc/source/ui/optdlg/tpcalc.cxx
+++ b/sc/source/ui/optdlg/tpcalc.cxx
@@ -55,6 +55,7 @@ ScTpCalcOptions::ScTpCalcOptions(vcl::Window* pParent, const SfxItemSet& rCoreAt
     get(m_pBtnCase, "case");
     get(m_pBtnCalc, "calc");
     get(m_pBtnMatch, "match");
+    get(m_pBtnWildcards, "wildcards");
     get(m_pBtnRegex, "regex");
     get(m_pBtnLookUp, "lookup");
     get(m_pBtnGeneralPrec, "generalprec");
@@ -84,6 +85,7 @@ void ScTpCalcOptions::dispose()
     m_pBtnCase.clear();
     m_pBtnCalc.clear();
     m_pBtnMatch.clear();
+    m_pBtnWildcards.clear();
     m_pBtnRegex.clear();
     m_pBtnLookUp.clear();
     m_pBtnGeneralPrec.clear();
@@ -99,6 +101,8 @@ void ScTpCalcOptions::Init()
     m_pBtnDateStd->SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
     m_pBtnDateSc10->SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
     m_pBtnDate1904->SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
+    m_pBtnWildcards->SetClickHdl( LINK( this, ScTpCalcOptions, CheckClickHdl ) );
+    m_pBtnRegex->SetClickHdl( LINK( this, ScTpCalcOptions, CheckClickHdl ) );
 }
 
 VclPtr<SfxTabPage> ScTpCalcOptions::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
@@ -115,7 +119,12 @@ void ScTpCalcOptions::Reset( const SfxItemSet* /* rCoreAttrs */ )
     m_pBtnCase->Check( !pLocalOptions->IsIgnoreCase() );
     m_pBtnCalc->Check( pLocalOptions->IsCalcAsShown() );
     m_pBtnMatch->Check( pLocalOptions->IsMatchWholeCell() );
-    m_pBtnRegex->Check( pLocalOptions->IsFormulaRegexEnabled() );
+    bool bWildcards = pLocalOptions->IsFormulaWildcardsEnabled();
+    bool bRegex = pLocalOptions->IsFormulaRegexEnabled();
+    if (bWildcards && bRegex)
+        bRegex = false;
+    m_pBtnWildcards->Check( bWildcards );
+    m_pBtnRegex->Check( bRegex );
     m_pBtnLookUp->Check( pLocalOptions->IsLookUpColRowNames() );
     m_pBtnIterate->Check( pLocalOptions->IsIter() );
     m_pEdSteps->SetValue( pLocalOptions->GetIterCount() );
@@ -161,6 +170,7 @@ bool ScTpCalcOptions::FillItemSet( SfxItemSet* rCoreAttrs )
     pLocalOptions->SetIgnoreCase( !m_pBtnCase->IsChecked() );
     pLocalOptions->SetCalcAsShown( m_pBtnCalc->IsChecked() );
     pLocalOptions->SetMatchWholeCell( m_pBtnMatch->IsChecked() );
+    pLocalOptions->SetFormulaWildcardsEnabled( m_pBtnWildcards->IsChecked() );
     pLocalOptions->SetFormulaRegexEnabled( m_pBtnRegex->IsChecked() );
     pLocalOptions->SetLookUpColRowNames( m_pBtnLookUp->IsChecked() );
 
@@ -253,6 +263,16 @@ IMPL_LINK_TYPED( ScTpCalcOptions, CheckClickHdl, Button*, p, void )
             m_pFtEps->Disable(); m_pEdEps->Disable();
         }
     }
+    else if (pBtn == m_pBtnWildcards)
+    {
+        if ( pBtn->IsChecked() )
+            m_pBtnRegex->Check( false );
+    }
+    else if (pBtn == m_pBtnRegex)
+    {
+        if ( pBtn->IsChecked() )
+            m_pBtnWildcards->Check( false );
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/uiconfig/scalc/ui/optcalculatepage.ui b/sc/uiconfig/scalc/ui/optcalculatepage.ui
index a9dca19..6b0e1c0 100644
--- a/sc/uiconfig/scalc/ui/optcalculatepage.ui
+++ b/sc/uiconfig/scalc/ui/optcalculatepage.ui
@@ -92,8 +92,8 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="regex">
-                    <property name="label" translatable="yes">_Enable regular expressions in formulas</property>
+                  <object class="GtkCheckButton" id="wildcards">
+                    <property name="label" translatable="yes">Enable w_ildcards in formulas</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
@@ -108,6 +108,22 @@
                   </packing>
                 </child>
                 <child>
+                  <object class="GtkCheckButton" id="regex">
+                    <property name="label" translatable="yes">Enable r_egular expressions in formulas</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">4</property>
+                    <property name="width">2</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkCheckButton" id="lookup">
                     <property name="label" translatable="yes">_Automatically find column and row labels</property>
                     <property name="visible">True</property>
@@ -119,7 +135,7 @@
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">4</property>
+                    <property name="top_attach">5</property>
                     <property name="width">2</property>
                   </packing>
                 </child>
@@ -135,7 +151,7 @@
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">5</property>
+                    <property name="top_attach">6</property>
                   </packing>
                 </child>
                 <child>
commit d098b76f3311ec1b1763dbcfc1561791a4a2945f
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 22 19:52:59 2016 +0100

    change to DetectSearchType(), tdf#72196
    
    Change-Id: I34cc3faa325f754e4f1dc5236a65f16e035d6c27

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 82f6beb..a35a976 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8147,9 +8147,7 @@ void ScInterpreter::ScSearch()
             PushNoValue();
         else
         {
-            utl::SearchParam::SearchType eSearchType =
-                (MayBeRegExp( SearchStr, pDok ) ?
-                utl::SearchParam::SRCH_REGEXP : utl::SearchParam::SRCH_NORMAL);
+            utl::SearchParam::SearchType eSearchType = DetectSearchType( SearchStr, pDok );
             utl::SearchParam sPar(SearchStr, eSearchType, false, false, false);
             utl::TextSearch sT( sPar, *ScGlobal::pCharClass );
             bool bBool = sT.SearchForward(sStr, &nPos, &nEndPos);
commit 41cd992b0229b2cb814b96b52c0038bf12473b37
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 22 19:47:30 2016 +0100

    confusing block indentation
    
    Change-Id: I42dc30742a65062374e700a70796f129e61b13c1

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index dfebe57..b3974f5 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2435,32 +2435,34 @@ public:
                     && (nStart != 0 || nEnd != aCellStr.getLength()) )
                 bMatch = false;    // RegExp must match entire cell string
             if ( bRealWildOrRegExp )
-                switch (rEntry.eOp)
             {
-                case SC_EQUAL:
-                case SC_CONTAINS:
-                    bOk = bMatch;
-                    break;
-                case SC_NOT_EQUAL:
-                case SC_DOES_NOT_CONTAIN:
-                    bOk = !bMatch;
-                    break;
-                case SC_BEGINS_WITH:
-                    bOk = ( bMatch && (nStart == 0) );
-                    break;
-                case SC_DOES_NOT_BEGIN_WITH:
-                    bOk = !( bMatch && (nStart == 0) );
-                    break;
-                case SC_ENDS_WITH:
-                    bOk = ( bMatch && (nEnd == aCellStr.getLength()) );
-                    break;
-                case SC_DOES_NOT_END_WITH:
-                    bOk = !( bMatch && (nEnd == aCellStr.getLength()) );
-                    break;
-                default:
-                    {
-                        // added to avoid warnings
-                    }
+                switch (rEntry.eOp)
+                {
+                    case SC_EQUAL:
+                    case SC_CONTAINS:
+                        bOk = bMatch;
+                        break;
+                    case SC_NOT_EQUAL:
+                    case SC_DOES_NOT_CONTAIN:
+                        bOk = !bMatch;
+                        break;
+                    case SC_BEGINS_WITH:
+                        bOk = ( bMatch && (nStart == 0) );
+                        break;
+                    case SC_DOES_NOT_BEGIN_WITH:
+                        bOk = !( bMatch && (nStart == 0) );
+                        break;
+                    case SC_ENDS_WITH:
+                        bOk = ( bMatch && (nEnd == aCellStr.getLength()) );
+                        break;
+                    case SC_DOES_NOT_END_WITH:
+                        bOk = !( bMatch && (nEnd == aCellStr.getLength()) );
+                        break;
+                    default:
+                        {
+                            // added to avoid warnings
+                        }
+                }
             }
             else
                 bTestEqual = bMatch;
commit d3c79d019114b7786268a1e821f96554e54767c0
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 22 19:43:40 2016 +0100

    adapt places that call GetSearchTextPtr(), tdf#72196
    
    ... to do that not only for regexp.
    
    Change-Id: I0a6d878c7b30b1668dda902f0e50ae3c3cc3b486

diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index d6e104d..b60e9c7 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -529,10 +529,10 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
         {   // by String
             OUString  aCellStr = pCellData->GetString();
 
-            bool bRealRegExp = (rParam.eSearchType == utl::SearchParam::SRCH_REGEXP &&
+            bool bRealWildOrRegExp = (rParam.eSearchType != utl::SearchParam::SRCH_NORMAL &&
                     ((rEntry.eOp == SC_EQUAL) || (rEntry.eOp == SC_NOT_EQUAL)));
-            bool bTestRegExp = false;
-            if (bRealRegExp || bTestRegExp)
+            bool bTestWildOrRegExp = false;
+            if (bRealWildOrRegExp || bTestWildOrRegExp)
             {
                 sal_Int32 nStart = 0;
                 sal_Int32 nEnd   = aCellStr.getLength();
@@ -543,10 +543,10 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
                 if (bMatch && bMatchWholeCell
                     && (nStart != 0 || nEnd != aCellStr.getLength()))
                     bMatch = false;    // RegExp must match entire cell string
-                if (bRealRegExp)
+                if (bRealWildOrRegExp)
                     bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch);
             }
-            if (!bRealRegExp)
+            if (!bRealWildOrRegExp)
             {
                 if (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL)
                 {
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index cfefd57..dfebe57 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2213,20 +2213,20 @@ class QueryEvaluator
         return false;
     }
 
-    bool isRealRegExp(const ScQueryEntry& rEntry) const
+    bool isRealWildOrRegExp(const ScQueryEntry& rEntry) const
     {
-        if (mrParam.eSearchType != utl::SearchParam::SRCH_REGEXP)
+        if (mrParam.eSearchType == utl::SearchParam::SRCH_NORMAL)
             return false;
 
         return isTextMatchOp(rEntry);
     }
 
-    bool isTestRegExp(const ScQueryEntry& rEntry) const
+    bool isTestWildOrRegExp(const ScQueryEntry& rEntry) const
     {
         if (!mpTestEqualCondition)
             return false;
 
-        if (mrParam.eSearchType != utl::SearchParam::SRCH_REGEXP)
+        if (mrParam.eSearchType == utl::SearchParam::SRCH_NORMAL)
             return false;
 
         return (rEntry.eOp == SC_LESS_EQUAL || rEntry.eOp == SC_GREATER_EQUAL);
@@ -2409,10 +2409,10 @@ public:
             aCellStr = mrStrPool.intern(aStr);
         }
 
-        bool bRealRegExp = isRealRegExp(rEntry);
-        bool bTestRegExp = isTestRegExp(rEntry);
+        bool bRealWildOrRegExp = isRealWildOrRegExp(rEntry);
+        bool bTestWildOrRegExp = isTestWildOrRegExp(rEntry);
 
-        if ( bRealRegExp || bTestRegExp )
+        if ( bRealWildOrRegExp || bTestWildOrRegExp )
         {
             sal_Int32 nStart = 0;
             sal_Int32 nEnd   = aCellStr.getLength();
@@ -2434,7 +2434,7 @@ public:
             if ( bMatch && bMatchWholeCell
                     && (nStart != 0 || nEnd != aCellStr.getLength()) )
                 bMatch = false;    // RegExp must match entire cell string
-            if ( bRealRegExp )
+            if ( bRealWildOrRegExp )
                 switch (rEntry.eOp)
             {
                 case SC_EQUAL:
@@ -2465,7 +2465,7 @@ public:
             else
                 bTestEqual = bMatch;
         }
-        if ( !bRealRegExp )
+        if ( !bRealWildOrRegExp )
         {
             // Simple string matching i.e. no regexp match.
             if (isTextMatchOp(rEntry))
diff --git a/sc/source/core/tool/compare.cxx b/sc/source/core/tool/compare.cxx
index 8433202..cf5c0ff 100644
--- a/sc/source/core/tool/compare.cxx
+++ b/sc/source/core/tool/compare.cxx
@@ -136,7 +136,7 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions )
             // regex to work through GetSearchTextPtr().
             ScQueryEntry& rEntry = pOptions->aQueryEntry;
             OSL_ENSURE(rEntry.GetQueryItem().maString == rCell2.maStr, "ScInterpreter::CompareFunc: broken options");
-            if (pOptions->eSearchType == utl::SearchParam::SRCH_REGEXP)
+            if (pOptions->eSearchType != utl::SearchParam::SRCH_NORMAL)
             {
                 sal_Int32 nStart = 0;
                 sal_Int32 nStop  = rCell1.maStr.getLength();
commit bad266fa06294f1dacec11ec02dfc6ae4ec8cdc4
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 22 19:20:08 2016 +0100

    ScQueryEntry::GetSearchTextPtr() with SearchType, tdf#72196
    
    Change-Id: I1c9c5c6271927bb2d2ac9309e9a6ca36016237f4

diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx
index cac1170..1669f6c 100644
--- a/sc/inc/queryentry.hxx
+++ b/sc/inc/queryentry.hxx
@@ -23,14 +23,10 @@
 #include "address.hxx"
 #include "global.hxx"
 #include <svl/sharedstring.hxx>
+#include <unotools/textsearch.hxx>
 
 #include <vector>
 
-namespace utl {
-    class SearchParam;
-    class TextSearch;
-}
-
 /**
  * Each instance of this struct represents a single filtering criteria.
  */
@@ -55,15 +51,15 @@ struct SC_DLLPUBLIC ScQueryEntry
     SCCOLROW        nField;
     ScQueryOp       eOp;
     ScQueryConnect  eConnect;
-    mutable utl::SearchParam* pSearchParam;       ///< if RegExp, not saved
-    mutable utl::TextSearch*  pSearchText;        ///< if RegExp, not saved
+    mutable utl::SearchParam* pSearchParam;       ///< if Wildcard or RegExp, not saved
+    mutable utl::TextSearch*  pSearchText;        ///< if Wildcard or RegExp, not saved
 
     ScQueryEntry();
     ScQueryEntry(const ScQueryEntry& r);
     ~ScQueryEntry();
 
-    /// creates pSearchParam and pSearchText if necessary, always RegExp!
-    utl::TextSearch* GetSearchTextPtr( bool bCaseSens ) const;
+    /// creates pSearchParam and pSearchText if necessary
+    utl::TextSearch* GetSearchTextPtr( utl::SearchParam::SearchType eSearchType, bool bCaseSens ) const;
 
     QueryItemsType& GetQueryItems() { return maQueryItems;}
     const QueryItemsType& GetQueryItems() const { return maQueryItems;}
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 7ff9ee9..1b86461 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1296,9 +1296,9 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
     SetStopOnMismatch( true ); // assume sorted keys
     SetTestEqualCondition( true );
     bIgnoreMismatchOnLeadingStrings = bIgnoreMismatchOnLeadingStringsP;
-    bool bRegExp = mpParam->eSearchType == utl::SearchParam::SRCH_REGEXP &&
+    bool bLiteral = mpParam->eSearchType == utl::SearchParam::SRCH_NORMAL &&
         mpParam->GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString;
-    bool bBinary = !bRegExp && mpParam->bByRow && (mpParam->GetEntry(0).eOp ==
+    bool bBinary = bLiteral && mpParam->bByRow && (mpParam->GetEntry(0).eOp ==
             SC_LESS_EQUAL || mpParam->GetEntry(0).eOp == SC_GREATER_EQUAL);
     bool bFound = false;
     if (bBinary)
@@ -1413,7 +1413,7 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
         maCurPos = aPosSave;
         return true;
     }
-    if ( (bSearchForEqualAfterMismatch || mpParam->eSearchType == utl::SearchParam::SRCH_REGEXP) &&
+    if ( (bSearchForEqualAfterMismatch || mpParam->eSearchType != utl::SearchParam::SRCH_NORMAL) &&
             StoppedOnMismatch() )
     {
         // Assume found entry to be the last value less than respectively
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 1e77d25..d6e104d 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -537,7 +537,7 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
                 sal_Int32 nStart = 0;
                 sal_Int32 nEnd   = aCellStr.getLength();
 
-                bool bMatch = (bool) rEntry.GetSearchTextPtr( rParam.bCaseSens )
+                bool bMatch = (bool) rEntry.GetSearchTextPtr( rParam.eSearchType, rParam.bCaseSens )
                               ->SearchForward( aCellStr, &nStart, &nEnd );
                 // from 614 on, nEnd is behind the found text
                 if (bMatch && bMatchWholeCell
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 67d9e3e..cfefd57 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2423,12 +2423,12 @@ public:
             {
                 nEnd = 0;
                 nStart = aCellStr.getLength();
-                bMatch = rEntry.GetSearchTextPtr( mrParam.bCaseSens )
+                bMatch = rEntry.GetSearchTextPtr( mrParam.eSearchType, mrParam.bCaseSens )
                     ->SearchBackward(aCellStr.getString(), &nStart, &nEnd);
             }
             else
             {
-                bMatch = rEntry.GetSearchTextPtr( mrParam.bCaseSens )
+                bMatch = rEntry.GetSearchTextPtr( mrParam.eSearchType, mrParam.bCaseSens )
                     ->SearchForward(aCellStr.getString(), &nStart, &nEnd);
             }
             if ( bMatch && bMatchWholeCell
diff --git a/sc/source/core/tool/compare.cxx b/sc/source/core/tool/compare.cxx
index d2d0322..8433202 100644
--- a/sc/source/core/tool/compare.cxx
+++ b/sc/source/core/tool/compare.cxx
@@ -140,7 +140,7 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions )
             {
                 sal_Int32 nStart = 0;
                 sal_Int32 nStop  = rCell1.maStr.getLength();
-                bool bMatch = rEntry.GetSearchTextPtr(
+                bool bMatch = rEntry.GetSearchTextPtr( pOptions->eSearchType,
                         !rComp.mbIgnoreCase)->SearchForward(
                             rCell1.maStr.getString(), &nStart, &nStop);
                 if (bMatch && pOptions->bMatchWholeCell && (nStart != 0 || nStop != rCell1.maStr.getLength()))
diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx
index 1a5c471..17529c5 100644
--- a/sc/source/core/tool/queryentry.cxx
+++ b/sc/source/core/tool/queryentry.cxx
@@ -164,13 +164,13 @@ bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
     // do not compare pSearchParam and pSearchText!
 }
 
-utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
+utl::TextSearch* ScQueryEntry::GetSearchTextPtr( utl::SearchParam::SearchType eSearchType, bool bCaseSens ) const
 {
     if ( !pSearchParam )
     {
         OUString aStr = maQueryItems[0].maString.getString();
         pSearchParam = new utl::SearchParam(
-            aStr, utl::SearchParam::SRCH_REGEXP, bCaseSens, false, false);
+            aStr, eSearchType, bCaseSens, false, false);
         pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
     }
     return pSearchText;
commit b3a66ccdd3f4098670b593883602093c4a9e712c
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 22 17:17:22 2016 +0100

    include '~' escape character in MaybeWildcard(), tdf#72196
    
    Change-Id: I09ff6b07f63b9b9199b73d27d8118c18d233f2b2

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 26b7f10..82f6beb 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8515,9 +8515,10 @@ bool ScInterpreter::MayBeWildcard( const OUString& rStr, const ScDocument* pDoc
     if ( pDoc && !pDoc->GetDocOptions().IsFormulaWildcardsEnabled() )
         return false;
 
-    // Wildcards without '~' escape, if there are no wildcards then an escaped
-    // character does not make sense.
-    static const sal_Unicode cw[] = { '*','?', 0 };
+    // Wildcards with '~' escape, if there are no wildcards then an escaped
+    // character does not make sense, but it modifies the search pattern in an
+    // Excel compatible wildcard search..
+    static const sal_Unicode cw[] = { '*','?','~', 0 };
     const sal_Unicode* p1 = rStr.getStr();
     sal_Unicode c1;
     while ( ( c1 = *p1++ ) != 0 )


More information about the Libreoffice-commits mailing list