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 long int 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 *pDoc)
 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 sal_Unicode *p, const ScAddress::Details &rDetails, ScAddress *pAddr, ScRefFlags *nFlags)
 
static const sal_Unicodelcl_r1c1_get_row (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 *pDoc, const ScAddress::Details &rDetails, bool bOnlyAcceptSingle, ScAddress::ExternalInfo *pExtInfo, sal_Int32 *pSheetEndPos)
 
static const sal_Unicodelcl_a1_get_col (const ScDocument *pDoc, const sal_Unicode *p, ScAddress *pAddr, ScRefFlags *nFlags, const OUString *pErrRef)
 
static const sal_Unicodelcl_a1_get_row (const ScDocument *pDoc, 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 *pDoc, 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 *pDoc, 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 *pDoc, 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 *pDoc, const OUString &rRefString, SCTAB nDefTab, ScRefAddress &rRefAddress, const ScAddress::Details &rDetails, ScAddress::ExternalInfo *pExtInfo)
 
bool ConvertDoubleRef (const ScDocument *pDoc, 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 *pDoc, 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, const OUString &sString)
 
static void lcl_string_append (OStringBuffer &rString, const OUString &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, const OUString &rStr)
 get column number of A..IV... string More...
 

Function Documentation

bool AlphaToCol ( const ScDocument rDoc,
SCCOL rCol,
const OUString &  rStr 
)
bool ConvertDoubleRef ( const ScDocument pDoc,
const OUString &  rRefString,
SCTAB  nDefTab,
ScRefAddress rStartRefAddress,
ScRefAddress rEndRefAddress,
const ScAddress::Details rDetails,
ScAddress::ExternalInfo pExtInfo 
)
bool ConvertSingleRef ( const ScDocument pDoc,
const OUString &  rRefString,
SCTAB  nDefTab,
ScRefAddress rRefAddress,
const ScAddress::Details rDetails,
ScAddress::ExternalInfo pExtInfo 
)
static OUString getFileNameFromDoc ( const ScDocument pDoc)
static
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 970 of file address.cxx.

References COL2_VALID, COL_VALID, ROW2_VALID, and ROW_VALID.

Referenced by lcl_ScRange_Parse_XL_A1().

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

Definition at line 1926 of file address.cxx.

References lcl_ScColToAlpha().

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

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

Definition at line 1933 of file address.cxx.

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

static const sal_Unicode* lcl_a1_get_col ( const ScDocument pDoc,
const sal_Unicode p,
ScAddress pAddr,
ScRefFlags nFlags,
const OUString *  pErrRef 
)
static
static const sal_Unicode* lcl_a1_get_row ( const ScDocument pDoc,
const sal_Unicode p,
ScAddress pAddr,
ScRefFlags nFlags,
const OUString *  pErrRef 
)
static
static bool lcl_ColAbsFlagDiffer ( const ScRefFlags  nFlags)
static

Definition at line 2198 of file address.cxx.

References COL2_ABS, and COL_ABS.

Referenced by ScRange::Format().

static const sal_Unicode* lcl_eatWhiteSpace ( const sal_Unicode p)
static

Definition at line 165 of file address.cxx.

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

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
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().

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

Definition at line 1940 of file address.cxx.

References ScAddress::Details::nCol.

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

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

Definition at line 1957 of file address.cxx.

References ScAddress::Details::nRow.

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

static const sal_Unicode* lcl_r1c1_get_col ( const sal_Unicode p,
const ScAddress::Details rDetails,
ScAddress pAddr,
ScRefFlags nFlags 
)
static
static const sal_Unicode* lcl_r1c1_get_row ( const sal_Unicode p,
const ScAddress::Details rDetails,
ScAddress pAddr,
ScRefFlags nFlags 
)
static
static bool lcl_RowAbsFlagDiffer ( const ScRefFlags  nFlags)
static

Definition at line 2202 of file address.cxx.

References ROW2_ABS, and ROW_ABS.

Referenced by ScRange::Format().

static ScRefFlags lcl_ScAddress_Parse ( const sal_Unicode p,
const ScDocument pDoc,
ScAddress rAddr,
const ScAddress::Details rDetails,
ScAddress::ExternalInfo pExtInfo,
const uno::Sequence< sheet::ExternalLinkInfo > *  pExternalLinks,
sal_Int32 *  pSheetEndPos,
const OUString *  pErrRef 
)
static
static ScRefFlags lcl_ScAddress_Parse_OOo ( const sal_Unicode p,
const ScDocument pDoc,
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 1141 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, MAXCOL, ScDocument::MaxCol(), MAXROW, ScDocument::MaxRow(), ScAddress::ExternalInfo::mbExternal, ScAddress::ExternalInfo::mnFileId, n, ScAddress::nCol, ScAddress::nRow, ScAddress::nTab, 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().

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

Definition at line 1895 of file address.cxx.

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

static bool lcl_ScRange_External_TabSpan ( ScRange rRange,
ScRefFlags rFlags,
ScAddress::ExternalInfo pExtInfo,
const OUString &  rExternDocName,
const OUString &  rStartTabName,
const OUString &  rEndTabName,
const ScDocument pDoc 
)
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, ScDocument::GetExternalRefManager(), ScDocument::GetTable(), 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().

static void lcl_ScRange_Format_XL_Header ( OUStringBuffer &  rString,
const ScRange rRange,
ScRefFlags  nFlags,
const ScDocument rDoc,
const ScAddress::Details rDetails 
)
static
static ScRefFlags lcl_ScRange_Parse_OOo ( ScRange rRange,
const OUString &  r,
const ScDocument pDoc,
ScAddress::ExternalInfo pExtInfo,
const OUString *  pErrRef 
)
static
static ScRefFlags lcl_ScRange_Parse_XL_A1 ( ScRange r,
const sal_Unicode p,
const ScDocument pDoc,
bool  bOnlyAcceptSingle,
ScAddress::ExternalInfo pExtInfo,
const uno::Sequence< sheet::ExternalLinkInfo > *  pExternalLinks,
sal_Int32 *  pSheetEndPos,
const OUString *  pErrRef 
)
static
static ScRefFlags lcl_ScRange_Parse_XL_R1C1 ( ScRange r,
const sal_Unicode p,
const ScDocument pDoc,
const ScAddress::Details rDetails,
bool  bOnlyAcceptSingle,
ScAddress::ExternalInfo pExtInfo,
sal_Int32 *  pSheetEndPos 
)
static
static void lcl_Split_DocTab ( const ScDocument rDoc,
SCTAB  nTab,
const ScAddress::Details rDetails,
ScRefFlags  nFlags,
OUString &  rTabName,
OUString &  rDocName 
)
static
static void lcl_string_append ( OUStringBuffer &  rString,
const OUString &  sString 
)
static

Definition at line 2000 of file address.cxx.

Referenced by lcl_Format().

static void lcl_string_append ( OStringBuffer &  rString,
const OUString &  sString 
)
static

Definition at line 2005 of file address.cxx.

References OUStringToOString().

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().

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().

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

static long int sal_Unicode_strtol ( const sal_Unicode p,
const sal_Unicode **  pEnd 
)
static

Definition at line 136 of file address.cxx.

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

void ScColToAlpha ( OUStringBuffer &  rBuf,
SCCOL  nCol 
)