[Libreoffice-commits] .: Branch 'feature/new-autofilter-popup' - 2 commits - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Nov 4 19:38:52 PDT 2011


 sc/inc/queryparam.hxx              |    9 +++-
 sc/source/core/data/table3.cxx     |    2 +
 sc/source/core/tool/queryparam.cxx |   70 +++++++++++++++++++++++++++++--------
 sc/source/ui/inc/gridwin.hxx       |    7 ++-
 sc/source/ui/view/gridwin.cxx      |    2 +
 sc/source/ui/view/gridwin2.cxx     |    4 ++
 sc/source/ui/view/tabview.cxx      |    4 ++
 7 files changed, 78 insertions(+), 20 deletions(-)

New commits:
commit be16da1407b237b18accc39f566b8a8509d66bf0
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Fri Nov 4 22:36:32 2011 -0400

    Temporarily disabling the new autofilter popup due to a set-back.
    
    Ugh!  I need to refactor the query validation code first before working
    on the new popup.  I will
    
    1) temporarily disable the new autofilter popup,
    2) merge my changes so far to master, and
    3) work on refactoring the query validation code without changing the
       current functionality, then come back to working on the new popup.
    
    Darn...

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 00827d9..4271df2 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -42,6 +42,8 @@
 #include <memory>
 #include <boost/scoped_ptr.hpp>
 
+#define USE_NEW_AUTOFILTER 0
+
 // ---------------------------------------------------------------------------
 
 struct ScTableInfo;
@@ -341,8 +343,10 @@ public:
 
     void            LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelect );
     void            DoScenarioMenue( const ScRange& rScenRange );
-
+#if USE_NEW_AUTOFILTER
     void            LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow);
+    void            UpdateAutoFilterFromMenu();
+#endif
     void            LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
     void            LaunchDPFieldMenu( SCCOL nCol, SCROW nRow );
 
@@ -379,7 +383,6 @@ public:
 
     void            CheckNeedsRepaint();
 
-    void            UpdateAutoFilterFromMenu();
     void            UpdateDPFromFieldPopupMenu();
     void            UpdateVisibleRange();
 
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index dc7ff54..8293b6f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -585,6 +585,7 @@ void ScGridWindow::ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSel
     }
 }
 
+#if USE_NEW_AUTOFILTER
 namespace {
 
 class PopupAction : public ScMenuFloatingWindow::Action
@@ -700,6 +701,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu()
     pViewData->GetView()->Query(aParam, NULL, true);
     pDBData->SetQueryParam(aParam);
 }
+#endif
 
 void ScGridWindow::LaunchPageFieldMenu( SCCOL nCol, SCROW nRow )
 {
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 2688e04..a3ecaae 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -165,7 +165,11 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent&
         HideCursor();
         mpFilterButton->draw();
         ShowCursor();
+#if USE_NEW_AUTOFILTER
         LaunchAutoFilterMenu(nCol, nRow);
+#else
+        LaunchDataSelectMenu(nCol, nRow, false);
+#endif
         return true;
     }
 
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 6e6863a..6804c36 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2403,10 +2403,14 @@ void ScTabView::StartDataSelect()
         aViewData.GetDocument()->GetAttr(
             nCol, nRow, aViewData.GetTabNo(), ATTR_MERGE_FLAG));
 
+#if USE_NEW_AUTOFILTER
     if (pAttr->HasAutoFilter())
         pWin->LaunchAutoFilterMenu(nCol, nRow);
     else
         pWin->LaunchDataSelectMenu(nCol, nRow, true);
+#else
+    pWin->LaunchDataSelectMenu(nCol, nRow, !pAttr->HasAutoFilter());
+#endif
 }
 
 void ScTabView::EnableRefInput(bool bFlag)
commit 7c387721b5de40d5a58189a9f05ebdcbea28d395
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Fri Nov 4 21:25:49 2011 -0400

    Hide the query strings member, and add relevant methods for it.

diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index f3d755c..6b87397 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -52,9 +52,8 @@ namespace utl {
 
 struct ScQueryEntry
 {
-private:
-    String*         pStr;
-public:
+    typedef std::vector<rtl::OUString> QueryStringsType;
+
     bool            bDoQuery;
     bool            bQueryByString;
     bool            bQueryByDate;
@@ -74,11 +73,15 @@ public:
 
     bool            IsQueryStringEmpty() const;
     bool            MatchByString(const rtl::OUString& rStr, bool bCaseSens) const;
+    void            SwapQueryStrings(QueryStringsType& rStrings);
+    void            SortQueryStrings(bool bCaseSens);
     SC_DLLPUBLIC void SetQueryString(const rtl::OUString& rStr);
     SC_DLLPUBLIC rtl::OUString GetQueryString() const;
     void            Clear();
     ScQueryEntry&   operator=( const ScQueryEntry& r );
     bool            operator==( const ScQueryEntry& r ) const;
+private:
+    QueryStringsType maQueryStrings;
 };
 
 struct ScQueryParamBase
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 7cae817..31ad25a 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1614,6 +1614,8 @@ static void lcl_PrepareQuery( ScDocument* pDoc, ScTable* pTab, ScQueryParam& rPa
         ScQueryEntry& rEntry = rParam.GetEntry(i);
         if ( rEntry.bDoQuery )
         {
+            rEntry.SortQueryStrings(rParam.bCaseSens);
+
             if ( rEntry.bQueryByString )
             {
                 sal_uInt32 nIndex = 0;
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index ca7d3a2..29fdb8b 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -34,6 +34,7 @@
 #include "queryparam.hxx"
 #include <unotools/textsearch.hxx>
 #include <unotools/transliterationwrapper.hxx>
+#include <unotools/collatorwrapper.hxx>
 
 using ::std::vector;
 
@@ -44,7 +45,6 @@ const SCSIZE MAXQUERY = 8;
 }
 
 ScQueryEntry::ScQueryEntry() :
-    pStr(new String),
     bDoQuery(false),
     bQueryByString(false),
     bQueryByDate(false),
@@ -58,7 +58,6 @@ ScQueryEntry::ScQueryEntry() :
 }
 
 ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
-    pStr(new String(*r.pStr)),
     bDoQuery(r.bDoQuery),
     bQueryByString(r.bQueryByString),
     bQueryByDate(r.bQueryByDate),
@@ -67,13 +66,13 @@ ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
     eConnect(r.eConnect),
     nVal(r.nVal),
     pSearchParam(NULL),
-    pSearchText(NULL)
+    pSearchText(NULL),
+    maQueryStrings(r.maQueryStrings)
 {
 }
 
 ScQueryEntry::~ScQueryEntry()
 {
-    delete pStr;
     delete pSearchParam;
     delete pSearchText;
 }
@@ -87,7 +86,7 @@ ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
     eConnect        = r.eConnect;
     nField          = r.nField;
     nVal            = r.nVal;
-    *pStr           = *r.pStr;
+    maQueryStrings  = r.maQueryStrings;
 
     delete pSearchParam;
     delete pSearchText;
@@ -99,24 +98,62 @@ ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
 
 bool ScQueryEntry::IsQueryStringEmpty() const
 {
-    return pStr->Len() == 0;
+    return maQueryStrings.empty();
+}
+
+namespace {
+
+class CompareString : std::binary_function<rtl::OUString, rtl::OUString, bool>
+{
+    CollatorWrapper* mpCollator;
+public:
+    CompareString(bool bCaseSens) :
+     mpCollator(
+         bCaseSens ? ScGlobal::GetCaseCollator() : ScGlobal::GetCollator())
+    {}
+
+    bool operator() (const rtl::OUString& rL, const rtl::OUString& rR) const
+    {
+        return mpCollator->compareString(rL, rR) < 0;
+    }
+};
+
 }
 
 bool ScQueryEntry::MatchByString(const rtl::OUString& rStr, bool bCaseSens) const
 {
-    utl::TransliterationWrapper* pTransliteration = bCaseSens ?
-        ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration();
-    return pTransliteration->isEqual(rStr, *pStr);
+    QueryStringsType::const_iterator itr =
+        std::lower_bound(
+            maQueryStrings.begin(), maQueryStrings.end(), rStr, CompareString(bCaseSens));
+
+    if (itr == maQueryStrings.end())
+        return false;
+
+    utl::TransliterationWrapper* pTransliteration =
+        bCaseSens ? ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration();
+    return pTransliteration->isEqual(rStr, *itr);
+}
+
+void ScQueryEntry::SwapQueryStrings(QueryStringsType& rStrings)
+{
+    maQueryStrings.swap(rStrings);
+}
+
+void ScQueryEntry::SortQueryStrings(bool bCaseSens)
+{
+    std::sort(maQueryStrings.begin(), maQueryStrings.end(), CompareString(bCaseSens));
 }
 
 void ScQueryEntry::SetQueryString(const rtl::OUString& rStr)
 {
-    *pStr = String(rStr);
+    maQueryStrings.clear();
+    if (!rStr.isEmpty())
+        maQueryStrings.push_back(rStr);
 }
 
 rtl::OUString ScQueryEntry::GetQueryString() const
 {
-    return *pStr;
+    return maQueryStrings.empty() ? rtl::OUString() : maQueryStrings[0];
 }
 
 void ScQueryEntry::Clear()
@@ -128,7 +165,7 @@ void ScQueryEntry::Clear()
     eConnect        = SC_AND;
     nField          = 0;
     nVal            = 0.0;
-    pStr->Erase();
+    maQueryStrings.clear();
 
     delete pSearchParam;
     delete pSearchText;
@@ -145,7 +182,7 @@ bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
         && eConnect         == r.eConnect
         && nField           == r.nField
         && nVal             == r.nVal
-        && *pStr            == *r.pStr;
+        && maQueryStrings   == r.maQueryStrings;
     //! pSearchParam und pSearchText nicht vergleichen
 }
 
@@ -153,8 +190,11 @@ utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
 {
     if ( !pSearchParam )
     {
-        pSearchParam = new utl::SearchParam( *pStr, utl::SearchParam::SRCH_REGEXP,
-            bCaseSens, false, false );
+        rtl::OUString aStr;
+        if (!maQueryStrings.empty())
+            aStr = maQueryStrings[0];
+        pSearchParam = new utl::SearchParam(
+            aStr, utl::SearchParam::SRCH_REGEXP, bCaseSens, false, false);
         pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
     }
     return pSearchText;


More information about the Libreoffice-commits mailing list