26#include <compiler.hxx> 
   27#include <document.hxx> 
   30#include <osl/diagnose.h> 
   32#include <com/sun/star/frame/XModel.hpp> 
   33#include <com/sun/star/sheet/ExternalLinkInfo.hpp> 
   34#include <com/sun/star/sheet/ExternalLinkType.hpp> 
   38#include <rtl/character.hxx> 
   47    eConv( rDoc.GetAddressConvention() ),
 
   60    OUStringBuffer 
aBuf(std::u16string_view(pStart+1, p-pStart-1));
 
   76        else if (cPrev == 
'\'')
 
   79            rName = 
aBuf.makeStringAndClear();
 
  116                return parseQuotedNameWithBuffer(pStart, p, rName);
 
  119        else if (cPrev == 
'\'')
 
  123            rName = OUString(pStart+1, p - pStart-2);
 
  138    sal_Int64 accum = 0, prev = 0;
 
  149    while (rtl::isAsciiDigit( *
p ))
 
  151        accum = accum * 10 + *
p - 
'0';
 
  162    return is_neg ? -accum : accum;
 
  178    const size_t n = rStr.getLength();
 
  182    for (
size_t i=0; 
i<
n; ++
i)
 
  189            if (
'A' <= c1 && c1 <= 
'Z')
 
  191            if (c1 < 
'a' || 
'z' < c1)
 
  195            if (
'A' <= c2 && c2 <= 
'Z')
 
  197            if (c2 < 
'a' || 
'z' < c2)
 
  219                            const OUString & rExternDocName,
 
  220                            const OUString & rStartTabName,
 
  221                            const OUString & rEndTabName,
 
  224    if (rExternDocName.isEmpty())
 
  232        if (!rStartTabName.isEmpty())
 
  239        if (!rEndTabName.isEmpty())
 
  265    if (rEndTabName.isEmpty() || rStartTabName == rEndTabName)
 
  295                                                 OUString& rExternTabName,
 
  298                                                 const OUString* pErrRef )
 
  307        while (
p < pMsoxlQuoteStop)
 
  314                    aTabName += std::u16string_view( pCurrentStart,
 
  315                            sal::static_int_cast<sal_Int32>( 
p - pCurrentStart));
 
  326        if (pCurrentStart < 
p)
 
  327            aTabName += std::u16string_view( pCurrentStart, sal::static_int_cast<sal_Int32>( 
p - pCurrentStart));
 
  328        if (aTabName.isEmpty())
 
  330        if (
p == pMsoxlQuoteStop)
 
  332        if( *
p != 
'!' && ( !bAllow3D || *
p != 
':' ) )
 
  333            return (!bAllow3D && *
p == 
':') ? 
p : 
start;
 
  337        p = parseQuotedName(
p, aTabName);
 
  338        if (aTabName.isEmpty())
 
  341    else if (pErrRef && 
lcl_isString( 
p, *pErrRef) && 
p[pErrRef->getLength()] == 
'!')
 
  343        p += pErrRef->getLength();  
 
  349        bool only_digits = 
true;
 
  369            if( rtl::isAsciiAlpha( uc ) || uc == 
'_' )
 
  371                if( only_digits && 
p != 
start &&
 
  372                   (uc == 
'e' || uc == 
'E' ) )
 
  380            else if( rtl::isAsciiDigit( uc ))
 
  402        if( *
p != 
'!' && ( !bAllow3D || *
p != 
':' ) )
 
  403            return (!bAllow3D && *
p == 
':') ? 
p : 
start;
 
  405        aTabName += std::u16string_view( 
start, sal::static_int_cast<sal_Int32>( 
p - 
start ) );
 
  408    rExternTabName = aTabName;
 
  425                                   const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
 
  428    if (pExternalLinks && pExternalLinks->hasElements())
 
  433            sal_Int32 
i = rExternDocName.toInt32();
 
  434            if (i < 0 || i >= pExternalLinks->getLength())
 
  436            const sheet::ExternalLinkInfo & rInfo = (*pExternalLinks)[
i];
 
  439                case sheet::ExternalLinkType::DOCUMENT :
 
  442                        if (!(rInfo.Data >>= 
aStr))
 
  446                                "Data type mismatch for ExternalLinkInfo " 
  451                        rExternDocName = 
aStr;
 
  454                    case sheet::ExternalLinkType::SELF :
 
  456                    case sheet::ExternalLinkType::SPECIAL :
 
  463                        "unhandled ExternalLinkType " << rInfo.Type
 
  464                            << 
" for index " << 
i);
 
  476                                OUString& rExternDocName,
 
  477                                OUString& rStartTabName,
 
  478                                OUString& rEndTabName,
 
  480                                bool bOnlyAcceptSingle,
 
  481                                const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks,
 
  482                                const OUString* pErrRef )
 
  488    rStartTabName.clear();
 
  490    rExternDocName.clear();
 
  499            p = parseQuotedName(
p, rExternDocName);
 
  500            if (*
p != 
']' || rExternDocName.isEmpty())
 
  502                rExternDocName.clear();
 
  512            rExternDocName += std::u16string_view( 
start+1, sal::static_int_cast<sal_Int32>( 
p-(
start+1) ) );
 
  531        p = parseQuotedName(
p, rExternDocName);
 
  534            rExternDocName.clear();
 
  537        if (!rExternDocName.isEmpty())
 
  539            sal_Int32 nOpen = rExternDocName.indexOf( 
'[');
 
  541                rExternDocName.clear();
 
  544                sal_Int32 nClose = rExternDocName.indexOf( 
']', nOpen+1);
 
  546                    rExternDocName.clear();
 
  549                    rExternDocName = rExternDocName.copy(0, nClose);
 
  550                    rExternDocName = rExternDocName.replaceAt( nOpen, 1, 
u"");
 
  551                    pMsoxlQuoteStop = 
p - 1;    
 
  556                    for ( ; *
p != 
']'; ++
p)
 
  570        if (rExternDocName.isEmpty())
 
  578    if (bOnlyAcceptSingle && *
p == 
':')
 
  586            startEndTabs = 
p + 1;
 
  600            aEnd.SetTab( aStart.Tab() );
 
  617    if (!rExternDocName.isEmpty())
 
  625        if (rStartTabName.isEmpty())
 
  632        if ((pErrRef && *startTabs != 
'\'' && rStartTabName == *pErrRef) || !rDoc.
GetTable(rStartTabName, 
nTab))
 
  642        if (!rEndTabName.isEmpty())
 
  644            if ((pErrRef && startEndTabs && *startEndTabs != 
'\'' && rEndTabName == *pErrRef) ||
 
  671    isRelative = *
p == 
'[';
 
  675    if( 
nullptr == pEnd )
 
  684    else if( isRelative )
 
  718    isRelative = *
p == 
'[';
 
  722    if( 
nullptr == pEnd )
 
  731    else if( isRelative )
 
  756                                             bool bOnlyAcceptSingle,
 
  758                                             sal_Int32* pSheetEndPos )
 
  764    OUString aExternDocName, aStartTabName, aEndTabName;
 
  770            aEndTabName, nFlags, bOnlyAcceptSingle );
 
  775        *pSheetEndPos = 
p - pStart;
 
  779    if (!aExternDocName.isEmpty())
 
  781                aStartTabName, aEndTabName, rDoc);
 
  786    if( *
p == 
'R' || *
p == 
'r' )
 
  789            return nBailOutFlags;
 
  791        if( *
p != 
'C' && *
p != 
'c' )    
 
  793            if( 
p[0] != 
':' || (
p[1] != 
'R' && 
p[1] != 
'r' ) ||
 
  830            (
p[1] != 
'R' && 
p[1] != 
'r') ||
 
  832            (*pTmp != 
'C' && *pTmp != 
'c') ||
 
  862    else if( *
p == 
'C' || *
p == 
'c' )   
 
  865            return nBailOutFlags;
 
  867        if( 
p[0] != 
':' || (
p[1] != 
'C' && 
p[1] != 
'c') ||
 
  896    return nBailOutFlags;
 
  903                                                 const OUString* pErrRef )
 
  913        p += pErrRef->getLength();
 
  919    if( !rtl::isAsciiAlpha( *
p ) )
 
  922    sal_Int64 
nCol = rtl::toAsciiUpperCase( *
p++ ) - 
'A';
 
  924    while (
nCol <= nMaxCol && rtl::isAsciiAlpha(*
p))
 
  925        nCol = ((
nCol + 1) * 26) + rtl::toAsciiUpperCase( *
p++ ) - 
'A';
 
  926    if( 
nCol > nMaxCol || 
nCol < 0 || rtl::isAsciiAlpha( *
p ) )
 
  930    pAddr->
SetCol( sal::static_int_cast<SCCOL>( 
nCol ));
 
  939                                                 const OUString* pErrRef )
 
  951        p += pErrRef->getLength();
 
  958    if( 
nullptr == pEnd || 
p == pEnd || n < 0 || n > rDoc.
MaxRow() )
 
  962    pAddr->
SetRow( sal::static_int_cast<SCROW>(
n) );
 
  972    return bCols != bRows;
 
  978                                           bool bOnlyAcceptSingle,
 
  980                                           const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks,
 
  981                                           sal_Int32* pSheetEndPos,
 
  982                                           const OUString* pErrRef )
 
  988    OUString aExternDocName, aStartTabName, aEndTabName; 
 
  992            aEndTabName, nFlags, bOnlyAcceptSingle, pExternalLinks, pErrRef );
 
  997        *pSheetEndPos = 
p - pStart;
 
 1001    if (!aExternDocName.isEmpty())
 
 1003                aStartTabName, aEndTabName, rDoc);
 
 1006        return nBailOutFlags;
 
 1009    if( tmp1 == 
nullptr )          
 
 1011        if( bOnlyAcceptSingle ) 
 
 1012            return nBailOutFlags;
 
 1017        if( !tmp1 || *tmp1++ != 
':' ) 
 
 1018            return nBailOutFlags;
 
 1022        if( !tmp2 || *tmp2 != 0 )   
 
 1023            return nBailOutFlags;
 
 1034    if( tmp2 == 
nullptr )          
 
 1036        if( bOnlyAcceptSingle ) 
 
 1037            return nBailOutFlags;
 
 1040        if( *tmp1++ != 
':' )    
 
 1041            return nBailOutFlags;
 
 1045        if( !tmp2 || *tmp2 != 0 )   
 
 1046            return nBailOutFlags;
 
 1060    if ( bOnlyAcceptSingle )
 
 1093    if( !tmp1 && aEndTabName.isEmpty() )     
 
 1099            if( !aEndTabName.isEmpty() && rDoc.
GetTable( aEndTabName, 
nTab ) )
 
 1104            if (*
p == 
'!' || *
p == 
':')
 
 1143                                           sal_Int32* pSheetEndPos,
 
 1144                                           const OUString* pErrRef )
 
 1153    bool    bExtDoc = 
false;
 
 1154    bool    bExtDocInherited = 
false;
 
 1161        p = parseQuotedName(
p, aTmp);
 
 1173        bExtDoc = bExtDocInherited = 
true;
 
 1193        if (pErrRef && 
lcl_isString( 
p, *pErrRef) && 
p[pErrRef->getLength()] == 
'.')
 
 1196            p += pErrRef->getLength() + 1;
 
 1207                p = parseQuotedName(
p, aTab);
 
 1211                OUStringBuffer aTabAcc;
 
 1224                aTab = aTabAcc.makeStringAndClear();
 
 1238            *pSheetEndPos = 
p - pStart;
 
 1244        if (bExtDoc && !bExtDocInherited)
 
 1263            p += pErrRef->getLength();
 
 1269            if (rtl::isAsciiAlpha( *
p ))
 
 1272                sal_Int64 
n = rtl::toAsciiUpperCase( *
p++ ) - 
'A';
 
 1273                while (
n < nMaxCol && rtl::isAsciiAlpha(*
p))
 
 1274                    n = ((
n + 1) * 26) + rtl::toAsciiUpperCase( *
p++ ) - 
'A';
 
 1275                if (
n > nMaxCol || 
n < 0 || (*
p && *
p != 
'$' && !rtl::isAsciiDigit( *
p ) &&
 
 1279                    nCol = sal::static_int_cast<SCCOL>( 
n );
 
 1303            p += pErrRef->getLength();
 
 1315            if( !rtl::isAsciiDigit( *
p ) )
 
 1322                sal_Int64 
n = rtl_ustr_toInt32( 
p, 10 ) - 1;
 
 1323                while (rtl::isAsciiDigit( *
p ))
 
 1326                if( n < 0 || n > nMaxRow )
 
 1328                nRow = sal::static_int_cast<SCROW>(
n);
 
 1343        if (bExtDocInherited)
 
 1354                aDocName = *pFileName;
 
 1422    else if (bExtDoc && pExtInfo && !bExtDocInherited && !pExtInfo->
mbExternal && pSheetEndPos)
 
 1446        nRes = rRawRes = nBailOutFlags;
 
 1453                                        const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks,
 
 1454                                        sal_Int32* pSheetEndPos,
 
 1455                                        const OUString* pErrRef )
 
 1460    switch (rDetails.
eConv)
 
 1467                    rRange, 
p, rDoc, 
true, pExtInfo,
 
 1469                    pSheetEndPos, pErrRef);
 
 1501            rRefAddress.
Set( aAddr,
 
 1520        ScRefFlags nRes = aRange.
Parse( rRefString, rDoc, rDetails, pExtInfo);
 
 1527            rEndRefAddress.
Set( aRange.
aEnd,
 
 1540                             const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks,
 
 1541                             sal_Int32* pSheetEndPos,
 
 1542                             const OUString* pErrRef )
 
 1544    return lcl_ScAddress_Parse( r.getStr(), rDoc, *
this, rDetails, pExtInfo, pExternalLinks, pSheetEndPos, pErrRef);
 
 1556    if (nCol1 > nCol2 || nRow1 > nRow2 || nTab1 > nTab2)
 
 1559    return ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
 
 1564    OSL_ENSURE( rRange.
IsValid(), 
"ScRange::ExtendTo - cannot extend to invalid range" );
 
 1567        aStart.SetCol( std::min( aStart.Col(), rRange.
aStart.
Col() ) );
 
 1568        aStart.SetRow( std::min( aStart.Row(), rRange.
aStart.
Row() ) );
 
 1569        aStart.SetTab( std::min( aStart.Tab(), rRange.
aStart.
Tab() ) );
 
 1570        aEnd.SetCol(   std::max( aEnd.Col(),   rRange.
aEnd.
Col() ) );
 
 1571        aEnd.SetRow(   std::max( aEnd.Row(),   rRange.
aEnd.
Row() ) );
 
 1572        aEnd.SetTab(   std::max( aEnd.Tab(),   rRange.
aEnd.
Tab() ) );
 
 1582                                         const OUString* pErrRef )
 
 1588        OUStringBuffer aTmp(r);
 
 1600                    pExtInfo, &rRange, 
nullptr, pErrRef);
 
 1658                    nBits1 = nRes1 & nMask;
 
 1659                    nBits2 = nRes2 & nMask;
 
 1660                    nRes1 = (nRes1 & ~nMask) | nBits2;
 
 1661                    nRes2 = (nRes2 & ~nMask) | nBits1;
 
 1668                    nBits1 = nRes1 & nMask;
 
 1669                    nBits2 = nRes2 & nMask;
 
 1670                    nRes1 = (nRes1 & ~nMask) | nBits2;
 
 1671                    nRes2 = (nRes2 & ~nMask) | nBits1;
 
 1678                    nBits1 = nRes1 & nMask;
 
 1679                    nBits2 = nRes2 & nMask;
 
 1680                    nRes1 = (nRes1 & ~nMask) | nBits2;
 
 1681                    nRes2 = (nRes2 & ~nMask) | nBits1;
 
 1703                           const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks,
 
 1704                           const OUString* pErrRef )
 
 1706    if (rString.isEmpty())
 
 1709    switch (rDetails.
eConv)
 
 1739    if ( (nRet & nValid) != nValid )
 
 1742        nRet = aAdr.
Parse( rString, rDoc, rDetails );
 
 1744            aStart = aEnd = aAdr;
 
 1751                               const OUString& rStr,
 
 1761    switch (rDetails.
eConv)
 
 1767        if (
nullptr != (
p = 
lcl_a1_get_col( rDoc, 
p, &aStart, &ignored, 
nullptr) ) )
 
 1785        if ((
p[0] == 
'C' || 
p[0] == 
'c') &&
 
 1790                if( (
p[1] == 
'C' || 
p[1] == 
'c') &&
 
 1810                               const OUString& rStr,
 
 1819    switch (rDetails.
eConv)
 
 1825        if (
nullptr != (
p = 
lcl_a1_get_row( rDoc, 
p, &aStart, &ignored, 
nullptr) ) )
 
 1839        if ((
p[0] == 
'R' || 
p[0] == 
'r') &&
 
 1844                if( 
p[1] == 
'R' || 
p[1] == 
'r' )
 
 1863            rBuf.append( 
static_cast<char>( 
'A' + 
nCol ));
 
 1866            rBuf.append( 
static_cast<char>( 
'A' + 
nCol / 26 - 1 ));
 
 1867            rBuf.append( 
static_cast<char>( 
'A' + 
nCol % 26 ));
 
 1872        sal_Int32 nInsert = rBuf.getLength();
 
 1876            rBuf.insert(nInsert, 
static_cast<char> ( 
'A' + nC ));
 
 1877            nCol = sal::static_int_cast<SCCOL>( 
nCol - nC );
 
 1880        rBuf.insert(nInsert, 
static_cast<char> ( 
'A' + 
nCol ));
 
 1892        rString.append(
"$");
 
 1899        rString.append(
"$");
 
 1900    rString.append( 
nRow + 1 );
 
 1906    rString.append(
"C");
 
 1909        rString.append( 
nCol + 1 );
 
 1915            rString.append(
"[").append(
nCol).append(
"]");
 
 1923    rString.append(
"R");
 
 1926        rString.append( 
nRow + 1 );
 
 1932            rString.append(
"[").append(
nRow).append(
"]");
 
 1944    if( 
nullptr != pDoc &&
 
 1950            if( !
xModel->getURL().isEmpty() )
 
 1953                sFileName = 
aURL.GetLastName();
 
 1965    rString.append(sString);
 
 1988            OUString aTabName, aDocName;
 
 1990            assert( !aTabName.isEmpty() && 
"empty sheet name");
 
 1992            if( aTabName[0] == 
'\'' )
 
 1997                    aDocName = aTabName.copy( 0, 
nPos + 1 );
 
 1998                    aTabName = aTabName.copy( 
nPos + 1 );
 
 2012            switch( rDetails.
eConv )
 
 2024                if (!aTabName.isEmpty() && aTabName[0] == 
'\'')
 
 2026                    if (!aDocName.isEmpty())
 
 2042                if (!aDocName.isEmpty())
 
 2053    switch( rDetails.
eConv )
 
 2076                                  const Details& rDetails)
 const 
 2082                           const Details& rDetails)
 const 
 2086    return r.makeStringAndClear();
 
 2092                              OUString& rTabName, OUString& rDocName )
 
 2097    if (!rTabName.isEmpty() && rTabName[0] == 
'\'')
 
 2102            rDocName = rTabName.copy( 0, 
nPos + 1 );
 
 2103            rTabName = rTabName.copy( 
nPos + 1 );
 
 2125    OUString aTabName, aDocName;
 
 2127    switch (rDetails.
eConv)
 
 2130            if (!aTabName.isEmpty() && aTabName[0] == 
'\'')
 
 2132                if (!aDocName.isEmpty())
 
 2134                    rString.append(
"'[" + aDocName + 
"]" + aTabName.subView(1));
 
 2138                    rString.append(aTabName);
 
 2144            if (!aDocName.isEmpty())
 
 2146                rString.append(
"[" + aDocName + 
"]");
 
 2148            rString.append(aTabName);
 
 2154        rString.append(
":");
 
 2155        rString.append(aTabName);
 
 2157    rString.append(
"!");
 
 2179    switch( rDetails.
eConv ) {
 
 2182        bool bOneTab = (aStart.Tab() == aEnd.Tab());
 
 2185        r = aStart.Format(nFlags, &rDoc, rDetails);
 
 2186        if( aStart != aEnd ||
 
 2197            r.append(
":" + aEnd.Format(nFlags, pDoc, rDetails));
 
 2208        if( aStart.Col() == 0 && aEnd.Col() >= nMaxCol && !bFullAddressNotation )
 
 2215        else if( aStart.Row() == 0 && aEnd.Row() >= nMaxRow && !bFullAddressNotation )
 
 2226            if( aStart.Col() != aEnd.Col() ||
 
 2228                aStart.Row() != aEnd.Row() ||
 
 2243        if( aStart.Col() == 0 && aEnd.Col() >= nMaxCol && !bFullAddressNotation )
 
 2246            if( aStart.Row() != aEnd.Row() ||
 
 2252        else if( aStart.Row() == 0 && aEnd.Row() >= nMaxRow && !bFullAddressNotation )
 
 2255            if( aStart.Col() != aEnd.Col() ||
 
 2265            if( aStart.Col() != aEnd.Col() ||
 
 2267                aStart.Row() != aEnd.Row() ||
 
 2277    return r.makeStringAndClear();
 
 2295    else if( dx > nMaxCol )
 
 2306    else if( dy > nMaxRow )
 
 2317    else if( dz > nMaxTab )
 
 2332    if (dy && aStart.Row() == 0 && aEnd.Row() == nMaxRow)
 
 2334    if (dx && aStart.Col() == 0 && aEnd.Col() == nMaxCol)
 
 2336    bool b = aStart.Move( dx, dy, dz, rErrorRange.
aStart, rDoc );
 
 2337    b &= aEnd.Move( dx, dy, dz, rErrorRange.
aEnd, rDoc );
 
 2345    bool bColRange = (aStart.Col() < aEnd.Col());
 
 2346    bool bRowRange = (aStart.Row() < aEnd.Row());
 
 2347    if (dy && aStart.Row() == 0 && aEnd.Row() == nMaxRow)
 
 2349    if (dx && aStart.Col() == 0 && aEnd.Col() == nMaxCol)
 
 2351    bool b1 = aStart.Move( dx, dy, dz, rErrorRange.
aStart, rDoc );
 
 2352    if (dx && bColRange && aEnd.Col() == nMaxCol)
 
 2354    if (dy && bRowRange && aEnd.Row() == nMaxRow)
 
 2356    SCTAB nOldTab = aEnd.Tab();
 
 2357    bool b2 = aEnd.Move( dx, dy, dz, rErrorRange.
aEnd, rDoc );
 
 2361        bColRange = (!dx || (bColRange && aEnd.Col() == nMaxCol));
 
 2362        if (dx && bColRange)
 
 2364        bRowRange = (!dy || (bRowRange && aEnd.Row() == nMaxRow));
 
 2365        if (dy && bRowRange)
 
 2367        b2 = bColRange && bRowRange && (aEnd.Tab() - nOldTab == dz);
 
 2374    if (aStart.Col() >= nStartCol)
 
 2376        aStart.IncCol(nOffset);
 
 2377        if (aStart.Col() < 0)
 
 2379        else if(aStart.Col() > rDoc.
MaxCol())
 
 2380            aStart.SetCol(rDoc.
MaxCol());
 
 2382    if (aEnd.Col() >= nStartCol)
 
 2384        aEnd.IncCol(nOffset);
 
 2387        else if(aEnd.Col() > rDoc.
MaxCol())
 
 2388            aEnd.SetCol(rDoc.
MaxCol());
 
 2394    if (aStart.Row() >= nStartRow)
 
 2396        aStart.IncRow(nOffset);
 
 2397        if (aStart.Row() < 0)
 
 2399        else if(aStart.Row() > rDoc.
MaxRow())
 
 2400            aStart.SetRow(rDoc.
MaxRow());
 
 2402    if (aEnd.Row() >= nStartRow)
 
 2404        aEnd.IncRow(nOffset);
 
 2407        else if(aEnd.Row() > rDoc.
MaxRow())
 
 2408            aEnd.SetRow(rDoc.
MaxRow());
 
 2415    return aEnd.Col() == rDoc.
MaxCol() && aStart.Col() < aEnd.Col();
 
 2421    return aEnd.Row() == rDoc.
MaxRow() && aStart.Row() < aEnd.Row();
 
 2427    if (aStart.Col() >= 
nCol)
 
 2430        aEnd.IncCol( nDelta);
 
 2435    if (
nCol == nMaxCol)
 
 2440        aEnd.SetCol( ::std::min( 
static_cast<SCCOL>(
nCol + nDelta), nMaxCol));
 
 2442        aEnd.IncCol( nDelta);   
 
 2448    if (aStart.Row() >= 
nRow)
 
 2451        aEnd.IncRow( nDelta);
 
 2460        aEnd.SetRow( ::std::min( 
static_cast<SCROW>(
nRow + nDelta), rDoc.
MaxRow()));
 
 2462        aEnd.IncRow( nDelta);   
 
 2467    OUStringBuffer aString;
 
 2476        aString.append(
nRow+1);
 
 2485    return aString.makeStringAndClear();
 
 2495    if ( nActTab != 
Tab() )
 
 2506    return aAdr.Format(nFlags, &rDoc, rDetails);
 
 2512    sal_Int32 nStop = rStr.size();
 
 2516    while (nResult <= nMaxCol && 
nPos < nStop && (c = rStr[
nPos]) != 0 &&
 
 2517            rtl::isAsciiAlpha(c))
 
 2520            nResult = (nResult + 1) * 26;
 
static bool lcl_ScRange_External_TabSpan(ScRange &rRange, ScRefFlags &rFlags, ScAddress::ExternalInfo *pExtInfo, const OUString &rExternDocName, const OUString &rStartTabName, const OUString &rEndTabName, const ScDocument &rDoc)
Determines the number of sheets an external reference spans and sets rRange.aEnd.nTab accordingly.
 
void ScColToAlpha(OUStringBuffer &rBuf, SCCOL nCol)
append alpha representation of column to buffer
 
static bool isValidSingleton(ScRefFlags nFlags, ScRefFlags nFlags2)
B:B or 2:2, but not B:2 or 2:B or B2:B or B:B2 or ...
 
static ScRefFlags lcl_ScRange_Parse_OOo(ScRange &rRange, const OUString &r, const ScDocument &rDoc, ScAddress::ExternalInfo *pExtInfo, const OUString *pErrRef)
 
static bool lcl_XL_getExternalDoc(const sal_Unicode **ppErrRet, OUString &rExternDocName, const uno::Sequence< sheet::ExternalLinkInfo > *pExternalLinks)
Tries to obtain the external document index and replace by actual document name.
 
static void lcl_r1c1_append_r(T &rString, sal_Int32 nRow, bool bIsAbs, const ScAddress::Details &rDetails)
 
static void lcl_ScRange_Format_XL_Header(OUStringBuffer &rString, const ScRange &rRange, ScRefFlags nFlags, const ScDocument &rDoc, const ScAddress::Details &rDetails)
 
static bool lcl_isString(const sal_Unicode *p1, const OUString &rStr)
 
static ScRefFlags lcl_ScRange_Parse_XL_A1(ScRange &r, const sal_Unicode *p, const ScDocument &rDoc, bool bOnlyAcceptSingle, ScAddress::ExternalInfo *pExtInfo, const uno::Sequence< sheet::ExternalLinkInfo > *pExternalLinks, sal_Int32 *pSheetEndPos, const OUString *pErrRef)
 
static ScRefFlags lcl_ScRange_Parse_XL_R1C1(ScRange &r, const sal_Unicode *p, const ScDocument &rDoc, const ScAddress::Details &rDetails, bool bOnlyAcceptSingle, ScAddress::ExternalInfo *pExtInfo, sal_Int32 *pSheetEndPos)
 
bool ConvertSingleRef(const ScDocument &rDoc, const OUString &rRefString, SCTAB nDefTab, ScRefAddress &rRefAddress, const ScAddress::Details &rDetails, ScAddress::ExternalInfo *pExtInfo)
 
static OUString getFileNameFromDoc(const ScDocument *pDoc)
 
static const sal_Unicode * lcl_a1_get_col(const ScDocument &rDoc, const sal_Unicode *p, ScAddress *pAddr, ScRefFlags *nFlags, const OUString *pErrRef)
 
static const sal_Unicode * lcl_eatWhiteSpace(const sal_Unicode *p)
 
bool ConvertDoubleRef(const ScDocument &rDoc, const OUString &rRefString, SCTAB nDefTab, ScRefAddress &rStartRefAddress, ScRefAddress &rEndRefAddress, const ScAddress::Details &rDetails, ScAddress::ExternalInfo *pExtInfo)
 
static sal_Int64 sal_Unicode_strtol(const sal_Unicode *p, const sal_Unicode **pEnd)
 
static void lcl_ScColToAlpha(T &rBuf, SCCOL nCol)
 
static void lcl_Format(T &r, SCTAB nTab, SCROW nRow, SCCOL nCol, ScRefFlags nFlags, const ScDocument *pDoc, const ScAddress::Details &rDetails)
 
static ScRefFlags lcl_ScAddress_Parse(const sal_Unicode *p, const ScDocument &rDoc, ScAddress &rAddr, const ScAddress::Details &rDetails, ScAddress::ExternalInfo *pExtInfo, const uno::Sequence< sheet::ExternalLinkInfo > *pExternalLinks, sal_Int32 *pSheetEndPos, const OUString *pErrRef)
 
static bool lcl_ColAbsFlagDiffer(const ScRefFlags nFlags)
 
static const sal_Unicode * lcl_a1_get_row(const ScDocument &rDoc, const sal_Unicode *p, ScAddress *pAddr, ScRefFlags *nFlags, const OUString *pErrRef)
 
static const sal_Unicode * lcl_r1c1_get_col(const ScSheetLimits &rSheetLimits, const sal_Unicode *p, const ScAddress::Details &rDetails, ScAddress *pAddr, ScRefFlags *nFlags)
 
static void lcl_a1_append_c(T &rString, int nCol, bool bIsAbs)
 
static bool lcl_RowAbsFlagDiffer(const ScRefFlags nFlags)
 
static ScRefFlags lcl_ScAddress_Parse_OOo(const sal_Unicode *p, const ScDocument &rDoc, ScAddress &rAddr, ScRefFlags &rRawRes, ScAddress::ExternalInfo *pExtInfo, ScRange *pRange, sal_Int32 *pSheetEndPos, const OUString *pErrRef)
 
static void lcl_Split_DocTab(const ScDocument &rDoc, SCTAB nTab, const ScAddress::Details &rDetails, ScRefFlags nFlags, OUString &rTabName, OUString &rDocName)
 
static const sal_Unicode * lcl_r1c1_get_row(const ScSheetLimits &rSheetLimits, const sal_Unicode *p, const ScAddress::Details &rDetails, ScAddress *pAddr, ScRefFlags *nFlags)
 
static void lcl_string_append(OUStringBuffer &rString, std::u16string_view sString)
 
static void lcl_r1c1_append_c(T &rString, sal_Int32 nCol, bool bIsAbs, const ScAddress::Details &rDetails)
 
static const sal_Unicode * lcl_XL_ParseSheetRef(const sal_Unicode *start, OUString &rExternTabName, bool bAllow3D, const sal_Unicode *pMsoxlQuoteStop, const OUString *pErrRef)
Returns NULL if the string should be a sheet name, but is invalid.
 
bool AlphaToCol(const ScDocument &rDoc, SCCOL &rCol, std::u16string_view rStr)
get column number of A..IV... string
 
static void lcl_a1_append_r(T &rString, sal_Int32 nRow, bool bIsAbs)
 
void applyStartToEndFlags(ScRefFlags &target, const ScRefFlags source)
 
static bool isAsciiNumeric(std::u16string_view rStr)
 
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
 
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
 
SC_DLLPUBLIC bool Move(SCCOL nDeltaX, SCROW nDeltaY, SCTAB nDeltaZ, ScAddress &rErrorPos, const ScDocument &rDoc)
 
static SC_DLLPUBLIC const Details detailsOOOa1
 
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
 
OUString GetColRowString() const
Create a human-readable string representation of the cell address.
 
static sal_Int32 GetDocTabPos(const OUString &rString)
Analyzes a string for a 'Doc'Tab construct, or 'Do''c'Tab etc...
 
static void CheckTabQuotes(OUString &aTabName, const formula::FormulaGrammar::AddressConvention eConv=formula::FormulaGrammar::CONV_OOO)
all
 
ScSheetLimits & GetSheetLimits() const
 
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
 
SC_DLLPUBLIC SCCOL MaxCol() const
 
SC_DLLPUBLIC SCROW MaxRow() const
 
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
 
SfxObjectShell * GetDocumentShell() const
 
bool ValidCol(SCCOL nCol) const
 
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
 
SC_DLLPUBLIC SCTAB GetTableCount() const
 
SCTAB getCachedTabSpan(sal_uInt16 nFileId, const OUString &rStartTabName, const OUString &rEndTabName) const
Get the span (distance+sign(distance)) of two sheets of a specified file.
 
sal_uInt16 getExternalFileId(const OUString &rFile)
 
const OUString * getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal=false)
It returns a pointer to the name of the URI associated with a given external file ID.
 
void convertToAbsName(OUString &rFile) const
Takes a flat file name, and convert it to an absolute URL path.
 
bool isOwnDocument(std::u16string_view rFile) const
 
ScExternalRefCache::TokenRef getSingleRefToken(sal_uInt16 nFileId, const OUString &rTabName, const ScAddress &rCell, const ScAddress *pCurPos, SCTAB *pTab, ScExternalRefCache::CellFormat *pFmt=nullptr)
 
static const sal_Unicode * UnicodeStrChr(const sal_Unicode *pStr, sal_Unicode c)
strchr() functionality on unicode, as long as we need it for FormulaToken etc.
 
static SC_DLLPUBLIC sal_Int32 FindUnquoted(const OUString &rString, sal_Unicode cChar, sal_Int32 nStart=0)
Finds an unquoted instance of cChar in rString, starting at offset nStart.
 
static SC_DLLPUBLIC OUString GetAbsDocName(const OUString &rFileName, const SfxObjectShell *pShell)
 
static sal_Unicode ToUpperAlpha(sal_Unicode c)
 
void ParseRows(const ScDocument &rDoc, const OUString &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
 
bool IsEndRowSticky(const ScDocument &rDoc) const
If maximum end row should not be adapted during reference update.
 
bool IsEndColSticky(const ScDocument &rDoc) const
If maximum end column should not be adapted during reference update.
 
ScRange Intersection(const ScRange &rOther) const
 
bool Move(SCCOL aDeltaX, SCROW aDeltaY, SCTAB aDeltaZ, ScRange &rErrorRange, const ScDocument &rDoc)
 
void IncEndRowSticky(const ScDocument &rDoc, SCROW nDelta)
Increment or decrement end row unless sticky or until it becomes sticky.
 
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
 
void IncColIfNotLessThan(const ScDocument &rDoc, SCCOL nStartCol, SCCOL nOffset)
 
void ExtendTo(const ScRange &rRange)
 
void IncEndColSticky(const ScDocument &rDoc, SCCOL nDelta)
Increment or decrement end column unless sticky or until it becomes sticky.
 
const sal_Unicode * Parse_XL_Header(const sal_Unicode *pString, const ScDocument &rDocument, OUString &rExternDocName, OUString &rStartTabName, OUString &rEndTabName, ScRefFlags &nFlags, bool bOnlyAcceptSingle, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, const OUString *pErrRef=nullptr)
Parse an Excel style reference up to and including the sheet name separator '!', including detection ...
 
ScRefFlags ParseAny(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
 
void IncRowIfNotLessThan(const ScDocument &rDoc, SCROW nStartRow, SCROW nOffset)
 
ScRefFlags ParseCols(const ScDocument &rDoc, const OUString &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
 
bool MoveSticky(const ScDocument &rDoc, SCCOL aDeltaX, SCROW aDeltaY, SCTAB aDeltaZ, ScRange &rErrorRange)
Same as Move() but with sticky end col/row anchors.
 
ScRefFlags Parse(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, ScAddress::ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, const OUString *pErrRef=nullptr)
 
OUString GetRefString(const ScDocument &rDocument, SCTAB nActTab, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1) const
 
void Set(const ScAddress &rAdr, bool bNewRelCol, bool bNewRelRow, bool bNewRelTab)
 
css::uno::Reference< css::frame::XModel3 > GetModel() const
 
OUString GetTitle(sal_uInt16 nMaxLen=0) const
 
#define SC_COMPILER_FILE_TAB_SEP
 
#define SAL_INFO(area, stream)
 
constexpr std::underlying_type_t< T > to_underlying(T e)
 
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
 
Details(formula::FormulaGrammar::AddressConvention eConvP, SCROW nRowP, SCCOL nColP)
 
formula::FormulaGrammar::AddressConvention eConv
 
SCROW GetMaxRowCount() const
 
SCCOL GetMaxColCount() const
 
Reference< XModel > xModel