View | Details | Raw Unified | Return to issue 6087
Collapse All | Expand All

(-)openoffice.org.orig/sc/inc/document.hxx (-1 lines)
Lines 559-565 Link Here
559
	void			SnapVisArea( Rectangle& rRect ) const;			// 1/100 mm
559
	void			SnapVisArea( Rectangle& rRect ) const;			// 1/100 mm
560
560
561
	SC_DLLPUBLIC BOOL			ValidTabName( const String& rName ) const;
561
	SC_DLLPUBLIC BOOL			ValidTabName( const String& rName ) const;
562
    static SC_DLLPUBLIC void      ConvertToValidTabName( String& rName, sal_Unicode cReplaceChar );
563
	SC_DLLPUBLIC BOOL			ValidNewTabName( const String& rName ) const;
562
	SC_DLLPUBLIC BOOL			ValidNewTabName( const String& rName ) const;
564
	SC_DLLPUBLIC void			CreateValidTabName(String& rName) const;
563
	SC_DLLPUBLIC void			CreateValidTabName(String& rName) const;
565
	BOOL			InsertTab( SCTAB nPos, const String& rName,
564
	BOOL			InsertTab( SCTAB nPos, const String& rName,
(-)openoffice.org.orig/sc/source/core/data/document.cxx (-34 / +1 lines)
Lines 167-206 Link Here
167
167
168
BOOL ScDocument::ValidTabName( const String& rName ) const
168
BOOL ScDocument::ValidTabName( const String& rName ) const
169
{
169
{
170
    // behaviour must be equal to ConvertToValidTabName(), see below
170
    return rName.Len() > 0;
171
	using namespace ::com::sun::star::i18n;
172
	sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER |
173
		KParseTokens::ASC_UNDERSCORE;
174
	sal_Int32 nContFlags = nStartFlags;
175
	String aContChars( RTL_CONSTASCII_USTRINGPARAM(" ") );
176
    ParseResult aRes = ScGlobal::pCharClass->parsePredefinedToken(
177
        KParseType::IDENTNAME, rName, 0, nStartFlags, EMPTY_STRING, nContFlags, aContChars );
178
    return (aRes.TokenType & KParseType::IDENTNAME) && aRes.EndPos == rName.Len();
179
}
180
181
182
void ScDocument::ConvertToValidTabName( String& rName, sal_Unicode cReplaceChar )
183
{
184
    // behaviour must be equal to ValidTabName(), see above
185
    using namespace ::com::sun::star::i18n;
186
    sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER |
187
        KParseTokens::ASC_UNDERSCORE;
188
    sal_Int32 nContFlags = nStartFlags;
189
    String aStartChars;
190
    String aContChars( RTL_CONSTASCII_USTRINGPARAM(" ") );
191
    sal_Int32 nStartPos = 0;
192
    while( nStartPos < rName.Len() )
193
    {
194
        ParseResult aRes = ScGlobal::pCharClass->parsePredefinedToken( KParseType::IDENTNAME,
195
            rName, nStartPos, nStartFlags, aStartChars, nContFlags, aContChars );
196
        if( aRes.EndPos < rName.Len() )
197
        {
198
            rName.SetChar( static_cast< xub_StrLen >( aRes.EndPos ), cReplaceChar );
199
            nStartFlags = nContFlags;
200
            aStartChars = aContChars;
201
        }
202
        nStartPos = aRes.EndPos + 1;
203
    }
204
}
171
}
205
172
206
173
(-)openoffice.org.orig/sc/source/core/tool/address.cxx (-7 / +36 lines)
Lines 651-673 Link Here
651
    BOOL    bExtDoc = FALSE;
651
    BOOL    bExtDoc = FALSE;
652
    BOOL    bNeedExtTab = FALSE;
652
    BOOL    bNeedExtTab = FALSE;
653
653
654
    //Lets see if this is a reference to something in an external file
655
    //A Documentname is always quoted and has a trailing #
654
    if ( *p == '\'' && ScGlobal::UnicodeStrChr( p, SC_COMPILER_FILE_TAB_SEP ) )
656
    if ( *p == '\'' && ScGlobal::UnicodeStrChr( p, SC_COMPILER_FILE_TAB_SEP ) )
655
    {
657
    {
656
        BOOL bQuote = TRUE;         // Dokumentenname ist immer quoted
658
        const sal_Unicode *pStart = p;   
659
        BOOL bQuote = TRUE;         // A Documentname is always quoted
657
        aDocTab += *p++;
660
        aDocTab += *p++;
658
        while ( bQuote && *p )
661
        while ( bQuote && *p )
659
        {
662
        {
660
            if ( *p == '\'' && *(p-1) != '\\' )
663
            if ( *p == '\'' && *(p-1) != '\\' )
661
                bQuote = FALSE;
664
                bQuote = FALSE;
662
            else if( !(*p == '\\' && *(p+1) == '\'') )
665
            else if( !(*p == '\\' && *(p+1) == '\'') )
663
                aDocName += *p;     // falls escaped Quote: nur Quote in den Namen
666
                aDocName += *p;     // An escaped Quote in the Documentname
664
            aDocTab += *p++;
667
            aDocTab += *p++;
665
        }
668
        }
666
        aDocTab += *p;              // den SC_COMPILER_FILE_TAB_SEP mitnehmen
669
        aDocTab += *p;              // den SC_COMPILER_FILE_TAB_SEP mitnehmen
667
        if( *p++ == SC_COMPILER_FILE_TAB_SEP )
670
        if( *p++ == SC_COMPILER_FILE_TAB_SEP )
668
            bExtDoc = TRUE;
671
            bExtDoc = TRUE;
669
        else
672
        else
670
            return nRes;
673
        {
674
            //It wasn't a document after all, reset and continue as normal
675
            p = pStart;
676
            aDocTab = String();
677
        }
671
    }
678
    }
672
679
673
    SCCOL   nCol = 0;
680
    SCCOL   nCol = 0;
Lines 682-693 Link Here
682
            nRes |= SCA_TAB_ABSOLUTE;
689
            nRes |= SCA_TAB_ABSOLUTE;
683
        if (*p == '$')
690
        if (*p == '$')
684
            nRes |= SCA_TAB_ABSOLUTE, p++;
691
            nRes |= SCA_TAB_ABSOLUTE, p++;
685
        BOOL bQuote = FALSE;
692
693
        //Tokens that start at ' can have anything in them until a final '
694
        //but '' marks an escaped '
695
        //We've earlier guaranteed that a string containing '' will be
696
        //surrounded by '
686
        if( *p == '\'' )
697
        if( *p == '\'' )
687
            p++, bQuote = TRUE;
688
        while (*p && (*p != '.'))
689
        {
698
        {
690
            if( bQuote && *p == '\'' )
699
            ++p;
700
            while (*p)
701
            {
702
                if (*p == '\'')
703
                {
704
                    if ( (*(p+1) != '\'') )
705
                        break;
706
                    else
707
                        *p++;
708
                }
709
                aTab += *p++;
710
            }
711
        }
712
713
        while (*p)
714
        {
715
            if( *p == '.')
716
                break;
717
718
            if( *p == '\'' )
691
            {
719
            {
692
                p++; break;
720
                p++; break;
693
            }
721
            }
Lines 736-741 Link Here
736
    }
764
    }
737
    nRes |= nBits;
765
    nRes |= nBits;
738
766
767
739
    q = p;
768
    q = p;
740
    if (*p)
769
    if (*p)
741
    {
770
    {
(-)openoffice.org.orig/sc/source/core/tool/compiler.cxx (-18 / +31 lines)
Lines 993-998 Link Here
993
                               xub_StrLen nSrcPos,
993
                               xub_StrLen nSrcPos,
994
                               const CharClass* pCharClass) const
994
                               const CharClass* pCharClass) const
995
    {
995
    {
996
        //Tokens that start at ' can have anything in them until a final '
997
        //but '' marks an escaped '
998
        //We've earlier guaranteed that a string containing '' will be
999
        //surrounded by '
1000
        if (rFormula.GetChar(nSrcPos) == '\'')
1001
        {
1002
            xub_StrLen nPos = nSrcPos+1;
1003
            while (nPos < rFormula.Len())
1004
            {
1005
                if (rFormula.GetChar(nPos) == '\'')
1006
                {
1007
                    if ( (nPos+1 == rFormula.Len()) || (rFormula.GetChar(nPos+1) != '\'') )
1008
                    {
1009
                        ParseResult aRet;
1010
                        aRet.TokenType = KParseType::SINGLE_QUOTE_NAME;
1011
                        aRet.EndPos = nPos+1;
1012
                        return aRet;
1013
                    }
1014
                    ++nPos;
1015
                }
1016
                ++nPos;
1017
            }
1018
        }
1019
996
        static const sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER |
1020
        static const sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER |
997
            KParseTokens::ASC_UNDERSCORE | KParseTokens::ASC_DOLLAR;
1021
            KParseTokens::ASC_UNDERSCORE | KParseTokens::ASC_DOLLAR;
998
        static const sal_Int32 nContFlags = nStartFlags | KParseTokens::ASC_DOT;
1022
        static const sal_Int32 nContFlags = nStartFlags | KParseTokens::ASC_DOT;
Lines 1524-1552 Link Here
1524
void ScCompiler::CheckTabQuotes( String& rString,
1538
void ScCompiler::CheckTabQuotes( String& rString,
1525
                                 const ScAddress::Convention eConv )
1539
                                 const ScAddress::Convention eConv )
1526
{
1540
{
1527
    register const xub_StrLen nLen = rString.Len();
1541
    using namespace ::com::sun::star::i18n;
1528
    register xub_StrLen i;
1542
    sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER | KParseTokens::ASC_UNDERSCORE;
1529
1543
    sal_Int32 nContFlags = nStartFlags;
1530
    bool bNeedsQuote = false;
1544
    ParseResult aRes = ScGlobal::pCharClass->parsePredefinedToken(
1531
1545
        KParseType::IDENTNAME, rString, 0, nStartFlags, EMPTY_STRING, nContFlags, EMPTY_STRING);
1532
    for ( i = 0 ; i < nLen ; i++ )
1546
    bool bNeedsQuote = !((aRes.TokenType & KParseType::IDENTNAME) && aRes.EndPos == rString.Len());
1533
    {
1534
        if( !IsWordChar( rString, i ) )
1535
        {
1536
            bNeedsQuote = true;
1537
            break;
1538
        }
1539
    }
1540
    if ( !bNeedsQuote && CharClass::isAsciiNumeric( rString ) )
1541
    {
1542
        bNeedsQuote = true;
1543
    }
1544
1547
1545
    switch ( eConv ) {
1548
    switch ( eConv ) {
1546
        default :
1549
        default :
1547
        case ScAddress::CONV_UNSPECIFIED :
1550
        case ScAddress::CONV_UNSPECIFIED :
1548
        case ScAddress::CONV_OOO :
1549
            break;
1551
            break;
1552
        case ScAddress::CONV_OOO :
1550
        case ScAddress::CONV_XL_A1 :
1553
        case ScAddress::CONV_XL_A1 :
1551
        case ScAddress::CONV_XL_R1C1 :
1554
        case ScAddress::CONV_XL_R1C1 :
1552
            if( bNeedsQuote )
1555
            if( bNeedsQuote )
(-)openoffice.org.orig/sc/source/filter/excel/excimp8.cxx (-1 lines)
Lines 186-192 Link Here
186
    String aName( aIn.ReadUniString( nLen ) );
186
    String aName( aIn.ReadUniString( nLen ) );
187
    GetTabInfo().AppendXclTabName( aName, nBdshtTab );
187
    GetTabInfo().AppendXclTabName( aName, nBdshtTab );
188
188
189
    ScfTools::ConvertToScSheetName( aName );
190
	*pExcRoot->pTabNameBuff << aName;
189
	*pExcRoot->pTabNameBuff << aName;
191
190
192
    SCTAB nScTab = static_cast< SCTAB >( nBdshtTab );
191
    SCTAB nScTab = static_cast< SCTAB >( nBdshtTab );
(-)openoffice.org.orig/sc/source/filter/excel/exctools.cxx (-1 lines)
Lines 391-397 Link Here
391
    ScDocument&         r = rRoot.GetDoc();
391
    ScDocument&         r = rRoot.GetDoc();
392
	ExcScenarioCell*	p = EXCSCFIRST();
392
	ExcScenarioCell*	p = EXCSCFIRST();
393
	String				aSzenName( *pName );
393
	String				aSzenName( *pName );
394
	ScfTools::ConvertToScSheetName( aSzenName );
395
	UINT16				nNewTab = nTab + 1;
394
	UINT16				nNewTab = nTab + 1;
396
395
397
	if( !r.InsertTab( nNewTab, aSzenName ) )
396
	if( !r.InsertTab( nNewTab, aSzenName ) )
(-)openoffice.org.orig/sc/source/filter/excel/impop.cxx (-2 lines)
Lines 435-441 Link Here
435
    bool bSameWorkBook;
435
    bool bSameWorkBook;
436
    String aEncodedUrl( aIn.ReadByteString( false ) );
436
    String aEncodedUrl( aIn.ReadByteString( false ) );
437
    XclImpUrlHelper::DecodeUrl( aUrl, aTabName, bSameWorkBook, *pExcRoot->pIR, aEncodedUrl );
437
    XclImpUrlHelper::DecodeUrl( aUrl, aTabName, bSameWorkBook, *pExcRoot->pIR, aEncodedUrl );
438
    ScfTools::ConvertToScSheetName( aTabName );
439
    pExcRoot->pExtSheetBuff->Add( aUrl, aTabName, bSameWorkBook );
438
    pExcRoot->pExtSheetBuff->Add( aUrl, aTabName, bSameWorkBook );
440
}
439
}
441
440
Lines 686-692 Link Here
686
	}
685
	}
687
686
688
    String aName( aIn.ReadByteString( FALSE ) );
687
    String aName( aIn.ReadByteString( FALSE ) );
689
    ScfTools::ConvertToScSheetName( aName );
690
688
691
	*pExcRoot->pTabNameBuff << aName;
689
	*pExcRoot->pTabNameBuff << aName;
692
690
(-)openoffice.org.orig/sc/source/filter/excel/xicontent.cxx (-5 lines)
Lines 354-365 Link Here
354
        {
354
        {
355
            bInQuote = !bInQuote;
355
            bInQuote = !bInQuote;
356
            if (!bInQuote && aTabName.Len() > 0)
356
            if (!bInQuote && aTabName.Len() > 0)
357
            {
358
                // Sheet name exists.  Convert it to valid name the same way the
359
                // sheet names are converted.
360
                ScDocument::ConvertToValidTabName(aTabName, sal_Unicode('_'));
361
                aNewUrl.Append(aTabName);
357
                aNewUrl.Append(aTabName);
362
            }
363
        }
358
        }
364
        else if (bInQuote)
359
        else if (bInQuote)
365
            aTabName.Append(c);
360
            aTabName.Append(c);
(-)openoffice.org.orig/sc/source/filter/excel/xilink.cxx (-1 lines)
Lines 422-428 Link Here
422
        for( sal_uInt16 nSBTab = 0; nSBTab < nSBTabCnt; ++nSBTab )
422
        for( sal_uInt16 nSBTab = 0; nSBTab < nSBTabCnt; ++nSBTab )
423
        {
423
        {
424
            String aTabName( rStrm.ReadUniString() );
424
            String aTabName( rStrm.ReadUniString() );
425
            ScfTools::ConvertToScSheetName( aTabName );
426
            maSupbTabList.Append( new XclImpSupbookTab( aTabName ) );
425
            maSupbTabList.Append( new XclImpSupbookTab( aTabName ) );
427
        }
426
        }
428
    }
427
    }
(-)openoffice.org.orig/sc/source/filter/excel/xipivot.cxx (-1 lines)
Lines 695-701 Link Here
695
            String aDummyName = CREATE_STRING( "DPCache" );
695
            String aDummyName = CREATE_STRING( "DPCache" );
696
            if( maTabName.Len() > 0 )
696
            if( maTabName.Len() > 0 )
697
                aDummyName.Append( '_' ).Append( maTabName );
697
                aDummyName.Append( '_' ).Append( maTabName );
698
            ScfTools::ConvertToScSheetName( aDummyName );
699
            rDoc.CreateValidTabName( aDummyName );
698
            rDoc.CreateValidTabName( aDummyName );
700
            rDoc.RenameTab( nScTab, aDummyName );
699
            rDoc.RenameTab( nScTab, aDummyName );
701
            // set sheet index to source range
700
            // set sheet index to source range
(-)openoffice.org.orig/sc/source/filter/ftools/ftools.cxx (-5 lines)
Lines 158-168 Link Here
158
158
159
// *** conversion of names *** ------------------------------------------------
159
// *** conversion of names *** ------------------------------------------------
160
160
161
void ScfTools::ConvertToScSheetName( String& rName )
162
{
163
    ScDocument::ConvertToValidTabName( rName, '_' );
164
}
165
166
void ScfTools::ConvertToScDefinedName( String& rName )
161
void ScfTools::ConvertToScDefinedName( String& rName )
167
{
162
{
168
    xub_StrLen nLen = rName.Len();
163
    xub_StrLen nLen = rName.Len();
(-)openoffice.org.orig/sc/source/filter/inc/ftools.hxx (-4 lines)
Lines 292-301 Link Here
292
292
293
// *** conversion of names *** ------------------------------------------------
293
// *** conversion of names *** ------------------------------------------------
294
294
295
    /** Converts a string to a valid Calc sheet name.
296
        @descr  Sheet names in Calc may contain letters, digits, underscores, and spaces
297
        (space characters are not allowed at first position). */
298
    static void         ConvertToScSheetName( String& rName );
299
    /** Converts a string to a valid Calc defined name or database range name.
295
    /** Converts a string to a valid Calc defined name or database range name.
300
        @descr  Defined names in Calc may contain letters, digits (*), underscores, periods (*),
296
        @descr  Defined names in Calc may contain letters, digits (*), underscores, periods (*),
301
        colons (*), question marks, and dollar signs.
297
        colons (*), question marks, and dollar signs.
(-)openoffice.org.orig/sc/source/filter/xcl97/XclImpChangeTrack.cxx (-1 lines)
Lines 179-185 Link Here
179
        pStrm->Ignore( 1 );
179
        pStrm->Ignore( 1 );
180
        // - sheet name, always separated from URL
180
        // - sheet name, always separated from URL
181
        String aTabName( pStrm->ReadUniString() );
181
        String aTabName( pStrm->ReadUniString() );
182
        ScfTools::ConvertToScSheetName( aTabName );
183
        pStrm->Ignore( 1 );
182
        pStrm->Ignore( 1 );
184
        rFirstTab = rLastTab = static_cast<SCTAB>(GetLinkManager().GetScTab( aUrl, aTabName ));
183
        rFirstTab = rLastTab = static_cast<SCTAB>(GetLinkManager().GetScTab( aUrl, aTabName ));
185
	}
184
	}
(-)openoffice.org.orig/sc/source/ui/vba/vbaworksheets.cxx (-3 / +1 lines)
Lines 402-410 Link Here
402
uno::Any 
402
uno::Any 
403
ScVbaWorksheets::getItemByStringIndex( const rtl::OUString& sIndex ) throw (uno::RuntimeException)
403
ScVbaWorksheets::getItemByStringIndex( const rtl::OUString& sIndex ) throw (uno::RuntimeException)
404
{
404
{
405
	String sScIndex = sIndex;
405
	return ScVbaWorksheets_BASE::getItemByStringIndex( sIndex );
406
	ScDocument::ConvertToValidTabName( sScIndex, '_' );
407
	return ScVbaWorksheets_BASE::getItemByStringIndex( sScIndex );
408
}
406
}
409
407
410
rtl::OUString& 
408
rtl::OUString& 

Return to issue 6087