diff -uNr i35579old/offapi/com/sun/star/sheet/FilterOperator2.idl i35579new/offapi/com/sun/star/sheet/FilterOperator2.idl --- i35579old/offapi/com/sun/star/sheet/FilterOperator2.idl 1970-01-01 08:00:00.000000000 +0800 +++ i35579new/offapi/com/sun/star/sheet/FilterOperator2.idl 2008-04-08 16:50:36.000000000 +0800 @@ -0,0 +1,169 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FilterOperator.idl,v $ + * + * $Revision: 1.6 $ + * + * last change: $Author: rt $ $Date: 2005/09/08 04:39:51 $ + * + * 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_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.0 + */ +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 i35579old/offapi/com/sun/star/sheet/TableFilterField2.idl i35579new/offapi/com/sun/star/sheet/TableFilterField2.idl --- i35579old/offapi/com/sun/star/sheet/TableFilterField2.idl 1970-01-01 08:00:00.000000000 +0800 +++ i35579new/offapi/com/sun/star/sheet/TableFilterField2.idl 2008-04-08 16:53:06.000000000 +0800 @@ -0,0 +1,108 @@ +/************************************************************************* + * + * 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_TableFilterField2_idl__ +#define __com_sun_star_sheet_TableFilterField2_idl__ + + +#ifndef __com_sun_star_sheet_FilterConnection_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.0 + */ +published struct TableFilterField2 +{ + //------------------------------------------------------------------------- + + /** specifies how the condition is connected to the previous condition. + */ + 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 i35579old/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl i35579new/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl --- i35579old/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl 1970-01-01 08:00:00.000000000 +0800 +++ i35579new/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl 2008-04-08 16:55:06.000000000 +0800 @@ -0,0 +1,85 @@ +/************************************************************************* + * + * 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_XSheetFilterDescriptor2_idl__ +#define __com_sun_star_sheet_XSheetFilterDescriptor2_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +#ifndef __com_sun_star_sheet_TableFilterField2_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.0 + */ +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 i35579old/offapi/com/sun/star/sheet/makefile.mk i35579new/offapi/com/sun/star/sheet/makefile.mk --- i35579old/offapi/com/sun/star/sheet/makefile.mk 2008-04-08 16:58:16.000000000 +0800 +++ i35579new/offapi/com/sun/star/sheet/makefile.mk 2008-04-08 17:00:38.000000000 +0800 @@ -126,6 +126,7 @@ FillMode.idl\ FilterConnection.idl\ FilterOperator.idl\ + FilterOperator2.idl\ FormulaLanguage.idl\ FormulaMapGroup.idl\ FormulaMapGroupSpecialOffset.idl\ @@ -204,6 +205,7 @@ TableConditionalEntryEnumeration.idl\ TableConditionalFormat.idl\ TableFilterField.idl\ + TableFilterField2.idl\ TableOperationMode.idl\ TablePageBreakData.idl\ TablePageStyle.idl\ @@ -294,6 +296,7 @@ XSheetConditionalEntries.idl\ XSheetConditionalEntry.idl\ XSheetFilterDescriptor.idl\ + XSheetFilterDescriptor2.idl\ XSheetFilterable.idl\ XSheetFilterableEx.idl\ XSheetLinkable.idl\ diff -uNr i35579old/sc/inc/datauno.hxx i35579new/sc/inc/datauno.hxx --- i35579old/sc/inc/datauno.hxx 2007-03-04 18:07:44.000000000 +0800 +++ i35579new/sc/inc/datauno.hxx 2008-04-09 11:03:44.000000000 +0800 @@ -60,6 +60,9 @@ #ifndef _COM_SUN_STAR_SHEET_XSHEETFILTERDESCRIPTOR_HPP_ #include #endif +#ifndef _COM_SUN_STAR_SHEET_XSHEETFILTERDESCRIPTOR2_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_SHEET_XCONSOLIDATIONDESCRIPTOR_HPP_ #include #endif @@ -397,7 +400,8 @@ // to uno, all three look the same -class ScFilterDescriptorBase : public cppu::WeakImplHelper3< +class ScFilterDescriptorBase : public cppu::WeakImplHelper4< + com::sun::star::sheet::XSheetFilterDescriptor2, com::sun::star::sheet::XSheetFilterDescriptor, com::sun::star::beans::XPropertySet, com::sun::star::lang::XServiceInfo >, @@ -424,6 +428,11 @@ virtual void SAL_CALL setFilterFields( const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::TableFilterField >& aFilterFields ) throw(::com::sun::star::uno::RuntimeException); + 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 > diff -uNr i35579old/sc/inc/global.hxx i35579new/sc/inc/global.hxx --- i35579old/sc/inc/global.hxx 2008-03-07 23:10:04.000000000 +0800 +++ i35579new/sc/inc/global.hxx 2008-04-08 14:06:34.000000000 +0800 @@ -709,7 +709,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 i35579old/sc/inc/sc.hrc i35579new/sc/inc/sc.hrc --- i35579old/sc/inc/sc.hrc 2008-03-11 18:43:02.000000000 +0800 +++ i35579new/sc/inc/sc.hrc 2008-04-08 14:09:46.000000000 +0800 @@ -1304,6 +1304,8 @@ #define SCSTR_DPFUNCLISTBOX (STR_START + 92) #define STR_PRINT_NOTHING (STR_START + 93) #define SCSTR_ALLFILTER (STR_START + 94) +#define SCSTR_MOREBTN_MOREOPTIONS (STR_START + 95) +#define SCSTR_MOREBTN_LESSOPTIONS (STR_START + 96) // Items diff -uNr i35579old/sc/source/core/data/table3.cxx i35579new/sc/source/core/data/table3.cxx --- i35579old/sc/source/core/data/table3.cxx 2007-09-22 15:53:28.000000000 +0800 +++ i35579new/sc/source/core/data/table3.cxx 2008-04-08 14:52:50.000000000 +0800 @@ -1019,12 +1019,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) @@ -1037,7 +1044,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))); @@ -1045,20 +1055,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 ) { @@ -1066,9 +1117,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; @@ -1078,10 +1135,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 i35579old/sc/source/filter/xml/XMLExportDatabaseRanges.cxx i35579new/sc/source/filter/xml/XMLExportDatabaseRanges.cxx --- i35579old/sc/source/filter/xml/XMLExportDatabaseRanges.cxx 2008-04-09 11:20:40.000000000 +0800 +++ i35579new/sc/source/filter/xml/XMLExportDatabaseRanges.cxx 2008-04-24 15:44:46.000000000 +0800 @@ -259,6 +259,64 @@ } } +rtl::OUString ScXMLExportDatabaseRanges::getOperatorXML(const long aFilterOperator, const sal_Bool bUseRegularExpressions) const +{ + 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 + } + } + return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); +} + rtl::OUString ScXMLExportDatabaseRanges::getOperatorXML(const sheet::FilterOperator aFilterOperator, const sal_Bool bUseRegularExpressions) const { switch (aFilterOperator) @@ -305,6 +363,24 @@ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")); } +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) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE); + if (aFilterField.IsNumeric) + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_NUMBER); + rtl::OUStringBuffer sBuffer; + rExport.GetMM100UnitConverter().convertDouble(sBuffer, aFilterField.NumericValue); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, sBuffer.makeStringAndClear()); + } + else + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, aFilterField.StringValue); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OPERATOR, getOperatorXML(aFilterField.Operator, bUseRegularExpressions)); + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, sal_True, sal_True); +} + void ScXMLExportDatabaseRanges::WriteCondition(const sheet::TableFilterField& aFilterField, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions) { rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, rtl::OUString::valueOf(aFilterField.Field)); @@ -323,6 +399,139 @@ SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, sal_True, sal_True); } +void ScXMLExportDatabaseRanges::WriteFilterDescriptor(const uno::Reference & xSheetFilterDescriptor, const rtl::OUString sDatabaseRangeName) +{ + uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor2( xSheetFilterDescriptor, uno::UNO_QUERY ); + if ( xSheetFilterDescriptor2.is() ) + { + uno::Sequence< sheet::TableFilterField2 > aTableFilterFields2( + xSheetFilterDescriptor2->getFilterFields2() ); + sal_Int32 nTableFilterFields = aTableFilterFields2.getLength(); + if (nTableFilterFields > 0) + { + uno::Reference xPropertySet (xSheetFilterDescriptor, uno::UNO_QUERY); + if (xPropertySet.is()) + { + if (::cppu::any2bool(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_COPYOUT))))) + { + table::CellAddress aOutputPosition; + if (xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_OUTPOS))) >>= aOutputPosition) + { + rtl::OUString sOUCellAddress; + ScRangeStringConverter::GetStringFromAddress( sOUCellAddress, aOutputPosition, pDoc ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, sOUCellAddress); + } + } + ScDBCollection* pDBCollection = pDoc->GetDBCollection(); + sal_uInt16 nIndex; + pDBCollection->SearchName(sDatabaseRangeName, nIndex); + ScDBData* pDBData = (*pDBCollection)[nIndex]; + ScRange aAdvSource; + if (pDBData->GetAdvancedQuerySource(aAdvSource)) + { + rtl::OUString sOUCellAddress; + ScRangeStringConverter::GetStringFromRange( sOUCellAddress, aAdvSource, pDoc ); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE_RANGE_ADDRESS, sOUCellAddress); + } + + if (::cppu::any2bool(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SKIPDUP))))) + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_DUPLICATES, XML_FALSE); + SvXMLElementExport aElemF(rExport, XML_NAMESPACE_TABLE, XML_FILTER, sal_True, sal_True); + rExport.CheckAttrList(); + sal_Bool bIsCaseSensitive = ::cppu::any2bool(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISCASE)))); + sal_Bool bUseRegularExpressions = ::cppu::any2bool(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_USEREGEX)))); + sal_Bool bAnd = sal_False; + sal_Bool bOr = sal_False; + for (sal_Int32 i = 1; i < nTableFilterFields; ++i) + { + if (aTableFilterFields2[i].Connection == sheet::FilterConnection_AND) + bAnd = sal_True; + else + bOr = sal_True; + } + if (bOr && !bAnd) + { + SvXMLElementExport aElemOr(rExport, XML_NAMESPACE_TABLE, XML_FILTER_OR, sal_True, sal_True); + for (sal_Int32 i = 0; i < nTableFilterFields; ++i) + { + WriteCondition(aTableFilterFields2[i], bIsCaseSensitive, bUseRegularExpressions); + } + } + else if (bAnd && !bOr) + { + SvXMLElementExport aElemAnd(rExport, XML_NAMESPACE_TABLE, XML_FILTER_AND, sal_True, sal_True); + for (sal_Int32 i = 0; i < nTableFilterFields; ++i) + { + WriteCondition(aTableFilterFields2[i], bIsCaseSensitive, bUseRegularExpressions); + } + } + else if (nTableFilterFields == 1) + { + WriteCondition(aTableFilterFields2[0], bIsCaseSensitive, bUseRegularExpressions); + } + else + { + SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_OR, sal_True, sal_True); + sheet::TableFilterField2 aPrevFilterField = aTableFilterFields2[0]; + sheet::FilterConnection aConnection = aTableFilterFields2[1].Connection; + sal_Bool bOpenAndElement; + rtl::OUString aName = rExport.GetNamespaceMap().GetQNameByKey(XML_NAMESPACE_TABLE, GetXMLToken(XML_FILTER_AND)); + if (aConnection == sheet::FilterConnection_AND) + { + rExport.StartElement( aName, sal_True); + bOpenAndElement = sal_True; + } + else + bOpenAndElement = sal_False; + for (sal_Int32 i = 1; i < nTableFilterFields; ++i) + { + if (aConnection != aTableFilterFields2[i].Connection) + { + aConnection = aTableFilterFields2[i].Connection; + if (aTableFilterFields2[i].Connection == sheet::FilterConnection_AND) + { + rExport.StartElement( aName, sal_True ); + bOpenAndElement = sal_True; + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + aPrevFilterField = aTableFilterFields2[i]; + if (i == nTableFilterFields - 1) + { + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + rExport.EndElement(aName, sal_True); + bOpenAndElement = sal_False; + } + } + else + { + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + aPrevFilterField = aTableFilterFields2[i]; + if (bOpenAndElement) + { + rExport.EndElement(aName, sal_True); + bOpenAndElement = sal_False; + } + if (i == nTableFilterFields - 1) + { + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + } + } + } + else + { + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + aPrevFilterField = aTableFilterFields2[i]; + if (i == nTableFilterFields - 1) + WriteCondition(aPrevFilterField, bIsCaseSensitive, bUseRegularExpressions); + } + } + if(bOpenAndElement) + rExport.EndElement(aName, sal_True); + } + } + } + } +} + void ScXMLExportDatabaseRanges::WriteFilterDescriptor(const uno::Reference & xSheetFilterDescriptor, const rtl::OUString sDatabaseRangeName) { uno::Sequence aTableFilterFields(xSheetFilterDescriptor->getFilterFields()); @@ -731,8 +940,16 @@ SvXMLElementExport aElemDR(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, sal_True, sal_True); rExport.CheckAttrList(); WriteImportDescriptor(xDatabaseRange->getImportDescriptor()); - if (xSheetFilterDescriptor.is()) - WriteFilterDescriptor(xSheetFilterDescriptor, sDatabaseRangeName); + uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor2( + xSheetFilterDescriptor, uno::UNO_QUERY ); + if ( xSheetFilterDescriptor2.is() ) + { + WriteFilterDescriptor( xSheetFilterDescriptor2, sDatabaseRangeName ); + } + else if ( xSheetFilterDescriptor.is() ) + { + WriteFilterDescriptor( xSheetFilterDescriptor, sDatabaseRangeName ); + } WriteSortDescriptor(aSortProperties); WriteSubTotalDescriptor(xDatabaseRange->getSubTotalDescriptor(), sDatabaseRangeName); } diff -uNr i35579old/sc/source/filter/xml/XMLExportDatabaseRanges.hxx i35579new/sc/source/filter/xml/XMLExportDatabaseRanges.hxx --- i35579old/sc/source/filter/xml/XMLExportDatabaseRanges.hxx 2005-12-16 16:08:52.000000000 +0800 +++ i35579new/sc/source/filter/xml/XMLExportDatabaseRanges.hxx 2008-04-09 15:04:02.000000000 +0800 @@ -45,12 +45,21 @@ #ifndef _COM_SUN_STAR_SHEET_FILTEROPERATOR_HPP_ #include #endif +#ifndef _COM_SUN_STAR_SHEET_FILTEROPERATOR2_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_SHEET_TABLEFILTERFIELD_HPP_ #include #endif +#ifndef _COM_SUN_STAR_SHEET_TABLEFILTERFIELD2_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_SHEET_XSHEETFILTERDESCRIPTOR_HPP_ #include #endif +#ifndef _COM_SUN_STAR_SHEET_XSHEETFILTERDESCRIPTOR2_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_SHEET_XSUBTOTALDESCRIPTOR_HPP_ #include #endif @@ -69,8 +78,11 @@ void WriteImportDescriptor(const com::sun::star::uno::Sequence aImportDescriptor); rtl::OUString getOperatorXML(const com::sun::star::sheet::FilterOperator aFilterOperator, const sal_Bool bUseRegularExpressions) const; + rtl::OUString getOperatorXML(const long aFilterOperator, const sal_Bool bUseRegularExpressions) const; void WriteCondition(const com::sun::star::sheet::TableFilterField& aFilterField, sal_Bool bIsCaseSensitive, sal_Bool bUseRegularExpressions); + 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 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 i35579old/sc/source/filter/xml/xmldrani.cxx i35579new/sc/source/filter/xml/xmldrani.cxx --- i35579old/sc/source/filter/xml/xmldrani.cxx 2007-05-24 17:27:34.000000000 +0800 +++ i35579new/sc/source/filter/xml/xmldrani.cxx 2008-04-25 15:08:12.000000000 +0800 @@ -426,7 +426,16 @@ 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); + uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor2( + xSheetFilterDescriptor, uno::UNO_QUERY ); + if ( xSheetFilterDescriptor2.is() ) + { + xSheetFilterDescriptor2->setFilterFields2(aFilterFields2); + } + else + { + xSheetFilterDescriptor->setFilterFields(aFilterFields); + } if (bFilterConditionSourceRange) { ScRange aAdvSource; diff -uNr i35579old/sc/source/filter/xml/xmldrani.hxx i35579new/sc/source/filter/xml/xmldrani.hxx --- i35579old/sc/source/filter/xml/xmldrani.hxx 2005-12-16 16:08:52.000000000 +0800 +++ i35579new/sc/source/filter/xml/xmldrani.hxx 2008-05-07 11:38:56.000000000 +0800 @@ -56,6 +56,9 @@ #ifndef _COM_SUN_STAR_SHEET_TABLEFILTERFIELD_HPP_ #include #endif +#ifndef _COM_SUN_STAR_SHEET_TABLEFILTERFIELD2_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_TABLE_CELLADDRESS_HPP_ #include #endif @@ -105,6 +108,7 @@ rtl::OUString sSourceObject; com::sun::star::uno::Sequence aSortSequence; com::sun::star::uno::Sequence aFilterFields; + com::sun::star::uno::Sequence aFilterFields2; std::vector < ScSubTotalRule > aSubTotalRules; com::sun::star::table::CellAddress aFilterOutputPosition; com::sun::star::table::CellRangeAddress aFilterConditionSourceRangeAddress; @@ -172,6 +176,7 @@ 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 SetFilterFields2(const com::sun::star::uno::Sequence & aTemp) { aFilterFields2 = 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 i35579old/sc/source/filter/xml/xmlfilti.cxx i35579new/sc/source/filter/xml/xmlfilti.cxx --- i35579old/sc/source/filter/xml/xmlfilti.cxx 2007-05-24 17:27:34.000000000 +0800 +++ i35579new/sc/source/filter/xml/xmlfilti.cxx 2008-06-12 14:16:24.000000000 +0800 @@ -178,7 +178,7 @@ pDatabaseRangeContext->SetFilterCopyOutputData(sal_False); pDatabaseRangeContext->SetFilterIsCaseSensitive(bIsCaseSensitive); pDatabaseRangeContext->SetFilterSkipDuplicates(bSkipDuplicates); - pDatabaseRangeContext->SetFilterFields(aFilterFields); + pDatabaseRangeContext->SetFilterFields2(aFilterFields2); if (bConditionSourceRange) pDatabaseRangeContext->SetFilterConditionSourceRangeAddress(aConditionSourceRangeAddress); } @@ -349,70 +349,84 @@ 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 sTempOperator2, long& aFilterOperator2, 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(sTempOperator2, XML_MATCH)) + { + bUseRegularExpressions = sal_True; + aFilterOperator2 = sheet::FilterOperator2::EQUAL; + } + else if (IsXMLToken(sTempOperator2, XML_NOMATCH)) + { + bUseRegularExpressions = sal_True; + aFilterOperator2 = sheet::FilterOperator2::NOT_EQUAL; + } + else if (sTempOperator2.compareToAscii("=") == 0) + aFilterOperator2 = sheet::FilterOperator2::EQUAL; + else if (sTempOperator2.compareToAscii("!=") == 0) + aFilterOperator2 = sheet::FilterOperator2::NOT_EQUAL; + else if (IsXMLToken(sTempOperator2, XML_BOTTOM_PERCENT)) + aFilterOperator2 = sheet::FilterOperator2::BOTTOM_PERCENT; + else if (IsXMLToken(sTempOperator2, XML_BOTTOM_VALUES)) + aFilterOperator2 = sheet::FilterOperator2::BOTTOM_VALUES; + else if (IsXMLToken(sTempOperator2, XML_EMPTY)) + aFilterOperator2 = sheet::FilterOperator2::EMPTY; + else if (sTempOperator2.compareToAscii(">") == 0) + aFilterOperator2 = sheet::FilterOperator2::GREATER; + else if (sTempOperator2.compareToAscii(">=") == 0) + aFilterOperator2 = sheet::FilterOperator2::GREATER_EQUAL; + else if (sTempOperator2.compareToAscii("<") == 0) + aFilterOperator2 = sheet::FilterOperator2::LESS; + else if (sTempOperator2.compareToAscii("<=") == 0) + aFilterOperator2 = sheet::FilterOperator2::LESS_EQUAL; + else if (IsXMLToken(sTempOperator2, XML_NOEMPTY)) + aFilterOperator2 = sheet::FilterOperator2::NOT_EMPTY; + else if (IsXMLToken(sTempOperator2, XML_TOP_PERCENT)) + aFilterOperator2 = sheet::FilterOperator2::TOP_PERCENT; + else if (IsXMLToken(sTempOperator2, XML_TOP_VALUES)) + aFilterOperator2 = sheet::FilterOperator2::TOP_VALUES; + else if (IsXMLToken(sTempOperator2, XML_CONTAINS)) + aFilterOperator2 = sheet::FilterOperator2::CONTAINS; + else if (IsXMLToken(sTempOperator2, XML_DOES_NOT_CONTAIN)) + aFilterOperator2 = sheet::FilterOperator2::DOES_NOT_CONTAIN; + else if (IsXMLToken(sTempOperator2, XML_BEGINS_WITH)) + aFilterOperator2 = sheet::FilterOperator2::BEGINS_WITH; + else if (IsXMLToken(sTempOperator2, XML_DOES_NOT_BEGIN_WITH)) + aFilterOperator2 = sheet::FilterOperator2::DOES_NOT_BEGIN_WITH; + else if (IsXMLToken(sTempOperator2, XML_ENDS_WITH)) + aFilterOperator2 = sheet::FilterOperator2::ENDS_WITH; + else if (IsXMLToken(sTempOperator2, XML_DOES_NOT_END_WITH)) + aFilterOperator2 = sheet::FilterOperator2::DOES_NOT_END_WITH; } void ScXMLConditionContext::EndElement() { - sheet::TableFilterField aFilterField; + sheet::TableFilterField2 aFilterField2; if (pFilterContext->GetConnection()) - aFilterField.Connection = sheet::FilterConnection_OR; + aFilterField2.Connection = sheet::FilterConnection_OR; else - aFilterField.Connection = sheet::FilterConnection_AND; + aFilterField2.Connection = sheet::FilterConnection_AND; pFilterContext->SetIsCaseSensitive(bIsCaseSensitive); sal_Bool bUseRegularExpressions; - getOperatorXML(sOperator, aFilterField.Operator, bUseRegularExpressions); + getOperatorXML(sOperator, aFilterField2.Operator, bUseRegularExpressions); pFilterContext->SetUseRegularExpressions(bUseRegularExpressions); - aFilterField.Field = nField; + aFilterField2.Field = nField; if (IsXMLToken(sDataType, XML_NUMBER)) { - aFilterField.NumericValue = sConditionValue.toDouble(); - aFilterField.IsNumeric = sal_True; + aFilterField2.NumericValue = sConditionValue.toDouble(); + aFilterField2.IsNumeric = sal_True; } else { - aFilterField.StringValue = sConditionValue; - aFilterField.IsNumeric = sal_False; + aFilterField2.StringValue = sConditionValue; + aFilterField2.IsNumeric = sal_False; } - pFilterContext->AddFilterField(aFilterField); + pFilterContext->AddFilterField2(aFilterField2); } + + //========================================================================== ScXMLDPFilterContext::ScXMLDPFilterContext( ScXMLImport& rImport, @@ -751,6 +765,18 @@ aFilterOperator = SC_TOPPERC; else if (IsXMLToken(sTempOperator, XML_TOP_VALUES)) aFilterOperator = SC_TOPVAL; + else if (IsXMLToken(sTempOperator, XML_CONTAINS)) + aFilterOperator = SC_CONTAINS; + else if (IsXMLToken(sTempOperator, XML_DOES_NOT_CONTAIN)) + aFilterOperator = SC_DOES_NOT_CONTAIN; + else if (IsXMLToken(sTempOperator, XML_BEGINS_WITH)) + aFilterOperator = SC_BEGINS_WITH; + else if (IsXMLToken(sTempOperator, XML_DOES_NOT_BEGIN_WITH)) + aFilterOperator = SC_DOES_NOT_BEGIN_WITH; + else if (IsXMLToken(sTempOperator, XML_ENDS_WITH)) + aFilterOperator = SC_ENDS_WITH; + else if (IsXMLToken(sTempOperator, XML_DOES_NOT_END_WITH)) + aFilterOperator = SC_DOES_NOT_END_WITH; } void ScXMLDPConditionContext::EndElement() diff -uNr i35579old/sc/source/filter/xml/xmlfilti.hxx i35579new/sc/source/filter/xml/xmlfilti.hxx --- i35579old/sc/source/filter/xml/xmlfilti.hxx 2008-04-25 16:04:16.000000000 +0800 +++ i35579new/sc/source/filter/xml/xmlfilti.hxx 2008-06-12 14:20:58.000000000 +0800 @@ -49,9 +49,15 @@ #ifndef _COM_SUN_STAR_SHEET_FILTEROPERATOR_HPP_ #include #endif +#ifndef _COM_SUN_STAR_SHEET_FILTEROPERATOR2_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_SHEET_TABLEFILTERFIELD_HPP_ #include #endif +#ifndef _COM_SUN_STAR_SHEET_TABLEFILTERFIELD2_HPP_ +#include +#endif #ifndef _STACK_HXX #include #endif @@ -66,6 +72,7 @@ ScXMLDatabaseRangeContext* pDatabaseRangeContext; com::sun::star::uno::Sequence aFilterFields; + com::sun::star::uno::Sequence aFilterFields2; com::sun::star::table::CellAddress aOutputPosition; com::sun::star::table::CellRangeAddress aConditionSourceRangeAddress; sal_Int16 nUserListIndex; @@ -106,8 +113,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 AddFilterField2 (const com::sun::star::sheet::TableFilterField2 aFilterField2) { aFilterFields2.realloc(aFilterFields2.getLength() + 1); + aFilterFields2[aFilterFields2.getLength() - 1] = aFilterField2; } }; class ScXMLAndContext : public SvXMLImportContext @@ -188,7 +195,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 sTempOperator2, long& aFilterOperator2, sal_Bool& bUseRegularExpressions) const; virtual void EndElement(); }; diff -uNr i35579old/sc/source/ui/dbgui/filtdlg.cxx i35579new/sc/source/ui/dbgui/filtdlg.cxx --- i35579old/sc/source/ui/dbgui/filtdlg.cxx 2008-01-30 21:32:24.000000000 +0800 +++ i35579new/sc/source/ui/dbgui/filtdlg.cxx 2008-04-08 14:14:50.000000000 +0800 @@ -103,6 +103,7 @@ aFtField ( this, ScResId( FT_FIELD ) ), aFtCond ( this, ScResId( FT_COND ) ), aFtVal ( this, ScResId( FT_VAL ) ), + aFlSeparator ( this, ScResId( FL_SEPARATOR ) ), _INIT_COMMON_FILTER_RSCOBJS aStrEmpty ( ScResId( SCSTR_EMPTY ) ), aStrNotEmpty ( ScResId( SCSTR_NOTEMPTY ) ), @@ -124,6 +125,8 @@ for (USHORT i=0; i<=MAXCOL; i++) pEntryLists[i] = NULL; + aBtnMore.SetMoreText( String(ScResId( SCSTR_MOREBTN_MOREOPTIONS )) ); + aBtnMore.SetLessText( String(ScResId( SCSTR_MOREBTN_LESSOPTIONS )) ); Init( rArgSet ); FreeResource(); diff -uNr i35579old/sc/source/ui/inc/filtdlg.hxx i35579new/sc/source/ui/inc/filtdlg.hxx --- i35579old/sc/source/ui/inc/filtdlg.hxx 2007-03-04 18:08:02.000000000 +0800 +++ i35579new/sc/source/ui/inc/filtdlg.hxx 2008-04-08 14:16:58.000000000 +0800 @@ -154,6 +154,7 @@ FixedText aFtField; FixedText aFtCond; FixedText aFtVal; + FixedLine aFlSeparator; _COMMON_FILTER_RSCOBJS diff -uNr i35579old/sc/source/ui/inc/filter.hrc i35579new/sc/source/ui/inc/filter.hrc --- i35579old/sc/source/ui/inc/filter.hrc 2005-12-16 16:08:58.000000000 +0800 +++ i35579new/sc/source/ui/inc/filter.hrc 2008-04-08 14:18:30.000000000 +0800 @@ -73,6 +73,7 @@ #define ED_VAL2 33 #define ED_VAL3 34 #define FL_CRITERIA 35 +#define FL_SEPARATOR 36 // Spezialfilter diff -uNr i35579old/sc/source/ui/src/filter.src i35579new/sc/source/ui/src/filter.src --- i35579old/sc/source/ui/src/filter.src 2007-04-20 21:21:46.000000000 +0800 +++ i35579new/sc/source/ui/src/filter.src 2008-04-08 15:53:54.000000000 +0800 @@ -39,7 +39,7 @@ HelpId = SID_FILTER ; Hide = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT ( 298 , 83 ) ; + Size = MAP_APPFONT ( 267 , 105 ) ; Text [ en-US ] = "Standard Filter" ; Moveable = TRUE ; Closeable = FALSE ; @@ -58,12 +58,12 @@ FixedText FT_COND { Pos = MAP_APPFONT ( 122 , 14 ) ; - Size = MAP_APPFONT ( 47 , 8 ) ; + Size = MAP_APPFONT ( 75 , 8 ) ; Text [ en-US ] = "Condition" ; }; FixedText FT_VAL { - Pos = MAP_APPFONT ( 173 , 14 ) ; + Pos = MAP_APPFONT ( 201 , 14 ) ; Size = MAP_APPFONT ( 60 , 8 ) ; Text [ en-US ] = "Value" ; }; @@ -121,7 +121,7 @@ { Border = TRUE ; Pos = MAP_APPFONT ( 122 , 25 ) ; - Size = MAP_APPFONT ( 47 , 105 ) ; + Size = MAP_APPFONT ( 75 , 145 ) ; TabStop = TRUE ; DropDown = TRUE ; stringlist [ en-US ] = @@ -136,13 +136,19 @@ < "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 { Border = TRUE ; Pos = MAP_APPFONT ( 122 , 41 ) ; - Size = MAP_APPFONT ( 47 , 105 ) ; + Size = MAP_APPFONT ( 75 , 145 ) ; TabStop = TRUE ; DropDown = TRUE ; stringlist [ en-US ] = @@ -157,13 +163,19 @@ < "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 { Border = TRUE ; Pos = MAP_APPFONT ( 122 , 57 ) ; - Size = MAP_APPFONT ( 47 , 105 ) ; + Size = MAP_APPFONT ( 75 , 145 ) ; TabStop = TRUE ; DropDown = TRUE ; stringlist [ en-US ] = @@ -178,25 +190,31 @@ < "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 { - Pos = MAP_APPFONT ( 173 , 25 ) ; + Pos = MAP_APPFONT ( 201 , 25 ) ; Size = MAP_APPFONT ( 60 , 90 ) ; TabStop = TRUE ; DropDown = TRUE ; }; ComboBox ED_VAL2 { - Pos = MAP_APPFONT ( 173 , 41 ) ; + Pos = MAP_APPFONT ( 201 , 41 ) ; Size = MAP_APPFONT ( 60 , 90 ) ; TabStop = TRUE ; DropDown = TRUE ; }; ComboBox ED_VAL3 { - Pos = MAP_APPFONT ( 173 , 57 ) ; + Pos = MAP_APPFONT ( 201 , 57 ) ; Size = MAP_APPFONT ( 60 , 90 ) ; TabStop = TRUE ; DropDown = TRUE ; @@ -204,13 +222,13 @@ FixedLine FL_CRITERIA { Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 230 , 8 ) ; + Size = MAP_APPFONT ( 258 , 8 ) ; Text [ en-US ] = "Filter criteria"; }; CheckBox BTN_CASE { Hide = TRUE ; - Pos = MAP_APPFONT ( 12 , 86 ) ; + Pos = MAP_APPFONT ( 12 , 116 ) ; Size = MAP_APPFONT ( 128 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Case ~sensitive" ; @@ -218,7 +236,7 @@ CheckBox BTN_REGEXP { Hide = TRUE ; - Pos = MAP_APPFONT ( 142 , 86 ) ; + Pos = MAP_APPFONT ( 142 , 116 ) ; Size = MAP_APPFONT ( 94 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Regular ~expression" ; @@ -226,7 +244,7 @@ CheckBox BTN_HEADER { Hide = TRUE ; - Pos = MAP_APPFONT ( 12 , 100 ) ; + Pos = MAP_APPFONT ( 12 , 130 ) ; Size = MAP_APPFONT ( 128 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Range contains ~column labels" ; @@ -234,7 +252,7 @@ CheckBox BTN_UNIQUE { Hide = TRUE ; - Pos = MAP_APPFONT ( 142 , 100 ) ; + Pos = MAP_APPFONT ( 142 , 130 ) ; Size = MAP_APPFONT ( 94 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~No duplication" ; @@ -242,7 +260,7 @@ CheckBox BTN_COPY_RESULT { Hide = TRUE ; - Pos = MAP_APPFONT ( 12 , 114 ) ; + Pos = MAP_APPFONT ( 12 , 144 ) ; Size = MAP_APPFONT ( 128 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Copy ~results to..." ; @@ -250,7 +268,7 @@ CheckBox BTN_DEST_PERS { Hide = TRUE ; - Pos = MAP_APPFONT ( 142 , 114 ) ; + Pos = MAP_APPFONT ( 142 , 144 ) ; Size = MAP_APPFONT ( 94 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Keep filter criteria" ; @@ -259,8 +277,8 @@ { Border = TRUE ; Hide = TRUE ; - Pos = MAP_APPFONT ( 21 , 126 ) ; - Size = MAP_APPFONT ( 90 , 90 ) ; + Pos = MAP_APPFONT ( 21 , 156 ) ; + Size = MAP_APPFONT ( 110 , 90 ) ; TabStop = TRUE ; DropDown = TRUE ; }; @@ -268,13 +286,13 @@ { Border = TRUE ; Hide = TRUE ; - Pos = MAP_APPFONT ( 115 , 126 ) ; - Size = MAP_APPFONT ( 104 , 12 ) ; + Pos = MAP_APPFONT ( 136 , 156 ) ; + Size = MAP_APPFONT ( 110 , 12 ) ; TabStop = TRUE ; }; ImageButton RB_COPY_AREA { - Pos = MAP_APPFONT ( 221 , 125 ) ; + Pos = MAP_APPFONT ( 248 , 155 ) ; Size = MAP_APPFONT ( 13 , 15 ) ; TabStop = FALSE ; QuickHelpText [ en-US ] = "Shrink" ; @@ -282,14 +300,14 @@ FixedLine FL_OPTIONS { Hide = TRUE ; - Pos = MAP_APPFONT ( 6 , 75 ) ; - Size = MAP_APPFONT ( 230 , 8 ) ; + Pos = MAP_APPFONT ( 6 , 104 ) ; + Size = MAP_APPFONT ( 258 , 8 ) ; Text [ en-US ] = "Options" ; }; FixedText FT_DBAREA { Hide = TRUE ; - Pos = MAP_APPFONT ( 66 , 144 ) ; + Pos = MAP_APPFONT ( 66 , 174 ) ; Size = MAP_APPFONT ( 167 , 8 ) ; Left = TRUE ; Text [ en-US ] = "dummy" ; @@ -297,36 +315,41 @@ FixedText FT_DBAREA_LABEL { Hide = TRUE ; - Pos = MAP_APPFONT ( 6 , 144 ) ; + Pos = MAP_APPFONT ( 6 , 174 ) ; Size = MAP_APPFONT ( 58 , 8 ) ; Text [ en-US ] = "Data range:" ; }; OKButton BTN_OK { - Pos = MAP_APPFONT ( 242 , 6 ) ; + Pos = MAP_APPFONT ( 103 , 85 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; DefButton = TRUE ; }; CancelButton BTN_CANCEL { - Pos = MAP_APPFONT ( 242 , 23 ) ; + Pos = MAP_APPFONT ( 157 , 85 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; HelpButton BTN_HELP { - Pos = MAP_APPFONT ( 242 , 43 ) ; + Pos = MAP_APPFONT ( 211 , 85 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; MoreButton BTN_MORE { - Pos = MAP_APPFONT ( 242 , 63 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + Pos = MAP_APPFONT ( 6 , 85 ) ; + Size = MAP_APPFONT ( 55 , 14 ) ; TabStop = TRUE ; MapUnit = MAP_APPFONT ; - Delta = 75 ; + Delta = 81 ; + }; + FixedLine FL_SEPARATOR + { + Pos = MAP_APPFONT ( 0 , 75 ) ; + Size = MAP_APPFONT ( 267 , 6 ) ; }; }; //============================================================================ diff -uNr i35579old/sc/source/ui/src/scstring.src i35579new/sc/source/ui/src/scstring.src --- i35579old/sc/source/ui/src/scstring.src 2007-09-22 15:53:56.000000000 +0800 +++ i35579new/sc/source/ui/src/scstring.src 2008-04-08 14:37:00.000000000 +0800 @@ -733,3 +733,13 @@ Text [ en-US ] = "Mouse button pressed"; }; +String SCSTR_MOREBTN_MOREOPTIONS +{ + Text [ en-US ] = "More ~Options"; +}; + +String SCSTR_MOREBTN_LESSOPTIONS +{ + Text [ en-US ] = "Less ~Options"; +}; + diff -uNr i35579old/sc/source/ui/unoobj/cellsuno.cxx i35579new/sc/source/ui/unoobj/cellsuno.cxx --- i35579old/sc/source/ui/unoobj/cellsuno.cxx 2008-03-07 23:11:08.000000000 +0800 +++ i35579new/sc/source/ui/unoobj/cellsuno.cxx 2008-04-11 09:54:46.000000000 +0800 @@ -5688,7 +5688,16 @@ 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 i35579old/sc/source/ui/unoobj/datauno.cxx i35579new/sc/source/ui/unoobj/datauno.cxx --- i35579old/sc/source/ui/unoobj/datauno.cxx 2008-01-17 03:56:06.000000000 +0800 +++ i35579new/sc/source/ui/unoobj/datauno.cxx 2008-04-30 10:25:44.000000000 +0800 @@ -51,6 +51,10 @@ #include #include +#include +#include +#include + #include "datauno.hxx" #include "dapiuno.hxx" #include "cellsuno.hxx" @@ -1190,6 +1194,81 @@ 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) @@ -1264,6 +1343,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 @@ -3844,6 +3847,92 @@ rFilterField.StringValue = sCriteria1; } +void lcl_setTableFieldsFromCriteria2( 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. + // right now I am more concerned with just getting it to work right + + sCriteria1 = sCriteria1.trim(); + // table of translation of criteria text to FilterOperators + // <>searchtext - NOT_EQUAL + // =searchtext - EQUAL + // *searchtext - startwith + // <>*searchtext - doesn't startwith + // *searchtext* - contains + // <>*searchtext* - doesn't contain + // [>|>=|<=|...]searchtext for GREATER_value, GREATER_EQUAL_value etc. + sal_Int32 nPos = 0; + bool bIsNumeric = false; + if ( ( nPos = sCriteria1.indexOf( EQUALS ) ) == 0 ) + { + if ( sCriteria1.getLength() == EQUALS.getLength() ) + rFilterField.Operator = sheet::FilterOperator2::EMPTY; + else + { + rFilterField.Operator = sheet::FilterOperator2::EQUAL; + sCriteria1 = sCriteria1.copy( EQUALS.getLength() ); + sCriteria1 = VBAToRegexp( sCriteria1 ); + // UseRegularExpressions + if ( xDescProps.is() ) + xDescProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseRegularExpressions" ) ), uno::Any( sal_True ) ); + } + + } + else if ( ( nPos = sCriteria1.indexOf( NOTEQUALS ) ) == 0 ) + { + if ( sCriteria1.getLength() == NOTEQUALS.getLength() ) + rFilterField.Operator = sheet::FilterOperator2::NOT_EMPTY; + else + { + rFilterField.Operator = sheet::FilterOperator2::NOT_EQUAL; + sCriteria1 = sCriteria1.copy( NOTEQUALS.getLength() ); + sCriteria1 = VBAToRegexp( sCriteria1 ); + // UseRegularExpressions + if ( xDescProps.is() ) + xDescProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseRegularExpressions" ) ), uno::Any( sal_True ) ); + } + } + else if ( ( nPos = sCriteria1.indexOf( GREATERTHAN ) ) == 0 ) + { + bIsNumeric = true; + if ( ( nPos = sCriteria1.indexOf( GREATERTHANEQUALS ) ) == 0 ) + { + sCriteria1 = sCriteria1.copy( GREATERTHANEQUALS.getLength() ); + rFilterField.Operator = sheet::FilterOperator2::GREATER_EQUAL; + } + else + { + sCriteria1 = sCriteria1.copy( GREATERTHAN.getLength() ); + rFilterField.Operator = sheet::FilterOperator2::GREATER; + } + + } + else if ( ( nPos = sCriteria1.indexOf( LESSTHAN ) ) == 0 ) + { + bIsNumeric = true; + if ( ( nPos = sCriteria1.indexOf( LESSTHANEQUALS ) ) == 0 ) + { + sCriteria1 = sCriteria1.copy( LESSTHANEQUALS.getLength() ); + rFilterField.Operator = sheet::FilterOperator2::LESS_EQUAL; + } + else + { + sCriteria1 = sCriteria1.copy( LESSTHAN.getLength() ); + rFilterField.Operator = sheet::FilterOperator2::LESS; + } + + } + else + rFilterField.Operator = sheet::FilterOperator2::EQUAL; + + if ( bIsNumeric ) + { + rFilterField.IsNumeric= sal_True; + rFilterField.NumericValue = sCriteria1.toDouble(); + } + rFilterField.StringValue = sCriteria1; +} void SAL_CALL ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const uno::Any& Operator, const uno::Any& Criteria2, const uno::Any& VisibleDropDown ) throw (uno::RuntimeException) { @@ -3943,106 +4032,213 @@ 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 ); - if ( Criteria1.hasValue() ) - { - sTabFilts.realloc( 1 ); - sTabFilts[0].Operator = sheet::FilterOperator_EQUAL;// sensible default - if ( !bCritHasNumericValue ) - { - Criteria1 >>= sCriteria1; - sTabFilts[0].IsNumeric = bCritHasNumericValue; - if ( bHasCritValue && sCriteria1.getLength() ) - lcl_setTableFieldsFromCriteria( sCriteria1, xDescProps, sTabFilts[0] ); - else - bAll = true; - } - else // numeric - { - sTabFilts[0].IsNumeric = sal_True; - sTabFilts[0].NumericValue = nCriteria1; - } - } - else // no value specified - bAll = true; - // not sure what the relationship between Criteria1 and Operator is, - // e.g. can you have a Operator without a Criteria ? in openoffice it - if ( Operator.hasValue() && ( Operator >>= nOperator ) ) - { - // if its a bottom/top Ten(Percent/Value) and there - // is no value specified for critera1 set it to 10 - if ( !bCritHasNumericValue && !sCriteria1.getLength() && ( nOperator != excel::XlAutoFilterOperator::xlOr ) && ( nOperator != excel::XlAutoFilterOperator::xlAnd ) ) - { - sTabFilts[0].IsNumeric = sal_True; - sTabFilts[0].NumericValue = 10; - bAll = false; - } - switch ( nOperator ) - { - case excel::XlAutoFilterOperator::xlBottom10Items: - sTabFilts[0].Operator = sheet::FilterOperator_BOTTOM_VALUES; - break; - case excel::XlAutoFilterOperator::xlBottom10Percent: - sTabFilts[0].Operator = sheet::FilterOperator_BOTTOM_PERCENT; - break; - case excel::XlAutoFilterOperator::xlTop10Items: - sTabFilts[0].Operator = sheet::FilterOperator_TOP_VALUES; - break; - case excel::XlAutoFilterOperator::xlTop10Percent: - sTabFilts[0].Operator = sheet::FilterOperator_TOP_PERCENT; - break; - case excel::XlAutoFilterOperator::xlOr: - nConn = sheet::FilterConnection_OR; - break; - case excel::XlAutoFilterOperator::xlAnd: - nConn = sheet::FilterConnection_AND; - break; - default: - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UnknownOption") ), uno::Reference< uno::XInterface >() ); - - } + uno::Reference< sheet::XSheetFilterDescriptor > xDesc = xDataBaseRange->getFilterDescriptor(); + uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc2( + xDesc, uno::UNO_QUERY ); + if ( xDesc2.is() ) + { + uno::Sequence< sheet::TableFilterField2 > sTabFilts2; + uno::Reference< beans::XPropertySet > xDescProps( xDesc2, uno::UNO_QUERY_THROW ); + if ( Criteria1.hasValue() ) + { + sTabFilts2.realloc( 1 ); + sTabFilts2[0].Operator = sheet::FilterOperator2::EQUAL;// sensible default + if ( !bCritHasNumericValue ) + { + Criteria1 >>= sCriteria1; + sTabFilts2[0].IsNumeric = bCritHasNumericValue; + if ( bHasCritValue && sCriteria1.getLength() ) + lcl_setTableFieldsFromCriteria2( sCriteria1, xDescProps, sTabFilts2[0] ); + else + bAll = true; + } + else // numeric + { + sTabFilts2[0].IsNumeric = sal_True; + sTabFilts2[0].NumericValue = nCriteria1; + } + } + else // no value specified + bAll = true; + // not sure what the relationship between Criteria1 and Operator is, + // e.g. can you have a Operator without a Criteria ? in openoffice it + if ( Operator.hasValue() && ( Operator >>= nOperator ) ) + { + // if its a bottom/top Ten(Percent/Value) and there + // is no value specified for critera1 set it to 10 + if ( !bCritHasNumericValue && !sCriteria1.getLength() && ( nOperator != excel::XlAutoFilterOperator::xlOr ) && ( nOperator != excel::XlAutoFilterOperator::xlAnd ) ) + { + sTabFilts2[0].IsNumeric = sal_True; + sTabFilts2[0].NumericValue = 10; + bAll = false; + } + switch ( nOperator ) + { + case excel::XlAutoFilterOperator::xlBottom10Items: + sTabFilts2[0].Operator = sheet::FilterOperator2::BOTTOM_VALUES; + break; + case excel::XlAutoFilterOperator::xlBottom10Percent: + sTabFilts2[0].Operator = sheet::FilterOperator2::BOTTOM_PERCENT; + break; + case excel::XlAutoFilterOperator::xlTop10Items: + sTabFilts2[0].Operator = sheet::FilterOperator2::TOP_VALUES; + break; + case excel::XlAutoFilterOperator::xlTop10Percent: + sTabFilts2[0].Operator = sheet::FilterOperator2::TOP_PERCENT; + break; + case excel::XlAutoFilterOperator::xlOr: + nConn = sheet::FilterConnection_OR; + break; + case excel::XlAutoFilterOperator::xlAnd: + nConn = sheet::FilterConnection_AND; + break; + default: + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UnknownOption") ), uno::Reference< uno::XInterface >() ); - } - if ( !bAll ) - { - sTabFilts[0].Connection = sheet::FilterConnection_AND; - sTabFilts[0].Field = (nField - 1); + } - rtl::OUString sCriteria2; - if ( Criteria2.hasValue() ) // there is a Criteria2 - { - sTabFilts.realloc(2); - sTabFilts[1].Field = sTabFilts[0].Field; - sTabFilts[1].Connection = nConn; + } + if ( !bAll ) + { + sTabFilts2[0].Connection = sheet::FilterConnection_AND; + sTabFilts2[0].Field = (nField - 1); - if ( Criteria2 >>= sCriteria2 ) - { - if ( sCriteria2.getLength() > 0 ) - { - uno::Reference< beans::XPropertySet > xProps; - lcl_setTableFieldsFromCriteria( sCriteria2, xProps, sTabFilts[1] ); - sTabFilts[1].IsNumeric = sal_False; - } - } - else // numeric - { - Criteria2 >>= sTabFilts[1].NumericValue; - sTabFilts[1].IsNumeric = sal_True; - sTabFilts[1].Operator = sheet::FilterOperator_EQUAL; - } - } - } + rtl::OUString sCriteria2; + if ( Criteria2.hasValue() ) // there is a Criteria2 + { + sTabFilts2.realloc(2); + sTabFilts2[1].Field = sTabFilts2[0].Field; + sTabFilts2[1].Connection = nConn; + + if ( Criteria2 >>= sCriteria2 ) + { + if ( sCriteria2.getLength() > 0 ) + { + uno::Reference< beans::XPropertySet > xProps; + lcl_setTableFieldsFromCriteria2( sCriteria2, xProps, sTabFilts2[1] ); + sTabFilts2[1].IsNumeric = sal_False; + } + } + else // numeric + { + Criteria2 >>= sTabFilts2[1].NumericValue; + sTabFilts2[1].IsNumeric = sal_True; + sTabFilts2[1].Operator = sheet::FilterOperator2::EQUAL; + } + } + } - xDesc->setFilterFields( sTabFilts ); - if ( !bAll ) - { - xDataBaseRange->refresh(); - } - else - // was 0 based now seems to be 1 - lcl_SetAllQueryForField( pShell, nField, nSheet ); + xDesc2->setFilterFields2( sTabFilts2 ); + if ( !bAll ) + { + xDataBaseRange->refresh(); + } + else + // was 0 based now seems to be 1 + lcl_SetAllQueryForField( pShell, nField, nSheet ); + } + else + { + uno::Sequence< sheet::TableFilterField > 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 + if ( !bCritHasNumericValue ) + { + Criteria1 >>= sCriteria1; + sTabFilts[0].IsNumeric = bCritHasNumericValue; + if ( bHasCritValue && sCriteria1.getLength() ) + lcl_setTableFieldsFromCriteria( sCriteria1, xDescProps, sTabFilts[0] ); + else + bAll = true; + } + else // numeric + { + sTabFilts[0].IsNumeric = sal_True; + sTabFilts[0].NumericValue = nCriteria1; + } + } + else // no value specified + bAll = true; + // not sure what the relationship between Criteria1 and Operator is, + // e.g. can you have a Operator without a Criteria ? in openoffice it + if ( Operator.hasValue() && ( Operator >>= nOperator ) ) + { + // if its a bottom/top Ten(Percent/Value) and there + // is no value specified for critera1 set it to 10 + if ( !bCritHasNumericValue && !sCriteria1.getLength() && ( nOperator != excel::XlAutoFilterOperator::xlOr ) && ( nOperator != excel::XlAutoFilterOperator::xlAnd ) ) + { + sTabFilts[0].IsNumeric = sal_True; + sTabFilts[0].NumericValue = 10; + bAll = false; + } + switch ( nOperator ) + { + case excel::XlAutoFilterOperator::xlBottom10Items: + sTabFilts[0].Operator = sheet::FilterOperator_BOTTOM_VALUES; + break; + case excel::XlAutoFilterOperator::xlBottom10Percent: + sTabFilts[0].Operator = sheet::FilterOperator_BOTTOM_PERCENT; + break; + case excel::XlAutoFilterOperator::xlTop10Items: + sTabFilts[0].Operator = sheet::FilterOperator_TOP_VALUES; + break; + case excel::XlAutoFilterOperator::xlTop10Percent: + sTabFilts[0].Operator = sheet::FilterOperator_TOP_PERCENT; + break; + case excel::XlAutoFilterOperator::xlOr: + nConn = sheet::FilterConnection_OR; + break; + case excel::XlAutoFilterOperator::xlAnd: + nConn = sheet::FilterConnection_AND; + break; + default: + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UnknownOption") ), uno::Reference< uno::XInterface >() ); + + } + + } + if ( !bAll ) + { + sTabFilts[0].Connection = sheet::FilterConnection_AND; + sTabFilts[0].Field = (nField - 1); + + rtl::OUString sCriteria2; + if ( Criteria2.hasValue() ) // there is a Criteria2 + { + sTabFilts.realloc(2); + sTabFilts[1].Field = sTabFilts[0].Field; + sTabFilts[1].Connection = nConn; + + if ( Criteria2 >>= sCriteria2 ) + { + if ( sCriteria2.getLength() > 0 ) + { + uno::Reference< beans::XPropertySet > xProps; + lcl_setTableFieldsFromCriteria( sCriteria2, xProps, sTabFilts[1] ); + sTabFilts[1].IsNumeric = sal_False; + } + } + else // numeric + { + Criteria2 >>= sTabFilts[1].NumericValue; + sTabFilts[1].IsNumeric = sal_True; + sTabFilts[1].Operator = sheet::FilterOperator_EQUAL; + } + } + } + + xDesc->setFilterFields( sTabFilts ); + if ( !bAll ) + { + xDataBaseRange->refresh(); + } + else + // was 0 based now seems to be 1 + lcl_SetAllQueryForField( pShell, nField, nSheet ); + } } else { diff -uNr i35579old/xmloff/inc/xmlkywd.hxx i35579new/xmloff/inc/xmlkywd.hxx --- i35579old/xmloff/inc/xmlkywd.hxx 2008-02-28 19:21:42.000000000 +0800 +++ i35579new/xmloff/inc/xmlkywd.hxx 2008-04-09 10:40:02.000000000 +0800 @@ -1998,4 +1998,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 i35579old/xmloff/inc/xmloff/xmltoken.hxx i35579new/xmloff/inc/xmloff/xmltoken.hxx --- i35579old/xmloff/inc/xmloff/xmltoken.hxx 2008-03-08 01:49:04.000000000 +0800 +++ i35579new/xmloff/inc/xmloff/xmltoken.hxx 2008-04-09 10:43:18.000000000 +0800 @@ -2963,6 +2963,12 @@ XML_NEAR_ORIGIN, XML_DEPENDENCY, 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_AUTOMATIC_CONTENT, XML_DISPLAY_R_SQUARE, XML_DISPLAY_EQUATION, diff -uNr i35579old/xmloff/source/core/xmltoken.cxx i35579new/xmloff/source/core/xmltoken.cxx --- i35579old/xmloff/source/core/xmltoken.cxx 2008-03-08 01:49:06.000000000 +0800 +++ i35579new/xmloff/source/core/xmltoken.cxx 2008-04-09 10:43:20.000000000 +0800 @@ -2962,6 +2962,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( "automatic-content", XML_AUTOMATIC_CONTENT ), TOKEN( "display-r-square", XML_DISPLAY_R_SQUARE ), TOKEN( "display-equation", XML_DISPLAY_EQUATION ),