[Libreoffice-commits] .: 3 commits - connectivity/inc connectivity/source dbaccess/source

Lionel Elie Mamane lmamane at kemper.freedesktop.org
Sun Oct 30 05:37:27 PDT 2011


 connectivity/inc/connectivity/sqlnode.hxx             |    7 +++
 connectivity/source/parse/sqliterator.cxx             |    4 --
 dbaccess/source/ui/querydesign/QueryDesignView.cxx    |   33 +++++++-----------
 dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx |   10 +----
 4 files changed, 22 insertions(+), 32 deletions(-)

New commits:
commit 6efdf794cdd0c979ffead0e5051309f711b23997
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Oct 30 13:34:01 2011 +0100

    factorise multiple SQL_ISRULEOR2 implementations into one

diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx
index 9329702..1d8381a 100644
--- a/connectivity/inc/connectivity/sqlnode.hxx
+++ b/connectivity/inc/connectivity/sqlnode.hxx
@@ -464,6 +464,13 @@ namespace connectivity
 
     // utilities to query for a specific rule, token or punctuation
     #define SQL_ISRULE(pParseNode, eRule)   ((pParseNode)->isRule() && (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::eRule))
+    #define SQL_ISRULEOR2(pParseNode, e1, e2)  ((pParseNode)->isRule() && ( \
+                                                  (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
+                                                  (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2)))
+    #define SQL_ISRULEOR3(pParseNode, e1, e2, e3)  ((pParseNode)->isRule() && ( \
+                                                      (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
+                                                      (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2) || \
+                                                      (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e3)))
     #define SQL_ISTOKEN(pParseNode, token) ((pParseNode)->isToken() && (pParseNode)->getTokenID() == SQL_TOKEN_##token)
     #define SQL_ISTOKENOR2(pParseNode, tok0, tok1) ((pParseNode)->isToken() &&  ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 ))
     #define SQL_ISTOKENOR3(pParseNode, tok0, tok1, tok2) ((pParseNode)->isToken() && ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok2 ))
diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx
index 0c3b6a0..325523c 100644
--- a/connectivity/source/parse/sqliterator.cxx
+++ b/connectivity/source/parse/sqliterator.cxx
@@ -51,10 +51,6 @@
 #include "diagnose_ex.h"
 #include <rtl/logfile.hxx>
 
-#define SQL_ISRULEOR2(pParseNode, e1,e2)    ((pParseNode)->isRule() && (\
-                                            (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
-                                            (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2)))
-
 using namespace ::comphelper;
 using namespace ::connectivity;
 using namespace ::connectivity::sdbcx;
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index 45bce3e..455b343 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -76,10 +76,6 @@ using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::container;
 
-#define SQL_ISRULEOR2(pParseNode, e1,e2)    ((pParseNode)->isRule() && (\
-                                            (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
-                                            (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2)))
-
 // here we define our functions used in the anonymous namespace to get our header file smaller
 // please look at the book LargeScale C++ to know why
 namespace
@@ -1432,10 +1428,9 @@ namespace
                     _pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine);
                 }
             }
-            else if(SQL_ISRULEOR2(pValueExp,general_set_fct ,set_fct_spec)          ||
-                            SQL_ISRULEOR2(pValueExp,position_exp,extract_exp)   ||
-                            SQL_ISRULEOR2(pValueExp,fold,char_substring_fct)    ||
-                            SQL_ISRULEOR2(pValueExp,length_exp,char_value_fct))
+            else if(SQL_ISRULEOR3(pValueExp, general_set_fct, set_fct_spec, position_exp)  ||
+                      SQL_ISRULEOR3(pValueExp, extract_exp, fold, char_substring_fct)       ||
+                      SQL_ISRULEOR2(pValueExp, length_exp, char_value_fct))
             {
                 AddFunctionCondition(   _pView,
                                         _pSelectionBrw,
@@ -1528,10 +1523,10 @@ namespace
 
         OSQLParseNode* pFunction = pCondition->getChild(0);
 
-        OSL_ENSURE(SQL_ISRULEOR2(pFunction,general_set_fct ,set_fct_spec)           ||
-                            SQL_ISRULEOR2(pFunction,position_exp,extract_exp)   ||
-                            SQL_ISRULEOR2(pFunction,fold,char_substring_fct)    ||
-                            SQL_ISRULEOR2(pFunction,length_exp,char_value_fct),"Illegal call!");
+        OSL_ENSURE(SQL_ISRULEOR3(pFunction, general_set_fct, set_fct_spec, position_exp)  ||
+                     SQL_ISRULEOR3(pFunction, extract_exp, fold, char_substring_fct)      ||
+                     SQL_ISRULEOR2(pFunction,length_exp,char_value_fct),
+                   "Illegal call!");
         ::rtl::OUString aCondition;
         OTableFieldDescRef aDragLeft = new OTableFieldDesc();
 
@@ -2196,10 +2191,9 @@ namespace
                         eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField);
                         bFirstField = sal_False;
                     }
-                    else if(SQL_ISRULEOR2(pColumnRef,general_set_fct ,set_fct_spec) ||
-                            SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp)      ||
-                            SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct)       ||
-                            SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct))
+                    else if(SQL_ISRULEOR3(pColumnRef, general_set_fct, set_fct_spec, position_exp)  ||
+                              SQL_ISRULEOR3(pColumnRef, extract_exp, fold, char_substring_fct)      ||
+                              SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct))
                     {
                         ::rtl::OUString aColumns;
                         pColumnRef->parseNodeToPredicateStr(aColumns,
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index 1b2328d..8b9330e 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -71,11 +71,6 @@ const String g_strZero = String::CreateFromAscii("0");
 #define HANDLE_ID            0
 #define HANDLE_COLUMN_WITDH 70
 
-#define SQL_ISRULEOR2(pParseNode, e1,e2)    ((pParseNode)->isRule() && (\
-                                            (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
-                                            (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2)))
-
-
 // -----------------------------------------------------------------------------
 namespace
 {
@@ -860,9 +855,8 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes
 
                 getDesignView()->fillFunctionInfo(pColumnRef,sFunction,aSelEntry);
 
-                if( SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp) ||
-                    SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct)  ||
-                    SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct) )
+                if( SQL_ISRULEOR3(pColumnRef, position_exp, extract_exp, fold) ||
+                    SQL_ISRULEOR3(pColumnRef, char_substring_fct, length_exp, char_value_fct) )
                     // a calculation has been found ( can be calc and function )
                 {
                     // now parse the whole statement
commit eaa8cb8ee384f4edbe77aaa9a533d62064622fbf
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Oct 30 13:17:52 2011 +0100

    add const

diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index 13ef270..45bce3e 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -2225,8 +2225,8 @@ namespace
                         {
                             if ( pParamRef && pParamRef->getTokenValue().toChar() == '*' )
                             {
-                                OJoinTableView::OTableWindowMap::iterator aIter = pTabList->begin();
-                                OJoinTableView::OTableWindowMap::iterator aEnd  = pTabList->end();
+                                OJoinTableView::OTableWindowMap::iterator             aIter = pTabList->begin();
+                                const OJoinTableView::OTableWindowMap::const_iterator aEnd  = pTabList->end();
                                 for(;aIter != aEnd;++aIter)
                                 {
                                     OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second);
commit 788283383e93a646a397d9a14847128b354f18bb
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Oct 30 13:05:17 2011 +0100

    Remove unnecessary variable

diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index 2b0fd2c..13ef270 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -3283,7 +3283,6 @@ void OQueryDesignView::fillFunctionInfo(  const ::connectivity::OSQLParseNode* p
     // get the type of the expression, as far as easily possible
     OQueryController& rController = static_cast<OQueryController&>(getController());
     sal_Int32 nDataType = DataType::DOUBLE;
-    ::rtl::OUString sFieldName = sFunctionTerm;
     switch(pNode->getNodeType())
     {
     case SQL_NODE_CONCAT:
@@ -3585,7 +3584,7 @@ void OQueryDesignView::fillFunctionInfo(  const ::connectivity::OSQLParseNode* p
 
     aInfo->SetDataType(nDataType);
     aInfo->SetFieldType(TAB_NORMAL_FIELD);
-    aInfo->SetField(sFieldName);
+    aInfo->SetField(sFunctionTerm);
     aInfo->SetTabWindow(NULL);
 }
 // -----------------------------------------------------------------------------


More information about the Libreoffice-commits mailing list