LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - queryfilter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 439 0.0 %
Date: 2012-08-25 Functions: 0 22 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1019 0.0 %

           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                 :            : #include "queryfilter.hxx"
      21                 :            : #include "moduledbu.hxx"
      22                 :            : #include <com/sun/star/sdbc/DataType.hpp>
      23                 :            : #include <com/sun/star/util/Date.hpp>
      24                 :            : #include <com/sun/star/util/DateTime.hpp>
      25                 :            : #include <com/sun/star/util/Time.hpp>
      26                 :            : #include <com/sun/star/sdb/XSQLQueryComposer.hpp>
      27                 :            : #include <com/sun/star/sdbc/ColumnSearch.hpp>
      28                 :            : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      29                 :            : #include <com/sun/star/sdb/SQLFilterOperator.hpp>
      30                 :            : #include <com/sun/star/sdbc/XRow.hpp>
      31                 :            : #include <com/sun/star/sdbc/XResultSet.hpp>
      32                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      33                 :            : #include <comphelper/string.hxx>
      34                 :            : #include <tools/diagnose_ex.h>
      35                 :            : #include <osl/diagnose.h>
      36                 :            : #include <connectivity/sqliterator.hxx>
      37                 :            : #include <connectivity/dbtools.hxx>
      38                 :            : #include "queryfilter.hrc"
      39                 :            : #include "dbustrings.hrc"
      40                 :            : #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
      41                 :            : 
      42                 :            : using namespace dbaui;
      43                 :            : using namespace connectivity;
      44                 :            : using namespace ::com::sun::star::uno;
      45                 :            : using namespace ::com::sun::star::lang;
      46                 :            : using namespace ::com::sun::star::container;
      47                 :            : using namespace ::com::sun::star::util;
      48                 :            : using namespace ::com::sun::star::sdb;
      49                 :            : using namespace ::com::sun::star::sdbc;
      50                 :            : using namespace ::com::sun::star::sdbcx;
      51                 :            : using namespace ::com::sun::star::sdb;
      52                 :            : using namespace ::com::sun::star::beans;
      53                 :            : 
      54                 :          0 : void Replace_OS_PlaceHolder(String& aString)
      55                 :            : {
      56         [ #  # ]:          0 :     while (aString.SearchAndReplace( '*', '%' ) != STRING_NOTFOUND) ;
      57         [ #  # ]:          0 :     while (aString.SearchAndReplace( '?', '_' ) != STRING_NOTFOUND) ;
      58                 :          0 : }
      59                 :            : 
      60                 :          0 : void Replace_SQL_PlaceHolder(String& aString)
      61                 :            : {
      62         [ #  # ]:          0 :     while (aString.SearchAndReplace( '%', '*' ) != STRING_NOTFOUND) ;
      63         [ #  # ]:          0 :     while (aString.SearchAndReplace( '_', '?' ) != STRING_NOTFOUND) ;
      64                 :          0 : }
      65                 :            : 
      66                 :            : DBG_NAME(DlgFilterCrit);
      67                 :            : 
      68                 :          0 : DlgFilterCrit::DlgFilterCrit(Window * pParent,
      69                 :            :                              const Reference< XMultiServiceFactory >& _rxORB,
      70                 :            :                              const Reference< XConnection>& _rxConnection,
      71                 :            :                              const Reference< XSingleSelectQueryComposer >& _rxComposer,
      72                 :            :                              const Reference< XNameAccess>& _rxCols
      73                 :            :                              )
      74                 :            :     :ModalDialog( pParent, ModuleRes( DLG_FILTERCRIT ) )
      75                 :            :     ,aLB_WHEREFIELD1    ( this, ModuleRes( LB_WHEREFIELD1 ) )
      76                 :            :     ,aLB_WHERECOMP1     ( this, ModuleRes( LB_WHERECOMP1 ) )
      77                 :            :     ,aET_WHEREVALUE1    ( this, ModuleRes( ET_WHEREVALUE1 ) )
      78                 :            :     ,aLB_WHERECOND2     ( this, ModuleRes( LB_WHERECOND2 ) )
      79                 :            :     ,aLB_WHEREFIELD2    ( this, ModuleRes( LB_WHEREFIELD2 ) )
      80                 :            :     ,aLB_WHERECOMP2     ( this, ModuleRes( LB_WHERECOMP2 ) )
      81                 :            :     ,aET_WHEREVALUE2    ( this, ModuleRes( ET_WHEREVALUE2 ) )
      82                 :            :     ,aLB_WHERECOND3     ( this, ModuleRes( LB_WHERECOND3 ) )
      83                 :            :     ,aLB_WHEREFIELD3    ( this, ModuleRes( LB_WHEREFIELD3 ) )
      84                 :            :     ,aLB_WHERECOMP3     ( this, ModuleRes( LB_WHERECOMP3 ) )
      85                 :            :     ,aET_WHEREVALUE3    ( this, ModuleRes( ET_WHEREVALUE3 ) )
      86                 :            :     ,aFT_WHEREFIELD     ( this, ModuleRes( FT_WHEREFIELD ) )
      87                 :            :     ,aFT_WHERECOMP      ( this, ModuleRes( FT_WHERECOMP ) )
      88                 :            :     ,aFT_WHEREVALUE     ( this, ModuleRes( FT_WHEREVALUE ) )
      89                 :            :     ,aFT_WHEREOPER      ( this, ModuleRes( FT_WHEREOPER ) )
      90                 :            :     ,aFL_FIELDS         ( this, ModuleRes( FL_FIELDS ) )
      91                 :            :     ,aBT_OK             ( this, ModuleRes( BT_OK ) )
      92                 :            :     ,aBT_CANCEL         ( this, ModuleRes( BT_CANCEL ) )
      93                 :            :     ,aBT_HELP           ( this, ModuleRes( BT_HELP ) )
      94                 :            :     ,aSTR_NOENTRY       ( ModuleRes( STR_NOENTRY ) )
      95                 :            :     ,aSTR_COMPARE_OPERATORS( ModuleRes( STR_COMPARE_OPERATORS ) )
      96                 :            :     ,m_xQueryComposer(_rxComposer)
      97                 :            :     ,m_xColumns( _rxCols )
      98                 :            :     ,m_xConnection( _rxConnection )
      99         [ #  # ]:          0 :     ,m_xMetaData( _rxConnection->getMetaData() )
     100 [ #  # ][ #  # ]:          0 :     ,m_aPredicateInput( _rxORB, _rxConnection, getParseContext() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     101                 :            : {
     102                 :            :     DBG_CTOR(DlgFilterCrit,NULL);
     103                 :            :     // Write the String for noEntry into the ListBoxes of the field names
     104         [ #  # ]:          0 :     aLB_WHEREFIELD1.InsertEntry( aSTR_NOENTRY );
     105         [ #  # ]:          0 :     aLB_WHEREFIELD2.InsertEntry( aSTR_NOENTRY );
     106         [ #  # ]:          0 :     aLB_WHEREFIELD3.InsertEntry( aSTR_NOENTRY );
     107                 :            : 
     108                 :            :     try
     109                 :            :     {
     110                 :            :         // ... also write it into the remaining fields
     111 [ #  # ][ #  # ]:          0 :         Sequence< ::rtl::OUString> aNames = m_xColumns->getElementNames();
     112                 :          0 :         const ::rtl::OUString* pIter = aNames.getConstArray();
     113                 :          0 :         const ::rtl::OUString* pEnd   = pIter + aNames.getLength();
     114                 :          0 :         Reference<XPropertySet> xColumn;
     115         [ #  # ]:          0 :         for(;pIter != pEnd;++pIter)
     116                 :            :         {
     117                 :            :             try
     118                 :            :             {
     119 [ #  # ][ #  # ]:          0 :                 xColumn.set( m_xColumns->getByName( *pIter ), UNO_QUERY_THROW );
                 [ #  # ]
     120                 :            : 
     121                 :          0 :                 sal_Int32 nDataType( 0 );
     122 [ #  # ][ #  # ]:          0 :                 OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_TYPE ) >>= nDataType );
                 [ #  # ]
     123         [ #  # ]:          0 :                 sal_Int32 eColumnSearch = ::dbtools::getSearchColumnFlag( m_xConnection, nDataType );
     124         [ #  # ]:          0 :                 if ( eColumnSearch == ColumnSearch::NONE )
     125                 :          0 :                     continue;
     126                 :            : 
     127                 :          0 :                 sal_Bool bIsSearchable( sal_True );
     128 [ #  # ][ #  # ]:          0 :                 OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_ISSEARCHABLE ) >>= bIsSearchable );
         [ #  # ][ #  # ]
     129         [ #  # ]:          0 :                 if ( !bIsSearchable )
     130                 :          0 :                     continue;
     131                 :            :             }
     132         [ #  # ]:          0 :             catch( const Exception& )
     133                 :            :             {
     134                 :            :                 DBG_UNHANDLED_EXCEPTION();
     135                 :            :             }
     136 [ #  # ][ #  # ]:          0 :             aLB_WHEREFIELD1.InsertEntry( *pIter );
                 [ #  # ]
     137 [ #  # ][ #  # ]:          0 :             aLB_WHEREFIELD2.InsertEntry( *pIter );
                 [ #  # ]
     138 [ #  # ][ #  # ]:          0 :             aLB_WHEREFIELD3.InsertEntry( *pIter );
                 [ #  # ]
     139                 :            :         }
     140                 :            : 
     141 [ #  # ][ #  # ]:          0 :         Reference<XNameAccess> xSelectColumns = Reference<XColumnsSupplier>(m_xQueryComposer,UNO_QUERY)->getColumns();
                 [ #  # ]
     142 [ #  # ][ #  # ]:          0 :         aNames = xSelectColumns->getElementNames();
         [ #  # ][ #  # ]
     143                 :          0 :         pIter = aNames.getConstArray();
     144                 :          0 :         pEnd   = pIter + aNames.getLength();
     145         [ #  # ]:          0 :         for(;pIter != pEnd;++pIter)
     146                 :            :         {
     147                 :            :             // don't insert a column name twice
     148 [ #  # ][ #  # ]:          0 :             if ( !m_xColumns->hasByName(*pIter) )
                 [ #  # ]
     149                 :            :             {
     150 [ #  # ][ #  # ]:          0 :                 xColumn.set(xSelectColumns->getByName(*pIter),UNO_QUERY);
                 [ #  # ]
     151                 :            :                 OSL_ENSURE(xColumn.is(),"DlgFilterCrit::DlgFilterCrit: Column is null!");
     152                 :          0 :                 sal_Int32 nDataType(0);
     153 [ #  # ][ #  # ]:          0 :                 xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
                 [ #  # ]
     154         [ #  # ]:          0 :                 sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType);
     155                 :            :                 // TODO
     156                 :            :                 // !pColumn->IsFunction()
     157         [ #  # ]:          0 :                 if(eColumnSearch != ColumnSearch::NONE)
     158                 :            :                 {
     159 [ #  # ][ #  # ]:          0 :                     aLB_WHEREFIELD1.InsertEntry( *pIter );
                 [ #  # ]
     160 [ #  # ][ #  # ]:          0 :                     aLB_WHEREFIELD2.InsertEntry( *pIter );
                 [ #  # ]
     161 [ #  # ][ #  # ]:          0 :                     aLB_WHEREFIELD3.InsertEntry( *pIter );
                 [ #  # ]
     162                 :            :                 }
     163                 :            :             }
     164                 :            :         }
     165                 :            :         // initialize the listboxes with noEntry
     166         [ #  # ]:          0 :         aLB_WHEREFIELD1.SelectEntryPos(0);
     167         [ #  # ]:          0 :         aLB_WHEREFIELD2.SelectEntryPos(0);
     168         [ #  # ]:          0 :         aLB_WHEREFIELD3.SelectEntryPos(0);
     169                 :            : 
     170                 :            :         // insert the criteria into the dialog
     171 [ #  # ][ #  # ]:          0 :         Sequence<Sequence<PropertyValue > > aValues = m_xQueryComposer->getStructuredFilter();
     172         [ #  # ]:          0 :         fillLines(aValues);
     173 [ #  # ][ #  # ]:          0 :         aValues = m_xQueryComposer->getStructuredHavingClause();
         [ #  # ][ #  # ]
     174 [ #  # ][ #  # ]:          0 :         fillLines(aValues);
                 [ #  # ]
     175                 :            : 
     176                 :            :     }
     177         [ #  # ]:          0 :     catch(const Exception&)
     178                 :            :     {
     179         [ #  # ]:          0 :         FreeResource();
     180                 :          0 :         throw;
     181                 :            :     }
     182                 :            : 
     183         [ #  # ]:          0 :     EnableLines();
     184                 :            : 
     185         [ #  # ]:          0 :     aLB_WHEREFIELD1.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl));
     186         [ #  # ]:          0 :     aLB_WHEREFIELD2.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl));
     187         [ #  # ]:          0 :     aLB_WHEREFIELD3.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl));
     188                 :            : 
     189         [ #  # ]:          0 :     aLB_WHERECOMP1.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl));
     190         [ #  # ]:          0 :     aLB_WHERECOMP2.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl));
     191         [ #  # ]:          0 :     aLB_WHERECOMP3.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl));
     192                 :            : 
     193         [ #  # ]:          0 :     aET_WHEREVALUE1.SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
     194         [ #  # ]:          0 :     aET_WHEREVALUE2.SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
     195         [ #  # ]:          0 :     aET_WHEREVALUE3.SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
     196                 :            : 
     197 [ #  # ][ #  # ]:          0 :     if ( aET_WHEREVALUE1.IsEnabled() )
     198         [ #  # ]:          0 :         aET_WHEREVALUE1.GrabFocus();
     199                 :            : 
     200         [ #  # ]:          0 :     FreeResource();
     201                 :          0 : }
     202                 :            : 
     203 [ #  # ][ #  # ]:          0 : DlgFilterCrit::~DlgFilterCrit()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     204                 :            : {
     205                 :            :     DBG_DTOR(DlgFilterCrit,NULL);
     206         [ #  # ]:          0 : }
     207                 :            : 
     208                 :            : #define LbText(x)       ((x).GetSelectEntry())
     209                 :            : #define LbPos(x)        ((x).GetSelectEntryPos())
     210                 :            : 
     211                 :          0 : sal_Int32 DlgFilterCrit::GetOSQLPredicateType( const String& _rSelectedPredicate ) const
     212                 :            : {
     213                 :          0 :     sal_Int32 nPredicateIndex = -1;
     214 [ #  # ][ #  # ]:          0 :     for ( xub_StrLen i=0; i < comphelper::string::getTokenCount(aSTR_COMPARE_OPERATORS, ';'); ++i)
     215 [ #  # ][ #  # ]:          0 :         if ( aSTR_COMPARE_OPERATORS.GetToken(i) == _rSelectedPredicate )
     216                 :            :         {
     217                 :          0 :             nPredicateIndex = i;
     218                 :          0 :             break;
     219                 :            :         }
     220                 :            : 
     221                 :          0 :     sal_Int32 nPredicateType = SQLFilterOperator::NOT_SQLNULL;
     222   [ #  #  #  #  :          0 :     switch ( nPredicateIndex )
          #  #  #  #  #  
                   #  # ]
     223                 :            :     {
     224                 :            :     case 0:
     225                 :          0 :         nPredicateType = SQLFilterOperator::EQUAL;
     226                 :          0 :         break;
     227                 :            :     case 1:
     228                 :          0 :         nPredicateType = SQLFilterOperator::NOT_EQUAL;
     229                 :          0 :         break;
     230                 :            :     case 2:
     231                 :          0 :         nPredicateType = SQLFilterOperator::LESS;
     232                 :          0 :         break;
     233                 :            :     case 3:
     234                 :          0 :         nPredicateType = SQLFilterOperator::LESS_EQUAL;
     235                 :          0 :         break;
     236                 :            :     case 4:
     237                 :          0 :         nPredicateType = SQLFilterOperator::GREATER;
     238                 :          0 :         break;
     239                 :            :     case 5:
     240                 :          0 :         nPredicateType = SQLFilterOperator::GREATER_EQUAL;
     241                 :          0 :         break;
     242                 :            :     case 6:
     243                 :          0 :         nPredicateType = SQLFilterOperator::LIKE;
     244                 :          0 :         break;
     245                 :            :     case 7:
     246                 :          0 :         nPredicateType = SQLFilterOperator::NOT_LIKE;
     247                 :          0 :         break;
     248                 :            :     case 8:
     249                 :          0 :         nPredicateType = SQLFilterOperator::SQLNULL;
     250                 :          0 :         break;
     251                 :            :     case 9:
     252                 :          0 :         nPredicateType = SQLFilterOperator::NOT_SQLNULL;
     253                 :          0 :         break;
     254                 :            :     default:
     255                 :            :         OSL_FAIL( "DlgFilterCrit::GetOSQLPredicateType: unknown predicate string!" );
     256                 :          0 :         break;
     257                 :            :     }
     258                 :            : 
     259                 :          0 :     return nPredicateType;
     260                 :            : }
     261                 :            : 
     262                 :          0 : sal_uInt16 DlgFilterCrit::GetSelectionPos(sal_Int32 eType,const ListBox& rListBox) const
     263                 :            : {
     264                 :            :     sal_uInt16 nPos;
     265   [ #  #  #  #  :          0 :     switch(eType)
          #  #  #  #  #  
                   #  # ]
     266                 :            :     {
     267                 :            :         case SQLFilterOperator::EQUAL:
     268                 :          0 :             nPos = 0;
     269                 :          0 :             break;
     270                 :            :         case SQLFilterOperator::NOT_EQUAL:
     271                 :          0 :             nPos = 1;
     272                 :          0 :             break;
     273                 :            :         case SQLFilterOperator::LESS:
     274                 :          0 :             nPos = 2;
     275                 :          0 :             break;
     276                 :            :         case SQLFilterOperator::LESS_EQUAL:
     277                 :          0 :             nPos = 3;
     278                 :          0 :             break;
     279                 :            :         case SQLFilterOperator::GREATER:
     280                 :          0 :             nPos = 4;
     281                 :          0 :             break;
     282                 :            :         case SQLFilterOperator::GREATER_EQUAL:
     283                 :          0 :             nPos = 5;
     284                 :          0 :             break;
     285                 :            :         case SQLFilterOperator::NOT_LIKE:
     286         [ #  # ]:          0 :             nPos = rListBox.GetEntryCount() > 2 ? rListBox.GetEntryCount()-3 : 0;
     287                 :          0 :             break;
     288                 :            :         case SQLFilterOperator::LIKE:
     289         [ #  # ]:          0 :             nPos = rListBox.GetEntryCount() > 2 ? rListBox.GetEntryCount()-4 : 1;
     290                 :          0 :             break;
     291                 :            :         case SQLFilterOperator::SQLNULL:
     292                 :          0 :             nPos = rListBox.GetEntryCount()-2;
     293                 :          0 :             break;
     294                 :            :         case SQLFilterOperator::NOT_SQLNULL:
     295                 :          0 :             nPos = rListBox.GetEntryCount()-1;
     296                 :          0 :             break;
     297                 :            :         default:
     298                 :            :             //  TODO  What value should this be?
     299                 :          0 :             nPos = 0;
     300                 :          0 :             break;
     301                 :            :     }
     302                 :          0 :     return nPos;
     303                 :            : }
     304                 :            : 
     305                 :          0 : sal_Bool DlgFilterCrit::getCondition(const ListBox& _rField,const ListBox& _rComp,const Edit& _rValue,PropertyValue& _rFilter) const
     306                 :            : {
     307                 :          0 :     sal_Bool bHaving = sal_False;
     308                 :            :     try
     309                 :            :     {
     310                 :          0 :         ::rtl::OUString sTableName;
     311                 :          0 :         sal_Bool bFunction = sal_False;
     312 [ #  # ][ #  # ]:          0 :         _rFilter.Name = _rField.GetSelectEntry();
                 [ #  # ]
     313         [ #  # ]:          0 :         Reference< XPropertySet > xColumn = getQueryColumn(_rFilter.Name);
     314         [ #  # ]:          0 :         if ( xColumn.is() )
     315                 :            :         {
     316 [ #  # ][ #  # ]:          0 :             Reference< XPropertySetInfo > xInfo = xColumn->getPropertySetInfo();
     317 [ #  # ][ #  # ]:          0 :             if ( xInfo->hasPropertyByName(PROPERTY_REALNAME) )
         [ #  # ][ #  # ]
     318                 :            :             {
     319 [ #  # ][ #  # ]:          0 :                 if ( xInfo->hasPropertyByName(PROPERTY_TABLENAME) )
         [ #  # ][ #  # ]
     320                 :            :                 {
     321 [ #  # ][ #  # ]:          0 :                     xColumn->getPropertyValue(PROPERTY_TABLENAME)   >>= sTableName;
                 [ #  # ]
     322         [ #  # ]:          0 :                     if ( !sTableName.isEmpty() )
     323                 :            :                     {
     324                 :            :                         // properly quote all parts of the table name, so
     325                 :            :                         // e.g. <schema>.<table> becomes "<schema>"."<table>"
     326                 :          0 :                         ::rtl::OUString aCatlog,aSchema,aTable;
     327         [ #  # ]:          0 :                         ::dbtools::qualifiedNameComponents( m_xMetaData, sTableName, aCatlog, aSchema, aTable, ::dbtools::eInDataManipulation );
     328         [ #  # ]:          0 :                         sTableName = ::dbtools::composeTableName( m_xMetaData, aCatlog, aSchema, aTable, sal_True, ::dbtools::eInDataManipulation );
     329                 :            :                     }
     330                 :            :                 }
     331 [ #  # ][ #  # ]:          0 :                 xColumn->getPropertyValue(PROPERTY_REALNAME)    >>= _rFilter.Name;
                 [ #  # ]
     332 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString sAgg(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction"));
         [ #  # ][ #  # ]
     333 [ #  # ][ #  # ]:          0 :                 if ( xInfo->hasPropertyByName(sAgg) )
                 [ #  # ]
     334 [ #  # ][ #  # ]:          0 :                     xColumn->getPropertyValue(sAgg) >>= bHaving;
     335 [ #  # ][ #  # ]:          0 :                 static ::rtl::OUString sFunction(RTL_CONSTASCII_USTRINGPARAM("Function"));
         [ #  # ][ #  # ]
     336 [ #  # ][ #  # ]:          0 :                 if ( xInfo->hasPropertyByName(sFunction) )
                 [ #  # ]
     337 [ #  # ][ #  # ]:          0 :                     xColumn->getPropertyValue(sFunction) >>= bFunction;
     338                 :            :             }
     339         [ #  # ]:          0 :             if ( !bFunction )
     340                 :            :             {
     341 [ #  # ][ #  # ]:          0 :                 const ::rtl::OUString aQuote    = m_xMetaData.is() ? m_xMetaData->getIdentifierQuoteString() : ::rtl::OUString();
                 [ #  # ]
     342         [ #  # ]:          0 :                 _rFilter.Name = ::dbtools::quoteName(aQuote,_rFilter.Name);
     343         [ #  # ]:          0 :                 if ( !sTableName.isEmpty() )
     344                 :            :                 {
     345 [ #  # ][ #  # ]:          0 :                     static ::rtl::OUString sSep(RTL_CONSTASCII_USTRINGPARAM("."));
         [ #  # ][ #  # ]
     346                 :          0 :                     sTableName += sSep;
     347                 :          0 :                     sTableName += _rFilter.Name;
     348                 :          0 :                     _rFilter.Name = sTableName;
     349                 :          0 :                 }
     350                 :          0 :             }
     351         [ #  # ]:          0 :         }
     352                 :            :     }
     353         [ #  # ]:          0 :     catch(const Exception&)
     354                 :            :     {
     355                 :            :     }
     356                 :            : 
     357 [ #  # ][ #  # ]:          0 :     _rFilter.Handle = GetOSQLPredicateType( _rComp.GetSelectEntry() );
                 [ #  # ]
     358 [ #  # ][ #  # ]:          0 :     if ( SQLFilterOperator::SQLNULL != _rFilter.Handle && _rFilter.Handle != SQLFilterOperator::NOT_SQLNULL )
     359                 :            :     {
     360 [ #  # ][ #  # ]:          0 :         String sPredicateValue = m_aPredicateInput.getPredicateValue( _rValue.GetText(), getMatchingColumn( _rValue ), sal_False );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     361         [ #  # ]:          0 :         ::Replace_OS_PlaceHolder( sPredicateValue );
     362 [ #  # ][ #  # ]:          0 :         _rFilter.Value <<= ::rtl::OUString(sPredicateValue);
                 [ #  # ]
     363                 :            :     }
     364                 :          0 :     return bHaving;
     365                 :            : }
     366                 :            : 
     367                 :          0 : Reference< XPropertySet > DlgFilterCrit::getColumn( const ::rtl::OUString& _rFieldName ) const
     368                 :            : {
     369                 :          0 :     Reference< XPropertySet > xColumn;
     370                 :            :     try
     371                 :            :     {
     372 [ #  # ][ #  # ]:          0 :         if ( m_xColumns.is() && m_xColumns->hasByName( _rFieldName ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     373 [ #  # ][ #  # ]:          0 :             m_xColumns->getByName( _rFieldName ) >>= xColumn;
                 [ #  # ]
     374                 :            : 
     375 [ #  # ][ #  # ]:          0 :         Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns();
                 [ #  # ]
     376 [ #  # ][ #  # ]:          0 :         if ( xColumns.is() && !xColumn.is() )
                 [ #  # ]
     377                 :            :         {
     378 [ #  # ][ #  # ]:          0 :             Sequence< ::rtl::OUString> aSeq = xColumns->getElementNames();
     379                 :          0 :             const ::rtl::OUString* pIter = aSeq.getConstArray();
     380                 :          0 :             const ::rtl::OUString* pEnd   = pIter + aSeq.getLength();
     381         [ #  # ]:          0 :             for(;pIter != pEnd;++pIter)
     382                 :            :             {
     383 [ #  # ][ #  # ]:          0 :                 Reference<XPropertySet> xProp(xColumns->getByName(*pIter),UNO_QUERY);
                 [ #  # ]
     384 [ #  # ][ #  # ]:          0 :                 if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
           #  # ][ #  # ]
     385                 :            :                 {
     386                 :          0 :                     ::rtl::OUString sRealName;
     387 [ #  # ][ #  # ]:          0 :                     xProp->getPropertyValue(PROPERTY_REALNAME)  >>= sRealName;
                 [ #  # ]
     388         [ #  # ]:          0 :                     if ( sRealName == _rFieldName )
     389                 :            :                     {
     390 [ #  # ][ #  # ]:          0 :                         if ( m_xColumns.is() && m_xColumns->hasByName( *pIter ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     391 [ #  # ][ #  # ]:          0 :                             m_xColumns->getByName( *pIter ) >>= xColumn;
                 [ #  # ]
     392                 :            :                         break;
     393         [ #  # ]:          0 :                     }
     394                 :            :                 }
     395 [ #  # ][ #  # ]:          0 :             }
     396         [ #  # ]:          0 :         }
     397                 :            :     }
     398         [ #  # ]:          0 :     catch( const Exception& )
     399                 :            :     {
     400                 :            :         DBG_UNHANDLED_EXCEPTION();
     401                 :            :     }
     402                 :            : 
     403                 :          0 :     return xColumn;
     404                 :            : }
     405                 :            : 
     406                 :          0 : Reference< XPropertySet > DlgFilterCrit::getQueryColumn( const ::rtl::OUString& _rFieldName ) const
     407                 :            : {
     408                 :          0 :     Reference< XPropertySet > xColumn;
     409                 :            :     try
     410                 :            :     {
     411 [ #  # ][ #  # ]:          0 :         Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns();
                 [ #  # ]
     412 [ #  # ][ #  # ]:          0 :         if ( xColumns.is() && xColumns->hasByName( _rFieldName ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     413 [ #  # ][ #  # ]:          0 :             xColumns->getByName( _rFieldName ) >>= xColumn;
         [ #  # ][ #  # ]
     414                 :            :     }
     415         [ #  # ]:          0 :     catch( const Exception& )
     416                 :            :     {
     417                 :            :         DBG_UNHANDLED_EXCEPTION();
     418                 :            :     }
     419                 :            : 
     420                 :          0 :     return xColumn;
     421                 :            : }
     422                 :            : 
     423                 :          0 : Reference< XPropertySet > DlgFilterCrit::getMatchingColumn( const Edit& _rValueInput ) const
     424                 :            : {
     425                 :            :     // the name
     426                 :          0 :     ::rtl::OUString sField;
     427         [ #  # ]:          0 :     if ( &_rValueInput == &aET_WHEREVALUE1 )
     428                 :            :     {
     429 [ #  # ][ #  # ]:          0 :         sField = aLB_WHEREFIELD1.GetSelectEntry();
                 [ #  # ]
     430                 :            :     }
     431         [ #  # ]:          0 :     else if ( &_rValueInput == &aET_WHEREVALUE2 )
     432                 :            :     {
     433 [ #  # ][ #  # ]:          0 :         sField = aLB_WHEREFIELD2.GetSelectEntry();
                 [ #  # ]
     434                 :            :     }
     435         [ #  # ]:          0 :     else if ( &_rValueInput == &aET_WHEREVALUE3 )
     436                 :            :     {
     437 [ #  # ][ #  # ]:          0 :         sField = aLB_WHEREFIELD3.GetSelectEntry();
                 [ #  # ]
     438                 :            :     }
     439                 :            :     else {
     440                 :            :         OSL_FAIL( "DlgFilterCrit::getMatchingColumn: invalid event source!" );
     441                 :            :     }
     442                 :            : 
     443                 :            :     // the field itself
     444         [ #  # ]:          0 :     return getColumn( sField );
     445                 :            : }
     446                 :            : 
     447                 :          0 : IMPL_LINK( DlgFilterCrit, PredicateLoseFocus, Edit*, _pField )
     448                 :            : {
     449                 :            :     OSL_ENSURE( _pField, "DlgFilterCrit::PredicateLoseFocus: invalid event source!" );
     450         [ #  # ]:          0 :     if ( _pField )
     451                 :            :     {
     452                 :            :         // retrieve the field affected
     453         [ #  # ]:          0 :         Reference< XPropertySet> xColumn( getMatchingColumn( *_pField ) );
     454                 :            :         // and normalize it's content
     455         [ #  # ]:          0 :         if ( xColumn.is() )
     456                 :            :         {
     457 [ #  # ][ #  # ]:          0 :             ::rtl::OUString sText( _pField->GetText() );
                 [ #  # ]
     458         [ #  # ]:          0 :             m_aPredicateInput.normalizePredicateString( sText, xColumn );
     459 [ #  # ][ #  # ]:          0 :             _pField->SetText( sText );
                 [ #  # ]
     460                 :          0 :         }
     461                 :            :     }
     462                 :            : 
     463                 :          0 :     return 0L;
     464                 :            : }
     465                 :            : 
     466                 :          0 : void DlgFilterCrit::SetLine( sal_uInt16 nIdx,const PropertyValue& _rItem,sal_Bool _bOr  )
     467                 :            : {
     468                 :            :     DBG_CHKTHIS(DlgFilterCrit,NULL);
     469                 :          0 :     ::rtl::OUString aCondition;
     470                 :          0 :     _rItem.Value >>= aCondition;
     471         [ #  # ]:          0 :     String aStr = aCondition;
     472         [ #  # ]:          0 :     ::Replace_SQL_PlaceHolder(aStr);
     473 [ #  # ][ #  # ]:          0 :     aStr = comphelper::string::stripEnd(aStr, ' ');
                 [ #  # ]
     474                 :            : 
     475         [ #  # ]:          0 :     Reference< XPropertySet > xColumn = getColumn( _rItem.Name );
     476                 :            : 
     477                 :            :     // remove the predicate from the condition
     478   [ #  #  #  #  :          0 :     switch(_rItem.Handle)
          #  #  #  #  #  
                   #  # ]
     479                 :            :     {
     480                 :            :         case SQLFilterOperator::EQUAL:
     481                 :            :             //  aStr.Erase(0,1);
     482                 :          0 :             break;
     483                 :            :         case SQLFilterOperator::NOT_EQUAL:
     484         [ #  # ]:          0 :             aStr.Erase(0,2);
     485                 :          0 :             break;
     486                 :            :         case SQLFilterOperator::LESS:
     487         [ #  # ]:          0 :             aStr.Erase(0,1);
     488                 :          0 :             break;
     489                 :            :         case SQLFilterOperator::LESS_EQUAL:
     490         [ #  # ]:          0 :             aStr.Erase(0,2);
     491                 :          0 :             break;
     492                 :            :         case SQLFilterOperator::GREATER:
     493         [ #  # ]:          0 :             aStr.Erase(0,1);
     494                 :          0 :             break;
     495                 :            :         case SQLFilterOperator::GREATER_EQUAL:
     496         [ #  # ]:          0 :             aStr.Erase(0,2);
     497                 :          0 :             break;
     498                 :            :         case SQLFilterOperator::NOT_LIKE:
     499         [ #  # ]:          0 :             aStr.Erase(0,8);
     500                 :          0 :             break;
     501                 :            :         case SQLFilterOperator::LIKE:
     502         [ #  # ]:          0 :             aStr.Erase(0,4);
     503                 :          0 :             break;
     504                 :            :         case SQLFilterOperator::SQLNULL:
     505         [ #  # ]:          0 :             aStr.Erase(0,7);
     506                 :          0 :             break;
     507                 :            :         case SQLFilterOperator::NOT_SQLNULL:
     508         [ #  # ]:          0 :             aStr.Erase(0,11);
     509                 :          0 :             break;
     510                 :            :     }
     511 [ #  # ][ #  # ]:          0 :     aStr = comphelper::string::stripStart(aStr, ' ');
                 [ #  # ]
     512                 :            : 
     513                 :            :     // to make sure that we only set first three
     514                 :          0 :     ListBox* pColumnListControl =  NULL;
     515                 :          0 :     ListBox* pPredicateListControl = NULL;
     516                 :          0 :     Edit* pPredicateValueControl = NULL;
     517   [ #  #  #  # ]:          0 :     switch( nIdx )
     518                 :            :     {
     519                 :            :         case 0:
     520                 :          0 :             pColumnListControl = &aLB_WHEREFIELD1;
     521                 :          0 :             pPredicateListControl = &aLB_WHERECOMP1;
     522                 :          0 :             pPredicateValueControl = &aET_WHEREVALUE1;
     523                 :          0 :             break;
     524                 :            :         case 1:
     525 [ #  # ][ #  # ]:          0 :             aLB_WHERECOND2.SelectEntryPos( _bOr ? 1 : 0 );
     526                 :            : 
     527                 :          0 :             pColumnListControl = &aLB_WHEREFIELD2;
     528                 :          0 :             pPredicateListControl = &aLB_WHERECOMP2;
     529                 :          0 :             pPredicateValueControl = &aET_WHEREVALUE2;
     530                 :          0 :             break;
     531                 :            :         case 2:
     532 [ #  # ][ #  # ]:          0 :             aLB_WHERECOND3.SelectEntryPos( _bOr ? 1 : 0 );
     533                 :            : 
     534                 :          0 :             pColumnListControl = &aLB_WHEREFIELD3;
     535                 :          0 :             pPredicateListControl = &aLB_WHERECOMP3;
     536                 :          0 :             pPredicateValueControl = &aET_WHEREVALUE3;
     537                 :          0 :             break;
     538                 :            :     }
     539                 :            : 
     540 [ #  # ][ #  # ]:          0 :     if ( pColumnListControl && pPredicateListControl && pPredicateValueControl )
                 [ #  # ]
     541                 :            :     {
     542                 :          0 :         ::rtl::OUString sName;
     543         [ #  # ]:          0 :         if ( xColumn.is() )
     544 [ #  # ][ #  # ]:          0 :             xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
                 [ #  # ]
     545                 :            :         else
     546                 :          0 :             sName = _rItem.Name;
     547                 :            :         // select the appropriate field name
     548 [ #  # ][ #  # ]:          0 :         SelectField( *pColumnListControl, sName );
                 [ #  # ]
     549         [ #  # ]:          0 :         ListSelectHdl( pColumnListControl );
     550                 :            : 
     551                 :            :         // select the appropriate condition
     552 [ #  # ][ #  # ]:          0 :         pPredicateListControl->SelectEntryPos( GetSelectionPos( (sal_Int32)_rItem.Handle, *pPredicateListControl ) );
     553                 :            : 
     554                 :            :         // initially normalize this value
     555         [ #  # ]:          0 :         ::rtl::OUString aString( aStr );
     556         [ #  # ]:          0 :         m_aPredicateInput.normalizePredicateString( aString, xColumn );
     557 [ #  # ][ #  # ]:          0 :         pPredicateValueControl->SetText( aString );
                 [ #  # ]
     558         [ #  # ]:          0 :     }
     559                 :          0 : }
     560                 :            : 
     561                 :          0 : void DlgFilterCrit::SelectField( ListBox& rBox, const String& rField )
     562                 :            : {
     563                 :            :     DBG_CHKTHIS(DlgFilterCrit,NULL);
     564                 :          0 :     sal_uInt16 nCnt = rBox.GetEntryCount();
     565                 :            : 
     566         [ #  # ]:          0 :     for( sal_uInt16 i=0 ; i<nCnt ; i++ )
     567                 :            :     {
     568 [ #  # ][ #  # ]:          0 :         if(rBox.GetEntry(i) == rField)
     569                 :            :         {
     570                 :          0 :             rBox.SelectEntryPos(i);
     571                 :          0 :             return;
     572                 :            :         }
     573                 :            :     }
     574                 :            : 
     575                 :          0 :     rBox.SelectEntryPos(0);
     576                 :            : }
     577                 :            : 
     578                 :          0 : void DlgFilterCrit::EnableLines()
     579                 :            : {
     580                 :            :     DBG_CHKTHIS(DlgFilterCrit,NULL);
     581                 :            :     // enabling/disabling of whole lines
     582         [ #  # ]:          0 :     if( LbPos(aLB_WHEREFIELD1) == 0 )
     583                 :            :     {
     584                 :          0 :         aLB_WHEREFIELD2.Disable();
     585                 :          0 :         aLB_WHERECOND2.Disable();
     586                 :          0 :         aLB_WHERECOMP2.Disable();
     587                 :          0 :         aET_WHEREVALUE2.Disable();
     588                 :            : 
     589                 :          0 :         aLB_WHEREFIELD3.Disable();
     590                 :          0 :         aLB_WHERECOND3.Disable();
     591                 :          0 :         aLB_WHERECOMP3.Disable();
     592                 :          0 :         aET_WHEREVALUE3.Disable();
     593                 :            :     }
     594                 :            :     else
     595                 :            :     {
     596                 :          0 :         aLB_WHEREFIELD2.Enable();
     597                 :          0 :         aLB_WHERECOND2.Enable();
     598                 :          0 :         aLB_WHERECOMP2.Enable();
     599                 :          0 :         aET_WHEREVALUE2.Enable();
     600                 :            : 
     601                 :          0 :         aLB_WHEREFIELD3.Enable();
     602                 :          0 :         aLB_WHERECOND3.Enable();
     603                 :          0 :         aLB_WHERECOMP3.Enable();
     604                 :          0 :         aET_WHEREVALUE3.Enable();
     605                 :            :     }
     606                 :            : 
     607         [ #  # ]:          0 :     if( LbPos(aLB_WHEREFIELD2) == 0 )
     608                 :            :     {
     609                 :          0 :         aLB_WHEREFIELD3.Disable();
     610                 :          0 :         aLB_WHERECOND3.Disable();
     611                 :          0 :         aLB_WHERECOMP3.Disable();
     612                 :          0 :         aET_WHEREVALUE3.Disable();
     613                 :            :     }
     614                 :            :     else
     615                 :            :     {
     616                 :          0 :         aLB_WHEREFIELD3.Enable();
     617                 :          0 :         aLB_WHERECOND3.Enable();
     618                 :          0 :         aLB_WHERECOMP3.Enable();
     619                 :          0 :         aET_WHEREVALUE3.Enable();
     620                 :            :     }
     621                 :            : 
     622                 :            :     // comparison field equal to NOENTRY
     623         [ #  # ]:          0 :     if( LbPos(aLB_WHEREFIELD1) == 0 )
     624                 :            :     {
     625                 :          0 :         aLB_WHERECOMP1.Disable();
     626                 :          0 :         aET_WHEREVALUE1.Disable();
     627                 :            :     }
     628                 :            :     else
     629                 :            :     {
     630                 :          0 :         aLB_WHEREFIELD1.Enable();
     631                 :          0 :         aLB_WHERECOMP1.Enable();
     632                 :          0 :         aET_WHEREVALUE1.Enable();
     633                 :            :     }
     634                 :            : 
     635         [ #  # ]:          0 :     if( LbPos(aLB_WHEREFIELD2) == 0 )
     636                 :            :     {
     637                 :          0 :         aLB_WHERECOND2.Disable();
     638                 :          0 :         aLB_WHERECOMP2.Disable();
     639                 :          0 :         aET_WHEREVALUE2.Disable();
     640                 :            :     }
     641                 :            :     else
     642                 :            :     {
     643                 :          0 :         aLB_WHERECOND2.Enable();
     644                 :          0 :         aLB_WHEREFIELD2.Enable();
     645                 :          0 :         aLB_WHERECOMP2.Enable();
     646                 :          0 :         aET_WHEREVALUE2.Enable();
     647                 :            :     }
     648                 :            : 
     649         [ #  # ]:          0 :     if( LbPos(aLB_WHEREFIELD3) == 0 )
     650                 :            :     {
     651                 :          0 :         aLB_WHERECOND3.Disable();
     652                 :          0 :         aLB_WHERECOMP3.Disable();
     653                 :          0 :         aET_WHEREVALUE3.Disable();
     654                 :            :     }
     655                 :            :     else
     656                 :            :     {
     657                 :          0 :         aLB_WHERECOND3.Enable();
     658                 :          0 :         aLB_WHERECOND3.Enable();
     659                 :          0 :         aLB_WHEREFIELD3.Enable();
     660                 :          0 :         aLB_WHERECOMP3.Enable();
     661                 :          0 :         aET_WHEREVALUE3.Enable();
     662                 :            :     }
     663                 :            : 
     664                 :            :     // comparison operator equal to ISNULL or ISNOTNULL
     665   [ #  #  #  #  :          0 :     if(aLB_WHERECOMP1.GetEntryCount() > 2 &&
           #  # ][ #  # ]
     666                 :          0 :         ((LbPos(aLB_WHERECOMP1) == aLB_WHERECOMP1.GetEntryCount()-1) ||
     667                 :          0 :          (LbPos(aLB_WHERECOMP1) == aLB_WHERECOMP1.GetEntryCount()-2)) )
     668                 :          0 :         aET_WHEREVALUE1.Disable();
     669                 :            : 
     670   [ #  #  #  #  :          0 :     if(aLB_WHERECOMP2.GetEntryCount() > 2 &&
           #  # ][ #  # ]
     671                 :          0 :         ((LbPos(aLB_WHERECOMP2) == aLB_WHERECOMP2.GetEntryCount()-1) ||
     672                 :          0 :          (LbPos(aLB_WHERECOMP2) == aLB_WHERECOMP2.GetEntryCount()-2)) )
     673                 :          0 :         aET_WHEREVALUE2.Disable();
     674                 :            : 
     675   [ #  #  #  #  :          0 :     if(aLB_WHERECOMP3.GetEntryCount() > 2 &&
           #  # ][ #  # ]
     676                 :          0 :         ((LbPos(aLB_WHERECOMP3) == aLB_WHERECOMP3.GetEntryCount()-1) ||
     677                 :          0 :          (LbPos(aLB_WHERECOMP3) == aLB_WHERECOMP3.GetEntryCount()-2)) )
     678                 :          0 :         aET_WHEREVALUE3.Disable();
     679                 :          0 : }
     680                 :            : 
     681                 :          0 : IMPL_LINK( DlgFilterCrit, ListSelectHdl, ListBox *, pListBox )
     682                 :            : {
     683         [ #  # ]:          0 :     String aName;
     684                 :            :     ListBox* pComp;
     685         [ #  # ]:          0 :     if(pListBox == &aLB_WHEREFIELD1)
     686                 :            :     {
     687 [ #  # ][ #  # ]:          0 :         aName = LbText(aLB_WHEREFIELD1);
                 [ #  # ]
     688                 :          0 :         pComp = &aLB_WHERECOMP1;
     689                 :            :     }
     690         [ #  # ]:          0 :     else if(pListBox == &aLB_WHEREFIELD2)
     691                 :            :     {
     692 [ #  # ][ #  # ]:          0 :         aName = LbText(aLB_WHEREFIELD2);
                 [ #  # ]
     693                 :          0 :         pComp = &aLB_WHERECOMP2;
     694                 :            :     }
     695                 :            :     else
     696                 :            :     {
     697 [ #  # ][ #  # ]:          0 :         aName = LbText(aLB_WHEREFIELD3);
                 [ #  # ]
     698                 :          0 :         pComp = &aLB_WHERECOMP3;
     699                 :            :     }
     700                 :            : 
     701         [ #  # ]:          0 :     pComp->Clear();
     702                 :            : 
     703 [ #  # ][ #  # ]:          0 :     Reference<XPropertySet> xColumn = getColumn(aName);
     704         [ #  # ]:          0 :     if ( xColumn.is() )
     705                 :            :     {
     706                 :          0 :         sal_Int32 nDataType = 0;
     707 [ #  # ][ #  # ]:          0 :         xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
                 [ #  # ]
     708         [ #  # ]:          0 :         sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType);
     709                 :            : 
     710         [ #  # ]:          0 :         if(eColumnSearch  == ColumnSearch::FULL)
     711                 :            :         {
     712 [ #  # ][ #  # ]:          0 :             for(xub_StrLen i=0;i < comphelper::string::getTokenCount(aSTR_COMPARE_OPERATORS, ';');i++)
                 [ #  # ]
     713 [ #  # ][ #  # ]:          0 :                 pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i));
                 [ #  # ]
     714                 :            :         }
     715         [ #  # ]:          0 :         else if(eColumnSearch == ColumnSearch::CHAR)
     716                 :            :         {
     717         [ #  # ]:          0 :             for(xub_StrLen i=6;i<10;i++)
     718 [ #  # ][ #  # ]:          0 :                 pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i));
                 [ #  # ]
     719                 :            :         }
     720         [ #  # ]:          0 :         else if(eColumnSearch == ColumnSearch::BASIC)
     721                 :            :         {
     722                 :            :             xub_StrLen i;
     723         [ #  # ]:          0 :             for( i = 0; i < 6; i++ )
     724 [ #  # ][ #  # ]:          0 :                 pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i));
                 [ #  # ]
     725 [ #  # ][ #  # ]:          0 :             for(i=8; i < comphelper::string::getTokenCount(aSTR_COMPARE_OPERATORS, ';'); ++i)
                 [ #  # ]
     726 [ #  # ][ #  # ]:          0 :                 pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i));
                 [ #  # ]
     727                 :            :         }
     728                 :            :         else
     729                 :            :         {
     730                 :            :             OSL_FAIL("DlgFilterCrit::ListSelectHdl: This column should not exist at all.");
     731                 :            :         }
     732                 :            :     }
     733         [ #  # ]:          0 :     pComp->SelectEntryPos(0);
     734                 :            : 
     735         [ #  # ]:          0 :     EnableLines();
     736         [ #  # ]:          0 :     return 0;
     737                 :            : }
     738                 :            : 
     739                 :          0 : IMPL_LINK_INLINE_START( DlgFilterCrit, ListSelectCompHdl, ListBox *, /*pListBox*/ )
     740                 :            : {
     741                 :          0 :     EnableLines();
     742                 :          0 :     return 0;
     743                 :            : }
     744                 :          0 : IMPL_LINK_INLINE_END( DlgFilterCrit, ListSelectCompHdl, ListBox *, pListBox )
     745                 :            : 
     746                 :          0 : void DlgFilterCrit::BuildWherePart()
     747                 :            : {
     748                 :            :     DBG_CHKTHIS(DlgFilterCrit,NULL);
     749 [ #  # ][ #  # ]:          0 :     Sequence<Sequence<PropertyValue> > aFilter,aHaving;
     750         [ #  # ]:          0 :     aFilter.realloc(1);
     751         [ #  # ]:          0 :     aHaving.realloc(1);
     752                 :            : 
     753 [ #  # ][ #  # ]:          0 :     if( LbPos(aLB_WHEREFIELD1) != 0 )
     754                 :            :     {
     755                 :          0 :         PropertyValue aValue;
     756 [ #  # ][ #  # ]:          0 :         if ( getCondition(aLB_WHEREFIELD1,aLB_WHERECOMP1,aET_WHEREVALUE1,aValue) )
     757                 :            :         {
     758 [ #  # ][ #  # ]:          0 :             aHaving[0].realloc(1);
     759 [ #  # ][ #  # ]:          0 :             aHaving[0][0] = aValue;
     760                 :            :         }
     761                 :            :         else
     762                 :            :         {
     763 [ #  # ][ #  # ]:          0 :             aFilter[0].realloc(1);
     764 [ #  # ][ #  # ]:          0 :             aFilter[0][0] = aValue;
     765                 :          0 :         }
     766                 :            :     }
     767                 :            : 
     768 [ #  # ][ #  # ]:          0 :     if( LbPos(aLB_WHEREFIELD2) != 0 )
     769                 :            :     {
     770                 :          0 :         PropertyValue aValue;
     771                 :          0 :         Sequence<Sequence<PropertyValue> >& _rValues = aFilter;
     772 [ #  # ][ #  # ]:          0 :         if ( getCondition(aLB_WHEREFIELD2,aLB_WHERECOMP2,aET_WHEREVALUE2,aValue) )
     773         [ #  # ]:          0 :             _rValues = aHaving;
     774                 :          0 :         PropertyValue* pPos = NULL;
     775 [ #  # ][ #  # ]:          0 :         if ( aLB_WHERECOND2.GetSelectEntryPos() )
     776                 :            :         {
     777                 :          0 :             sal_Int32 nPos = _rValues.getLength();
     778         [ #  # ]:          0 :             _rValues.realloc( nPos + 1);
     779 [ #  # ][ #  # ]:          0 :             _rValues[nPos].realloc( 1);
     780 [ #  # ][ #  # ]:          0 :             pPos = &_rValues[nPos][0];
     781                 :            :         }
     782                 :            :         else
     783                 :            :         {
     784                 :          0 :             sal_Int32 nPos = _rValues.getLength() - 1;
     785         [ #  # ]:          0 :             sal_Int32 nAndPos = _rValues[nPos].getLength();
     786 [ #  # ][ #  # ]:          0 :             _rValues[nPos].realloc( _rValues[nPos].getLength() + 1);
                 [ #  # ]
     787 [ #  # ][ #  # ]:          0 :             pPos = &_rValues[nPos][nAndPos];
     788                 :            :         }
     789                 :          0 :         *pPos = aValue;
     790                 :            :     }
     791                 :            : 
     792 [ #  # ][ #  # ]:          0 :     if( LbPos(aLB_WHEREFIELD3) != 0 )
     793                 :            :     {
     794                 :          0 :         PropertyValue aValue;
     795                 :          0 :         Sequence<Sequence<PropertyValue> >& _rValues = aFilter;
     796 [ #  # ][ #  # ]:          0 :         if ( getCondition(aLB_WHEREFIELD3,aLB_WHERECOMP3,aET_WHEREVALUE3,aValue) )
     797         [ #  # ]:          0 :             _rValues = aHaving;
     798                 :          0 :         PropertyValue* pPos = NULL;
     799 [ #  # ][ #  # ]:          0 :         if ( aLB_WHERECOND3.GetSelectEntryPos() )
     800                 :            :         {
     801                 :          0 :             sal_Int32 nPos = _rValues.getLength();
     802         [ #  # ]:          0 :             _rValues.realloc( nPos + 1);
     803 [ #  # ][ #  # ]:          0 :             _rValues[nPos].realloc( 1);
     804 [ #  # ][ #  # ]:          0 :             pPos = &_rValues[nPos][0];
     805                 :            :         }
     806                 :            :         else
     807                 :            :         {
     808                 :          0 :             sal_Int32 nPos = _rValues.getLength() - 1;
     809         [ #  # ]:          0 :             sal_Int32 nAndPos = _rValues[nPos].getLength();
     810 [ #  # ][ #  # ]:          0 :             _rValues[nPos].realloc( _rValues[nPos].getLength() + 1);
                 [ #  # ]
     811 [ #  # ][ #  # ]:          0 :             pPos = &_rValues[nPos][nAndPos];
     812                 :            :         }
     813         [ #  # ]:          0 :         *pPos = aValue;
     814                 :            :     }
     815                 :            :     try
     816                 :            :     {
     817 [ #  # ][ #  # ]:          0 :         m_xQueryComposer->setStructuredFilter(aFilter);
     818 [ #  # ][ #  # ]:          0 :         m_xQueryComposer->setStructuredHavingClause(aHaving);
     819                 :            :     }
     820         [ #  # ]:          0 :     catch(const Exception&)
     821                 :            :     {
     822                 :            :         DBG_UNHANDLED_EXCEPTION();
     823 [ #  # ][ #  # ]:          0 :     }
     824                 :          0 : }
     825                 :            : 
     826                 :          0 : void DlgFilterCrit::fillLines(const Sequence<Sequence<PropertyValue > >& _aValues)
     827                 :            : {
     828                 :          0 :     const Sequence<PropertyValue >* pOrIter = _aValues.getConstArray();
     829                 :          0 :     const Sequence<PropertyValue >* pOrEnd   = pOrIter + _aValues.getLength();
     830                 :          0 :     sal_Bool bOr = sal_True;
     831         [ #  # ]:          0 :     for(sal_uInt16 i=0;pOrIter != pOrEnd; ++pOrIter)
     832                 :            :     {
     833                 :          0 :         bOr = sal_True;
     834                 :          0 :         const PropertyValue* pAndIter   = pOrIter->getConstArray();
     835                 :          0 :         const PropertyValue* pAndEnd    = pAndIter + pOrIter->getLength();
     836         [ #  # ]:          0 :         for(;pAndIter != pAndEnd; ++pAndIter)
     837                 :            :         {
     838                 :          0 :             SetLine( i++,*pAndIter,bOr);
     839                 :          0 :             bOr = sal_False;
     840                 :            :         }
     841                 :            :     }
     842                 :          0 : }
     843                 :            : 
     844                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10