28#include <rtl/ustrbuf.hxx>
50 if ( nPos2 >=
aSels.size() )
80 aTotRange(rOrig.aTotRange),
81 nSelCount(rOrig.nSelCount),
82 bCurValid(rOrig.bCurValid)
162 if ( nSubSelPos > 0 &&
172 else if ( nSubSelPos <
aSels.size()
180 if ( nSubSelPos <
aSels.size() ) {
192 if ( nSubSelPos >=
aSels.size()
203 if (
aSels[ nSubSelPos ].Len() == 1 )
212 ++
aSels[ nSubSelPos ].Min();
215 --
aSels[ nSubSelPos ].Max();
220 if ( nSubSelPos <
aSels.size() ) {
236 sal_Int32 nTmpMin = rIndexRange.
Min();
237 sal_Int32 nTmpMax = rIndexRange.
Max();
244 if(
aSels.empty() || (nTmpMin <= nCurMin && nTmpMax >= nCurMax ) )
249 aSels.push_back( rIndexRange );
255 if( nTmpMax < nCurMin )
260 if( nCurMin > (nTmpMax+1) )
267 auto & rRange =
aSels.front();
269 rRange.Min() = nTmpMin;
277 else if( nTmpMin > nCurMax )
282 if( nTmpMin > (nCurMax+1) )
284 aSels.push_back( rIndexRange );
289 auto & rRange =
aSels.back();
291 rRange.Max() = nTmpMax;
300 while( nTmpMin <= nTmpMax )
302 Select( nTmpMin, bSelect );
321 if ( nSubSelPos <
aSels.size() )
326 if ( nSubSelPos <
aSels.size() ) {
353 if ( nSubSelPos <
aSels.size()
357 if (
aSels[ nSubSelPos ].Len() == 1 ) {
362 --(
aSels[ nSubSelPos++ ].Max() );
442 pRange =
aSels.empty() ? nullptr : &
aSels.front();
477 sal_Int32 i_nMinNumber,
478 sal_Int32 i_nMaxNumber,
479 sal_Int32 i_nLogicalOffset
482 , mnMin( i_nMinNumber )
483 , mnMax( i_nMaxNumber )
484 , mnOffset( i_nLogicalOffset )
485 , mbValidInput( false )
494 if( i_nValue < 0 || i_nValue < mnMin || i_nValue >
mnMax )
496 if( i_pPossibleValues && i_pPossibleValues->
find( i_nValue ) == i_pPossibleValues->
end() )
503 bool bSuccess =
true;
510 if( i_nFirst <
mnMin )
512 if( i_nFirst >
mnMax )
514 if( i_nLast <
mnMin )
516 if( i_nLast >
mnMax )
521 sal_Int32 nNumber = i_nLast - i_nFirst;
522 nNumber = nNumber < 0 ? -nNumber : nNumber;
548 const std::vector< sal_Int32 >& rNumbers )
550 size_t nCount = rNumbers.size();
562 sal_Int32 nFirst = rNumbers[
i];
563 sal_Int32 nLast = rNumbers[
i + 1];
566 if ( nFirst > nLast ) nFirst--;
567 else if( nFirst < nLast ) nFirst++;
579 auto pInput = aNewRange.begin();
580 auto pInputEnd = aNewRange.end();
581 OUStringBuffer aNumberBuf( 16 );
582 std::vector< sal_Int32 > aNumbers;
583 bool bSequence =
false;
584 while( pInput != pInputEnd )
586 while( pInput != pInputEnd && *pInput >=
'0' && *pInput <=
'9' )
587 aNumberBuf.append( *pInput++ );
588 if( !aNumberBuf.isEmpty() )
591 aNumberBuf.setLength(0);
592 aNumbers.push_back( nNumber );
595 if (pInput == pInputEnd)
600 if( aNumbers.empty() )
603 aNumbers.push_back(
mnMin-1 );
606 else if( *pInput ==
',' || *pInput ==
';' )
608 if( bSequence && !aNumbers.empty() )
611 aNumbers.push_back(
mnMax+1 );
618 else if( *pInput !=
' ' )
624 if( bSequence && !aNumbers.empty() )
627 aNumbers.push_back(
mnMax+1 );
636 if( i_pPossibleValues && i_pPossibleValues->
find( i_nValue ) == i_pPossibleValues->
end() )
639 for(
size_t i= 0;
i <
n; ++
i )
644 if( i_nValue >= rRange.
nFirst && i_nValue <= rRange.
nLast )
649 if( i_nValue >= rRange.
nLast && i_nValue <= rRange.
nFirst )
661 bool bRangeChange =
false;
721 std::vector< sal_Int32 >& o_rPageVector,
722 sal_Int32 i_nMinNumber,
723 sal_Int32 i_nMaxNumber,
724 sal_Int32 i_nLogicalOffset,
728 o_rPageVector.clear();
734 o_rPageVector.reserve(
static_cast< size_t >( aEnum.
size() ) );
736 it != aEnum.
end( i_pPossibleValues ); ++it )
738 o_rPageVector.push_back( *it );
void Remove(sal_Int32 nIndex)
void Insert(sal_Int32 nIndex, sal_Int32 nCount=1)
TOOLS_DLLPRIVATE void ImplClear()
sal_Int32 FirstSelected()
TOOLS_DLLPRIVATE void ImplMergeSubSelections(sal_Int32 nPos1, std::size_t nPos2)
MultiSelection & operator=(const MultiSelection &rOrig)
bool Select(sal_Int32 nIndex, bool bSelect=true)
void SetTotalRange(const Range &rTotRange)
bool IsSelected(sal_Int32 nIndex) const
std::vector< Range > aSels
TOOLS_DLLPRIVATE std::size_t ImplFindSubSelection(sal_Int32 nIndex) const
void SelectAll(bool bSelect=true)
bool Contains(tools::Long nIs) const
const o3tl::sorted_vector< sal_Int32 > * pPossibleValues
const StringRangeEnumerator * pEnumerator
bool operator==(const Iterator &) const
void insertJoinedRanges(const std::vector< sal_Int32 > &rNumbers)
bool setRange(std::u16string_view i_rNewRange)
bool checkValue(sal_Int32, const o3tl::sorted_vector< sal_Int32 > *i_pPossibleValues=nullptr) const
bool hasValue(sal_Int32 nValue, const o3tl::sorted_vector< sal_Int32 > *i_pPossibleValues=nullptr) const
bool insertRange(sal_Int32 nFirst, sal_Int32 nLast, bool bSequence)
static bool getRangesFromString(std::u16string_view i_rPageRange, std::vector< sal_Int32 > &o_rPageVector, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, sal_Int32 i_nLogicalOffset=-1, o3tl::sorted_vector< sal_Int32 > const *i_pPossibleValues=nullptr)
i_rPageRange: the string to be changed into a sequence of numbers valid format example "5-3,...
std::vector< StringRangeEnumerator::Range > maSequence
Iterator end(const o3tl::sorted_vector< sal_Int32 > *i_pPossibleValues=nullptr) const
StringRangeEnumerator(std::u16string_view i_rInput, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, sal_Int32 i_nLogicalOffset=-1)
Iterator begin(const o3tl::sorted_vector< sal_Int32 > *i_pPossibleValues=nullptr) const
const_iterator find(const Value &x) const
const_iterator end() const
#define DBG_ASSERT(sCon, aError)
#define SFX_ENDOFSELECTION
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)