diff -uNr old/offapi/com/sun/star/sheet/FilterOperator2.idl new/offapi/com/sun/star/sheet/FilterOperator2.idl --- old/offapi/com/sun/star/sheet/FilterOperator2.idl 1970-01-01 08:00:00.000000000 +0800 +++ new/offapi/com/sun/star/sheet/FilterOperator2.idl 2009-05-19 16:10:28.000000000 +0800 @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FilterOperator2.idl,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_FilterOperator2_idl__ +#define __com_sun_star_sheet_FilterOperator2_idl__ + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** specifies the type of a single condition in a filter descriptor. + +

This constants group extends the FilterOperator enum by + additional filter operators.

+ + @since OOo 3.2 + */ +published constants FilterOperator2 +{ + + //------------------------------------------------------------------------- + + /** selects empty entries. + */ + const long EMPTY = 0; + + //------------------------------------------------------------------------- + + /** selects non-empty entries. + */ + const long NOT_EMPTY = 1; + + //------------------------------------------------------------------------- + + /** value has to be equal to the specified value. + */ + const long EQUAL = 2; + + //------------------------------------------------------------------------- + + /** value must not be equal to the specified value. + */ + const long NOT_EQUAL = 3; + + //------------------------------------------------------------------------- + + /** value has to be greater than the specified value. + */ + const long GREATER = 4; + + //------------------------------------------------------------------------- + + /** value has to be greater than or equal to the specified value. + */ + const long GREATER_EQUAL = 5; + + //------------------------------------------------------------------------- + + /** value has to be less than the specified value. + */ + const long LESS = 6; + + //------------------------------------------------------------------------- + + /** value has to be less than or equal to the specified value. + */ + const long LESS_EQUAL = 7; + + //------------------------------------------------------------------------- + + /** selects a specified number of entries with the greatest values. + */ + const long TOP_VALUES = 8; + + //------------------------------------------------------------------------- + + /** selects a specified percentage of entries with the greatest values. + */ + const long TOP_PERCENT = 9; + + //------------------------------------------------------------------------- + + /** selects a specified number of entries with the lowest values. + */ + const long BOTTOM_VALUES = 10; + + //------------------------------------------------------------------------- + + /** selects a specified percentage of entries with the lowest values. + */ + const long BOTTOM_PERCENT = 11; + + //------------------------------------------------------------------------- + + /** selects contains entries. + */ + const long CONTAINS = 12; + + //------------------------------------------------------------------------- + + /** selects does-not-contain entries. + */ + const long DOES_NOT_CONTAIN = 13; + + //------------------------------------------------------------------------- + + /** selects begins-with entries. + */ + const long BEGINS_WITH = 14; + + //------------------------------------------------------------------------- + + /** selects does-not-begin-with entries. + */ + const long DOES_NOT_BEGIN_WITH = 15; + //------------------------------------------------------------------------- + + /** selects ends-with entries. + */ + const long ENDS_WITH = 16; + + //------------------------------------------------------------------------- + + /** selects does-not-end-with entries. + */ + const long DOES_NOT_END_WITH = 17; + +}; + +//============================================================================= + +}; }; }; }; + +#endif + diff -uNr old/offapi/com/sun/star/sheet/makefile.mk new/offapi/com/sun/star/sheet/makefile.mk --- old/offapi/com/sun/star/sheet/makefile.mk 2009-05-31 11:21:40.000000000 +0800 +++ new/offapi/com/sun/star/sheet/makefile.mk 2009-06-02 10:32:22.000000000 +0800 @@ -138,6 +138,7 @@ FillMode.idl\ FilterConnection.idl\ FilterOperator.idl\ + FilterOperator2.idl\ FormulaLanguage.idl\ FormulaMapGroup.idl\ FormulaMapGroupSpecialOffset.idl\ @@ -219,6 +220,7 @@ TableConditionalEntryEnumeration.idl\ TableConditionalFormat.idl\ TableFilterField.idl\ + TableFilterField2.idl\ TableOperationMode.idl\ TablePageBreakData.idl\ TablePageStyle.idl\ @@ -315,6 +317,7 @@ XSheetConditionalEntries.idl\ XSheetConditionalEntry.idl\ XSheetFilterDescriptor.idl\ + XSheetFilterDescriptor2.idl\ XSheetFilterable.idl\ XSheetFilterableEx.idl\ XSheetLinkable.idl\ diff -uNr old/offapi/com/sun/star/sheet/TableFilterField2.idl new/offapi/com/sun/star/sheet/TableFilterField2.idl --- old/offapi/com/sun/star/sheet/TableFilterField2.idl 1970-01-01 08:00:00.000000000 +0800 +++ new/offapi/com/sun/star/sheet/TableFilterField2.idl 2009-05-19 16:10:58.000000000 +0800 @@ -0,0 +1,106 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TableFilterField2.idl,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_TableFilterField2_idl__ +#define __com_sun_star_sheet_TableFilterField2_idl__ + + +#ifndef __com_sun_star_sheet_FilterConnection_idl__ +#include +#endif + +#ifndef __com_sun_star_sheet_FilterOperator2_idl__ +#include +#endif + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** describes a single condition in a filter descriptor. + +

This struct has the FilterOperator2 constants group as + member, whereas the TableFilterField struct uses the + FilterOperator enum.

+ + @see com::sun::star::sheet::SheetFilterDescriptor + @since OOo 3.2 + */ +published struct TableFilterField2 +{ + //------------------------------------------------------------------------- + + /** specifies how the condition is connected to the previous condition. + */ + com::sun::star::sheet::FilterConnection Connection; + + //------------------------------------------------------------------------- + + /** specifies which field (column) is used for the condition. + */ + long Field; + + //------------------------------------------------------------------------- + + /** specifies the type of the condition as defined in + FilterOperator2. + */ + long Operator; + + //------------------------------------------------------------------------- + + /** selects whether the TableFilterField2::NumericValue + or the TableFilterField2::StringValue is used. + */ + boolean IsNumeric; + + //------------------------------------------------------------------------- + + /** specifies a numeric value for the condition. + */ + double NumericValue; + + //------------------------------------------------------------------------- + + /** specifies a string value for the condition. + */ + string StringValue; + +}; + +//============================================================================= + +}; }; }; }; + + +#endif + diff -uNr old/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl new/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl --- old/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl 1970-01-01 08:00:00.000000000 +0800 +++ new/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl 2009-05-19 16:11:29.000000000 +0800 @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: XSheetFilterDescriptor2.idl,v $ + * $Revision: 1.9 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_XSheetFilterDescriptor2_idl__ +#define __com_sun_star_sheet_XSheetFilterDescriptor2_idl__ + +#ifndef __com_sun_star_sheet_TableFilterField2_idl__ +#include +#endif + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** provides access to a collection of filter conditions (filter fields). + +

This interface uses the TableFilterField2 struct, + whereas the XSheetFilterDescriptor interface uses the + TableFilterField struct.

+ + @see com::sun::star::sheet::SheetFilterDescriptor + @since OOo 3.2 + */ +published interface XSheetFilterDescriptor2: com::sun::star::uno::XInterface +{ + //------------------------------------------------------------------------- + + /** returns the collection of filter fields. + */ + sequence< com::sun::star::sheet::TableFilterField2 > getFilterFields2(); + + //------------------------------------------------------------------------- + + /** sets a new collection of filter fields. + */ + void setFilterFields2( + [in] sequence< com::sun::star::sheet::TableFilterField2 > aFilterFields ); + +}; + +//============================================================================= + +}; }; }; }; + +#endif + diff -uNr old/sc/inc/datauno.hxx new/sc/inc/datauno.hxx --- old/sc/inc/datauno.hxx 2009-03-12 18:06:11.000000000 +0800 +++ new/sc/inc/datauno.hxx 2009-05-19 09:37:55.000000000 +0800 @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -340,8 +341,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::XSheetFilterDescriptor2, com::sun::star::beans::XPropertySet, com::sun::star::lang::XServiceInfo >, public SfxListener @@ -368,6 +370,13 @@ ::com::sun::star::sheet::TableFilterField >& aFilterFields ) throw(::com::sun::star::uno::RuntimeException); + // XSheetFilterDescriptor2 + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::TableFilterField2 > SAL_CALL + getFilterFields2() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFilterFields2( const ::com::sun::star::uno::Sequence< + ::com::sun::star::sheet::TableFilterField2 >& aFilterFields ) + throw(::com::sun::star::uno::RuntimeException); + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() diff -uNr old/sc/inc/global.hxx new/sc/inc/global.hxx --- old/sc/inc/global.hxx 2009-05-31 10:51:35.000000000 +0800 +++ new/sc/inc/global.hxx 2009-06-02 10:36:38.000000000 +0800 @@ -727,7 +727,13 @@ SC_TOPVAL, SC_BOTVAL, SC_TOPPERC, - SC_BOTPERC + SC_BOTPERC, + SC_CONTAINS, + SC_DOES_NOT_CONTAIN, + SC_BEGINS_WITH, + SC_DOES_NOT_BEGIN_WITH, + SC_ENDS_WITH, + SC_DOES_NOT_END_WITH }; // ----------------------------------------------------------------------- diff -uNr old/sc/source/core/data/table3.cxx new/sc/source/core/data/table3.cxx --- old/sc/source/core/data/table3.cxx 2009-05-31 10:45:14.000000000 +0800 +++ new/sc/source/core/data/table3.cxx 2009-06-02 10:40:34.000000000 +0800 @@ -1022,12 +1022,19 @@ } } else if ( (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL) || + (rEntry.eOp == SC_CONTAINS || rEntry.eOp == SC_DOES_NOT_CONTAIN || + rEntry.eOp == SC_BEGINS_WITH || rEntry.eOp == SC_ENDS_WITH || + rEntry.eOp == SC_DOES_NOT_BEGIN_WITH || rEntry.eOp == SC_DOES_NOT_END_WITH) || (rEntry.bQueryByString && (pCell ? pCell->HasStringData() : HasStringData( static_cast(rEntry.nField), nRow)))) { // by String String aCellStr; + if( rEntry.eOp == SC_CONTAINS || rEntry.eOp == SC_DOES_NOT_CONTAIN + || rEntry.eOp == SC_BEGINS_WITH || rEntry.eOp == SC_ENDS_WITH + || rEntry.eOp == SC_DOES_NOT_BEGIN_WITH || rEntry.eOp == SC_DOES_NOT_END_WITH ) + bMatchWholeCell = FALSE; if ( pCell ) { if (pCell->GetCellType() != CELLTYPE_NOTE) @@ -1040,7 +1047,10 @@ GetInputString( static_cast(rEntry.nField), nRow, aCellStr ); BOOL bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL) - || (rEntry.eOp == SC_NOT_EQUAL))); + || (rEntry.eOp == SC_NOT_EQUAL) || (rEntry.eOp == SC_CONTAINS) + || (rEntry.eOp == SC_DOES_NOT_CONTAIN) || (rEntry.eOp == SC_BEGINS_WITH) + || (rEntry.eOp == SC_ENDS_WITH) || (rEntry.eOp == SC_DOES_NOT_BEGIN_WITH) + || (rEntry.eOp == SC_DOES_NOT_END_WITH))); BOOL bTestRegExp = (pbTestEqualCondition && rParam.bRegExp && ((rEntry.eOp == SC_LESS_EQUAL) || (rEntry.eOp == SC_GREATER_EQUAL))); @@ -1048,20 +1058,61 @@ { 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 + BOOL bMatch = FALSE; + if ( rEntry.eOp == SC_ENDS_WITH || rEntry.eOp == SC_DOES_NOT_END_WITH ) + { + nEnd = 0; + nStart = aCellStr.Len(); + bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens ) + ->SearchBkwrd( aCellStr, &nStart, &nEnd ); + } + else + { + bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens ) + ->SearchFrwrd( aCellStr, &nStart, &nEnd ); + } 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); + switch (rEntry.eOp) + { + case SC_EQUAL: + case SC_CONTAINS: + bOk = bMatch; + break; + case SC_NOT_EQUAL: + case SC_DOES_NOT_CONTAIN: + bOk = !bMatch; + break; + case SC_BEGINS_WITH: + bOk = ( bMatch && (nStart == 0) ); + break; + case SC_DOES_NOT_BEGIN_WITH: + bOk = !( bMatch && (nStart == 0) ); + break; + case SC_ENDS_WITH: + bOk = ( bMatch && (nEnd == aCellStr.Len()) ); + break; + case SC_DOES_NOT_END_WITH: + bOk = !( bMatch && (nEnd == aCellStr.Len()) ); + break; + default: + { + // added to avoid warnings + } + } else bTestEqual = bMatch; } if ( !bRealRegExp ) { - if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL ) + if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL + || rEntry.eOp == SC_CONTAINS || rEntry.eOp == SC_DOES_NOT_CONTAIN + || rEntry.eOp == SC_BEGINS_WITH || rEntry.eOp == SC_ENDS_WITH + || rEntry.eOp == SC_DOES_NOT_BEGIN_WITH || rEntry.eOp == SC_DOES_NOT_END_WITH ) { if ( !rEntry.bQueryByString && rEntry.pStr->Len() == 0 ) { @@ -1069,9 +1120,15 @@ // 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.eOp == SC_NOT_EQUAL ) + bOk = !bOk; } else if ( bMatchWholeCell ) + { bOk = pTransliteration->isEqual( aCellStr, *rEntry.pStr ); + if ( rEntry.eOp == SC_NOT_EQUAL ) + bOk = !bOk; + } else { ::com::sun::star::uno::Sequence< sal_Int32 > xOff; @@ -1081,10 +1138,37 @@ String aQuer( pTransliteration->transliterate( *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(), &xOff ) ); - bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND); + xub_StrLen nIndex = (rEntry.eOp == SC_ENDS_WITH + || rEntry.eOp == SC_DOES_NOT_END_WITH)? (aCell.Len()-aQuer.Len()):0; + xub_StrLen nStrPos = aCell.Search( aQuer, nIndex ); + switch (rEntry.eOp) + { + case SC_EQUAL: + case SC_CONTAINS: + bOk = ( nStrPos != STRING_NOTFOUND ); + break; + case SC_NOT_EQUAL: + case SC_DOES_NOT_CONTAIN: + bOk = ( nStrPos == STRING_NOTFOUND ); + break; + case SC_BEGINS_WITH: + bOk = ( nStrPos == 0 ); + break; + case SC_DOES_NOT_BEGIN_WITH: + bOk = ( nStrPos != 0 ); + break; + case SC_ENDS_WITH: + bOk = ( nStrPos + aQuer.Len() == aCell.Len() ); + break; + case SC_DOES_NOT_END_WITH: + bOk = ( nStrPos + aQuer.Len() != aCell.Len() ); + break; + default: + { + // added to avoid warnings + } + } } - if ( rEntry.eOp == SC_NOT_EQUAL ) - bOk = !bOk; } else { // use collator here because data was probably sorted diff -uNr old/sc/source/filter/excel/excimp8.cxx new/sc/source/filter/excel/excimp8.cxx --- old/sc/source/filter/excel/excimp8.cxx 2009-03-12 18:02:50.000000000 +0800 +++ new/sc/source/filter/excel/excimp8.cxx 2009-03-24 15:58:36.000000000 +0800 @@ -426,6 +426,38 @@ } } +static void ExcelQueryToOooQuery( ScQueryEntry& rEntry ) +{ + if( ( rEntry.eOp != SC_EQUAL && rEntry.eOp != SC_NOT_EQUAL ) || rEntry.pStr == NULL ) + return; + else + { + xub_StrLen nLen = rEntry.pStr->Len(); + sal_Unicode nStart = rEntry.pStr->GetChar( 0 ); + sal_Unicode nEnd = rEntry.pStr->GetChar( nLen-1 ); + if( nLen >2 && nStart == '*' && nEnd == '*' ) + { + rEntry.pStr->Erase( nLen-1, 1 ); + rEntry.pStr->Erase( 0, 1 ); + rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_CONTAINS : SC_DOES_NOT_CONTAIN; + } + else if( nLen > 1 && nStart == '*' && nEnd != '*' ) + { + rEntry.pStr->Erase( 0, 1 ); + rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_ENDS_WITH : SC_DOES_NOT_END_WITH; + } + else if( nLen > 1 && nStart != '*' && nEnd == '*' ) + { + rEntry.pStr->Erase( nLen-1, 1 ); + rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_BEGINS_WITH : SC_DOES_NOT_BEGIN_WITH; + } + else if( nLen == 2 && nStart == '*' && nEnd == '*' ) + { + rEntry.pStr->Erase( 0, 1 ); + } + } +} + void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm ) { UINT16 nCol, nFlags; @@ -463,14 +495,14 @@ BOOL bIgnore; UINT8 nStrLen[ 2 ] = { 0, 0 }; - String* pEntryStr[ 2 ] = { NULL, NULL }; + ScQueryEntry *pQueryEntries[ 2 ] = { NULL, NULL }; for( nE = 0; nE < 2; nE++ ) { if( nFirstEmpty < nCount ) { ScQueryEntry& aEntry = aParam.GetEntry( nFirstEmpty ); - pEntryStr[ nE ] = aEntry.pStr; + pQueryEntries[ nE ] = &aEntry; bIgnore = FALSE; rStrm >> nType >> nOper; @@ -558,8 +590,12 @@ } for( nE = 0; nE < 2; nE++ ) - if( nStrLen[ nE ] && pEntryStr[ nE ] ) - pEntryStr[ nE ]->Assign( rStrm.ReadUniString( nStrLen[ nE ] ) ); + if( nStrLen[ nE ] && pQueryEntries[ nE ] ) + { + pQueryEntries[ nE ]->pStr->Assign ( rStrm.ReadUniString( nStrLen[ nE ] ) ); + ExcelQueryToOooQuery( *pQueryEntries[ nE ] ); + } + } } diff -uNr old/sc/source/filter/excel/excrecds.cxx new/sc/source/filter/excel/excrecds.cxx --- old/sc/source/filter/excel/excrecds.cxx 2009-03-12 18:02:50.000000000 +0800 +++ new/sc/source/filter/excel/excrecds.cxx 2009-03-24 15:57:52.000000000 +0800 @@ -699,7 +699,31 @@ String sText; if( rEntry.pStr ) - sText.Assign( *rEntry.pStr ); + { + sText.Assign( *rEntry.pStr ); + switch( rEntry.eOp ) + { + case SC_CONTAINS: + case SC_DOES_NOT_CONTAIN: + { + sText.InsertAscii( "*" , 0 ); + sText.AppendAscii( "*" ); + } + break; + case SC_BEGINS_WITH: + case SC_DOES_NOT_BEGIN_WITH: + sText.AppendAscii( "*" ); + break; + case SC_ENDS_WITH: + case SC_DOES_NOT_END_WITH: + sText.InsertAscii( "*" , 0 ); + break; + default: + { + //nothing + } + } + } BOOL bLen = sText.Len() > 0; @@ -759,6 +783,14 @@ case SC_LESS_EQUAL: nOper = EXC_AFOPER_LESSEQUAL; break; case SC_GREATER_EQUAL: nOper = EXC_AFOPER_GREATEREQUAL; break; case SC_NOT_EQUAL: nOper = EXC_AFOPER_NOTEQUAL; break; + case SC_CONTAINS: + case SC_BEGINS_WITH: + case SC_ENDS_WITH: + nOper = EXC_AFOPER_EQUAL; break; + case SC_DOES_NOT_CONTAIN: + case SC_DOES_NOT_BEGIN_WITH: + case SC_DOES_NOT_END_WITH: + nOper = EXC_AFOPER_NOTEQUAL; break; default:; } bConflict = !AddCondition( rEntry.eConnect, nType, nOper, fVal, pText ); diff -uNr old/sc/source/filter/xml/xmldrani.cxx new/sc/source/filter/xml/xmldrani.cxx --- old/sc/source/filter/xml/xmldrani.cxx 2009-05-31 10:45:02.000000000 +0800 +++ new/sc/source/filter/xml/xmldrani.cxx 2009-06-02 10:48:52.000000000 +0800 @@ -381,7 +381,8 @@ pDBData->SetSortParam(aSortParam); } - uno::Reference xSheetFilterDescriptor(xDatabaseRange->getFilterDescriptor()); + uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor( + xDatabaseRange->getFilterDescriptor(), uno::UNO_QUERY ); if (xSheetFilterDescriptor.is()) { uno::Reference xFilterPropertySet (xSheetFilterDescriptor, uno::UNO_QUERY); @@ -396,7 +397,7 @@ xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_USEREGEX)), uno::makeAny(bFilterUseRegularExpressions)); xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_OUTPOS)), uno::makeAny(aFilterOutputPosition)); } - xSheetFilterDescriptor->setFilterFields(aFilterFields); + xSheetFilterDescriptor->setFilterFields2(aFilterFields); if (bFilterConditionSourceRange) { ScRange aAdvSource; diff -uNr old/sc/source/filter/xml/xmldrani.hxx new/sc/source/filter/xml/xmldrani.hxx --- old/sc/source/filter/xml/xmldrani.hxx 2009-03-12 18:02:56.000000000 +0800 +++ new/sc/source/filter/xml/xmldrani.hxx 2009-03-24 15:33:09.000000000 +0800 @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -79,7 +79,7 @@ rtl::OUString sDatabaseName; rtl::OUString sSourceObject; com::sun::star::uno::Sequence aSortSequence; - com::sun::star::uno::Sequence aFilterFields; + com::sun::star::uno::Sequence aFilterFields; std::vector < ScSubTotalRule > aSubTotalRules; com::sun::star::table::CellAddress aFilterOutputPosition; com::sun::star::table::CellRangeAddress aFilterConditionSourceRangeAddress; @@ -146,7 +146,7 @@ void SetFilterIsCaseSensitive(const sal_Bool bTemp) { bFilterIsCaseSensitive = bTemp; } void SetFilterSkipDuplicates(const sal_Bool bTemp) { bFilterSkipDuplicates = bTemp; } void SetFilterUseRegularExpressions(const sal_Bool bTemp) { bFilterUseRegularExpressions = bTemp; } - void SetFilterFields(const com::sun::star::uno::Sequence & aTemp) { aFilterFields = aTemp; } + void SetFilterFields(const com::sun::star::uno::Sequence & aTemp) { aFilterFields = aTemp; } void SetFilterOutputPosition(const com::sun::star::table::CellAddress& aTemp) { aFilterOutputPosition = aTemp; } void SetFilterConditionSourceRangeAddress(const com::sun::star::table::CellRangeAddress& aTemp) { aFilterConditionSourceRangeAddress = aTemp; bFilterConditionSourceRange = sal_True; } diff -uNr old/sc/source/filter/xml/XMLExportDatabaseRanges.cxx new/sc/source/filter/xml/XMLExportDatabaseRanges.cxx --- old/sc/source/filter/xml/XMLExportDatabaseRanges.cxx 2009-05-31 10:45:02.000000000 +0800 +++ new/sc/source/filter/xml/XMLExportDatabaseRanges.cxx 2009-06-02 10:47:19.000000000 +0800 @@ -203,44 +203,56 @@ } } -rtl::OUString ScXMLExportDatabaseRanges::getOperatorXML(const sheet::FilterOperator aFilterOperator, const sal_Bool bUseRegularExpressions) const +rtl::OUString ScXMLExportDatabaseRanges::getOperatorXML(const long aFilterOperator, const sal_Bool bUseRegularExpressions) const { - switch (aFilterOperator) - { - case sheet::FilterOperator_EQUAL : - { - if (bUseRegularExpressions) - return GetXMLToken(XML_MATCH); - else - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); - } - case sheet::FilterOperator_NOT_EQUAL : - { - if (bUseRegularExpressions) - return GetXMLToken(XML_NOMATCH); - else - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!=")); - } - case sheet::FilterOperator_BOTTOM_PERCENT : - return GetXMLToken(XML_BOTTOM_PERCENT); - case sheet::FilterOperator_BOTTOM_VALUES : - return GetXMLToken(XML_BOTTOM_VALUES); - case sheet::FilterOperator_EMPTY : - return GetXMLToken(XML_EMPTY); - case sheet::FilterOperator_GREATER : - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">")); - case sheet::FilterOperator_GREATER_EQUAL : - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">=")); - case sheet::FilterOperator_LESS : - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<")); - case sheet::FilterOperator_LESS_EQUAL : - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<=")); - case sheet::FilterOperator_NOT_EMPTY : - return GetXMLToken(XML_NOEMPTY); - case sheet::FilterOperator_TOP_PERCENT : - return GetXMLToken(XML_TOP_PERCENT); - case sheet::FilterOperator_TOP_VALUES : - return GetXMLToken(XML_TOP_VALUES); + switch (aFilterOperator) + { + case sheet::FilterOperator2::EQUAL : + { + if (bUseRegularExpressions) + return GetXMLToken(XML_MATCH); + else + return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); + } + case sheet::FilterOperator2::NOT_EQUAL : + { + if (bUseRegularExpressions) + return GetXMLToken(XML_NOMATCH); + else + return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!=")); + } + case sheet::FilterOperator2::BOTTOM_PERCENT : + return GetXMLToken(XML_BOTTOM_PERCENT); + case sheet::FilterOperator2::BOTTOM_VALUES : + return GetXMLToken(XML_BOTTOM_VALUES); + case sheet::FilterOperator2::EMPTY : + return GetXMLToken(XML_EMPTY); + case sheet::FilterOperator2::GREATER : + return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">")); + case sheet::FilterOperator2::GREATER_EQUAL : + return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">=")); + case sheet::FilterOperator2::LESS : + return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<")); + case sheet::FilterOperator2::LESS_EQUAL : + return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<=")); + case sheet::FilterOperator2::NOT_EMPTY : + return GetXMLToken(XML_NOEMPTY); + case sheet::FilterOperator2::TOP_PERCENT : + return GetXMLToken(XML_TOP_PERCENT); + case sheet::FilterOperator2::TOP_VALUES : + return GetXMLToken(XML_TOP_VALUES); + case sheet::FilterOperator2::CONTAINS : + return GetXMLToken(XML_CONTAINS); + case sheet::FilterOperator2::DOES_NOT_CONTAIN : + return GetXMLToken(XML_DOES_NOT_CONTAIN); + case sheet::FilterOperator2::BEGINS_WITH : + return GetXMLToken(XML_BEGINS_WITH); + case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH : + return GetXMLToken(XML_DOES_NOT_BEGIN_WITH); + case sheet::FilterOperator2::ENDS_WITH : + return GetXMLToken(XML_ENDS_WITH); + case sheet::FilterOperator2::DOES_NOT_END_WITH : + return GetXMLToken(XML_DOES_NOT_END_WITH); default: { // added to avoid warnings @@ -249,7 +261,7 @@ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); } -void ScXMLExportDatabaseRanges::WriteCondition(const sheet::TableFilterField& aFilterField, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions) +void ScXMLExportDatabaseRanges::WriteCondition(const sheet::TableFilterField2& aFilterField, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions) { rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, rtl::OUString::valueOf(aFilterField.Field)); if (bIsCaseSensitive) @@ -267,9 +279,9 @@ SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, sal_True, sal_True); } -void ScXMLExportDatabaseRanges::WriteFilterDescriptor(const uno::Reference & xSheetFilterDescriptor, const rtl::OUString sDatabaseRangeName) +void ScXMLExportDatabaseRanges::WriteFilterDescriptor(const uno::Reference & xSheetFilterDescriptor, const rtl::OUString sDatabaseRangeName) { - uno::Sequence aTableFilterFields(xSheetFilterDescriptor->getFilterFields()); + uno::Sequence< sheet::TableFilterField2 > aTableFilterFields( xSheetFilterDescriptor->getFilterFields2() ); sal_Int32 nTableFilterFields = aTableFilterFields.getLength(); if (nTableFilterFields > 0) { @@ -336,7 +348,7 @@ else { SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_OR, sal_True, sal_True); - sheet::TableFilterField aPrevFilterField = aTableFilterFields[0]; + sheet::TableFilterField2 aPrevFilterField = aTableFilterFields[0]; sheet::FilterConnection aConnection = aTableFilterFields[1].Connection; sal_Bool bOpenAndElement; rtl::OUString aName = rExport.GetNamespaceMap().GetQNameByKey(XML_NAMESPACE_TABLE, GetXMLToken(XML_FILTER_AND)); @@ -632,7 +644,9 @@ if (::cppu::any2bool(xPropertySetDatabaseRange->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_STRIPDAT))))) rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_HAS_PERSISTENT_DATA, XML_FALSE); } - uno::Reference xSheetFilterDescriptor(xDatabaseRange->getFilterDescriptor()); + + uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor( + xDatabaseRange->getFilterDescriptor(), uno::UNO_QUERY ); uno::Sequence aSortProperties(xDatabaseRange->getSortDescriptor()); if (xSheetFilterDescriptor.is()) { diff -uNr old/sc/source/filter/xml/XMLExportDatabaseRanges.hxx new/sc/source/filter/xml/XMLExportDatabaseRanges.hxx --- old/sc/source/filter/xml/XMLExportDatabaseRanges.hxx 2009-03-12 18:02:56.000000000 +0800 +++ new/sc/source/filter/xml/XMLExportDatabaseRanges.hxx 2009-03-24 15:45:02.000000000 +0800 @@ -33,9 +33,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -49,9 +49,9 @@ ScDocument* pDoc; void WriteImportDescriptor(const com::sun::star::uno::Sequence aImportDescriptor); - rtl::OUString getOperatorXML(const com::sun::star::sheet::FilterOperator aFilterOperator, const sal_Bool bUseRegularExpressions) const; - void WriteCondition(const com::sun::star::sheet::TableFilterField& aFilterField, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions); - void WriteFilterDescriptor(const com::sun::star::uno::Reference & xSheetFilterDescriptor, const rtl::OUString sDatabaseRangeName); + rtl::OUString getOperatorXML(const long aFilterOperator, const sal_Bool bUseRegularExpressions) const; + void WriteCondition(const com::sun::star::sheet::TableFilterField2& aFilterField, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions); + void WriteFilterDescriptor(const com::sun::star::uno::Reference & xSheetFilterDescriptor, const rtl::OUString sDatabaseRangeName); void WriteSortDescriptor(const com::sun::star::uno::Sequence aSortProperties); void WriteSubTotalDescriptor(const com::sun::star::uno::Reference xSubTotalDescriptor, const rtl::OUString sDatabaseRangeName); public: diff -uNr old/sc/source/filter/xml/xmlfilti.cxx new/sc/source/filter/xml/xmlfilti.cxx --- old/sc/source/filter/xml/xmlfilti.cxx 2009-05-31 10:45:02.000000000 +0800 +++ new/sc/source/filter/xml/xmlfilti.cxx 2009-06-02 10:50:40.000000000 +0800 @@ -335,48 +335,60 @@ return new SvXMLImportContext( GetImport(), nPrefix, rLName ); } -void ScXMLConditionContext::getOperatorXML(const rtl::OUString sTempOperator, sheet::FilterOperator& aFilterOperator, sal_Bool& bUseRegularExpressions) const +void ScXMLConditionContext::getOperatorXML(const rtl::OUString sTempOperator, long& aFilterOperator, sal_Bool& bUseRegularExpressions) const { - bUseRegularExpressions = sal_False; - if (IsXMLToken(sTempOperator, XML_MATCH)) - { - bUseRegularExpressions = sal_True; - aFilterOperator = sheet::FilterOperator_EQUAL; - } - else if (IsXMLToken(sTempOperator, XML_NOMATCH)) - { - bUseRegularExpressions = sal_True; - aFilterOperator = sheet::FilterOperator_NOT_EQUAL; - } - else if (sTempOperator.compareToAscii("=") == 0) - aFilterOperator = sheet::FilterOperator_EQUAL; - else if (sTempOperator.compareToAscii("!=") == 0) - aFilterOperator = sheet::FilterOperator_NOT_EQUAL; - else if (IsXMLToken(sTempOperator, XML_BOTTOM_PERCENT)) - aFilterOperator = sheet::FilterOperator_BOTTOM_PERCENT; - else if (IsXMLToken(sTempOperator, XML_BOTTOM_VALUES)) - aFilterOperator = sheet::FilterOperator_BOTTOM_VALUES; - else if (IsXMLToken(sTempOperator, XML_EMPTY)) - aFilterOperator = sheet::FilterOperator_EMPTY; - else if (sTempOperator.compareToAscii(">") == 0) - aFilterOperator = sheet::FilterOperator_GREATER; - else if (sTempOperator.compareToAscii(">=") == 0) - aFilterOperator = sheet::FilterOperator_GREATER_EQUAL; - else if (sTempOperator.compareToAscii("<") == 0) - aFilterOperator = sheet::FilterOperator_LESS; - else if (sTempOperator.compareToAscii("<=") == 0) - aFilterOperator = sheet::FilterOperator_LESS_EQUAL; - else if (IsXMLToken(sTempOperator, XML_NOEMPTY)) - aFilterOperator = sheet::FilterOperator_NOT_EMPTY; - else if (IsXMLToken(sTempOperator, XML_TOP_PERCENT)) - aFilterOperator = sheet::FilterOperator_TOP_PERCENT; - else if (IsXMLToken(sTempOperator, XML_TOP_VALUES)) - aFilterOperator = sheet::FilterOperator_TOP_VALUES; + bUseRegularExpressions = sal_False; + if (IsXMLToken(sTempOperator, XML_MATCH)) + { + bUseRegularExpressions = sal_True; + aFilterOperator = sheet::FilterOperator2::EQUAL; + } + else if (IsXMLToken(sTempOperator, XML_NOMATCH)) + { + bUseRegularExpressions = sal_True; + aFilterOperator = sheet::FilterOperator2::NOT_EQUAL; + } + else if (sTempOperator.compareToAscii("=") == 0) + aFilterOperator = sheet::FilterOperator2::EQUAL; + else if (sTempOperator.compareToAscii("!=") == 0) + aFilterOperator = sheet::FilterOperator2::NOT_EQUAL; + else if (IsXMLToken(sTempOperator, XML_BOTTOM_PERCENT)) + aFilterOperator = sheet::FilterOperator2::BOTTOM_PERCENT; + else if (IsXMLToken(sTempOperator, XML_BOTTOM_VALUES)) + aFilterOperator = sheet::FilterOperator2::BOTTOM_VALUES; + else if (IsXMLToken(sTempOperator, XML_EMPTY)) + aFilterOperator = sheet::FilterOperator2::EMPTY; + else if (sTempOperator.compareToAscii(">") == 0) + aFilterOperator = sheet::FilterOperator2::GREATER; + else if (sTempOperator.compareToAscii(">=") == 0) + aFilterOperator = sheet::FilterOperator2::GREATER_EQUAL; + else if (sTempOperator.compareToAscii("<") == 0) + aFilterOperator = sheet::FilterOperator2::LESS; + else if (sTempOperator.compareToAscii("<=") == 0) + aFilterOperator = sheet::FilterOperator2::LESS_EQUAL; + else if (IsXMLToken(sTempOperator, XML_NOEMPTY)) + aFilterOperator = sheet::FilterOperator2::NOT_EMPTY; + else if (IsXMLToken(sTempOperator, XML_TOP_PERCENT)) + aFilterOperator = sheet::FilterOperator2::TOP_PERCENT; + else if (IsXMLToken(sTempOperator, XML_TOP_VALUES)) + aFilterOperator = sheet::FilterOperator2::TOP_VALUES; + else if (IsXMLToken(sTempOperator, XML_CONTAINS)) + aFilterOperator = sheet::FilterOperator2::CONTAINS; + else if (IsXMLToken(sTempOperator, XML_DOES_NOT_CONTAIN)) + aFilterOperator = sheet::FilterOperator2::DOES_NOT_CONTAIN; + else if (IsXMLToken(sTempOperator, XML_BEGINS_WITH)) + aFilterOperator = sheet::FilterOperator2::BEGINS_WITH; + else if (IsXMLToken(sTempOperator, XML_DOES_NOT_BEGIN_WITH)) + aFilterOperator = sheet::FilterOperator2::DOES_NOT_BEGIN_WITH; + else if (IsXMLToken(sTempOperator, XML_ENDS_WITH)) + aFilterOperator = sheet::FilterOperator2::ENDS_WITH; + else if (IsXMLToken(sTempOperator, XML_DOES_NOT_END_WITH)) + aFilterOperator = sheet::FilterOperator2::DOES_NOT_END_WITH; } void ScXMLConditionContext::EndElement() { - sheet::TableFilterField aFilterField; + sheet::TableFilterField2 aFilterField; if (pFilterContext->GetConnection()) aFilterField.Connection = sheet::FilterConnection_OR; else diff -uNr old/sc/source/filter/xml/xmlfilti.hxx new/sc/source/filter/xml/xmlfilti.hxx --- old/sc/source/filter/xml/xmlfilti.hxx 2009-03-12 18:02:56.000000000 +0800 +++ new/sc/source/filter/xml/xmlfilti.hxx 2009-03-24 15:46:16.000000000 +0800 @@ -36,7 +36,8 @@ #include #include #include -#include +#include +#include #include #include "xmldrani.hxx" @@ -48,7 +49,7 @@ { ScXMLDatabaseRangeContext* pDatabaseRangeContext; - com::sun::star::uno::Sequence aFilterFields; + com::sun::star::uno::Sequence aFilterFields; com::sun::star::table::CellAddress aOutputPosition; com::sun::star::table::CellRangeAddress aConditionSourceRangeAddress; sal_Int16 nUserListIndex; @@ -89,8 +90,8 @@ aConnectionOrStack.Push(pTemp);} void CloseConnection() { sal_Bool* pTemp = static_cast (aConnectionOrStack.Pop()); bConnectionOr = *pTemp; bNextConnectionOr = *pTemp; delete pTemp;} sal_Bool GetConnection() { sal_Bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; } - void AddFilterField (const com::sun::star::sheet::TableFilterField aFilterField) { aFilterFields.realloc(aFilterFields.getLength() + 1); - aFilterFields[aFilterFields.getLength() - 1] = aFilterField; } + void AddFilterField(const com::sun::star::sheet::TableFilterField2 aFilterField) { aFilterFields.realloc(aFilterFields.getLength() + 1); + aFilterFields[aFilterFields.getLength() - 1] = aFilterField; } }; class ScXMLAndContext : public SvXMLImportContext @@ -171,7 +172,7 @@ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - void getOperatorXML(const rtl::OUString sTempOperator, com::sun::star::sheet::FilterOperator& aFilterOperator, sal_Bool& bUseRegularExpressions) const; + void getOperatorXML(const rtl::OUString sTempOperator, long& aFilterOperator, sal_Bool& bUseRegularExpressions) const; virtual void EndElement(); }; diff -uNr old/sc/source/ui/src/filter.src new/sc/source/ui/src/filter.src --- old/sc/source/ui/src/filter.src 2009-05-31 10:50:42.000000000 +0800 +++ new/sc/source/ui/src/filter.src 2009-06-03 10:23:29.000000000 +0800 @@ -165,6 +165,12 @@ < "Smallest" ; Default ; > ; < "Largest %" ; Default ; > ; < "Smallest %" ; Default ; > ; + < "Contains" ; Default ; > ; + < "Does not contain" ; Default ; > ; + < "Begins with" ; Default ; > ; + < "Does not begin with" ; Default ; > ; + < "Ends with" ; Default ; > ; + < "Does not end with" ; Default ; > ; }; }; ListBox LB_COND2 @@ -186,6 +192,12 @@ < "Smallest" ; Default ; > ; < "Largest %" ; Default ; > ; < "Smallest %" ; Default ; > ; + < "Contains" ; Default ; > ; + < "Does not contain" ; Default ; > ; + < "Begins with" ; Default ; > ; + < "Does not begin with" ; Default ; > ; + < "Ends with" ; Default ; > ; + < "Does not end with" ; Default ; > ; }; }; ListBox LB_COND3 @@ -207,6 +219,12 @@ < "Smallest" ; Default ; > ; < "Largest %" ; Default ; > ; < "Smallest %" ; Default ; > ; + < "Contains" ; Default ; > ; + < "Does not contain" ; Default ; > ; + < "Begins with" ; Default ; > ; + < "Does not begin with" ; Default ; > ; + < "Ends with" ; Default ; > ; + < "Does not end with" ; Default ; > ; }; }; ListBox LB_COND4 @@ -228,6 +246,12 @@ < "Smallest" ; Default ; > ; < "Largest %" ; Default ; > ; < "Smallest %" ; Default ; > ; + < "Contains" ; Default ; > ; + < "Does not contain" ; Default ; > ; + < "Begins with" ; Default ; > ; + < "Does not begin with" ; Default ; > ; + < "Ends with" ; Default ; > ; + < "Does not end with" ; Default ; > ; }; }; ComboBox ED_VAL1 diff -uNr old/sc/source/ui/unoobj/cellsuno.cxx new/sc/source/ui/unoobj/cellsuno.cxx --- old/sc/source/ui/unoobj/cellsuno.cxx 2009-05-31 10:51:06.000000000 +0800 +++ new/sc/source/ui/unoobj/cellsuno.cxx 2009-06-02 10:55:28.000000000 +0800 @@ -5702,7 +5702,15 @@ ScDocShell* pDocSh = GetDocShell(); ScFilterDescriptor aImpl(pDocSh); - aImpl.setFilterFields( xDescriptor->getFilterFields() ); + uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY ); + if ( xDescriptor2.is() ) + { + aImpl.setFilterFields2( xDescriptor2->getFilterFields2() ); + } + else + { + aImpl.setFilterFields( xDescriptor->getFilterFields() ); + } // Rest sind jetzt Properties... uno::Reference xPropSet( xDescriptor, uno::UNO_QUERY ); diff -uNr old/sc/source/ui/unoobj/datauno.cxx new/sc/source/ui/unoobj/datauno.cxx --- old/sc/source/ui/unoobj/datauno.cxx 2009-03-12 18:04:52.000000000 +0800 +++ new/sc/source/ui/unoobj/datauno.cxx 2009-03-24 15:50:08.000000000 +0800 @@ -45,6 +45,8 @@ #include #include #include +#include +#include #include "datauno.hxx" #include "dapiuno.hxx" @@ -1106,7 +1108,7 @@ } } -// XSheetFilterDescriptor +// XSheetFilterDescriptor and XSheetFilterDescriptor2 uno::Sequence SAL_CALL ScFilterDescriptorBase::getFilterFields() throw(uno::RuntimeException) @@ -1177,6 +1179,80 @@ return aSeq; } +uno::Sequence SAL_CALL ScFilterDescriptorBase::getFilterFields2() +throw(uno::RuntimeException) +{ + ScUnoGuard aGuard; + ScQueryParam aParam; + GetData(aParam); + + SCSIZE nEntries = aParam.GetEntryCount(); // allozierte Eintraege im Param + SCSIZE nCount = 0; // aktive + while ( nCount < nEntries && + aParam.GetEntry(nCount).bDoQuery ) + ++nCount; + + sheet::TableFilterField2 aField; + uno::Sequence aSeq(static_cast(nCount)); + sheet::TableFilterField2* pAry = aSeq.getArray(); + for (SCSIZE i=0; i& aFilterFields ) throw(uno::RuntimeException) @@ -1251,6 +1327,86 @@ PutData(aParam); } +void SAL_CALL ScFilterDescriptorBase::setFilterFields2( + const uno::Sequence& aFilterFields ) + throw(uno::RuntimeException) +{ + ScUnoGuard aGuard; + ScQueryParam aParam; + GetData(aParam); + + SCSIZE nCount = static_cast(aFilterFields.getLength()); + DBG_ASSERT( nCount <= MAXQUERY, "setFilterFields: zu viele" ); + + aParam.Resize( nCount ); + + const sheet::TableFilterField2* pAry = aFilterFields.getConstArray(); + SCSIZE i; + for (i=0; iGetDocument()->GetFormatTable()->GetInputLineString(rEntry.nVal, 0, *rEntry.pStr); + } + + switch (pAry[i].Operator) // FilterOperator + { + case sheet::FilterOperator2::EQUAL: rEntry.eOp = SC_EQUAL; break; + case sheet::FilterOperator2::LESS: rEntry.eOp = SC_LESS; break; + case sheet::FilterOperator2::GREATER: rEntry.eOp = SC_GREATER; break; + case sheet::FilterOperator2::LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break; + case sheet::FilterOperator2::GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break; + case sheet::FilterOperator2::NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break; + case sheet::FilterOperator2::TOP_VALUES: rEntry.eOp = SC_TOPVAL; break; + case sheet::FilterOperator2::BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break; + case sheet::FilterOperator2::TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break; + case sheet::FilterOperator2::BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break; + case sheet::FilterOperator2::CONTAINS: rEntry.eOp = SC_CONTAINS; break; + case sheet::FilterOperator2::DOES_NOT_CONTAIN: rEntry.eOp = SC_DOES_NOT_CONTAIN; break; + case sheet::FilterOperator2::BEGINS_WITH: rEntry.eOp = SC_BEGINS_WITH; break; + case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH: rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;break; + case sheet::FilterOperator2::ENDS_WITH: rEntry.eOp = SC_ENDS_WITH; break; + case sheet::FilterOperator2::DOES_NOT_END_WITH: rEntry.eOp = SC_DOES_NOT_END_WITH; break; + case sheet::FilterOperator2::EMPTY: + { + rEntry.eOp = SC_EQUAL; + rEntry.nVal = SC_EMPTYFIELDS; + rEntry.bQueryByString = FALSE; + *rEntry.pStr = EMPTY_STRING; + } + break; + case sheet::FilterOperator2::NOT_EMPTY: + { + rEntry.eOp = SC_EQUAL; + rEntry.nVal = SC_NONEMPTYFIELDS; + rEntry.bQueryByString = FALSE; + *rEntry.pStr = EMPTY_STRING; + } + break; + default: + DBG_ERROR("Falscher Query-enum"); + rEntry.eOp = SC_EQUAL; + } + } + + SCSIZE nParamCount = aParam.GetEntryCount(); // Param wird nicht unter 8 resized + for (i=nCount; i #include #include +#include #include +#include +#include #include #include #include @@ -4027,7 +4030,7 @@ } // Modifies sCriteria, and nOp depending on the value of sCriteria -void lcl_setTableFieldsFromCriteria( rtl::OUString& sCriteria1, uno::Reference< beans::XPropertySet >& xDescProps, sheet::TableFilterField& rFilterField ) +void lcl_setTableFieldsFromCriteria( rtl::OUString& sCriteria1, uno::Reference< beans::XPropertySet >& xDescProps, sheet::TableFilterField2& rFilterField ) { // #TODO make this more efficient and cycle through // sCriteria1 character by character to pick up <,<>,=, * etc. @@ -4047,10 +4050,10 @@ if ( ( nPos = sCriteria1.indexOf( EQUALS ) ) == 0 ) { if ( sCriteria1.getLength() == EQUALS.getLength() ) - rFilterField.Operator = sheet::FilterOperator_EMPTY; + rFilterField.Operator = sheet::FilterOperator2::EMPTY; else { - rFilterField.Operator = sheet::FilterOperator_EQUAL; + rFilterField.Operator = sheet::FilterOperator2::EQUAL; sCriteria1 = sCriteria1.copy( EQUALS.getLength() ); sCriteria1 = VBAToRegexp( sCriteria1 ); // UseRegularExpressions @@ -4062,10 +4065,10 @@ else if ( ( nPos = sCriteria1.indexOf( NOTEQUALS ) ) == 0 ) { if ( sCriteria1.getLength() == NOTEQUALS.getLength() ) - rFilterField.Operator = sheet::FilterOperator_NOT_EMPTY; + rFilterField.Operator = sheet::FilterOperator2::NOT_EMPTY; else { - rFilterField.Operator = sheet::FilterOperator_NOT_EQUAL; + rFilterField.Operator = sheet::FilterOperator2::NOT_EQUAL; sCriteria1 = sCriteria1.copy( NOTEQUALS.getLength() ); sCriteria1 = VBAToRegexp( sCriteria1 ); // UseRegularExpressions @@ -4079,12 +4082,12 @@ if ( ( nPos = sCriteria1.indexOf( GREATERTHANEQUALS ) ) == 0 ) { sCriteria1 = sCriteria1.copy( GREATERTHANEQUALS.getLength() ); - rFilterField.Operator = sheet::FilterOperator_GREATER_EQUAL; + rFilterField.Operator = sheet::FilterOperator2::GREATER_EQUAL; } else { sCriteria1 = sCriteria1.copy( GREATERTHAN.getLength() ); - rFilterField.Operator = sheet::FilterOperator_GREATER; + rFilterField.Operator = sheet::FilterOperator2::GREATER; } } @@ -4094,17 +4097,17 @@ if ( ( nPos = sCriteria1.indexOf( LESSTHANEQUALS ) ) == 0 ) { sCriteria1 = sCriteria1.copy( LESSTHANEQUALS.getLength() ); - rFilterField.Operator = sheet::FilterOperator_LESS_EQUAL; + rFilterField.Operator = sheet::FilterOperator2::LESS_EQUAL; } else { sCriteria1 = sCriteria1.copy( LESSTHAN.getLength() ); - rFilterField.Operator = sheet::FilterOperator_LESS; + rFilterField.Operator = sheet::FilterOperator2::LESS; } } else - rFilterField.Operator = sheet::FilterOperator_EQUAL; + rFilterField.Operator = sheet::FilterOperator2::EQUAL; if ( bIsNumeric ) { @@ -4213,13 +4216,16 @@ bool bAll = false;; if ( ( Field >>= nField ) ) { - uno::Sequence< sheet::TableFilterField > sTabFilts; - uno::Reference< sheet::XSheetFilterDescriptor > xDesc = xDataBaseRange->getFilterDescriptor(); - uno::Reference< beans::XPropertySet > xDescProps( xDesc, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc( + xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY ); + if ( xDesc.is() ) + { + uno::Sequence< sheet::TableFilterField2 > sTabFilts; + uno::Reference< beans::XPropertySet > xDescProps( xDesc, uno::UNO_QUERY_THROW ); if ( Criteria1.hasValue() ) { sTabFilts.realloc( 1 ); - sTabFilts[0].Operator = sheet::FilterOperator_EQUAL;// sensible default + sTabFilts[0].Operator = sheet::FilterOperator2::EQUAL;// sensible default if ( !bCritHasNumericValue ) { Criteria1 >>= sCriteria1; @@ -4252,16 +4258,16 @@ switch ( nOperator ) { case excel::XlAutoFilterOperator::xlBottom10Items: - sTabFilts[0].Operator = sheet::FilterOperator_BOTTOM_VALUES; + sTabFilts[0].Operator = sheet::FilterOperator2::BOTTOM_VALUES; break; case excel::XlAutoFilterOperator::xlBottom10Percent: - sTabFilts[0].Operator = sheet::FilterOperator_BOTTOM_PERCENT; + sTabFilts[0].Operator = sheet::FilterOperator2::BOTTOM_PERCENT; break; case excel::XlAutoFilterOperator::xlTop10Items: - sTabFilts[0].Operator = sheet::FilterOperator_TOP_VALUES; + sTabFilts[0].Operator = sheet::FilterOperator2::TOP_VALUES; break; case excel::XlAutoFilterOperator::xlTop10Percent: - sTabFilts[0].Operator = sheet::FilterOperator_TOP_PERCENT; + sTabFilts[0].Operator = sheet::FilterOperator2::TOP_PERCENT; break; case excel::XlAutoFilterOperator::xlOr: nConn = sheet::FilterConnection_OR; @@ -4300,12 +4306,12 @@ { Criteria2 >>= sTabFilts[1].NumericValue; sTabFilts[1].IsNumeric = sal_True; - sTabFilts[1].Operator = sheet::FilterOperator_EQUAL; + sTabFilts[1].Operator = sheet::FilterOperator2::EQUAL; } } } - xDesc->setFilterFields( sTabFilts ); + xDesc->setFilterFields2( sTabFilts ); if ( !bAll ) { xDataBaseRange->refresh(); @@ -4313,6 +4319,7 @@ else // was 0 based now seems to be 1 lcl_SetAllQueryForField( pShell, nField, nSheet ); + } } else { @@ -4333,7 +4340,10 @@ lcl_SetAllQueryForField( pShell, rEntry.nField, nSheet ); } // remove exising filters - xDataBaseRange->getFilterDescriptor()->setFilterFields( uno::Sequence< sheet::TableFilterField >() ); + uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor( + xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY ); + if( xSheetFilterDescriptor.is() ) + xSheetFilterDescriptor->setFilterFields2( uno::Sequence< sheet::TableFilterField2 >() ); } xDBRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ), uno::Any(!bHasAuto) ); diff -uNr old/xmloff/inc/xmlkywd.hxx new/xmloff/inc/xmlkywd.hxx --- old/xmloff/inc/xmlkywd.hxx 2009-03-12 17:22:34.000000000 +0800 +++ new/xmloff/inc/xmlkywd.hxx 2009-03-24 15:30:08.000000000 +0800 @@ -1991,4 +1991,11 @@ XML_CONSTASCII_ACTION( sXML_page_continuation, "page-continuation" ); +XML_CONSTASCII_ACTION( sXML_contains, "contains" ); +XML_CONSTASCII_ACTION( sXML_does_not_contain, "does-not-contain" ); +XML_CONSTASCII_ACTION( sXML_begins_with, "begins-with" ); +XML_CONSTASCII_ACTION( sXML_does_not_begin_with, "does-not-begin-with" ); +XML_CONSTASCII_ACTION( sXML_ends_with, "ends-with" ); +XML_CONSTASCII_ACTION( sXML_does_not_end_with, "does-not-end-with" ); + #endif diff -uNr old/xmloff/inc/xmloff/xmltoken.hxx new/xmloff/inc/xmloff/xmltoken.hxx --- old/xmloff/inc/xmloff/xmltoken.hxx 2009-05-31 09:30:47.000000000 +0800 +++ new/xmloff/inc/xmloff/xmltoken.hxx 2009-06-02 11:14:51.000000000 +0800 @@ -2976,7 +2976,13 @@ XML_AVOID_OVERLAP, XML_NEAR_ORIGIN, XML_DEPENDENCY, - XML_NAV_ORDER, + XML_NAV_ORDER, + XML_CONTAINS, + XML_DOES_NOT_CONTAIN, + XML_BEGINS_WITH, + XML_DOES_NOT_BEGIN_WITH, + XML_ENDS_WITH, + XML_DOES_NOT_END_WITH, XML_USE_FIRST_ROW_STYLES, XML_USE_LAST_ROW_STYLES, diff -uNr old/xmloff/source/core/xmltoken.cxx new/xmloff/source/core/xmltoken.cxx --- old/xmloff/source/core/xmltoken.cxx 2009-05-31 09:30:47.000000000 +0800 +++ new/xmloff/source/core/xmltoken.cxx 2009-06-02 11:15:49.000000000 +0800 @@ -2977,6 +2977,12 @@ TOKEN( "near-origin", XML_NEAR_ORIGIN ), TOKEN( "dependency", XML_DEPENDENCY ), TOKEN( "nav-order", XML_NAV_ORDER ), + TOKEN( "contains", XML_CONTAINS ), + TOKEN( "does-not-contain", XML_DOES_NOT_CONTAIN ), + TOKEN( "begins-with", XML_BEGINS_WITH ), + TOKEN( "does-not-begin-with", XML_DOES_NOT_BEGIN_WITH ), + TOKEN( "ends-with", XML_ENDS_WITH ), + TOKEN( "does-not-end-with", XML_DOES_NOT_END_WITH ), TOKEN( "use-first-row-styles", XML_USE_FIRST_ROW_STYLES ), TOKEN( "use-last-row-styles", XML_USE_LAST_ROW_STYLES ),