LCOV - code coverage report
Current view: top level - connectivity/source/commontools - predicateinput.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 52 177 29.4 %
Date: 2012-08-25 Functions: 4 8 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 45 306 14.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include <connectivity/predicateinput.hxx>
      22                 :            : #include <comphelper/types.hxx>
      23                 :            : #include <connectivity/dbtools.hxx>
      24                 :            : #include <com/sun/star/sdbc/DataType.hpp>
      25                 :            : #include <com/sun/star/sdbc/ColumnValue.hpp>
      26                 :            : #include <osl/diagnose.h>
      27                 :            : #include <connectivity/sqlnode.hxx>
      28                 :            : #include <connectivity/PColumn.hxx>
      29                 :            : #include <comphelper/numbers.hxx>
      30                 :            : 
      31                 :            : #include <boost/shared_ptr.hpp>
      32                 :            : 
      33                 :            : //.........................................................................
      34                 :            : namespace dbtools
      35                 :            : {
      36                 :            : //.........................................................................
      37                 :            : 
      38                 :            :     using ::com::sun::star::sdbc::XConnection;
      39                 :            :     using ::com::sun::star::lang::XMultiServiceFactory;
      40                 :            :     using ::com::sun::star::util::XNumberFormatsSupplier;
      41                 :            :     using ::com::sun::star::util::XNumberFormatter;
      42                 :            :     using ::com::sun::star::uno::UNO_QUERY;
      43                 :            :     using ::com::sun::star::beans::XPropertySet;
      44                 :            :     using ::com::sun::star::beans::XPropertySetInfo;
      45                 :            :     using ::com::sun::star::lang::Locale;
      46                 :            :     using ::com::sun::star::uno::Exception;
      47                 :            :     using ::com::sun::star::i18n::XLocaleData;
      48                 :            :     using ::com::sun::star::i18n::LocaleDataItem;
      49                 :            : 
      50                 :            :     using namespace ::com::sun::star::sdbc;
      51                 :            :     using namespace ::connectivity;
      52                 :            : 
      53                 :            :     using ::connectivity::OSQLParseNode;
      54                 :            : 
      55                 :            :     #define Reference ::com::sun::star::uno::Reference
      56                 :            : 
      57                 :            :     //=====================================================================
      58                 :            :     //---------------------------------------------------------------------
      59                 :          0 :     static sal_Unicode lcl_getSeparatorChar( const ::rtl::OUString& _rSeparator, sal_Unicode _nFallback )
      60                 :            :     {
      61                 :            :         OSL_ENSURE( !_rSeparator.isEmpty(), "::lcl_getSeparatorChar: invalid separator string!" );
      62                 :            : 
      63                 :          0 :         sal_Unicode nReturn( _nFallback );
      64         [ #  # ]:          0 :         if ( !_rSeparator.isEmpty() )
      65                 :          0 :             nReturn = static_cast< sal_Char >( _rSeparator.getStr()[0] );
      66                 :          0 :         return nReturn;
      67                 :            :     }
      68                 :            : 
      69                 :            :     //=====================================================================
      70                 :            :     //= OPredicateInputController
      71                 :            :     //=====================================================================
      72                 :            :     //---------------------------------------------------------------------
      73                 :          0 :     sal_Bool OPredicateInputController::getSeparatorChars( const Locale& _rLocale, sal_Unicode& _rDecSep, sal_Unicode& _rThdSep ) const
      74                 :            :     {
      75                 :          0 :         _rDecSep = '.';
      76                 :          0 :         _rThdSep = ',';
      77                 :            :         try
      78                 :            :         {
      79                 :          0 :             LocaleDataItem aLocaleData;
      80         [ #  # ]:          0 :             if ( m_xLocaleData.is() )
      81                 :            :             {
      82 [ #  # ][ #  # ]:          0 :                 aLocaleData = m_xLocaleData->getLocaleItem( _rLocale );
      83                 :          0 :                 _rDecSep = lcl_getSeparatorChar( aLocaleData.decimalSeparator, _rDecSep );
      84                 :          0 :                 _rThdSep = lcl_getSeparatorChar( aLocaleData.decimalSeparator, _rThdSep );
      85                 :          0 :                 return sal_True;
      86 [ #  # ][ #  # ]:          0 :             }
      87                 :            :         }
      88                 :          0 :         catch( const Exception& )
      89                 :            :         {
      90                 :            :             OSL_FAIL( "OPredicateInputController::getSeparatorChars: caught an exception!" );
      91                 :            :         }
      92                 :          0 :         return sal_False;
      93                 :            :     }
      94                 :            : 
      95                 :            :     //---------------------------------------------------------------------
      96                 :          8 :     OPredicateInputController::OPredicateInputController(
      97                 :            :         const Reference< XMultiServiceFactory >& _rxORB, const Reference< XConnection >& _rxConnection, const IParseContext* _pParseContext )
      98                 :            :         :m_xORB( _rxORB )
      99                 :            :         ,m_xConnection( _rxConnection )
     100         [ +  - ]:          8 :         ,m_aParser( m_xORB, _pParseContext )
     101                 :            :     {
     102                 :            :         try
     103                 :            :         {
     104                 :            :             // create a number formatter / number formats supplier pair
     105                 :            :             OSL_ENSURE( m_xORB.is(), "OPredicateInputController::OPredicateInputController: need a service factory!" );
     106         [ +  - ]:          8 :             if ( m_xORB.is() )
     107                 :            :             {
     108         [ +  - ]:          8 :                 m_xFormatter = Reference< XNumberFormatter >( m_xORB->createInstance(
     109                 :          8 :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.NumberFormatter" ) ) ),
     110                 :            :                     UNO_QUERY
     111 [ +  - ][ +  - ]:          8 :                 );
         [ +  - ][ +  - ]
     112                 :            :             }
     113                 :            : 
     114         [ +  - ]:          8 :             Reference< XNumberFormatsSupplier >  xNumberFormats = ::dbtools::getNumberFormats( m_xConnection, sal_True );
     115         [ -  + ]:          8 :             if ( !xNumberFormats.is() )
     116         [ #  # ]:          0 :                 ::comphelper::disposeComponent( m_xFormatter );
     117         [ +  - ]:          8 :             else if ( m_xFormatter.is() )
     118 [ +  - ][ +  - ]:          8 :                 m_xFormatter->attachNumberFormatsSupplier( xNumberFormats );
     119                 :            : 
     120                 :            :             // create the locale data
     121         [ +  - ]:          8 :             if ( m_xORB.is() )
     122                 :            :             {
     123         [ +  - ]:          8 :                 m_xLocaleData = m_xLocaleData.query( m_xORB->createInstance(
     124                 :          8 :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.LocaleData" ) ) )
     125 [ +  - ][ +  - ]:          8 :                 );
         [ +  - ][ +  - ]
     126         [ #  # ]:          8 :             }
     127                 :            :         }
     128         [ #  # ]:          0 :         catch( const Exception& )
     129                 :            :         {
     130                 :            :             OSL_FAIL( "OPredicateInputController::OPredicateInputController: caught an exception!" );
     131                 :            :         }
     132                 :          8 :     }
     133                 :            : 
     134                 :            :     //---------------------------------------------------------------------
     135                 :         72 :     OSQLParseNode* OPredicateInputController::implPredicateTree(::rtl::OUString& _rErrorMessage, const ::rtl::OUString& _rStatement, const Reference< XPropertySet > & _rxField) const
     136                 :            :     {
     137                 :         72 :         OSQLParseNode* pReturn = const_cast< OSQLParser& >( m_aParser ).predicateTree( _rErrorMessage, _rStatement, m_xFormatter, _rxField );
     138         [ -  + ]:         72 :         if ( !pReturn )
     139                 :            :         {   // is it a text field ?
     140                 :          0 :             sal_Int32 nType = DataType::OTHER;
     141 [ #  # ][ #  # ]:          0 :             _rxField->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Type" )) ) >>= nType;
                 [ #  # ]
     142                 :            : 
     143 [ #  # ][ #  # ]:          0 :             if  (   ( DataType::CHAR        == nType )
         [ #  # ][ #  # ]
     144                 :            :                 ||  ( DataType::VARCHAR     == nType )
     145                 :            :                 ||  ( DataType::LONGVARCHAR == nType )
     146                 :            :                 ||  ( DataType::CLOB        == nType )
     147                 :            :                 )
     148                 :            :             {   // yes -> force a quoted text and try again
     149                 :          0 :                 ::rtl::OUString sQuoted( _rStatement );
     150 [ #  # ][ #  #  :          0 :                 if  (   !sQuoted.isEmpty()
             #  #  #  # ]
     151                 :          0 :                     &&  (   (sQuoted.getStr()[0] != '\'')
     152                 :          0 :                         ||  (sQuoted.getStr()[ sQuoted.getLength() - 1 ] != '\'' )
     153                 :            :                         )
     154                 :            :                     )
     155                 :            :                 {
     156 [ #  # ][ #  # ]:          0 :                     static const ::rtl::OUString sSingleQuote( RTL_CONSTASCII_USTRINGPARAM( "'" ) );
         [ #  # ][ #  # ]
     157 [ #  # ][ #  # ]:          0 :                     static const ::rtl::OUString sDoubleQuote( RTL_CONSTASCII_USTRINGPARAM( "''" ) );
         [ #  # ][ #  # ]
     158                 :            : 
     159                 :          0 :                     sal_Int32 nIndex = -1;
     160                 :          0 :                     sal_Int32 nTemp = 0;
     161         [ #  # ]:          0 :                     while ( -1 != ( nIndex = sQuoted.indexOf( '\'',nTemp ) ) )
     162                 :            :                     {
     163                 :          0 :                         sQuoted = sQuoted.replaceAt( nIndex, 1, sDoubleQuote );
     164                 :          0 :                         nTemp = nIndex+2;
     165                 :            :                     }
     166                 :            : 
     167                 :          0 :                     ::rtl::OUString sTemp( sSingleQuote );
     168                 :          0 :                     ( sTemp += sQuoted ) += sSingleQuote;
     169                 :          0 :                     sQuoted = sTemp;
     170                 :            :                 }
     171         [ #  # ]:          0 :                 pReturn = const_cast< OSQLParser& >( m_aParser ).predicateTree( _rErrorMessage, sQuoted, m_xFormatter, _rxField );
     172                 :            :             }
     173                 :            : 
     174                 :            :             // one more fallback: for numeric fields, and value strings containing a decimal/thousands separator
     175                 :            :             // problem which is to be solved with this:
     176                 :            :             // * a system locale "german"
     177                 :            :             // * a column formatted with an english number format
     178                 :            :             // => the output is german (as we use the system locale for this), i.e. "3,4"
     179                 :            :             // => the input does not recognize the german text, as predicateTree uses the number format
     180                 :            :             //    of the column to determine the main locale - the locale on the context is only a fallback
     181 [ #  # ][ #  # ]:          0 :             if  (   ( DataType::FLOAT == nType )
         [ #  # ][ #  # ]
                 [ #  # ]
     182                 :            :                 ||  ( DataType::REAL == nType )
     183                 :            :                 ||  ( DataType::DOUBLE == nType )
     184                 :            :                 ||  ( DataType::NUMERIC == nType )
     185                 :            :                 ||  ( DataType::DECIMAL == nType )
     186                 :            :                 )
     187                 :            :             {
     188                 :          0 :                 const IParseContext& rParseContext = m_aParser.getContext();
     189                 :            :                 // get the separators for the locale of our parse context
     190                 :            :                 sal_Unicode nCtxDecSep;
     191                 :            :                 sal_Unicode nCtxThdSep;
     192 [ #  # ][ #  # ]:          0 :                 getSeparatorChars( rParseContext.getPreferredLocale(), nCtxDecSep, nCtxThdSep );
     193                 :            : 
     194                 :            :                 // determine the locale of the column we're building a predicate string for
     195                 :          0 :                 sal_Unicode nFmtDecSep( nCtxDecSep );
     196                 :          0 :                 sal_Unicode nFmtThdSep( nCtxThdSep );
     197                 :            :                 try
     198                 :            :                 {
     199 [ #  # ][ #  # ]:          0 :                     Reference< XPropertySetInfo > xPSI( _rxField->getPropertySetInfo() );
     200 [ #  # ][ #  # ]:          0 :                     if ( xPSI.is() && xPSI->hasPropertyByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FormatKey" )) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     201                 :            :                     {
     202                 :          0 :                         sal_Int32 nFormatKey = 0;
     203 [ #  # ][ #  # ]:          0 :                         _rxField->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FormatKey" )) ) >>= nFormatKey;
                 [ #  # ]
     204 [ #  # ][ #  # ]:          0 :                         if ( nFormatKey && m_xFormatter.is() )
                 [ #  # ]
     205                 :            :                         {
     206                 :          0 :                             Locale aFormatLocale;
     207                 :            :                             ::comphelper::getNumberFormatProperty(
     208                 :            :                                 m_xFormatter,
     209                 :            :                                 nFormatKey,
     210                 :            :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Locale" ) )
     211 [ #  # ][ #  # ]:          0 :                             ) >>= aFormatLocale;
                 [ #  # ]
     212                 :            : 
     213                 :            :                             // valid locale
     214         [ #  # ]:          0 :                             if ( !aFormatLocale.Language.isEmpty() )
     215                 :            :                             {
     216         [ #  # ]:          0 :                                 getSeparatorChars( aFormatLocale, nFmtDecSep, nCtxThdSep );
     217                 :          0 :                             }
     218                 :            :                         }
     219         [ #  # ]:          0 :                     }
     220                 :            :                 }
     221         [ #  # ]:          0 :                 catch( const Exception& )
     222                 :            :                 {
     223                 :            :                     OSL_FAIL( "OPredicateInputController::implPredicateTree: caught an exception while dealing with the formats!" );
     224                 :            :                 }
     225                 :            : 
     226                 :          0 :                 sal_Bool bDecDiffers = ( nCtxDecSep != nFmtDecSep );
     227                 :          0 :                 sal_Bool bFmtDiffers = ( nCtxThdSep != nFmtThdSep );
     228 [ #  # ][ #  # ]:          0 :                 if ( bDecDiffers || bFmtDiffers )
     229                 :            :                 {   // okay, at least one differs
     230                 :            :                     // "translate" the value into the "format locale"
     231                 :          0 :                     ::rtl::OUString sTranslated( _rStatement );
     232                 :          0 :                     const sal_Unicode nIntermediate( '_' );
     233                 :          0 :                     sTranslated = sTranslated.replace( nCtxDecSep,  nIntermediate );
     234                 :          0 :                     sTranslated = sTranslated.replace( nCtxThdSep,  nFmtThdSep );
     235                 :          0 :                     sTranslated = sTranslated.replace( nIntermediate, nFmtDecSep );
     236                 :            : 
     237         [ #  # ]:          0 :                     pReturn = const_cast< OSQLParser& >( m_aParser ).predicateTree( _rErrorMessage, sTranslated, m_xFormatter, _rxField );
     238                 :            :                 }
     239                 :            :             }
     240                 :            :         }
     241                 :         72 :         return pReturn;
     242                 :            :     }
     243                 :            : 
     244                 :            :     //---------------------------------------------------------------------
     245                 :          0 :     sal_Bool OPredicateInputController::normalizePredicateString(
     246                 :            :         ::rtl::OUString& _rPredicateValue, const Reference< XPropertySet > & _rxField, ::rtl::OUString* _pErrorMessage ) const
     247                 :            :     {
     248                 :            :         OSL_ENSURE( m_xConnection.is() && m_xFormatter.is() && _rxField.is(),
     249                 :            :             "OPredicateInputController::normalizePredicateString: invalid state or params!" );
     250                 :            : 
     251                 :          0 :         sal_Bool bSuccess = sal_False;
     252 [ #  # ][ #  # ]:          0 :         if ( m_xConnection.is() && m_xFormatter.is() && _rxField.is() )
         [ #  # ][ #  # ]
     253                 :            :         {
     254                 :            :             // parse the string
     255                 :          0 :             ::rtl::OUString sError;
     256                 :          0 :             ::rtl::OUString sTransformedText( _rPredicateValue );
     257         [ #  # ]:          0 :             OSQLParseNode* pParseNode = implPredicateTree( sError, sTransformedText, _rxField );
     258         [ #  # ]:          0 :             if ( _pErrorMessage ) *_pErrorMessage = sError;
     259                 :            : 
     260         [ #  # ]:          0 :             if ( pParseNode )
     261                 :            :             {
     262                 :          0 :                 const IParseContext& rParseContext = m_aParser.getContext();
     263                 :            :                 sal_Unicode nDecSeparator, nThousandSeparator;
     264 [ #  # ][ #  # ]:          0 :                 getSeparatorChars( rParseContext.getPreferredLocale(), nDecSeparator, nThousandSeparator );
     265                 :            : 
     266                 :            :                 // translate it back into a string
     267                 :          0 :                 sTransformedText = ::rtl::OUString();
     268                 :            :                 pParseNode->parseNodeToPredicateStr(
     269                 :            :                     sTransformedText, m_xConnection, m_xFormatter, _rxField,
     270                 :          0 :                     rParseContext.getPreferredLocale(), (sal_Char)nDecSeparator, &rParseContext
     271 [ #  # ][ #  # ]:          0 :                 );
     272                 :          0 :                 _rPredicateValue = sTransformedText;
     273 [ #  # ][ #  # ]:          0 :                 delete pParseNode;
     274                 :            : 
     275                 :          0 :                 bSuccess = sal_True;
     276                 :          0 :             }
     277                 :            :         }
     278                 :            : 
     279                 :          0 :         return bSuccess;
     280                 :            :     }
     281                 :            : 
     282                 :            :     //---------------------------------------------------------------------
     283                 :         72 :     ::rtl::OUString OPredicateInputController::getPredicateValue(
     284                 :            :         const ::rtl::OUString& _rPredicateValue, const Reference< XPropertySet > & _rxField,
     285                 :            :         sal_Bool _bForStatementUse, ::rtl::OUString* _pErrorMessage ) const
     286                 :            :     {
     287                 :            :         OSL_ENSURE( _rxField.is(), "OPredicateInputController::getPredicateValue: invalid params!" );
     288                 :         72 :         ::rtl::OUString sReturn;
     289         [ +  - ]:         72 :         if ( _rxField.is() )
     290                 :            :         {
     291                 :         72 :             ::rtl::OUString sValue( _rPredicateValue );
     292                 :            : 
     293                 :            :             // a little problem : if the field is a text field, the normalizePredicateString added two
     294                 :            :             // '-characters to the text. If we would give this to predicateTree this would add
     295                 :            :             // two  additional '-characters which we don't want. So check the field format.
     296                 :            :             // FS - 06.01.00 - 71532
     297                 :         72 :             sal_Bool bValidQuotedText = ( sValue.getLength() >= 2 )
     298                 :         72 :                                     &&  ( sValue.getStr()[0] == '\'' )
     299         [ +  - ]:        144 :                                     &&  ( sValue.getStr()[ sValue.getLength() - 1 ] == '\'' );
           [ +  -  +  - ]
     300                 :            :                 // again : as normalizePredicateString always did a conversion on the value text,
     301                 :            :                 // bValidQuotedText == sal_True implies that we have a text field, as no other field
     302                 :            :                 // values will be formatted with the quote characters
     303         [ +  - ]:         72 :             if ( bValidQuotedText )
     304                 :            :             {
     305                 :         72 :                 sValue = sValue.copy( 1, sValue.getLength() - 2 );
     306 [ +  - ][ +  - ]:         72 :                 static const ::rtl::OUString sSingleQuote( RTL_CONSTASCII_USTRINGPARAM( "'" ) );
         [ #  # ][ +  + ]
     307 [ +  + ][ +  - ]:         72 :                 static const ::rtl::OUString sDoubleQuote( RTL_CONSTASCII_USTRINGPARAM( "''" ) );
         [ +  - ][ #  # ]
     308                 :            : 
     309                 :         72 :                 sal_Int32 nIndex = -1;
     310                 :         72 :                 sal_Int32 nTemp = 0;
     311         [ -  + ]:         72 :                 while ( -1 != ( nIndex = sValue.indexOf( sDoubleQuote,nTemp ) ) )
     312                 :            :                 {
     313                 :          0 :                     sValue = sValue.replaceAt( nIndex, 2, sSingleQuote );
     314                 :          0 :                     nTemp = nIndex+2;
     315                 :            :                 }
     316                 :            :             }
     317                 :            : 
     318                 :            :             // The following is mostly stolen from the former implementation in the parameter dialog
     319                 :            :             // (dbaccess/source/ui/dlg/paramdialog.cxx). I do not fully understand this .....
     320                 :            : 
     321                 :         72 :             ::rtl::OUString sError;
     322         [ +  - ]:         72 :             OSQLParseNode* pParseNode = implPredicateTree( sError, sValue, _rxField );
     323         [ -  + ]:         72 :             if ( _pErrorMessage )
     324                 :          0 :                 *_pErrorMessage = sError;
     325                 :            : 
     326         [ +  - ]:         72 :             sReturn = implParseNode(pParseNode,_bForStatementUse);
     327                 :            :         }
     328                 :            : 
     329                 :         72 :         return sReturn;
     330                 :            :     }
     331                 :            : 
     332                 :          0 :     ::rtl::OUString OPredicateInputController::getPredicateValue(
     333                 :            :         const ::rtl::OUString& _sField, const ::rtl::OUString& _rPredicateValue, sal_Bool _bForStatementUse, ::rtl::OUString* _pErrorMessage ) const
     334                 :            :     {
     335                 :          0 :         ::rtl::OUString sReturn = _rPredicateValue;
     336                 :          0 :         ::rtl::OUString sError;
     337                 :          0 :         ::rtl::OUString sField = _sField;
     338                 :          0 :         sal_Int32 nIndex = 0;
     339                 :          0 :         sField = sField.getToken(0,'(',nIndex);
     340         [ #  # ]:          0 :         if(nIndex == -1)
     341                 :          0 :             sField = _sField;
     342         [ #  # ]:          0 :         sal_Int32 nType = ::connectivity::OSQLParser::getFunctionReturnType(sField,&m_aParser.getContext());
     343 [ #  # ][ #  # ]:          0 :         if ( nType == DataType::OTHER || sField.isEmpty() )
                 [ #  # ]
     344                 :            :         {
     345                 :            :             // first try the international version
     346                 :          0 :             ::rtl::OUString sSql;
     347         [ #  # ]:          0 :             sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * "));
     348         [ #  # ]:          0 :             sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x WHERE "));
     349                 :          0 :             sSql += sField;
     350                 :          0 :             sSql += _rPredicateValue;
     351         [ #  # ]:          0 :             ::std::auto_ptr<OSQLParseNode> pParseNode( const_cast< OSQLParser& >( m_aParser ).parseTree( sError, sSql, sal_True ) );
     352                 :          0 :             nType = DataType::DOUBLE;
     353         [ #  # ]:          0 :             if ( pParseNode.get() )
     354                 :            :             {
     355         [ #  # ]:          0 :                 OSQLParseNode* pColumnRef = pParseNode->getByRule(OSQLParseNode::column_ref);
     356                 :            :                 if ( pColumnRef )
     357                 :            :                 {
     358                 :            :                 }
     359         [ #  # ]:          0 :             }
     360                 :            :         }
     361                 :            : 
     362 [ #  # ][ #  # ]:          0 :         Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
     363                 :            :         parse::OParseColumn* pColumn = new parse::OParseColumn( sField,
     364                 :            :                                                                 ::rtl::OUString(),
     365                 :            :                                                                 ::rtl::OUString(),
     366                 :            :                                                                 ::rtl::OUString(),
     367                 :            :                                                                 ColumnValue::NULLABLE_UNKNOWN,
     368                 :            :                                                                 0,
     369                 :            :                                                                 0,
     370                 :            :                                                                 nType,
     371                 :            :                                                                 sal_False,
     372                 :            :                                                                 sal_False,
     373 [ #  # ][ #  # ]:          0 :                                                                 xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
         [ #  # ][ #  # ]
                 [ #  # ]
     374 [ #  # ][ #  # ]:          0 :         Reference<XPropertySet> xColumn = pColumn;
     375                 :          0 :         pColumn->setFunction(sal_True);
     376                 :          0 :         pColumn->setRealName(sField);
     377                 :            : 
     378         [ #  # ]:          0 :         OSQLParseNode* pParseNode = implPredicateTree( sError, _rPredicateValue, xColumn );
     379         [ #  # ]:          0 :         if ( _pErrorMessage )
     380                 :          0 :             *_pErrorMessage = sError;
     381 [ #  # ][ #  # ]:          0 :         return pParseNode ? implParseNode(pParseNode,_bForStatementUse) : sReturn;
     382                 :            :     }
     383                 :            : 
     384                 :         72 :     ::rtl::OUString OPredicateInputController::implParseNode(OSQLParseNode* pParseNode,sal_Bool _bForStatementUse) const
     385                 :            :     {
     386                 :         72 :         ::rtl::OUString sReturn;
     387         [ +  - ]:         72 :         if ( pParseNode )
     388                 :            :         {
     389         [ +  - ]:         72 :             boost::shared_ptr<OSQLParseNode> xTakeOwnership(pParseNode);
     390         [ +  - ]:         72 :             OSQLParseNode* pOdbcSpec = pParseNode->getByRule( OSQLParseNode::odbc_fct_spec );
     391         [ -  + ]:         72 :             if ( pOdbcSpec )
     392                 :            :             {
     393         [ #  # ]:          0 :                 if ( _bForStatementUse )
     394                 :            :                 {
     395                 :          0 :                     OSQLParseNode* pFuncSpecParent = pOdbcSpec->getParent();
     396                 :            :                     OSL_ENSURE( pFuncSpecParent, "OPredicateInputController::getPredicateValue: an ODBC func spec node without parent?" );
     397         [ #  # ]:          0 :                     if ( pFuncSpecParent )
     398         [ #  # ]:          0 :                         pFuncSpecParent->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True);
     399                 :            :                 }
     400                 :            :                 else
     401                 :            :                 {
     402         [ #  # ]:          0 :                     OSQLParseNode* pValueNode = pOdbcSpec->getChild(1);
     403         [ #  # ]:          0 :                     if ( SQL_NODE_STRING == pValueNode->getNodeType() )
     404                 :          0 :                         sReturn = pValueNode->getTokenValue();
     405                 :            :                     else
     406         [ #  # ]:          0 :                         pValueNode->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True);
     407                 :            :                 }
     408                 :            :             }
     409                 :            :             else
     410                 :            :             {
     411         [ +  - ]:         72 :                 if  ( pParseNode->count() >= 3 )
     412                 :            :                 {
     413         [ +  - ]:         72 :                     OSQLParseNode* pValueNode = pParseNode->getChild(2);
     414                 :            :                     OSL_ENSURE( pValueNode, "OPredicateInputController::getPredicateValue: invalid node child!" );
     415         [ -  + ]:         72 :                     if ( !_bForStatementUse )
     416                 :            :                     {
     417         [ #  # ]:          0 :                         if ( SQL_NODE_STRING == pValueNode->getNodeType() )
     418                 :          0 :                             sReturn = pValueNode->getTokenValue();
     419                 :            :                         else
     420                 :            :                             pValueNode->parseNodeToStr(
     421                 :          0 :                                 sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True
     422         [ #  # ]:          0 :                             );
     423                 :            :                     }
     424                 :            :                     else
     425                 :            :                         pValueNode->parseNodeToStr(
     426                 :         72 :                             sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True
     427         [ +  - ]:         72 :                         );
     428                 :            :                 }
     429                 :            :                 else
     430                 :            :                     OSL_FAIL( "OPredicateInputController::getPredicateValue: unknown/invalid structure (noodbc)!" );
     431         [ +  - ]:         72 :             }
     432                 :            :         }
     433                 :         72 :         return sReturn;
     434                 :            :     }
     435                 :            : //.........................................................................
     436                 :            : }   // namespace dbtools
     437                 :            : //.........................................................................
     438                 :            : 
     439                 :            : 
     440                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10