diff -ur --exclude=CVS sc.clean/inc/datauno.hxx sc/inc/datauno.hxx --- sc.clean/inc/datauno.hxx 2007-02-27 06:54:55.000000000 -0500 +++ sc/inc/datauno.hxx 2007-06-14 23:05:08.000000000 -0400 @@ -51,6 +51,9 @@ #ifndef _COM_SUN_STAR_SHEET_TABLEFILTERFIELD_HPP_ #include #endif +#ifndef _COM_SUN_STAR_SHEET_TABLEFILTERFIELDMULTISTRING_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_SHEET_GENERALFUNCTION_HPP_ #include #endif @@ -60,6 +63,9 @@ #ifndef _COM_SUN_STAR_SHEET_XSHEETFILTERDESCRIPTOR_HPP_ #include #endif +#ifndef _COM_SUN_STAR_SHEET_XEXTENDEDSHEETFILTERDESCRIPTOR_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_SHEET_XCONSOLIDATIONDESCRIPTOR_HPP_ #include #endif @@ -113,12 +119,15 @@ #include #endif +#include + class ScDBData; class ScDocShell; class ScSubTotalFieldObj; class ScDatabaseRangeObj; class ScDataPilotDescriptorBase; +class ScExtendedFilterDescriptor; struct ScSortParam; @@ -397,8 +406,9 @@ // to uno, all three look the same -class ScFilterDescriptorBase : public cppu::WeakImplHelper3< +class ScFilterDescriptorBase : public cppu::WeakImplHelper4< com::sun::star::sheet::XSheetFilterDescriptor, + com::sun::star::sheet::XExtendedSheetFilterDescriptor, com::sun::star::beans::XPropertySet, com::sun::star::lang::XServiceInfo >, public SfxListener @@ -406,6 +416,7 @@ private: SfxItemPropertySet aPropSet; ScDocShell* pDocSh; + ::std::auto_ptr pExtDescriptor; public: ScFilterDescriptorBase(ScDocShell* pDocShell); @@ -425,6 +436,17 @@ ::com::sun::star::sheet::TableFilterField >& aFilterFields ) throw(::com::sun::star::uno::RuntimeException); + // XExtendedSheetFilterDescriptor + virtual void SAL_CALL begin() throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL commit() throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL addFilterField( const ::com::sun::star::sheet::TableFilterField& aField ) + throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL addMultiStringFilterField( const ::com::sun::star::sheet::TableMultiStringFilterField& aField ) + throw(::com::sun::star::uno::RuntimeException); + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() diff -ur --exclude=CVS sc.clean/inc/dbcolect.hxx sc/inc/dbcolect.hxx --- sc.clean/inc/dbcolect.hxx 2007-04-25 11:56:28.000000000 -0400 +++ sc/inc/dbcolect.hxx 2007-06-14 17:02:46.000000000 -0400 @@ -113,6 +113,7 @@ String* pQueryStr[MAXQUERY]; double nQueryVal[MAXQUERY]; ScQueryConnect eQueryConnect[MAXQUERY]; + ScHashOUStringSet aStrValues[MAXQUERY]; BOOL bIsAdvanced; // TRUE if created by advanced filter ScRange aAdvSource; // source range // SubTotalParam diff -ur --exclude=CVS sc.clean/inc/global.hxx sc/inc/global.hxx --- sc.clean/inc/global.hxx 2007-04-25 11:57:24.000000000 -0400 +++ sc/inc/global.hxx 2007-06-14 17:09:02.000000000 -0400 @@ -58,6 +58,8 @@ #include "scdllapi.h" #endif +#include + class ImageList; class Bitmap; class SfxItemSet; @@ -887,6 +889,8 @@ class TextSearch; } +typedef ::std::hash_set< ::rtl::OUString, ::rtl::OUStringHash, ::std::equal_to > ScHashOUStringSet; + struct ScQueryEntry { BOOL bDoQuery; @@ -899,6 +903,8 @@ utl::SearchParam* pSearchParam; // falls RegExp, nicht gespeichert utl::TextSearch* pSearchText; // falls RegExp, nicht gespeichert + ScHashOUStringSet aStrValues; + ScQueryEntry(); ScQueryEntry(const ScQueryEntry& r); ~ScQueryEntry(); Only in sc: sc.vpj diff -ur --exclude=CVS sc.clean/source/core/data/global2.cxx sc/source/core/data/global2.cxx --- sc.clean/source/core/data/global2.cxx 2007-02-27 07:06:31.000000000 -0500 +++ sc/source/core/data/global2.cxx 2007-06-14 17:09:22.000000000 -0400 @@ -176,6 +176,7 @@ pStr = new String(*r.pStr); pSearchParam = NULL; pSearchText = NULL; + aStrValues = r.aStrValues; } ScQueryEntry::~ScQueryEntry() @@ -205,6 +206,8 @@ pSearchParam = NULL; pSearchText = NULL; + aStrValues = r.aStrValues; + return *this; } @@ -224,6 +227,7 @@ } pSearchParam = NULL; pSearchText = NULL; + aStrValues.clear(); } BOOL ScQueryEntry::operator==( const ScQueryEntry& r ) const @@ -234,7 +238,8 @@ && eConnect == r.eConnect && nField == r.nField && nVal == r.nVal - && *pStr == *r.pStr; + && *pStr == *r.pStr + && aStrValues == r.aStrValues; //! pSearchParam und pSearchText nicht vergleichen } diff -ur --exclude=CVS sc.clean/source/core/data/table3.cxx sc/source/core/data/table3.cxx --- sc.clean/source/core/data/table3.cxx 2007-03-05 09:40:30.000000000 -0500 +++ sc/source/core/data/table3.cxx 2007-06-14 17:31:32.000000000 -0400 @@ -1036,82 +1036,96 @@ else GetInputString( static_cast(rEntry.nField), nRow, aCellStr ); - BOOL bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL) - || (rEntry.eOp == SC_NOT_EQUAL))); - BOOL bTestRegExp = (pbTestEqualCondition && rParam.bRegExp - && ((rEntry.eOp == SC_LESS_EQUAL) - || (rEntry.eOp == SC_GREATER_EQUAL))); - if ( bRealRegExp || bTestRegExp ) + if ( !rEntry.aStrValues.empty() ) { - xub_StrLen nStart = 0; - xub_StrLen nEnd = aCellStr.Len(); - BOOL bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens ) - ->SearchFrwrd( aCellStr, &nStart, &nEnd ); - // from 614 on, nEnd is behind the found text - if ( bMatch && bMatchWholeCell - && (nStart != 0 || nEnd != aCellStr.Len()) ) - bMatch = FALSE; // RegExp must match entire cell string - if ( bRealRegExp ) - bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch); + // Filter by individual string values. + rtl::OUString aCellStr2(aCellStr); + ScHashOUStringSet::const_iterator pos = rEntry.aStrValues.find(aCellStr2); + if (pos == rEntry.aStrValues.end()) + bOk = FALSE; else - bTestEqual = bMatch; + bOk = TRUE; } - if ( !bRealRegExp ) - { - if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL ) - { - if ( !rEntry.bQueryByString && rEntry.pStr->Len() == 0 ) + else + { + rtl::OUString aCellStr2(aCellStr); + BOOL bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL) + || (rEntry.eOp == SC_NOT_EQUAL))); + BOOL bTestRegExp = (pbTestEqualCondition && rParam.bRegExp + && ((rEntry.eOp == SC_LESS_EQUAL) + || (rEntry.eOp == SC_GREATER_EQUAL))); + if ( bRealRegExp || bTestRegExp ) + { + xub_StrLen nStart = 0; + xub_StrLen nEnd = aCellStr.Len(); + BOOL bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens ) + ->SearchFrwrd( aCellStr, &nStart, &nEnd ); + // from 614 on, nEnd is behind the found text + if ( bMatch && bMatchWholeCell + && (nStart != 0 || nEnd != aCellStr.Len()) ) + bMatch = FALSE; // RegExp must match entire cell string + if ( bRealRegExp ) + bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch); + else + bTestEqual = bMatch; + } + if ( !bRealRegExp ) + { + if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL ) { - // #i18374# When used from functions (match, countif, sumif, vlookup, hlookup, lookup), - // the query value is assigned directly, and the string is empty. In that case, - // don't find any string (isEqual would find empty string results in formula cells). - bOk = FALSE; + if ( !rEntry.bQueryByString && rEntry.pStr->Len() == 0 ) + { + // #i18374# When used from functions (match, countif, sumif, vlookup, hlookup, lookup), + // the query value is assigned directly, and the string is empty. In that case, + // don't find any string (isEqual would find empty string results in formula cells). + bOk = FALSE; + } + else if ( bMatchWholeCell ) + bOk = pTransliteration->isEqual( aCellStr, *rEntry.pStr ); + else + { + ::com::sun::star::uno::Sequence< sal_Int32 > xOff; + String aCell( pTransliteration->transliterate( + aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(), + &xOff ) ); + String aQuer( pTransliteration->transliterate( + *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(), + &xOff ) ); + bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND); + } + if ( rEntry.eOp == SC_NOT_EQUAL ) + bOk = !bOk; } - else if ( bMatchWholeCell ) - bOk = pTransliteration->isEqual( aCellStr, *rEntry.pStr ); - else - { - ::com::sun::star::uno::Sequence< sal_Int32 > xOff; - String aCell( pTransliteration->transliterate( - aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(), - &xOff ) ); - String aQuer( pTransliteration->transliterate( - *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(), - &xOff ) ); - bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND); - } - if ( rEntry.eOp == SC_NOT_EQUAL ) - bOk = !bOk; - } - else - { // use collator here because data was probably sorted - sal_Int32 nCompare = pCollator->compareString( - aCellStr, *rEntry.pStr ); - switch (rEntry.eOp) - { - case SC_LESS : - bOk = (nCompare < 0); - break; - case SC_GREATER : - bOk = (nCompare > 0); - break; - case SC_LESS_EQUAL : - bOk = (nCompare <= 0); - if ( bOk && pbTestEqualCondition && !bTestEqual ) - bTestEqual = (nCompare == 0); - break; - case SC_GREATER_EQUAL : - bOk = (nCompare >= 0); - if ( bOk && pbTestEqualCondition && !bTestEqual ) - bTestEqual = (nCompare == 0); - break; - default: + else + { // use collator here because data was probably sorted + sal_Int32 nCompare = pCollator->compareString( + aCellStr, *rEntry.pStr ); + switch (rEntry.eOp) { - // added to avoid warnings + case SC_LESS : + bOk = (nCompare < 0); + break; + case SC_GREATER : + bOk = (nCompare > 0); + break; + case SC_LESS_EQUAL : + bOk = (nCompare <= 0); + if ( bOk && pbTestEqualCondition && !bTestEqual ) + bTestEqual = (nCompare == 0); + break; + case SC_GREATER_EQUAL : + bOk = (nCompare >= 0); + if ( bOk && pbTestEqualCondition && !bTestEqual ) + bTestEqual = (nCompare == 0); + break; + default: + { + // added to avoid warnings + } } - } - } - } + } + } + } } else if (rParam.bMixedComparison) { @@ -1325,7 +1339,11 @@ { ScQueryEntry& rEntry = rParamOrg.GetEntry(i); - if ( rEntry.bQueryByString ) + if ( !rEntry.aStrValues.empty() ) + { + // Do nothing. + } + else if ( rEntry.bQueryByString ) { sal_uInt32 nIndex = 0; rEntry.bQueryByString = !(pDocument->GetFormatTable()-> diff -ur --exclude=CVS sc.clean/source/core/tool/dbcolect.cxx sc/source/core/tool/dbcolect.cxx --- sc.clean/source/core/tool/dbcolect.cxx 2007-02-27 07:14:19.000000000 -0500 +++ sc/source/core/tool/dbcolect.cxx 2007-06-14 17:31:58.000000000 -0400 @@ -544,6 +544,7 @@ *pQueryStr[i] = *rData.pQueryStr[i]; nQueryVal[i] = rData.nQueryVal[i]; eQueryConnect[i] = rData.eQueryConnect[i]; + aStrValues[i] = rData.aStrValues[i]; } for (i=0; i(nField) - 1) : static_cast(0); rEntry.eOp = eOp; + + // Disable multi-string matching until we have the UI implemented. + // TODO: Implement it in the UI (kohei). + rEntry.aStrValues.clear(); } } diff -ur --exclude=CVS sc.clean/source/ui/unoobj/datauno.cxx sc/source/ui/unoobj/datauno.cxx --- sc.clean/source/ui/unoobj/datauno.cxx 2007-03-05 09:45:54.000000000 -0500 +++ sc/source/ui/unoobj/datauno.cxx 2007-06-15 15:50:31.000000000 -0400 @@ -52,6 +52,7 @@ #include #include "datauno.hxx" +#include "extfilterdescriptor.hxx" #include "dapiuno.hxx" #include "cellsuno.hxx" #include "miscuno.hxx" @@ -1094,7 +1095,8 @@ ScFilterDescriptorBase::ScFilterDescriptorBase(ScDocShell* pDocShell) : aPropSet( lcl_GetFilterPropertyMap() ), - pDocSh(pDocShell) + pDocSh(pDocShell), + pExtDescriptor(NULL) { if (pDocSh) pDocSh->GetDocument()->AddUnoObject(*this); @@ -1263,6 +1265,44 @@ PutData(aParam); } +void SAL_CALL ScFilterDescriptorBase::begin() throw(uno::RuntimeException) +{ + ScUnoGuard aGuard; + if ( !pDocSh ) + return; + + pExtDescriptor.reset(new ScExtendedFilterDescriptor(this, *pDocSh->GetDocument()) ); +} + +void SAL_CALL ScFilterDescriptorBase::commit() throw(uno::RuntimeException) +{ + ScUnoGuard aGuard; + if ( !pExtDescriptor.get() ) + return; + + pExtDescriptor->commit(); + pExtDescriptor.reset(NULL); +} + +void SAL_CALL ScFilterDescriptorBase::addFilterField( const sheet::TableFilterField& aField ) throw(uno::RuntimeException) +{ + ScUnoGuard aGuard; + if ( !pExtDescriptor.get() ) + return; + + pExtDescriptor->addField(aField); +} + +void SAL_CALL ScFilterDescriptorBase::addMultiStringFilterField( + const sheet::TableMultiStringFilterField& aField ) throw(uno::RuntimeException) +{ + ScUnoGuard aGuard; + if ( !pExtDescriptor.get() ) + return; + + pExtDescriptor->addMultiStringField(aField); +} + // Rest sind Properties // XPropertySet Only in sc/source/ui/unoobj: extfilterdescriptor.cxx Only in sc/source/ui/unoobj: extfilterdescriptor.hxx diff -ur --exclude=CVS sc.clean/source/ui/unoobj/makefile.mk sc/source/ui/unoobj/makefile.mk --- sc.clean/source/ui/unoobj/makefile.mk 2007-06-14 17:21:16.000000000 -0400 +++ sc/source/ui/unoobj/makefile.mk 2007-06-14 23:00:00.000000000 -0400 @@ -75,6 +75,7 @@ $(SLO)$/viewuno.obj \ $(SLO)$/dispuno.obj \ $(SLO)$/datauno.obj \ + $(SLO)$/extfilterdescriptor.obj \ $(SLO)$/dapiuno.obj \ $(SLO)$/chartuno.obj \ $(SLO)$/chart2uno.obj \ diff -ur --exclude=CVS sc.clean/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx --- sc.clean/source/ui/view/gridwin.cxx 2007-05-10 13:00:50.000000000 -0400 +++ sc/source/ui/view/gridwin.cxx 2007-06-14 17:09:28.000000000 -0400 @@ -1299,6 +1299,10 @@ ScQueryParam aParam; pDBData->GetQueryParam( aParam ); // kann nur MAXQUERY Eintraege ergeben + // Disable multi-string match flag until we implement it in the UI. + for (SCSIZE i = 0; i < MAXQUERY; ++i) + aParam.GetEntry(i).aStrValues.clear(); + if (SC_AUTOFILTER_CUSTOM == nSel) { pViewData->GetView()->SetCursor(nCol,nRow); //! auch ueber Slot ?? Only in sc: unxlngi6.pro diff -ur --exclude=CVS offapi.clean/com/sun/star/sheet/makefile.mk offapi/com/sun/star/sheet/makefile.mk --- offapi.clean/com/sun/star/sheet/makefile.mk 2007-06-14 17:24:10.000000000 -0400 +++ offapi/com/sun/star/sheet/makefile.mk 2007-06-14 22:39:30.000000000 -0400 @@ -228,6 +228,7 @@ TableConditionalEntryEnumeration.idl\ TableConditionalFormat.idl\ TableFilterField.idl\ + TableMultiStringFilterField.idl\ TableOperationMode.idl\ TablePageBreakData.idl\ TablePageStyle.idl\ @@ -312,6 +313,7 @@ XSheetFilterable.idl\ XSheetFilterableEx.idl\ XSheetFilterDescriptor.idl\ + XExtendedSheetFilterDescriptor.idl\ XSheetLinkable.idl\ XSheetOperation.idl\ XSheetOutline.idl\ diff -ur --exclude=CVS offapi.clean/com/sun/star/sheet/SheetFilterDescriptor.idl offapi/com/sun/star/sheet/SheetFilterDescriptor.idl --- offapi.clean/com/sun/star/sheet/SheetFilterDescriptor.idl 2005-09-08 00:49:59.000000000 -0400 +++ offapi/com/sun/star/sheet/SheetFilterDescriptor.idl 2007-06-14 14:21:08.000000000 -0400 @@ -40,6 +40,10 @@ #include #endif +#ifndef __com_sun_star_sheet_XExtendedSheetFilterDescriptor_idl__ +#include +#endif + #ifndef __com_sun_star_beans_XPropertySet_idl__ #include #endif @@ -74,6 +78,12 @@ //------------------------------------------------------------------------- + /** provides access to the collection of filter fields. + */ + [optional] interface com::sun::star::sheet::XExtendedSheetFilterDescriptor; + + //------------------------------------------------------------------------- + //!published service PropertySet /** provides access to the properties. */ Only in offapi/com/sun/star/sheet: TableMultiStringFilterField.idl Only in offapi/com/sun/star/sheet: XExtendedSheetFilterDescriptor.idl Only in offapi: offapi.vpj Only in offapi: unxlngi6.pro --- /dev/null 2007-03-30 11:25:40.000000000 -0400 +++ sc/source/ui/unoobj/extfilterdescriptor.hxx 2007-06-15 13:16:41.000000000 -0400 @@ -0,0 +1,69 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dbcolect.hxx,v $ + * + * $Revision: 1.12 $ + * + * last change: $Author: rt $ $Date: 2007/04/25 15:56:28 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef SC_EXTFILTER_DESCRIPTOR_HXX +#define SC_EXTFILTER_DESCRIPTOR_HXX + +#include "global.hxx" + +#include + +namespace com { namespace sun { namespace star { namespace sheet { + class TableFilterField; + class TableMultiStringFilterField; +}}}} + +class ScDocument; +class ScFilterDescriptorBase; + +class ScExtendedFilterDescriptor +{ +public: + ScExtendedFilterDescriptor(ScFilterDescriptorBase* pParent, ScDocument& rDoc); + ~ScExtendedFilterDescriptor() throw(); + + void addField( const ::com::sun::star::sheet::TableFilterField& aField ); + void addMultiStringField( const ::com::sun::star::sheet::TableMultiStringFilterField& aField ); + void commit(); + +private: + ScFilterDescriptorBase* mpParent; + ScDocument& mrDoc; + ::std::list maParamList; +}; + + + +#endif --- /dev/null 2007-03-30 11:25:40.000000000 -0400 +++ sc/source/ui/unoobj/extfilterdescriptor.cxx 2007-06-15 15:52:29.000000000 -0400 @@ -0,0 +1,169 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dbcolect.hxx,v $ + * + * $Revision: 1.12 $ + * + * last change: $Author: rt $ $Date: 2007/04/25 15:56:28 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#include "extfilterdescriptor.hxx" + +#include +#include +#include +#include + +#include "document.hxx" +#include "datauno.hxx" + +using namespace ::com::sun::star; + +ScExtendedFilterDescriptor::ScExtendedFilterDescriptor(ScFilterDescriptorBase* pParent, ScDocument& rDoc) : + mpParent(pParent), + mrDoc(rDoc) +{ +} + +ScExtendedFilterDescriptor::~ScExtendedFilterDescriptor() throw() +{ +} + +void lclTranslateOperator(ScQueryEntry& rEntry, const sheet::FilterOperator eOp) +{ + using namespace ::com::sun::star::sheet; + + switch ( eOp ) + { + case FilterOperator_EMPTY: + rEntry.eOp = SC_EQUAL; + rEntry.nVal = SC_EMPTYFIELDS; + rEntry.bQueryByString = false; + *rEntry.pStr = EMPTY_STRING; + break; + case FilterOperator_NOT_EMPTY: + rEntry.eOp = SC_EQUAL; + rEntry.nVal = SC_NONEMPTYFIELDS; + rEntry.bQueryByString = FALSE; + *rEntry.pStr = EMPTY_STRING; + break; + case FilterOperator_EQUAL: + rEntry.eOp = SC_EQUAL; + break; + case FilterOperator_NOT_EQUAL: + rEntry.eOp = SC_NOT_EQUAL; + break; + case FilterOperator_GREATER: + rEntry.eOp = SC_GREATER; + break; + case FilterOperator_GREATER_EQUAL: + rEntry.eOp = SC_GREATER_EQUAL; + break; + case FilterOperator_LESS: + rEntry.eOp = SC_LESS; + break; + case FilterOperator_LESS_EQUAL: + rEntry.eOp = SC_LESS_EQUAL; + break; + case FilterOperator_TOP_VALUES: + rEntry.eOp = SC_TOPVAL; + break; + case FilterOperator_TOP_PERCENT: + rEntry.eOp = SC_TOPPERC; + break; + case FilterOperator_BOTTOM_VALUES: + rEntry.eOp = SC_BOTVAL; + break; + case FilterOperator_BOTTOM_PERCENT: + rEntry.eOp = SC_BOTPERC; + break; + default: + DBG_ERROR("lclTranslateOperator: unexpected enum value"); + rEntry.eOp = SC_EQUAL; + } +} + +void ScExtendedFilterDescriptor::addField( const sheet::TableFilterField& aField ) +{ + ScQueryEntry aEntry; + aEntry.pStr = new String; + aEntry.bDoQuery = true; + aEntry.eConnect = (aField.Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR; + aEntry.nField = aField.Field; + aEntry.bQueryByString = !aField.IsNumeric; + *aEntry.pStr = String( aField.StringValue ); + aEntry.nVal = aField.NumericValue; + + if ( !aEntry.bQueryByString ) + mrDoc.GetFormatTable()->GetInputLineString(aEntry.nVal, 0, *aEntry.pStr); + + lclTranslateOperator(aEntry, aField.Operator); + + maParamList.push_back(aEntry); +} + +void ScExtendedFilterDescriptor::addMultiStringField( const sheet::TableMultiStringFilterField& aField ) +{ + sal_Int32 nSize = aField.StringSet.getLength(); + + if ( !nSize ) + return; + + ScQueryEntry aEntry; + aEntry.pStr = new String; + aEntry.bDoQuery = true; + aEntry.eConnect = (aField.Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR; + aEntry.nField = aField.Field; + aEntry.bQueryByString = true; + *aEntry.pStr = String( aField.StringSet[0] ); + aEntry.nVal = 0; + aEntry.eOp = SC_EQUAL; + + for ( sal_Int32 i = 0; i < nSize; ++i ) + aEntry.aStrValues.insert( aField.StringSet[i] ); + + maParamList.push_back(aEntry); +} + +void ScExtendedFilterDescriptor::commit() +{ + ScQueryParam aParam; + mpParent->GetData(aParam); + + ::std::list::const_iterator itr = maParamList.begin(), itrEnd = maParamList.end(); + for ( size_t i = 0; i < MAXQUERY; ++i, ++itr ) + { + if ( itr != itrEnd ) + aParam.GetEntry(i) = *itr; + else + aParam.GetEntry(i).bDoQuery = false; + } + + mpParent->PutData(aParam); +} --- /dev/null 2007-03-30 11:25:40.000000000 -0400 +++ offapi/com/sun/star/sheet/XExtendedSheetFilterDescriptor.idl 2007-06-15 15:42:51.000000000 -0400 @@ -0,0 +1,81 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: XSheetFilterDescriptor.idl,v $ + * + * $Revision: 1.8 $ + * + * last change: $Author: rt $ $Date: 2005/09/08 05:19:41 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_XExtendedSheetFilterDescriptor_idl__ +#define __com_sun_star_sheet_XExtendedSheetFilterDescriptor_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +#ifndef __com_sun_star_sheet_TableMultiStringFilterField_idl__ +#include +#endif + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** provides access to a collection of filter conditions (filter fields). + + @see com::sun::star::sheet::SheetFilterDescriptor + */ +published interface XExtendedSheetFilterDescriptor +{ + //------------------------------------------------------------------------- + + void begin(); + + //------------------------------------------------------------------------- + + void commit(); + + //------------------------------------------------------------------------- + + void addFilterField( [in] com::sun::star::sheet::TableFilterField aField ); + + //------------------------------------------------------------------------- + + void addMultiStringFilterField( [in] com::sun::star::sheet::TableMultiStringFilterField aField ); +}; + +//============================================================================= + +}; }; }; }; + +#endif + --- /dev/null 2007-03-30 11:25:40.000000000 -0400 +++ offapi/com/sun/star/sheet/TableMultiStringFilterField.idl 2007-06-15 15:43:30.000000000 -0400 @@ -0,0 +1,70 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TableFilterField.idl,v $ + * + * $Revision: 1.6 $ + * + * last change: $Author: rt $ $Date: 2005/09/08 04:58:16 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_TableMultiStringFilterField_idl__ +#define __com_sun_star_sheet_TableMultiStringFilterField_idl__ + +#ifndef __com_sun_star_sheet_TableFilterField_idl__ +#include +#endif + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** describes a single condition in a filter descriptor that contains a set of + multiple string values. When this struct is used instead of the regular + TableFilterField, the filter compares each cell content for textual equality + against one of the string values provided. + + @see com::sun::star::sheet::SheetFilterDescriptor + */ +published struct TableMultiStringFilterField: TableFilterField +{ + //------------------------------------------------------------------------- + + /** contains a set of multiple string values to be used for filter evaluation. + */ + sequence< string > StringSet; +}; + +//============================================================================= + +}; }; }; }; + +#endif +