bye-bye old range parser

This commit is contained in:
Ivan Timofeev 2011-10-20 23:11:17 +04:00
parent 593e4c36d2
commit d72701bba6
2 changed files with 0 additions and 161 deletions

View file

@ -71,9 +71,6 @@ public:
MultiSelection();
MultiSelection( const MultiSelection& rOrig );
MultiSelection( const Range& rRange );
MultiSelection( const UniString& rString,
sal_Unicode cRange = '-',
sal_Unicode cSep = ';' );
~MultiSelection();
MultiSelection& operator= ( const MultiSelection& rOrig );

View file

@ -137,164 +137,6 @@ MultiSelection::MultiSelection():
// -----------------------------------------------------------------------
MultiSelection::MultiSelection( const UniString& rString, sal_Unicode cRange, sal_Unicode cSep ):
aTotRange(0,RANGE_MAX),
nCurSubSel(0),
nSelCount(0),
bCurValid(sal_False),
bSelectNew(sal_False)
{
// Dies ist nur ein Schnellschuss und sollte bald optimiert,
// an die verschiedenen Systeme (UNIX etc.)
// und die gewuenschte Eingabe-Syntax angepasst werden.
UniString aStr( rString );
sal_Unicode* pStr = aStr.GetBufferAccess();
sal_Unicode* pOld = pStr;
sal_Bool bReady = sal_False;
sal_Bool bUntil = sal_False;
xub_StrLen nCut = 0;
// Hier normieren wir den String, sodass nur Ziffern,
// Semikola als Trenn- und Minus als VonBis-Zeichen
// uebrigbleiben, z.B. "99-117;55;34;-17;37-43"
while ( *pOld )
{
switch( *pOld )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
DBG_ASSERT( *pOld != cRange, "digit for range char not allowed" );
DBG_ASSERT( *pOld != cSep, "digit for separator not allowed" );
if( bReady )
{
*pStr++ = ';';
nCut++;
bReady = sal_False;
}
*pStr++ = *pOld;
nCut++;
bUntil = sal_False;
break;
case '-':
case ':':
case '/':
if ( *pOld != cSep )
{
if ( !bUntil )
{
*pStr++ = '-';
nCut++;
bUntil = sal_True;
}
bReady = sal_False;
}
else
bReady = sal_True;
break;
case ' ':
DBG_ASSERT( *pOld != cRange, "SPACE for range char not allowed" );
DBG_ASSERT( *pOld != cSep, "SPACE for separator not allowed" );
bReady = !bUntil;
break;
default:
if ( *pOld == cRange )
{
if ( !bUntil )
{
*pStr++ = '-';
nCut++;
bUntil = sal_True;
}
bReady = sal_False;
}
else
bReady = sal_True;
break;
}
pOld++;
}
aStr.ReleaseBufferAccess( nCut );
// Jetzt wird der normierte String ausgewertet ..
UniString aNumStr;
Range aRg( 1, RANGE_MAX );
const sal_Unicode* pCStr = aStr.GetBuffer();
long nPage = 1;
long nNum = 1;
bUntil = sal_False;
while ( *pCStr )
{
switch ( *pCStr )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
aNumStr += *pCStr;
break;
case ';':
nNum = aNumStr.ToInt32();
if ( bUntil )
{
if ( !aNumStr.Len() )
nNum = RANGE_MAX;
aRg.Min() = nPage;
aRg.Max() = nNum;
aRg.Justify();
Select( aRg );
}
else
Select( nNum );
nPage = 0;
aNumStr.Erase();
bUntil = sal_False;
break;
case '-':
nPage = aNumStr.ToInt32();
aNumStr.Erase();
bUntil = sal_True;
break;
}
pCStr++;
}
nNum = aNumStr.ToInt32();
if ( bUntil )
{
if ( !aNumStr.Len() )
nNum = RANGE_MAX;
aRg.Min() = nPage;
aRg.Max() = nNum;
aRg.Justify();
Select( aRg );
}
else
Select( nNum );
}
// -----------------------------------------------------------------------
MultiSelection::MultiSelection( const MultiSelection& rOrig ) :
aTotRange(rOrig.aTotRange),
nSelCount(rOrig.nSelCount),