diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-29 21:08:36 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-29 22:35:46 -0500 |
commit | d4a51391d32d9c1f53dcdcc48aeb7a0c63f6c374 (patch) | |
tree | b099d015c081cfc65c6831f043b30de74c27ceb7 /oox | |
parent | af4435c5a4964a86457fe61c3bade42ca3cf236d (diff) |
Correctly import multi-value filter settings.
We are still not 100% compatible, e.g. Excel's "show blanks" setting
is not cleanly mapped (partly due to ODF's limitation). But that's
a future TODO.
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/xls/autofilterbuffer.hxx | 5 | ||||
-rw-r--r-- | oox/source/xls/autofilterbuffer.cxx | 18 |
2 files changed, 19 insertions, 4 deletions
diff --git a/oox/inc/oox/xls/autofilterbuffer.hxx b/oox/inc/oox/xls/autofilterbuffer.hxx index 869c2114b098..493c512b7b42 100644 --- a/oox/inc/oox/xls/autofilterbuffer.hxx +++ b/oox/inc/oox/xls/autofilterbuffer.hxx @@ -54,8 +54,9 @@ struct ApiFilterSettings explicit ApiFilterSettings(); - void appendField( bool bAnd, sal_Int32 nOperator, double fValue ); - void appendField( bool bAnd, sal_Int32 nOperator, const ::rtl::OUString& rValue ); + void appendField( bool bAnd, sal_Int32 nOperator, double fValue ); + void appendField( bool bAnd, sal_Int32 nOperator, const ::rtl::OUString& rValue ); + void appendField( bool bAnd, const std::vector<rtl::OUString>& rValues ); }; // ============================================================================ diff --git a/oox/source/xls/autofilterbuffer.cxx b/oox/source/xls/autofilterbuffer.cxx index dd3fc5acf31d..7a3e6fad0be0 100644 --- a/oox/source/xls/autofilterbuffer.cxx +++ b/oox/source/xls/autofilterbuffer.cxx @@ -189,6 +189,21 @@ void ApiFilterSettings::appendField( bool bAnd, sal_Int32 nOperator, const OUStr rFilterField.Values[0].StringValue = rValue; } +void ApiFilterSettings::appendField( bool bAnd, const std::vector<rtl::OUString>& rValues ) +{ + maFilterFields.resize( maFilterFields.size() + 1 ); + TableFilterField3& rFilterField = maFilterFields.back(); + rFilterField.Connection = bAnd ? FilterConnection_AND : FilterConnection_OR; + rFilterField.Operator = FilterOperator2::EQUAL; + size_t n = rValues.size(); + rFilterField.Values.realloc(n); + for (size_t i = 0; i < n; ++i) + { + rFilterField.Values[i].IsNumeric = false; + rFilterField.Values[i].StringValue = rValues[i]; + } +} + // ============================================================================ FilterSettingsBase::FilterSettingsBase( const WorkbookHelper& rHelper ) : @@ -276,8 +291,7 @@ ApiFilterSettings DiscreteFilter::finalizeImport( sal_Int32 nMaxCount ) aSettings.maFilterFields.reserve( maValues.size() ); // insert all filter values - for( FilterValueVector::iterator aIt = maValues.begin(), aEnd = maValues.end(); aIt != aEnd; ++aIt ) - aSettings.appendField( false, FilterOperator2::EQUAL, *aIt ); + aSettings.appendField( true, maValues ); // extra field for 'show empty' if( mbShowBlank ) |