From e83bd2a5f6cab65ececd3a22722a41bbbeaf43b7 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 8 Jul 2009 16:27:08 +0000 Subject: #i95216# get a new enumerator that parsers a page range --- tools/inc/tools/multisel.hxx | 75 ++++++++++++++++ tools/source/memtools/multisel.cxx | 172 +++++++++++++++++++++++++++++++++++++ 2 files changed, 247 insertions(+) (limited to 'tools') diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index 46fd8947e21b..9e018d6b8479 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -35,6 +35,8 @@ #include #include +#include + //------------------------------------------------------------------ #ifdef _SV_MULTISEL_CXX @@ -112,4 +114,77 @@ public: const Range& GetRange( ULONG nRange ) const { return *(const Range*)aSels.GetObject(nRange); } }; +class TOOLS_DLLPUBLIC StringRangeEnumerator +{ + std::vector< sal_Int32 > maSequence; + sal_Int32 mnMin; + sal_Int32 mnMax; + sal_Int32 mnOffset; +public: + + typedef std::vector< sal_Int32 >::const_iterator Iterator; + + StringRangeEnumerator() {} + StringRangeEnumerator( const rtl::OUString& i_rInput, + sal_Int32 i_nMinNumber = -1, + sal_Int32 i_nMaxNumber = -1, + sal_Int32 i_nLogicalOffset = -1 ) : + mnMin( i_nMinNumber ), + mnMax( i_nMaxNumber ), + mnOffset( i_nLogicalOffset ) + { + getRangesFromString( i_rInput, maSequence, mnMin, mnMax, mnOffset ); + } + + size_t size() const { return maSequence.size(); } + Iterator begin() const { return maSequence.begin(); } + Iterator end() const { return maSequence.end(); } + + sal_Int32 getMin() const { return mnMin; } + void setMin( sal_Int32 i_nMinValue ) { mnMin = i_nMinValue; } + sal_Int32 getMax() const { return mnMax; } + void setMax( sal_Int32 i_nMaxValue ) { mnMax = i_nMaxValue; } + sal_Int32 getLogicalOffset() const { return mnOffset; } + void setLogicalOffset( sal_Int32 i_nOffset ) { mnOffset = i_nOffset; } + + void setRange( const rtl::OUString& i_rNewRange ) + { + maSequence.clear(); + getRangesFromString( i_rNewRange, maSequence, mnMin, mnMax, mnOffset ); + } + + + /** + i_rPageRange: the string to be changed into a sequence of numbers + valid format example "5-3,9,9,7-8" ; instead of ',' ';' or ' ' are allowed as well + o_rPageVector: the output sequence of numbers + i_nLogicalOffset: an offset to be applied to each number in the string before inserting it in the resulting sequence + example: a user enters page numbers from 1 to n (since that is logical) + of course usable page numbers in code would start from 0 and end at n-1 + so the logical offset would be -1 + i_nMinNumber: the minimum allowed number, a negative number means no minimum check + i_nMaxNumber: the maximum allowed number, a negative number means no maximum check + + @returns: true if the input string was valid, o_rPageVector will contain the resulting sequence + false if the input string was invalid, o_rPageVector will be unchanged + + behavior: + - only non-negative sequence numbers are allowed + - only non-negative values in the input string are allowed + - the string "-3" will be either + * an error if no minimum is given + * or result in the sequence i_nMinNumber to 3 + - the string "3-" will be either + * an error if no maximum is given + * or result in the seqeuence 3 to i_nMaxNumber + - an empty string as input is valid and will result in an empty result vector + */ + static bool getRangesFromString( const rtl::OUString& i_rPageRange, + std::vector< sal_Int32 >& o_rPageVector, + sal_Int32 i_nMinNumber = -1, + sal_Int32 i_nMaxNumber = -1, + sal_Int32 i_nLogicalOffset = -1 + ); +}; + #endif // _SV_MULTISEL_HXX diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index 6b32badc283e..a28b54c2347e 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -47,6 +47,8 @@ #define DBG(x) #endif +using namespace rtl; + //================================================================== #ifdef MI_DEBUG @@ -865,3 +867,173 @@ void MultiSelection::SetTotalRange( const Range& rTotRange ) bCurValid = FALSE; nCurIndex = 0; } + +// ----------------------------------------------------------------------- +// +// StringRangeEnumerator +// +// ----------------------------------------------------------------------- + +static bool lcl_getSingleValue( + const OUString &rText, + sal_Int32 &rVal, + sal_Int32 nLogicalOffset, + sal_Int32 nMinNumber, + sal_Int32 nMaxNumber + ) +{ + bool bRes = false; + const sal_Int32 nLen = rText.getLength(); + if (nLen > 0) + { + // verify that text consists of decimal number 0..9 only + bool bValidText = true; + const sal_Unicode *pText = rText.getStr(); + for (sal_Int32 i = 0; i < nLen && bValidText; ++i) + { + const sal_Unicode cChar = pText[i]; + if (cChar < '0' || cChar > '9') + bValidText = false; + } + + // get integer value if text is valid + if (bValidText) + { + sal_Int32 nTmpVal = rText.toInt32(); + nTmpVal += nLogicalOffset; + if( nTmpVal >= 0 && + (nMinNumber < 0 || nTmpVal >= nMinNumber) && + (nMaxNumber < 0 || nTmpVal <= nMaxNumber) + ) + { + bRes = true; + rVal = nTmpVal; + } + } + } + return bRes; +} + +static bool lcl_getSubRangeBounds( + const OUString &rSubRange, + sal_Int32 &rFirst, + sal_Int32 &rLast, + sal_Int32 nLogicalOffset, + sal_Int32 nMinNumber, + sal_Int32 nMaxNumber + ) +{ + bool bRes = false; + + // check for page range... + sal_Int32 nPos = rSubRange.indexOf( (sal_Unicode)'-' ); + if (nPos > 0) + { + // page range found... + nPos = 0; + const OUString aFirstPage( rSubRange.getToken( 0, '-', nPos ) ); + const OUString aLastPage( rSubRange.getToken( 0, '-', nPos ) ); + sal_Int32 nTmpFirst = -1; + sal_Int32 nTmpLast = -1; + if( aFirstPage.getLength() == 0 && nMinNumber >= 0 ) + nTmpFirst = nMinNumber; + else + lcl_getSingleValue( aFirstPage, nTmpFirst, nLogicalOffset, nMinNumber, nMaxNumber ); + if( aLastPage.getLength() == 0 && nMaxNumber >= 0 ) + nTmpLast = nMaxNumber; + else + lcl_getSingleValue( aLastPage, nTmpLast, nLogicalOffset, nMinNumber, nMaxNumber ); + if( nTmpFirst != -1 && nTmpLast != -1 ) + { + rFirst = nTmpFirst; + rLast = nTmpLast; + bRes = true; + } + } + else + { + // single page value... + sal_Int32 nVal = -1; + if (lcl_getSingleValue( rSubRange, nVal, nLogicalOffset, nMinNumber, nMaxNumber )) + { + rFirst = rLast = nVal; + bRes = true; + } + } + + return bRes; +} + +bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, + std::vector< sal_Int32 >& o_rPageVector, + sal_Int32 i_nMinNumber, + sal_Int32 i_nMaxNumber, + sal_Int32 i_nLogicalOffset + ) +{ + bool bRes = false; + + // - strip leading and trailing whitespaces + // - unify token delimeters to ';' + // - remove duplicate delimiters + OUString aRange( i_rPageRange.trim() ); + aRange = aRange.replace( (sal_Unicode)' ', (sal_Unicode)';' ); + aRange = aRange.replace( (sal_Unicode)',', (sal_Unicode)';' ); + sal_Int32 nPos = -1; + rtl::OUString aDoubleSemi( RTL_CONSTASCII_USTRINGPARAM(";;") ); + rtl::OUString aSingleSemi( RTL_CONSTASCII_USTRINGPARAM(";;") ); + while ((nPos = aRange.indexOf( aDoubleSemi )) >= 0) + aRange = aRange.replaceAt( nPos, 2, aSingleSemi ); + + if (aRange.getLength() > 0) + { + std::vector< sal_Int32 > aTmpVector; + + // iterate over all sub ranges and add the respective pages to the + // vector while preserving the page order + bool bFailed = false; + nPos = 0; + do + { + const OUString aSubRange = aRange.getToken( 0, ';', nPos ); + sal_Int32 nFirst = -1, nLast = -1; + if (lcl_getSubRangeBounds( aSubRange, nFirst, nLast, i_nLogicalOffset, i_nMinNumber, i_nMaxNumber ) + && nFirst >= 0 && nLast >= 0) + { + // add pages of sub range to vector + if (nFirst == nLast) + aTmpVector.push_back( nFirst ); + else if (nFirst < nLast) + { + for (sal_Int32 i = nFirst; i <= nLast; ++i) + aTmpVector.push_back( i ); + } + else if (nFirst > nLast) + { + for (sal_Int32 i = nFirst; i >= nLast; --i) + aTmpVector.push_back( i ); + } + else + OSL_ENSURE( 0, "unexpected case" ); + } + else + bFailed = true; + } + while (!bFailed && 0 <= nPos && nPos < aRange.getLength()); + + if (!bFailed) + { + o_rPageVector = aTmpVector; + bRes = true; + } + } + else + { + // empty string ... + o_rPageVector.clear(); + bRes = true; + } + + return bRes; +} + -- cgit v1.2.3 From 3f6401a45f6c8b112752900e959384080e5a4522 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 9 Jul 2009 14:01:10 +0000 Subject: add: set of possible values --- tools/inc/tools/multisel.hxx | 14 +++++++++----- tools/source/memtools/multisel.cxx | 23 +++++++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) (limited to 'tools') diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index 9e018d6b8479..e30aff744897 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -36,6 +36,7 @@ #include #include +#include //------------------------------------------------------------------ @@ -128,12 +129,14 @@ public: StringRangeEnumerator( const rtl::OUString& i_rInput, sal_Int32 i_nMinNumber = -1, sal_Int32 i_nMaxNumber = -1, - sal_Int32 i_nLogicalOffset = -1 ) : + sal_Int32 i_nLogicalOffset = -1, + std::set< sal_Int32 >* i_pPossibleValues = NULL + ) : mnMin( i_nMinNumber ), mnMax( i_nMaxNumber ), mnOffset( i_nLogicalOffset ) { - getRangesFromString( i_rInput, maSequence, mnMin, mnMax, mnOffset ); + getRangesFromString( i_rInput, maSequence, mnMin, mnMax, mnOffset, i_pPossibleValues ); } size_t size() const { return maSequence.size(); } @@ -147,10 +150,10 @@ public: sal_Int32 getLogicalOffset() const { return mnOffset; } void setLogicalOffset( sal_Int32 i_nOffset ) { mnOffset = i_nOffset; } - void setRange( const rtl::OUString& i_rNewRange ) + void setRange( const rtl::OUString& i_rNewRange, std::set< sal_Int32 >* i_pPossibleValues = NULL ) { maSequence.clear(); - getRangesFromString( i_rNewRange, maSequence, mnMin, mnMax, mnOffset ); + getRangesFromString( i_rNewRange, maSequence, mnMin, mnMax, mnOffset, i_pPossibleValues ); } @@ -183,7 +186,8 @@ public: std::vector< sal_Int32 >& o_rPageVector, sal_Int32 i_nMinNumber = -1, sal_Int32 i_nMaxNumber = -1, - sal_Int32 i_nLogicalOffset = -1 + sal_Int32 i_nLogicalOffset = -1, + std::set< sal_Int32 >* i_pPossibleValues = NULL ); }; diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index a28b54c2347e..642a2398ae91 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -964,11 +964,17 @@ static bool lcl_getSubRangeBounds( return bRes; } +inline bool checkValue( std::set< sal_Int32 >* i_pPossibleValues, sal_Int32 nVal ) +{ + return i_pPossibleValues ? (i_pPossibleValues->find( nVal ) != i_pPossibleValues->end()) : true; +} + bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, std::vector< sal_Int32 >& o_rPageVector, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, - sal_Int32 i_nLogicalOffset + sal_Int32 i_nLogicalOffset, + std::set< sal_Int32 >* i_pPossibleValues ) { bool bRes = false; @@ -1002,16 +1008,25 @@ bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, { // add pages of sub range to vector if (nFirst == nLast) - aTmpVector.push_back( nFirst ); + { + if( checkValue( i_pPossibleValues, nFirst ) ) + aTmpVector.push_back( nFirst ); + } else if (nFirst < nLast) { for (sal_Int32 i = nFirst; i <= nLast; ++i) - aTmpVector.push_back( i ); + { + if( checkValue( i_pPossibleValues, i ) ) + aTmpVector.push_back( i ); + } } else if (nFirst > nLast) { for (sal_Int32 i = nFirst; i >= nLast; --i) - aTmpVector.push_back( i ); + { + if( checkValue( i_pPossibleValues, i ) ) + aTmpVector.push_back( i ); + } } else OSL_ENSURE( 0, "unexpected case" ); -- cgit v1.2.3 From a2459a0cb43b28458b1fef79db93067bb7f3bfc4 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 10 Jul 2009 13:52:54 +0000 Subject: #i92516# new parser for ranges --- tools/inc/tools/multisel.hxx | 74 +++++--- tools/source/memtools/multisel.cxx | 355 +++++++++++++++++++++++-------------- 2 files changed, 270 insertions(+), 159 deletions(-) (limited to 'tools') diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index e30aff744897..e9b8b0f00177 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -117,31 +117,58 @@ public: class TOOLS_DLLPUBLIC StringRangeEnumerator { - std::vector< sal_Int32 > maSequence; - sal_Int32 mnMin; - sal_Int32 mnMax; - sal_Int32 mnOffset; + struct Range + { + sal_Int32 nFirst; + sal_Int32 nLast; + + Range() : nFirst( -1 ), nLast( -1 ) {} + Range( sal_Int32 i_nFirst, sal_Int32 i_nLast ) : nFirst( i_nFirst ), nLast( i_nLast ) {} + }; + std::vector< StringRangeEnumerator::Range > maSequence; + sal_Int32 mnCount; + sal_Int32 mnMin; + sal_Int32 mnMax; + sal_Int32 mnOffset; + + bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence ); + bool checkValue( sal_Int32, const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; public: - - typedef std::vector< sal_Int32 >::const_iterator Iterator; - - StringRangeEnumerator() {} + class TOOLS_DLLPUBLIC Iterator + { + const StringRangeEnumerator* pEnumerator; + const std::set< sal_Int32 >* pPossibleValues; + sal_Int32 nRangeIndex; + sal_Int32 nCurrent; + + friend class StringRangeEnumerator; + Iterator( const StringRangeEnumerator* i_pEnum, + const std::set< sal_Int32 >* i_pPossibleValues, + sal_Int32 i_nRange, + sal_Int32 i_nCurrent ) + : pEnumerator( i_pEnum ), pPossibleValues( i_pPossibleValues ) + , nRangeIndex( i_nRange ), nCurrent( i_nCurrent ) {} + public: + Iterator() : pEnumerator( NULL ), pPossibleValues( NULL ), nRangeIndex( -1 ), nCurrent( -1 ) {} + Iterator& operator++(); + sal_Int32 operator*() const; + bool operator==(const Iterator&) const; + bool operator!=(const Iterator& i_rComp) const + { return ! (*this == i_rComp); } + }; + + friend class StringRangeEnumerator::Iterator; + + StringRangeEnumerator() : mnCount( 0 ), mnMin( -1 ), mnMax( -1 ), mnOffset( -1 ) {} StringRangeEnumerator( const rtl::OUString& i_rInput, sal_Int32 i_nMinNumber = -1, sal_Int32 i_nMaxNumber = -1, - sal_Int32 i_nLogicalOffset = -1, - std::set< sal_Int32 >* i_pPossibleValues = NULL - ) : - mnMin( i_nMinNumber ), - mnMax( i_nMaxNumber ), - mnOffset( i_nLogicalOffset ) - { - getRangesFromString( i_rInput, maSequence, mnMin, mnMax, mnOffset, i_pPossibleValues ); - } + sal_Int32 i_nLogicalOffset = -1 + ); - size_t size() const { return maSequence.size(); } - Iterator begin() const { return maSequence.begin(); } - Iterator end() const { return maSequence.end(); } + size_t size() const { return size_t(mnCount); } + Iterator begin( const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; + Iterator end( const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; sal_Int32 getMin() const { return mnMin; } void setMin( sal_Int32 i_nMinValue ) { mnMin = i_nMinValue; } @@ -150,11 +177,8 @@ public: sal_Int32 getLogicalOffset() const { return mnOffset; } void setLogicalOffset( sal_Int32 i_nOffset ) { mnOffset = i_nOffset; } - void setRange( const rtl::OUString& i_rNewRange, std::set< sal_Int32 >* i_pPossibleValues = NULL ) - { - maSequence.clear(); - getRangesFromString( i_rNewRange, maSequence, mnMin, mnMax, mnOffset, i_pPossibleValues ); - } + bool setRange( const rtl::OUString& i_rNewRange ); + 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 642a2398ae91..db83f3b47866 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -41,6 +41,8 @@ #include #include +#include "rtl/ustrbuf.hxx" + #ifdef MI_DEBUG #define DBG(x) x #else @@ -873,100 +875,240 @@ void MultiSelection::SetTotalRange( const Range& rTotRange ) // StringRangeEnumerator // // ----------------------------------------------------------------------- +StringRangeEnumerator::StringRangeEnumerator( const rtl::OUString& i_rInput, + sal_Int32 i_nMinNumber, + sal_Int32 i_nMaxNumber, + sal_Int32 i_nLogicalOffset + ) + : mnCount( 0 ) + , mnMin( i_nMinNumber ) + , mnMax( i_nMaxNumber ) + , mnOffset( i_nLogicalOffset ) +{ + setRange( i_rInput ); +} -static bool lcl_getSingleValue( - const OUString &rText, - sal_Int32 &rVal, - sal_Int32 nLogicalOffset, - sal_Int32 nMinNumber, - sal_Int32 nMaxNumber - ) +bool StringRangeEnumerator::checkValue( sal_Int32 i_nValue, const std::set< sal_Int32 >* i_pPossibleValues ) const { - bool bRes = false; - const sal_Int32 nLen = rText.getLength(); - if (nLen > 0) + if( mnMin >= 0 && i_nValue < mnMin ) + return false; + if( mnMax >= 0 && i_nValue > mnMax ) + return false; + if( i_nValue < 0 ) + return false; + if( i_pPossibleValues && i_pPossibleValues->find( i_nValue ) == i_pPossibleValues->end() ) + return false; + return true; +} + +bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, bool bSequence ) +{ + bool bSuccess = true; + if( bSequence ) { - // verify that text consists of decimal number 0..9 only - bool bValidText = true; - const sal_Unicode *pText = rText.getStr(); - for (sal_Int32 i = 0; i < nLen && bValidText; ++i) + if( i_nFirst == -1 ) + i_nFirst = mnMin; + if( i_nLast == -1 ) + i_nLast = mnMax; + if( checkValue( i_nFirst ) && checkValue( i_nLast ) ) { - const sal_Unicode cChar = pText[i]; - if (cChar < '0' || cChar > '9') - bValidText = false; + maSequence.push_back( Range( i_nFirst, i_nLast ) ); + mnCount += std::abs( i_nLast - i_nFirst - 1 ); } - - // get integer value if text is valid - if (bValidText) + else + bSuccess = false; + } + else + { + if( i_nFirst >= 0 ) + { + if( checkValue( i_nFirst ) ) + { + maSequence.push_back( Range( i_nFirst, i_nFirst ) ); + mnCount++; + } + else + bSuccess = false; + } + if( i_nLast >= 0 ) { - sal_Int32 nTmpVal = rText.toInt32(); - nTmpVal += nLogicalOffset; - if( nTmpVal >= 0 && - (nMinNumber < 0 || nTmpVal >= nMinNumber) && - (nMaxNumber < 0 || nTmpVal <= nMaxNumber) - ) + if( checkValue( i_nLast ) ) { - bRes = true; - rVal = nTmpVal; + maSequence.push_back( Range( i_nLast, i_nLast ) ); + mnCount++; } + else + bSuccess = false; } } - return bRes; + + return bSuccess; } -static bool lcl_getSubRangeBounds( - const OUString &rSubRange, - sal_Int32 &rFirst, - sal_Int32 &rLast, - sal_Int32 nLogicalOffset, - sal_Int32 nMinNumber, - sal_Int32 nMaxNumber - ) +bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) { - bool bRes = false; - - // check for page range... - sal_Int32 nPos = rSubRange.indexOf( (sal_Unicode)'-' ); - if (nPos > 0) + mnCount = 0; + maSequence.clear(); + + const sal_Unicode* pInput = i_rNewRange.getStr(); + rtl::OUStringBuffer aNumberBuf( 16 ); + sal_Int32 nLastNumber = -1, nNumber = -1; + bool bSequence = false; + bool bSuccess = true; + while( *pInput ) { - // page range found... - nPos = 0; - const OUString aFirstPage( rSubRange.getToken( 0, '-', nPos ) ); - const OUString aLastPage( rSubRange.getToken( 0, '-', nPos ) ); - sal_Int32 nTmpFirst = -1; - sal_Int32 nTmpLast = -1; - if( aFirstPage.getLength() == 0 && nMinNumber >= 0 ) - nTmpFirst = nMinNumber; + while( *pInput >= sal_Unicode('0') && *pInput <= sal_Unicode('9') ) + aNumberBuf.append( *pInput++ ); + if( aNumberBuf.getLength() ) + { + if( nNumber != -1 ) + { + if( bSequence ) + { + if( ! insertRange( nLastNumber, nNumber, true ) ) + { + bSuccess = false; + break; + } + nLastNumber = -1; + } + else + { + if( ! insertRange( nNumber, nNumber, false ) ) + { + bSuccess = false; + break; + } + } + } + nNumber = aNumberBuf.makeStringAndClear().toInt32(); + nNumber += mnOffset; + } + bool bInsertRange = false; + if( *pInput == sal_Unicode('-') ) + { + nLastNumber = nNumber; + nNumber = -1; + bSequence = true; + } + else if( *pInput == ' ' ) + { + } + else if( *pInput == sal_Unicode(',') || *pInput == sal_Unicode(';') ) + bInsertRange = true; else - lcl_getSingleValue( aFirstPage, nTmpFirst, nLogicalOffset, nMinNumber, nMaxNumber ); - if( aLastPage.getLength() == 0 && nMaxNumber >= 0 ) - nTmpLast = nMaxNumber; + { + bSuccess = false; + break; // parse error + } + + if( bInsertRange ) + { + if( ! insertRange( nLastNumber, nNumber, bSequence ) ) + { + bSuccess = false; + break; + } + nNumber = nLastNumber = -1; + bSequence = false; + } + if( *pInput ) + pInput++; + } + // insert last entries + insertRange( nLastNumber, nNumber, bSequence ); + + return bSuccess; +} + +bool StringRangeEnumerator::hasValue( sal_Int32 i_nValue, const std::set< sal_Int32 >* i_pPossibleValues ) const +{ + if( i_pPossibleValues && i_pPossibleValues->find( i_nValue ) == i_pPossibleValues->end() ) + return false; + size_t n = maSequence.size(); + for( size_t i= 0; i < n; ++i ) + { + const StringRangeEnumerator::Range rRange( maSequence[i] ); + if( rRange.nFirst < rRange.nLast ) + { + if( i_nValue >= rRange.nFirst && i_nValue <= rRange.nLast ) + return true; + } else - lcl_getSingleValue( aLastPage, nTmpLast, nLogicalOffset, nMinNumber, nMaxNumber ); - if( nTmpFirst != -1 && nTmpLast != -1 ) { - rFirst = nTmpFirst; - rLast = nTmpLast; - bRes = true; + if( i_nValue >= rRange.nLast && i_nValue <= rRange.nFirst ) + return true; } } - else + return false; +} + +StringRangeEnumerator::Iterator& StringRangeEnumerator::Iterator::operator++() +{ + if( nRangeIndex >= 0 && nCurrent >= 0 && pEnumerator ) { - // single page value... - sal_Int32 nVal = -1; - if (lcl_getSingleValue( rSubRange, nVal, nLogicalOffset, nMinNumber, nMaxNumber )) + const StringRangeEnumerator::Range& rRange( pEnumerator->maSequence[nRangeIndex] ); + bool bRangeChange = false; + if( rRange.nLast < rRange.nFirst ) + { + // backward range + if( nCurrent > rRange.nLast ) + nCurrent--; + else + bRangeChange = true; + } + else + { + // forward range + if( nCurrent < rRange.nLast ) + nCurrent++; + else + bRangeChange = true; + } + if( bRangeChange ) + { + nRangeIndex++; + if( size_t(nRangeIndex) == pEnumerator->maSequence.size() ) + { + // reached the end + nRangeIndex = nCurrent = -1; + } + else + nCurrent = pEnumerator->maSequence[nRangeIndex].nFirst; + } + if( nRangeIndex != -1 && nCurrent != -1 ) { - rFirst = rLast = nVal; - bRes = true; + if( ! pEnumerator->checkValue( nCurrent, pPossibleValues ) ) + return ++(*this); } } + return *this; +} - return bRes; +sal_Int32 StringRangeEnumerator::Iterator::operator*() const +{ + return nCurrent; +} + +bool StringRangeEnumerator::Iterator::operator==( const Iterator& i_rCompare ) const +{ + return i_rCompare.pEnumerator == pEnumerator && i_rCompare.nRangeIndex == nRangeIndex && i_rCompare.nCurrent == nCurrent; } -inline bool checkValue( std::set< sal_Int32 >* i_pPossibleValues, sal_Int32 nVal ) +StringRangeEnumerator::Iterator StringRangeEnumerator::begin( const std::set< sal_Int32 >* i_pPossibleValues ) const { - return i_pPossibleValues ? (i_pPossibleValues->find( nVal ) != i_pPossibleValues->end()) : true; + StringRangeEnumerator::Iterator it( this, + i_pPossibleValues, + maSequence.empty() ? -1 : 0, + maSequence.empty() ? -1 : maSequence[0].nFirst ); + if( ! checkValue(*it, i_pPossibleValues ) ) + ++it; + return it; +} + +StringRangeEnumerator::Iterator StringRangeEnumerator::end( const std::set< sal_Int32 >* i_pPossibleValues ) const +{ + return StringRangeEnumerator::Iterator( this, i_pPossibleValues, -1, -1 ); } bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, @@ -977,76 +1119,21 @@ bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, std::set< sal_Int32 >* i_pPossibleValues ) { - bool bRes = false; - - // - strip leading and trailing whitespaces - // - unify token delimeters to ';' - // - remove duplicate delimiters - OUString aRange( i_rPageRange.trim() ); - aRange = aRange.replace( (sal_Unicode)' ', (sal_Unicode)';' ); - aRange = aRange.replace( (sal_Unicode)',', (sal_Unicode)';' ); - sal_Int32 nPos = -1; - rtl::OUString aDoubleSemi( RTL_CONSTASCII_USTRINGPARAM(";;") ); - rtl::OUString aSingleSemi( RTL_CONSTASCII_USTRINGPARAM(";;") ); - while ((nPos = aRange.indexOf( aDoubleSemi )) >= 0) - aRange = aRange.replaceAt( nPos, 2, aSingleSemi ); - - if (aRange.getLength() > 0) - { - std::vector< sal_Int32 > aTmpVector; + StringRangeEnumerator aEnum; + aEnum.setMin( i_nMinNumber ); + aEnum.setMax( i_nMaxNumber ); + aEnum.setLogicalOffset( i_nLogicalOffset ); - // iterate over all sub ranges and add the respective pages to the - // vector while preserving the page order - bool bFailed = false; - nPos = 0; - do - { - const OUString aSubRange = aRange.getToken( 0, ';', nPos ); - sal_Int32 nFirst = -1, nLast = -1; - if (lcl_getSubRangeBounds( aSubRange, nFirst, nLast, i_nLogicalOffset, i_nMinNumber, i_nMaxNumber ) - && nFirst >= 0 && nLast >= 0) - { - // add pages of sub range to vector - if (nFirst == nLast) - { - if( checkValue( i_pPossibleValues, nFirst ) ) - aTmpVector.push_back( nFirst ); - } - else if (nFirst < nLast) - { - for (sal_Int32 i = nFirst; i <= nLast; ++i) - { - if( checkValue( i_pPossibleValues, i ) ) - aTmpVector.push_back( i ); - } - } - else if (nFirst > nLast) - { - for (sal_Int32 i = nFirst; i >= nLast; --i) - { - if( checkValue( i_pPossibleValues, i ) ) - aTmpVector.push_back( i ); - } - } - else - OSL_ENSURE( 0, "unexpected case" ); - } - else - bFailed = true; - } - while (!bFailed && 0 <= nPos && nPos < aRange.getLength()); - - if (!bFailed) - { - o_rPageVector = aTmpVector; - bRes = true; - } - } - else + bool bRes = aEnum.setRange( i_rPageRange ); + if( bRes ) { - // empty string ... o_rPageVector.clear(); - bRes = true; + o_rPageVector.reserve( aEnum.size() ); + for( StringRangeEnumerator::Iterator it = aEnum.begin( i_pPossibleValues ); + it != aEnum.end( i_pPossibleValues ); ++it ) + { + o_rPageVector.push_back( *it ); + } } return bRes; -- cgit v1.2.3 From d6ad6af9da5d94ecad27aceedf9cb719858e5cfd Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 10 Jul 2009 14:33:03 +0000 Subject: #i92516# fix count --- tools/source/memtools/multisel.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index db83f3b47866..b6f483312fa5 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -913,7 +913,9 @@ bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, if( checkValue( i_nFirst ) && checkValue( i_nLast ) ) { maSequence.push_back( Range( i_nFirst, i_nLast ) ); - mnCount += std::abs( i_nLast - i_nFirst - 1 ); + sal_Int32 nNumber = i_nLast - i_nFirst; + nNumber = nNumber < 0 ? -nNumber : nNumber; + mnCount += nNumber + 1; } else bSuccess = false; -- cgit v1.2.3 From 92cb6e5eac5e9108ddfe37f70189a96f61c27c39 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 13 Jul 2009 14:32:36 +0000 Subject: fix number at end, change behaviour for empty string --- tools/inc/tools/multisel.hxx | 3 ++- tools/source/memtools/multisel.cxx | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index e9b8b0f00177..bd2f7023bf8d 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -204,7 +204,8 @@ public: - the string "3-" will be either * an error if no maximum is given * or result in the seqeuence 3 to i_nMaxNumber - - an empty string as input is valid and will result in an empty result vector + - an empty string as input is valid and will result in the range [min,max] if given + or an empty vector, if not */ static bool getRangesFromString( const rtl::OUString& i_rPageRange, std::vector< sal_Int32 >& o_rPageVector, diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index b6f483312fa5..4f5ccbbabeae 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -952,6 +952,16 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) mnCount = 0; maSequence.clear(); + // we love special cases + if( i_rNewRange.getLength() == 0 ) + { + if( mnMin >= 0 && mnMax >= 0 ) + { + insertRange( mnMin, mnMax, mnMin != mnMax ); + } + return true; + } + const sal_Unicode* pInput = i_rNewRange.getStr(); rtl::OUStringBuffer aNumberBuf( 16 ); sal_Int32 nLastNumber = -1, nNumber = -1; @@ -998,8 +1008,9 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) } else if( *pInput == sal_Unicode(',') || *pInput == sal_Unicode(';') ) bInsertRange = true; - else + else if( *pInput ) { + bSuccess = false; break; // parse error } -- cgit v1.2.3 From e1ede83e9d1d354bbf454fb76ae95084f681c1e6 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 17 Jul 2009 00:30:17 +0000 Subject: add exceptions for stl --- tools/source/memtools/makefile.mk | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools') diff --git a/tools/source/memtools/makefile.mk b/tools/source/memtools/makefile.mk index 037dadbf4a46..51d831ec0fed 100644 --- a/tools/source/memtools/makefile.mk +++ b/tools/source/memtools/makefile.mk @@ -47,6 +47,8 @@ SLOFILES= $(SLO)$/contnr.obj \ $(SLO)$/mempool.obj \ $(SLO)$/multisel.obj +EXCEPTIONSFILES= $(SLO)$/multisel.obj $(OBJ)$/multisel.obj + OBJFILES= $(OBJ)$/contnr.obj \ $(OBJ)$/table.obj \ $(OBJ)$/unqidx.obj \ -- cgit v1.2.3 From b7362dfa446a3876529d7223306675f3b7d371c8 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 2 Nov 2009 19:08:00 +0100 Subject: #i105745#: tools/stream.hxx: API change: make SvMemoryStream::GetSize() private introduce new public SvMemoryStream::GetEndOfData() --- sot/source/sdstor/stgstrms.cxx | 2 +- sot/source/sdstor/stgstrms.hxx | 3 +-- svtools/source/filter.vcl/filter/filter2.cxx | 3 ++- svtools/source/numbers/numhead.cxx | 2 +- tools/inc/tools/stream.hxx | 5 ++++- vcl/source/gdi/bmpconv.cxx | 3 ++- 6 files changed, 11 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index 46ae3529439c..0e20af6118af 100644 --- a/sot/source/sdstor/stgstrms.cxx +++ b/sot/source/sdstor/stgstrms.cxx @@ -1104,7 +1104,7 @@ StgTmpStrm::~StgTmpStrm() } } -ULONG StgTmpStrm::GetSize() +ULONG StgTmpStrm::GetSize() const { ULONG n; if( pStrm ) diff --git a/sot/source/sdstor/stgstrms.hxx b/sot/source/sdstor/stgstrms.hxx index 806d562af6d0..fd7971da3aba 100644 --- a/sot/source/sdstor/stgstrms.hxx +++ b/sot/source/sdstor/stgstrms.hxx @@ -167,8 +167,7 @@ public: ~StgTmpStrm(); BOOL Copy( StgTmpStrm& ); void SetSize( ULONG ); - using SvMemoryStream::GetSize; - ULONG GetSize(); + ULONG GetSize() const; }; #endif diff --git a/svtools/source/filter.vcl/filter/filter2.cxx b/svtools/source/filter.vcl/filter/filter2.cxx index d570dd34e50f..9e0e3ba43d54 100644 --- a/svtools/source/filter.vcl/filter/filter2.cxx +++ b/svtools/source/filter.vcl/filter/filter2.cxx @@ -471,7 +471,8 @@ BOOL GraphicDescriptor::ImpDetectJPG( SvStream& rStm, BOOL bExtendedInfo ) // Groesse des verbleibenden Puffers ermitteln if ( bLinked ) - nMax = ( (SvMemoryStream&) rStm ).GetSize() - 16; + nMax = static_cast< SvMemoryStream& >(rStm).GetEndOfData() + - 16; else nMax = DATA_SIZE - 16; diff --git a/svtools/source/numbers/numhead.cxx b/svtools/source/numbers/numhead.cxx index 7e79aad624f3..921442de1b66 100644 --- a/svtools/source/numbers/numhead.cxx +++ b/svtools/source/numbers/numhead.cxx @@ -139,7 +139,7 @@ ImpSvNumMultipleReadHeader::ImpSvNumMultipleReadHeader(SvStream& rNewStream) : ImpSvNumMultipleReadHeader::~ImpSvNumMultipleReadHeader() { - DBG_ASSERT( pMemStream->Tell() == pMemStream->GetSize(), + DBG_ASSERT( pMemStream->Tell() == pMemStream->GetEndOfData(), "Sizes nicht vollstaendig gelesen" ); delete pMemStream; delete [] pBuf; diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx index bacaac89fe44..23496322fa4c 100644 --- a/tools/inc/tools/stream.hxx +++ b/tools/inc/tools/stream.hxx @@ -776,6 +776,9 @@ class TOOLS_DLLPUBLIC SvMemoryStream : public SvStream SvMemoryStream (const SvMemoryStream&); SvMemoryStream & operator= (const SvMemoryStream&); + friend class SvCacheStream; + sal_Size GetSize() const { return nSize; } + protected: sal_Size nSize; sal_Size nResize; @@ -817,7 +820,7 @@ public: virtual void ResetError(); - sal_Size GetSize() const { return nSize; } + sal_Size GetEndOfData() const { return nEndOfData; } const void* GetData() { Flush(); return pBuf; } operator const void*() { Flush(); return pBuf; } virtual sal_uInt16 IsA() const; diff --git a/vcl/source/gdi/bmpconv.cxx b/vcl/source/gdi/bmpconv.cxx index 9d9b81ba50d4..03d85acb0159 100644 --- a/vcl/source/gdi/bmpconv.cxx +++ b/vcl/source/gdi/bmpconv.cxx @@ -192,7 +192,8 @@ BmpTransporter::BmpTransporter( const Bitmap& rBM ) m_aSize.Height = rBM.GetSizePixel().Height(); SvMemoryStream aStream; rBM.Write( aStream, FALSE, TRUE ); - m_aBM = Sequence((const sal_Int8*)aStream.GetData(), aStream.GetSize() ); + m_aBM = Sequence(static_cast(aStream.GetData()), + aStream.GetEndOfData()); } BmpTransporter::~BmpTransporter() -- cgit v1.2.3 From fe537060e40a6d0c5411a800fd5c518d04a6209c Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 13 Nov 2009 11:04:06 +0100 Subject: sb116: #i106845# removed obsolete IRIX port --- goodies/source/filter.vcl/ios2met/ios2met.cxx | 2 +- rsc/source/parser/rsclex.cxx | 2 +- rsc/source/parser/rsclex.hxx | 2 +- rsc/source/rsc/makefile.mk | 4 ---- svtools/inc/svtools/svarray.hxx | 2 +- tools/inc/tools/inetdef.hxx | 2 -- tools/inc/tools/solar.h | 2 -- tools/source/fsys/unx.cxx | 2 +- vcl/source/glyphs/glyphcache.cxx | 2 -- vcl/unx/inc/salunx.h | 6 ------ vcl/unx/source/app/i18n_ic.cxx | 4 ++-- vcl/unx/source/app/i18n_im.cxx | 2 +- vcl/unx/source/app/saldisp.cxx | 7 ++----- vcl/unx/source/app/saltimer.cxx | 3 --- vcl/unx/source/printer/printerinfomanager.cxx | 2 +- 15 files changed, 11 insertions(+), 33 deletions(-) (limited to 'tools') diff --git a/goodies/source/filter.vcl/ios2met/ios2met.cxx b/goodies/source/filter.vcl/ios2met/ios2met.cxx index 0fbf24f56029..8c3c19e22379 100644 --- a/goodies/source/filter.vcl/ios2met/ios2met.cxx +++ b/goodies/source/filter.vcl/ios2met/ios2met.cxx @@ -846,7 +846,7 @@ void OS2METReader::ReadRelLine(BOOL bGivenPos, USHORT nOrderLen) if (nPolySize==0) return; Polygon aPolygon(nPolySize); for (i=0; i> nunsignedbyte; aP0.X()+=(INT8)nunsignedbyte; *pOS2MET >> nunsignedbyte; aP0.Y()+=(INT8)nunsignedbyte; diff --git a/rsc/source/parser/rsclex.cxx b/rsc/source/parser/rsclex.cxx index 3c2c95e541d1..8c34637fa304 100644 --- a/rsc/source/parser/rsclex.cxx +++ b/rsc/source/parser/rsclex.cxx @@ -317,7 +317,7 @@ int yylex() /****************** yyerror **********************************************/ #ifdef RS6000 extern "C" void yyerror( char* pMessage ) -#elif defined HP9000 || defined SCO || defined IRIX || defined SOLARIS +#elif defined HP9000 || defined SCO || defined SOLARIS extern "C" void yyerror( const char* pMessage ) #else void yyerror( char* pMessage ) diff --git a/rsc/source/parser/rsclex.hxx b/rsc/source/parser/rsclex.hxx index 89feed4dd132..63afd0b208c7 100644 --- a/rsc/source/parser/rsclex.hxx +++ b/rsc/source/parser/rsclex.hxx @@ -107,7 +107,7 @@ class ObjectStack { extern "C" int yyparse(); // forward Deklaration fuer erzeugte Funktion extern "C" void yyerror( char * ); extern "C" int yylex( void ); -#elif defined( HP9000 ) || defined( SCO ) || defined ( IRIX ) || defined ( SOLARIS ) +#elif defined( HP9000 ) || defined( SCO ) || defined ( SOLARIS ) extern "C" int yyparse(); // forward Deklaration fuer erzeugte Funktion extern "C" void yyerror( const char * ); extern "C" int yylex( void ); diff --git a/rsc/source/rsc/makefile.mk b/rsc/source/rsc/makefile.mk index 40e2d77740a3..89abd22207d9 100644 --- a/rsc/source/rsc/makefile.mk +++ b/rsc/source/rsc/makefile.mk @@ -40,10 +40,6 @@ ENABLE_EXCEPTIONS=true .INCLUDE : settings.mk -.IF "$(OS)"=="IRIX" -NOOPTFILES= $(OBJ)$/rsc.obj -.ENDIF - OBJFILES= $(OBJ)$/rsc.obj .INCLUDE : target.mk diff --git a/svtools/inc/svtools/svarray.hxx b/svtools/inc/svtools/svarray.hxx index 3ab3676fa5e0..1518c20f5084 100644 --- a/svtools/inc/svtools/svarray.hxx +++ b/svtools/inc/svtools/svarray.hxx @@ -1034,7 +1034,7 @@ public:\ #define C40_PTR_REPLACE( c, p) Replace( (c const *) p ) #define C40_GETPOS( c, r) GetPos( (c const *)r ) #else -#if defined WTC || defined IRIX || defined ICC || defined HPUX || (defined GCC && __GNUC__ >= 3) || (defined(WNT) && _MSC_VER >= 1400) +#if defined WTC || defined ICC || defined HPUX || (defined GCC && __GNUC__ >= 3) || (defined(WNT) && _MSC_VER >= 1400) #define C40_INSERT( c, p, n ) Insert( (c const *&) p, n ) #define C40_PUSH( c, p) Push( (c const *&) p ) #define C40_PTR_INSERT( c, p ) Insert( (c const *&) p ) diff --git a/tools/inc/tools/inetdef.hxx b/tools/inc/tools/inetdef.hxx index 38cd8935e06b..d9861f64961d 100644 --- a/tools/inc/tools/inetdef.hxx +++ b/tools/inc/tools/inetdef.hxx @@ -61,8 +61,6 @@ #define TOOLS_INETDEF_OS "FreeBSD/amd64" #elif defined SINIX #define TOOLS_INETDEF_OS "SINIX" -#elif defined IRIX -#define TOOLS_INETDEF_OS "IRIX" #else // AIX, HPUX, SOLARIS, ... #define TOOLS_INETDEF_OS "Unix" #endif // AIX, HPUX, SOLARIS, ... diff --git a/tools/inc/tools/solar.h b/tools/inc/tools/solar.h index 46fe42b9c36f..4fe00adc9da0 100644 --- a/tools/inc/tools/solar.h +++ b/tools/inc/tools/solar.h @@ -391,8 +391,6 @@ template inline T Abs(T a) { return (a>=0?a:-a); } #define __DLLEXTENSION "fi.so" #elif defined FREEBSD && defined X86_64 #define __DLLEXTENSION "fx.so" -#elif defined IRIX - #define __DLLEXTENSION "im.so" #elif defined MACOSX && defined POWERPC #define __DLLEXTENSION "mxp.dylib" #elif defined MACOSX && defined X86 diff --git a/tools/source/fsys/unx.cxx b/tools/source/fsys/unx.cxx index 76910683df13..4a2e3c6ad76a 100644 --- a/tools/source/fsys/unx.cxx +++ b/tools/source/fsys/unx.cxx @@ -36,7 +36,7 @@ #include #include #include -#if defined HPUX || defined LINUX || defined IRIX +#if defined HPUX || defined LINUX #include #define mnttab mntent #elif defined SCO diff --git a/vcl/source/glyphs/glyphcache.cxx b/vcl/source/glyphs/glyphcache.cxx index e3e840e40730..17e70c539254 100644 --- a/vcl/source/glyphs/glyphcache.cxx +++ b/vcl/source/glyphs/glyphcache.cxx @@ -79,9 +79,7 @@ GlyphCache::~GlyphCache() // ----------------------------------------------------------------------- -#ifndef IRIX inline -#endif size_t GlyphCache::IFSD_Hash::operator()( const ImplFontSelectData& rFontSelData ) const { // TODO: is it worth to improve this hash function? diff --git a/vcl/unx/inc/salunx.h b/vcl/unx/inc/salunx.h index cdf45fd30867..c1fee6c68d94 100644 --- a/vcl/unx/inc/salunx.h +++ b/vcl/unx/inc/salunx.h @@ -38,12 +38,6 @@ #include #include #include -#elif defined IRIX -#ifdef __cplusplus -#include -#endif -#include -#include #endif #include #include diff --git a/vcl/unx/source/app/i18n_ic.cxx b/vcl/unx/source/app/i18n_ic.cxx index cacffbcfdbb1..bb8f86d93e01 100644 --- a/vcl/unx/source/app/i18n_ic.cxx +++ b/vcl/unx/source/app/i18n_ic.cxx @@ -340,7 +340,7 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame *pFrame ) : if ( mnPreeditStyle != XIMPreeditNone ) { -#if defined LINUX || defined FREEBSD || defined NETBSD || defined IRIX +#if defined LINUX || defined FREEBSD || defined NETBSD if ( mpPreeditAttributes != NULL ) #endif mpAttributes = XVaAddToNestedList( mpAttributes, @@ -348,7 +348,7 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame *pFrame ) : } if ( mnStatusStyle != XIMStatusNone ) { -#if defined LINUX || defined FREEBSD || defined NETBSD || defined IRIX +#if defined LINUX || defined FREEBSD || defined NETBSD if ( mpStatusAttributes != NULL ) #endif mpAttributes = XVaAddToNestedList( mpAttributes, diff --git a/vcl/unx/source/app/i18n_im.cxx b/vcl/unx/source/app/i18n_im.cxx index ae472d6323f4..0a48c054167f 100644 --- a/vcl/unx/source/app/i18n_im.cxx +++ b/vcl/unx/source/app/i18n_im.cxx @@ -59,7 +59,7 @@ using namespace vcl; #include "i18n_cb.hxx" -#if defined(SOLARIS) || defined(LINUX) || defined(IRIX) +#if defined(SOLARIS) || defined(LINUX) extern "C" char * XSetIMValues(XIM im, ...); #endif diff --git a/vcl/unx/source/app/saldisp.cxx b/vcl/unx/source/app/saldisp.cxx index 07955d426b8c..cfd568ac9b6c 100644 --- a/vcl/unx/source/app/saldisp.cxx +++ b/vcl/unx/source/app/saldisp.cxx @@ -38,16 +38,13 @@ #include #include #include -#if defined(IRIX) -#include -#endif #include #include #include #include #include -#if defined(SOLARIS) || defined(IRIX) +#if defined(SOLARIS) #include #include #endif @@ -898,7 +895,7 @@ void SalDisplay::Init() sscanf( pProperties, "%li", &nProperties_ ); else { -#if defined DBG_UTIL || defined SUN || defined LINUX || defined FREEBSD || defined IRIX +#if defined DBG_UTIL || defined SUN || defined LINUX || defined FREEBSD nProperties_ |= PROPERTY_FEATURE_Maximize; #endif // Server Bugs & Properties diff --git a/vcl/unx/source/app/saltimer.cxx b/vcl/unx/source/app/saltimer.cxx index bf8aa202b066..afcecc0d0667 100644 --- a/vcl/unx/source/app/saltimer.cxx +++ b/vcl/unx/source/app/saltimer.cxx @@ -32,9 +32,6 @@ #include "precompiled_vcl.hxx" #include -#if defined(IRIX) -#include -#endif #include #include #include diff --git a/vcl/unx/source/printer/printerinfomanager.cxx b/vcl/unx/source/printer/printerinfomanager.cxx index b3e5b4667a6a..53cd662db8e0 100644 --- a/vcl/unx/source/printer/printerinfomanager.cxx +++ b/vcl/unx/source/printer/printerinfomanager.cxx @@ -441,7 +441,7 @@ void PrinterInfoManager::initialize() * porters: please append your platform to the Solaris * case if your platform has SystemV printing per default. */ - #if defined SOLARIS || defined(IRIX) + #if defined SOLARIS aValue = "lp"; #else aValue = "lpr"; -- cgit v1.2.3 From b0fe07fec29262fdc5e1aaf97812caadbb9d5c15 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 23 Nov 2009 13:30:17 +0100 Subject: printerpullpages: #i106836# allow less strict parsing of passed ranges string --- tools/inc/tools/multisel.hxx | 4 ++-- tools/source/memtools/multisel.cxx | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'tools') 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; } -- cgit v1.2.3 From aed7c63fea58badc64a0b6be2122b97de4520e95 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 24 Nov 2009 12:13:33 +0100 Subject: #i103340# added MaskPrimitive2D::getB2DRange implementation --- tools/source/generic/poly.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 5cca29b3066e..eb8442f7cd93 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -1668,7 +1668,16 @@ void Polygon::Clip( const Rectangle& rRect, BOOL bPolygon ) Rectangle Polygon::GetBoundRect() const { DBG_CHKTHIS( Polygon, NULL ); - DBG_ASSERT( !mpImplPolygon->mpFlagAry, "GetBoundRect could fail with beziers!" ); + // Removing the assert. Bezier curves have the attribute that each single + // curve segment defined by four points can not exit the four-point polygon + // defined by that points. This allows to say that the curve segment can also + // never leave the Range of it's defining points. + // The result is that Polygon::GetBoundRect() may not create the minimal + // BoundRect of the Polygon (to get that, use basegfx::B2DPolygon classes), + // but will always create a valid BoundRect, at least as long as this method + // 'blindly' travels over all points, including control points. + // + // DBG_ASSERT( !mpImplPolygon->mpFlagAry, "GetBoundRect could fail with beziers!" ); USHORT nCount = mpImplPolygon->mnPoints; if( ! nCount ) -- cgit v1.2.3 From 86f7dae1d7a3f95a68cf5132cef03073787d3810 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 7 Jan 2010 16:18:32 +0000 Subject: #i53184# further fix in INetURLObject::setAbsURIRef for UNC server names containing underscores --- tools/source/fsys/urlobj.cxx | 18 ++++++++---------- tools/workben/urltest.cxx | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'tools') diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index f7ffed5e4dd1..e0f711bd2883 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -1022,16 +1022,14 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, if (pEnd - pPos >= 2 && pPos[0] == '/' && pPos[1] == '/') { sal_Unicode const * p1 = pPos + 2; - if ( - p1 == pEnd || *p1 == nFragmentDelimiter || *p1 == '/' || - ( - ( - scanDomain(p1, pEnd) > 0 || - scanIPv6reference(p1, pEnd) - ) && - (p1 == pEnd || *p1 == nFragmentDelimiter || *p1 == '/') - ) - ) + while (p1 != pEnd && *p1 != '/' && + *p1 != nFragmentDelimiter) + { + ++p1; + } + if (parseHostOrNetBiosName( + pPos + 2, p1, bOctets, ENCODE_ALL, + RTL_TEXTENCODING_DONTKNOW, true, NULL)) { aSynAbsURIRef. appendAscii(RTL_CONSTASCII_STRINGPARAM("//")); diff --git a/tools/workben/urltest.cxx b/tools/workben/urltest.cxx index a232f8ebdd93..0e9d22081cb4 100644 --- a/tools/workben/urltest.cxx +++ b/tools/workben/urltest.cxx @@ -1629,6 +1629,20 @@ main() rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); } + if (true) { // #i53184# + rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM("file://comp_name/path")); + bSuccess &= assertEqual( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("#i53184# smart INET_PROT_FILE")), + INetURLObject(url, INET_PROT_FILE).GetMainURL( + INetURLObject::NO_DECODE), + url); + bSuccess &= assertEqual( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("#i53184# strict")), + INetURLObject(url).GetMainURL(INetURLObject::NO_DECODE), url); + } + if (true) { rtl::OUString path; path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/a/b/c")); -- cgit v1.2.3