User: kz      
Date: 2006/11/06 06:42:54

Modified:
   dba/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx

Log:
 INTEGRATION: CWS dba21fini (1.75.4); FILE MERGED
 2006/10/30 09:49:52 fs 1.75.4.1: #i70989# saveField: don't quote in the field 
name in the first pass

File Changes:

Directory: /dba/dbaccess/source/ui/querydesign/
===============================================

File [changed]: SelectionBrowseBox.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx?r1=1.75&r2=1.76
Delta lines:  +229 -215
-----------------------
--- SelectionBrowseBox.cxx      24 Oct 2006 15:15:01 -0000      1.75
+++ SelectionBrowseBox.cxx      6 Nov 2006 14:42:51 -0000       1.76
@@ -731,19 +731,44 @@
        // second test if the name can be set as select columns in a pseudo 
statement
        // we have to look which entries  we should quote
        
+    size_t nPass = 4;
+    ::connectivity::OSQLParser& rParser( pController->getParser() );
+    OSQLParseNode* pParseNode = NULL;
+    // 4 passes in trying to interprete the field name
+    // - don't quote the field name, parse internationally
+    // - don't quote the field name, parse en-US
+    // - quote the field name, parse internationally
+    // - quote the field name, parse en-US
+    do
+    {
+        bool bQuote = ( nPass <= 2 );
+        bool bInternational = ( nPass % 2 ) == 0;
+
        ::rtl::OUString sSql;
        sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT "));
+        if ( bQuote )
     sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), 
_sFieldName );
+        else
+            sSql += _sFieldName;
        sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x"));
 
-       ::connectivity::OSQLParser& rParser( pController->getParser() );
-       // first try the international version
-       OSQLParseNode* pParseNode = rParser.parseTree(sErrorMsg, sSql,sal_True);
-       if ( !pParseNode ) // if that doesn't work try the english one
-               pParseNode = rParser.parseTree(sErrorMsg, sSql,sal_False);
+        pParseNode = rParser.parseTree( sErrorMsg, sSql, bInternational );
+    }
+    while ( ( pParseNode == NULL ) && ( --nPass > 0 ) );
 
-       if ( pParseNode ) // we got a valid select column
+    if ( pParseNode == NULL )
        {
+        // something different which we have to check (may be a select 
statement)
+        String sErrorMessage( ModuleRes( STR_QRY_COLUMN_NOT_FOUND ) );
+        sErrorMessage.SearchAndReplaceAscii("$name$",_sFieldName);
+        OSQLMessageBox aDlg( this,
+            String( ModuleRes( STR_STAT_WARNING ) ), sErrorMessage,
+            WB_OK | WB_DEF_OK, OSQLMessageBox::Warning );
+        aDlg.Execute();
+        return sal_True;
+    }
+
+    // we got a valid select column
                // find what type of column has be inserted
                ::connectivity::OSQLParseNode* pSelection = 
pParseNode->getChild(2);
                if ( SQL_ISRULE(pSelection,selection) ) // we found the asterix
@@ -937,17 +962,6 @@
                        }
                }
                delete pParseNode;
-       }
-       else // something different which we have to check (may be a select 
statement)
-       {
-        String sErrorMessage( ModuleRes( STR_QRY_COLUMN_NOT_FOUND ) );
-               sErrorMessage.SearchAndReplaceAscii("$name$",_sFieldName);
-               OSQLMessageBox aDlg( this,
-            String( ModuleRes( STR_STAT_WARNING ) ), sErrorMessage,
-            WB_OK | WB_DEF_OK, OSQLMessageBox::Warning );
-               aDlg.Execute();
-               bError = sal_True;
-       }
 
        return bError;
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to