LibreOffice Module sc (master) 1
Functions
address.cxx File Reference
#include <sal/config.h>
#include <string_view>
#include <address.hxx>
#include <global.hxx>
#include <compiler.hxx>
#include <document.hxx>
#include <externalrefmgr.hxx>
#include <osl/diagnose.h>
#include <o3tl/underlyingenumvalue.hxx>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/sheet/ExternalLinkInfo.hpp>
#include <com/sun/star/sheet/ExternalLinkType.hpp>
#include <sfx2/objsh.hxx>
#include <tools/urlobj.hxx>
#include <sal/log.hxx>
#include <rtl/character.hxx>
#include <unotools/charclass.hxx>
Include dependency graph for address.cxx:

Go to the source code of this file.

Functions

static sal_Int64 sal_Unicode_strtol (const sal_Unicode *p, const sal_Unicode **pEnd)
 
static const sal_Unicodelcl_eatWhiteSpace (const sal_Unicode *p)
 
static bool lcl_isString (const sal_Unicode *p1, const OUString &rStr)
 
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. More...
 
static const sal_Unicodelcl_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. More...
 
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. More...
 
static const sal_Unicodelcl_r1c1_get_col (const ScSheetLimits &rSheetLimits, const sal_Unicode *p, const ScAddress::Details &rDetails, ScAddress *pAddr, ScRefFlags *nFlags)
 
static const sal_Unicodelcl_r1c1_get_row (const ScSheetLimits &rSheetLimits, const sal_Unicode *p, const ScAddress::Details &rDetails, ScAddress *pAddr, ScRefFlags *nFlags)
 
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)
 
static const sal_Unicodelcl_a1_get_col (const ScDocument &rDoc, const sal_Unicode *p, ScAddress *pAddr, ScRefFlags *nFlags, const OUString *pErrRef)
 
static const sal_Unicodelcl_a1_get_row (const ScDocument &rDoc, const sal_Unicode *p, ScAddress *pAddr, ScRefFlags *nFlags, const OUString *pErrRef)
 
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 ... More...
 
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_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 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)
 
bool ConvertSingleRef (const ScDocument &rDoc, const OUString &rRefString, SCTAB nDefTab, ScRefAddress &rRefAddress, const ScAddress::Details &rDetails, ScAddress::ExternalInfo *pExtInfo)
 
bool ConvertDoubleRef (const ScDocument &rDoc, const OUString &rRefString, SCTAB nDefTab, ScRefAddress &rStartRefAddress, ScRefAddress &rEndRefAddress, const ScAddress::Details &rDetails, ScAddress::ExternalInfo *pExtInfo)
 
static ScRefFlags lcl_ScRange_Parse_OOo (ScRange &rRange, const OUString &r, const ScDocument &rDoc, ScAddress::ExternalInfo *pExtInfo, const OUString *pErrRef)
 
template<typename T >
static void lcl_ScColToAlpha (T &rBuf, SCCOL nCol)
 
void ScColToAlpha (OUStringBuffer &rBuf, SCCOL nCol)
 append alpha representation of column to buffer More...
 
template<typename T >
static void lcl_a1_append_c (T &rString, int nCol, bool bIsAbs)
 
template<typename T >
static void lcl_a1_append_r (T &rString, sal_Int32 nRow, bool bIsAbs)
 
template<typename T >
static void lcl_r1c1_append_c (T &rString, sal_Int32 nCol, bool bIsAbs, const ScAddress::Details &rDetails)
 
template<typename T >
static void lcl_r1c1_append_r (T &rString, sal_Int32 nRow, bool bIsAbs, const ScAddress::Details &rDetails)
 
static OUString getFileNameFromDoc (const ScDocument *pDoc)
 
static void lcl_string_append (OUStringBuffer &rString, std::u16string_view sString)
 
static void lcl_string_append (OStringBuffer &rString, std::u16string_view sString)
 
template<typename T >
static void lcl_Format (T &r, SCTAB nTab, SCROW nRow, SCCOL nCol, ScRefFlags nFlags, const ScDocument *pDoc, const ScAddress::Details &rDetails)
 
static void lcl_Split_DocTab (const ScDocument &rDoc, SCTAB nTab, const ScAddress::Details &rDetails, ScRefFlags nFlags, OUString &rTabName, OUString &rDocName)
 
static void lcl_ScRange_Format_XL_Header (OUStringBuffer &rString, const ScRange &rRange, ScRefFlags nFlags, const ScDocument &rDoc, const ScAddress::Details &rDetails)
 
static bool lcl_ColAbsFlagDiffer (const ScRefFlags nFlags)
 
static bool lcl_RowAbsFlagDiffer (const ScRefFlags nFlags)
 
bool AlphaToCol (const ScDocument &rDoc, SCCOL &rCol, std::u16string_view rStr)
 get column number of A..IV... string More...
 

Function Documentation

◆ AlphaToCol()

bool AlphaToCol ( const ScDocument rDoc,
SCCOL rCol,
std::u16string_view  rStr 
)

◆ ConvertDoubleRef()

bool ConvertDoubleRef ( const ScDocument rDoc,
const OUString &  rRefString,
SCTAB  nDefTab,
ScRefAddress rStartRefAddress,
ScRefAddress rEndRefAddress,
const ScAddress::Details rDetails,
ScAddress::ExternalInfo pExtInfo 
)

◆ ConvertSingleRef()

bool ConvertSingleRef ( const ScDocument rDoc,
const OUString &  rRefString,
SCTAB  nDefTab,
ScRefAddress rRefAddress,
const ScAddress::Details rDetails,
ScAddress::ExternalInfo pExtInfo 
)

◆ getFileNameFromDoc()

static OUString getFileNameFromDoc ( const ScDocument pDoc)
static

◆ isValidSingleton()

static bool isValidSingleton ( ScRefFlags  nFlags,
ScRefFlags  nFlags2 
)
static

B:B or 2:2, but not B:2 or 2:B or B2:B or B:B2 or ...

Definition at line 968 of file address.cxx.

References COL2_VALID, COL_VALID, ROW2_VALID, and ROW_VALID.

Referenced by lcl_ScRange_Parse_XL_A1().

◆ lcl_a1_append_c()

template<typename T >
static void lcl_a1_append_c ( T &  rString,
int  nCol,
bool  bIsAbs 
)
static

Definition at line 1889 of file address.cxx.

References lcl_ScColToAlpha(), and ScAddress::nCol.

Referenced by ScRange::Format(), and lcl_Format().

◆ lcl_a1_append_r()

template<typename T >
static void lcl_a1_append_r ( T &  rString,
sal_Int32  nRow,
bool  bIsAbs 
)
static

Definition at line 1896 of file address.cxx.

References ScAddress::nRow.

Referenced by ScRange::Format(), and lcl_Format().

◆ lcl_a1_get_col()

static const sal_Unicode * lcl_a1_get_col ( const ScDocument rDoc,
const sal_Unicode p,
ScAddress pAddr,
ScRefFlags nFlags,
const OUString *  pErrRef 
)
static

◆ lcl_a1_get_row()

static const sal_Unicode * lcl_a1_get_row ( const ScDocument rDoc,
const sal_Unicode p,
ScAddress pAddr,
ScRefFlags nFlags,
const OUString *  pErrRef 
)
static

◆ lcl_ColAbsFlagDiffer()

static bool lcl_ColAbsFlagDiffer ( const ScRefFlags  nFlags)
static

Definition at line 2161 of file address.cxx.

References COL2_ABS, and COL_ABS.

Referenced by ScRange::Format().

◆ lcl_eatWhiteSpace()

static const sal_Unicode * lcl_eatWhiteSpace ( const sal_Unicode p)
static

Definition at line 165 of file address.cxx.

References p.

Referenced by lcl_ScRange_Parse_XL_A1(), and ScRange::Parse_XL_Header().

◆ lcl_Format()

template<typename T >
static void lcl_Format ( T &  r,
SCTAB  nTab,
SCROW  nRow,
SCCOL  nCol,
ScRefFlags  nFlags,
const ScDocument pDoc,
const ScAddress::Details rDetails 
)
static

◆ lcl_isString()

static bool lcl_isString ( const sal_Unicode p1,
const OUString &  rStr 
)
static

Definition at line 176 of file address.cxx.

References i, and n.

Referenced by lcl_a1_get_col(), lcl_a1_get_row(), lcl_ScAddress_Parse_OOo(), and lcl_XL_ParseSheetRef().

◆ lcl_r1c1_append_c()

template<typename T >
static void lcl_r1c1_append_c ( T &  rString,
sal_Int32  nCol,
bool  bIsAbs,
const ScAddress::Details rDetails 
)
static

Definition at line 1903 of file address.cxx.

References ScAddress::nCol, and ScAddress::Details::nCol.

Referenced by ScRange::Format(), ScAddress::GetColRowString(), and lcl_Format().

◆ lcl_r1c1_append_r()

template<typename T >
static void lcl_r1c1_append_r ( T &  rString,
sal_Int32  nRow,
bool  bIsAbs,
const ScAddress::Details rDetails 
)
static

Definition at line 1920 of file address.cxx.

References ScAddress::nRow, and ScAddress::Details::nRow.

Referenced by ScRange::Format(), ScAddress::GetColRowString(), and lcl_Format().

◆ lcl_r1c1_get_col()

static const sal_Unicode * lcl_r1c1_get_col ( const ScSheetLimits rSheetLimits,
const sal_Unicode p,
const ScAddress::Details rDetails,
ScAddress pAddr,
ScRefFlags nFlags 
)
static

◆ lcl_r1c1_get_row()

static const sal_Unicode * lcl_r1c1_get_row ( const ScSheetLimits rSheetLimits,
const sal_Unicode p,
const ScAddress::Details rDetails,
ScAddress pAddr,
ScRefFlags nFlags 
)
static

◆ lcl_RowAbsFlagDiffer()

static bool lcl_RowAbsFlagDiffer ( const ScRefFlags  nFlags)
static

Definition at line 2165 of file address.cxx.

References ROW2_ABS, and ROW_ABS.

Referenced by ScRange::Format().

◆ lcl_ScAddress_Parse()

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

◆ lcl_ScAddress_Parse_OOo()

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
Parameters
ppointer to null-terminated sal_Unicode string
rRawResreturns ScRefFlags::... flags without the final check for full validity that is applied to the return value, with which two addresses that form a column or row singleton range, e.g. A:A or 1:1, can be detected. Used in lcl_ScRange_Parse_OOo().
pRangepointer to range where rAddr effectively is *pRange->aEnd, used in conjunction with pExtInfo to determine the tab span of a 3D reference.

Definition at line 1139 of file address.cxx.

References ScRange::aEnd, COL_ABS, COL_VALID, ScExternalRefManager::convertToAbsName(), ScGlobal::FindUnquoted(), ScExternalRefManager::getExternalFileId(), ScExternalRefManager::getExternalFileName(), ScDocument::GetExternalRefManager(), ScExternalRefManager::getSingleRefToken(), ScDocument::GetTable(), ScExternalRefManager::isOwnDocument(), lcl_isString(), lcl_ScRange_External_TabSpan(), ScAddress::ExternalInfo::maTabName, ScDocument::MaxCol(), ScDocument::MaxRow(), ScAddress::ExternalInfo::mbExternal, ScAddress::ExternalInfo::mnFileId, n, ScAddress::nCol, ScAddress::nRow, ScAddress::nTab, p, ROW_ABS, ROW_VALID, SC_COMPILER_FILE_TAB_SEP, ScAddress::Set(), ScAddress::SetTab(), ScAddress::Tab(), TAB2_VALID, TAB_3D, TAB_ABS, TAB_VALID, VALID, and ZERO.

Referenced by lcl_ScAddress_Parse(), and lcl_ScRange_Parse_OOo().

◆ lcl_ScColToAlpha()

template<typename T >
static void lcl_ScColToAlpha ( T &  rBuf,
SCCOL  nCol 
)
static

Definition at line 1858 of file address.cxx.

References ScAddress::nCol.

Referenced by ScAddress::GetColRowString(), lcl_a1_append_c(), and ScColToAlpha().

◆ lcl_ScRange_External_TabSpan()

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 
)
static

Determines the number of sheets an external reference spans and sets rRange.aEnd.nTab accordingly.

If a sheet is not found, the corresponding bits in rFlags are cleared. pExtInfo is filled if it wasn't already. If in cached order rStartTabName comes after rEndTabName, pExtInfo->maTabName is set to rEndTabName.

Returns
<FALSE> if pExtInfo is already filled and rExternDocName does not result in the identical file ID. Else <TRUE>.

Definition at line 215 of file address.cxx.

References ScRange::aEnd, ScRange::aStart, ScExternalRefManager::getCachedTabSpan(), ScExternalRefManager::getExternalFileId(), ScDocument::GetExternalRefManager(), ScDocument::GetTable(), ScExternalRefManager::isOwnDocument(), ScAddress::ExternalInfo::maTabName, ScAddress::ExternalInfo::mbExternal, ScAddress::ExternalInfo::mnFileId, ScAddress::nTab, ScAddress::SetTab(), ScAddress::Tab(), TAB2_VALID, and TAB_VALID.

Referenced by lcl_ScAddress_Parse_OOo(), lcl_ScRange_Parse_XL_A1(), and lcl_ScRange_Parse_XL_R1C1().

◆ lcl_ScRange_Format_XL_Header()

static void lcl_ScRange_Format_XL_Header ( OUStringBuffer &  rString,
const ScRange rRange,
ScRefFlags  nFlags,
const ScDocument rDoc,
const ScAddress::Details rDetails 
)
static

◆ lcl_ScRange_Parse_OOo()

static ScRefFlags lcl_ScRange_Parse_OOo ( ScRange rRange,
const OUString &  r,
const ScDocument rDoc,
ScAddress::ExternalInfo pExtInfo,
const OUString *  pErrRef 
)
static

◆ lcl_ScRange_Parse_XL_A1()

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

◆ lcl_ScRange_Parse_XL_R1C1()

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 
)
static

◆ lcl_Split_DocTab()

static void lcl_Split_DocTab ( const ScDocument rDoc,
SCTAB  nTab,
const ScAddress::Details rDetails,
ScRefFlags  nFlags,
OUString &  rTabName,
OUString &  rDocName 
)
static

◆ lcl_string_append() [1/2]

static void lcl_string_append ( OStringBuffer &  rString,
std::u16string_view  sString 
)
static

Definition at line 1968 of file address.cxx.

References OUStringToOString().

◆ lcl_string_append() [2/2]

static void lcl_string_append ( OUStringBuffer &  rString,
std::u16string_view  sString 
)
static

Definition at line 1963 of file address.cxx.

Referenced by lcl_Format().

◆ lcl_XL_getExternalDoc()

static bool lcl_XL_getExternalDoc ( const sal_Unicode **  ppErrRet,
OUString &  rExternDocName,
const uno::Sequence< sheet::ExternalLinkInfo > *  pExternalLinks 
)
static

Tries to obtain the external document index and replace by actual document name.

Parameters
ppErrRetContains the default pointer the caller would return if this method returns FALSE, may be replaced by NULL for type or data errors.
Returns
FALSE only if the input name is numeric and not within the index sequence, or the link type cannot be determined or data mismatch. Returns TRUE in all other cases, also when there is no index sequence or the input name is not numeric.

Definition at line 424 of file address.cxx.

References aStr, i, CharClass::isAsciiNumeric(), and SAL_INFO.

Referenced by ScRange::Parse_XL_Header().

◆ lcl_XL_ParseSheetRef()

static const sal_Unicode * lcl_XL_ParseSheetRef ( const sal_Unicode start,
OUString &  rExternTabName,
bool  bAllow3D,
const sal_Unicode pMsoxlQuoteStop,
const OUString *  pErrRef 
)
static

Returns NULL if the string should be a sheet name, but is invalid.

Returns a pointer to the first character after the sheet name, if there was any, else pointer to start.

Parameters
pMsoxlQuoteStopStarting within a quoted name, but still may be 3D; quoted name stops at pMsoxlQuoteStop

Definition at line 294 of file address.cxx.

References lcl_isString(), p, and start.

Referenced by lcl_ScRange_Parse_XL_A1(), and ScRange::Parse_XL_Header().

◆ sal_Unicode_strtol()

static sal_Int64 sal_Unicode_strtol ( const sal_Unicode p,
const sal_Unicode **  pEnd 
)
static

Definition at line 136 of file address.cxx.

References p.

Referenced by lcl_a1_get_row(), lcl_r1c1_get_col(), and lcl_r1c1_get_row().

◆ ScColToAlpha()

void ScColToAlpha ( OUStringBuffer &  rBuf,
SCCOL  nCol 
)