Tag: cws_src680_codecleanup01 User: mt Date: 2006/08/10 07:33:07 Modified: dba/dbaccess/source/core/api/FilteredContainer.cxx
Log: RESYNC: (1.6-1.8); FILE MERGED File Changes: Directory: /dba/dbaccess/source/core/api/ ========================================= File [changed]: FilteredContainer.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/FilteredContainer.cxx?r1=1.5.70.2&r2=1.5.70.3 Delta lines: +26 -26 --------------------- --- FilteredContainer.cxx 7 Oct 2005 23:50:51 -0000 1.5.70.2 +++ FilteredContainer.cxx 10 Aug 2006 14:33:04 -0000 1.5.70.3 @@ -42,7 +42,7 @@ #include <com/sun/star/sdbc/XRow.hpp> #endif #ifndef _CONNECTIVITY_DBTOOLS_HXX_ -#include <connectivity/dbtools.hxx> +#include "connectivity/dbtools.hxx" #endif #ifndef _WLDCRD_HXX #include <tools/wldcrd.hxx> @@ -65,17 +65,6 @@ using namespace ::connectivity::sdbcx; //------------------------------------------------------------------------------ - /** compare two strings - */ - extern int - #if defined( WNT ) - __cdecl - #endif - NameCompare( const void* pFirst, const void* pSecond) - { - return reinterpret_cast< const ::rtl::OUString* >(pFirst)->compareTo(*reinterpret_cast< const ::rtl::OUString* >(pSecond)); - } - //------------------------------------------------------------------------------ /** creates a vector of WildCards and reduce the _rTableFilter of the length of WildsCards */ sal_Int32 createWildCardVector(Sequence< ::rtl::OUString >& _rTableFilter, ::std::vector< WildCard >& _rOut) @@ -116,10 +105,10 @@ IRefreshListener* _pRefreshListener, IWarningsContainer* _pWarningsContainer) :OCollection(_rParent,_bCase,_rMutex,::std::vector< ::rtl::OUString>()) - ,m_bConstructed(sal_False) - ,m_xConnection(_xCon) ,m_pWarningsContainer(_pWarningsContainer) ,m_pRefreshListener(_pRefreshListener) + ,m_xConnection(_xCon) + ,m_bConstructed(sal_False) { } @@ -151,8 +140,9 @@ { Sequence< ::rtl::OUString > aTableFilter = _rTableFilter; Sequence< ::rtl::OUString > aTableTypeFilter = _rTableTypeFilter; + // build sorted versions of the filter sequences, so the visibility decision is faster - qsort(aTableFilter.getArray(), nTableFilterLen, sizeof(::rtl::OUString), NameCompare); + ::std::sort( aTableFilter.getArray(), aTableFilter.getArray() + nTableFilterLen ); // as we want to modify nTableFilterLen, remember this @@ -205,7 +195,7 @@ sal_Int32 nTableFilterLen = aTableFilter.getLength(); if (nTableFilterLen) - qsort(aTableFilter.getArray(), nTableFilterLen, sizeof(::rtl::OUString), NameCompare); + ::std::sort( aTableFilter.getArray(), aTableFilter.getArray() + nTableFilterLen ); sal_Bool bNoTableFilters = ((nTableFilterLen == 1) && _rTableFilter[0].equalsAsciiL("%", 1)); // as we want to modify nTableFilterLen, remember this @@ -249,9 +239,17 @@ // we're not interested in the "wasNull", as the getStrings would return an empty string in // that case, which is sufficient here - composeTableName(m_xMetaData, sCatalog, sSchema, sName, sComposedName, sal_False,::dbtools::eInDataManipulation); + sComposedName = composeTableName( m_xMetaData, sCatalog, sSchema, sName, sal_False, ::dbtools::eInDataManipulation ); + + const ::rtl::OUString* tableFilter = aTableFilter.getConstArray(); + const ::rtl::OUString* tableFilterEnd = aTableFilter.getConstArray() + nTableFilterLen; + bool composedNameInFilter = ::std::find( tableFilter, tableFilterEnd, sComposedName ) != tableFilterEnd; + bFilterMatch = bNoTableFilters - || ((nTableFilterLen != 0) && (NULL != bsearch(&sComposedName, aTableFilter.getConstArray(), nTableFilterLen, sizeof(::rtl::OUString), NameCompare))); + || ( ( nTableFilterLen != 0 ) + && composedNameInFilter + ); + // the table is allowed to "pass" if we had no filters at all or any of the non-wildcard filters matches if (!bFilterMatch && aWCSearch.size()) @@ -315,12 +313,14 @@ // ------------------------------------------------------------------------- sal_Bool OFilteredContainer::isNameValid( const ::rtl::OUString& _rName, const Sequence< ::rtl::OUString >& _rTableFilter, - const Sequence< ::rtl::OUString >& _rTableTypeFilter, + const Sequence< ::rtl::OUString >& /*_rTableTypeFilter*/, const ::std::vector< WildCard >& _rWCSearch) const { sal_Int32 nTableFilterLen = _rTableFilter.getLength(); - sal_Bool bFilterMatch = (NULL != bsearch(&_rName, _rTableFilter.getConstArray(), nTableFilterLen, sizeof(::rtl::OUString), NameCompare)); + const ::rtl::OUString* tableFilter = _rTableFilter.getConstArray(); + const ::rtl::OUString* tableFilterEnd = _rTableFilter.getConstArray() + nTableFilterLen; + bool bFilterMatch = ::std::find( tableFilter, tableFilterEnd, _rName ) != tableFilterEnd; // the table is allowed to "pass" if we had no filters at all or any of the non-wildcard filters matches if (!bFilterMatch && !_rWCSearch.empty()) { // or if one of the wildcrad expression matches @@ -338,7 +338,7 @@ ::rtl::OUString OFilteredContainer::getNameForObject(const ObjectType& _xObject) { OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!"); - return ::dbtools::composeTableName(m_xMetaData,_xObject,sal_False,::dbtools::eInDataManipulation); + return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::eInDataManipulation, false, false, false ); } // .............................................................................. } // namespace --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
