diff options
author | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2009-11-23 13:30:17 +0100 |
---|---|---|
committer | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2009-11-23 13:30:17 +0100 |
commit | b0fe07fec29262fdc5e1aaf97812caadbb9d5c15 (patch) | |
tree | 657adde6ae059b3422fcb2582c601bd481248350 /tools | |
parent | 9bf73f92e0645538720958375b2930bead4d8dc7 (diff) |
printerpullpages: #i106836# allow less strict parsing of passed ranges string
Diffstat (limited to 'tools')
-rw-r--r-- | tools/inc/tools/multisel.hxx | 4 | ||||
-rw-r--r-- | tools/source/memtools/multisel.cxx | 25 |
2 files changed, 20 insertions, 9 deletions
diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index bd2f7023bf8d..9de3cc172e70 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -131,7 +131,7 @@ class TOOLS_DLLPUBLIC StringRangeEnumerator sal_Int32 mnMax; sal_Int32 mnOffset; - bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence ); + bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence, bool bMayAdjust ); bool checkValue( sal_Int32, const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; public: class TOOLS_DLLPUBLIC Iterator @@ -177,7 +177,7 @@ public: sal_Int32 getLogicalOffset() const { return mnOffset; } void setLogicalOffset( sal_Int32 i_nOffset ) { mnOffset = i_nOffset; } - bool setRange( const rtl::OUString& i_rNewRange ); + bool setRange( const rtl::OUString& i_rNewRange, bool i_bStrict = false ); bool hasValue( sal_Int32 nValue, const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index 4f5ccbbabeae..5fe920b6998a 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -901,7 +901,7 @@ bool StringRangeEnumerator::checkValue( sal_Int32 i_nValue, const std::set< sal_ return true; } -bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, bool bSequence ) +bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, bool bSequence, bool bMayAdjust ) { bool bSuccess = true; if( bSequence ) @@ -910,6 +910,17 @@ bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, i_nFirst = mnMin; if( i_nLast == -1 ) i_nLast = mnMax; + if( bMayAdjust ) + { + if( i_nFirst < mnMin ) + i_nFirst = mnMin; + if( i_nFirst > mnMax ) + i_nFirst = mnMax; + if( i_nLast < mnMin ) + i_nLast = mnMin; + if( i_nLast > mnMax ) + i_nLast = mnMax; + } if( checkValue( i_nFirst ) && checkValue( i_nLast ) ) { maSequence.push_back( Range( i_nFirst, i_nLast ) ); @@ -947,7 +958,7 @@ bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, return bSuccess; } -bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) +bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange, bool i_bStrict ) { mnCount = 0; maSequence.clear(); @@ -957,7 +968,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) { if( mnMin >= 0 && mnMax >= 0 ) { - insertRange( mnMin, mnMax, mnMin != mnMax ); + insertRange( mnMin, mnMax, mnMin != mnMax, ! i_bStrict ); } return true; } @@ -977,7 +988,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) { if( bSequence ) { - if( ! insertRange( nLastNumber, nNumber, true ) ) + if( ! insertRange( nLastNumber, nNumber, true, ! i_bStrict ) && i_bStrict ) { bSuccess = false; break; @@ -986,7 +997,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) } else { - if( ! insertRange( nNumber, nNumber, false ) ) + if( ! insertRange( nNumber, nNumber, false, ! i_bStrict ) && i_bStrict ) { bSuccess = false; break; @@ -1017,7 +1028,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) if( bInsertRange ) { - if( ! insertRange( nLastNumber, nNumber, bSequence ) ) + if( ! insertRange( nLastNumber, nNumber, bSequence, ! i_bStrict ) && i_bStrict ) { bSuccess = false; break; @@ -1029,7 +1040,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) pInput++; } // insert last entries - insertRange( nLastNumber, nNumber, bSequence ); + insertRange( nLastNumber, nNumber, bSequence, ! i_bStrict ); return bSuccess; } |