Kaydet (Commit) 6087da0d authored tarafından Kohei Yoshida's avatar Kohei Yoshida

getChar() to return a null-terminated char array.

No need to fetch string size with this change.

Change-Id: Iae5f6c60430fc57985a0fec5bfec59727e5a8f0f
üst 151beeb0
......@@ -75,12 +75,6 @@ public:
class OOX_DLLPUBLIC AttributeList
{
public:
struct Char
{
const char* mpPos;
size_t mnSize;
};
explicit AttributeList(
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs );
......@@ -138,7 +132,7 @@ public:
passed default string if the attribute is missing. */
OUString getXString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
Char getChar( sal_Int32 nAttrToken ) const;
const char* getChar( sal_Int32 nAttrToken ) const;
/** Returns the double value of the specified attribute, or the passed
......
......@@ -76,7 +76,7 @@ public:
// performance sensitive shortcuts to avoid allocation ...
bool getAsInteger( sal_Int32 nToken, sal_Int32 &rInt);
bool getAsDouble( sal_Int32 nToken, double &rDouble);
bool getAsChar( sal_Int32 nToken, const char*& rPos, size_t& rLen ) const;
bool getAsChar( sal_Int32 nToken, const char*& rPos ) const;
// XFastAttributeList
virtual ::sal_Bool SAL_CALL hasAttribute( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException);
......
......@@ -261,16 +261,14 @@ OUString AttributeList::getXString( sal_Int32 nAttrToken, const OUString& rDefau
return getXString( nAttrToken ).get( rDefault );
}
AttributeList::Char AttributeList::getChar( sal_Int32 nAttrToken ) const
const char* AttributeList::getChar( sal_Int32 nAttrToken ) const
{
Char aRet;
bool bValid = getAttribList()->getAsChar(nAttrToken, aRet.mpPos, aRet.mnSize);
const char* p = NULL;
bool bValid = getAttribList()->getAsChar(nAttrToken, p);
if (!bValid)
{
aRet.mpPos = NULL;
aRet.mnSize = 0;
}
return aRet;
p = NULL;
return p;
}
double AttributeList::getDouble( sal_Int32 nAttrToken, double fDefault ) const
......
......@@ -157,7 +157,7 @@ bool FastAttributeList::getAsDouble( sal_Int32 nToken, double &rDouble)
return false;
}
bool FastAttributeList::getAsChar( sal_Int32 nToken, const char*& rPos, size_t& rLen ) const
bool FastAttributeList::getAsChar( sal_Int32 nToken, const char*& rPos ) const
{
for (size_t i = 0, n = maAttributeTokens.size(); i < n; ++i)
{
......@@ -166,12 +166,6 @@ bool FastAttributeList::getAsChar( sal_Int32 nToken, const char*& rPos, size_t&
sal_Int32 nOffset = maAttributeValues[i];
rPos = mpChunk + nOffset;
if (i + 1 < maAttributeValues.size())
rLen = maAttributeValues[i+1] - nOffset - 1;
else
rLen = mnChunkLength - nOffset - 1;
return true;
}
......
......@@ -214,7 +214,7 @@ public:
sal_Int32 nLength = SAL_MAX_INT32 );
static bool parseOoxAddress2d(
sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr, sal_Int32 nStrLen );
sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr );
/** Tries to parse the passed string for a 2d cell range in A1 notation.
......@@ -320,8 +320,7 @@ public:
sal_Int16 nSheet );
bool convertToCellAddressUnchecked(
com::sun::star::table::CellAddress& orAddress,
const char* pStr, size_t nStrLen, sal_Int16 nSheet ) const;
com::sun::star::table::CellAddress& orAddress, const char* pStr, sal_Int16 nSheet ) const;
/** Tries to convert the passed string to a single cell address.
......@@ -340,7 +339,7 @@ public:
bool convertToCellAddress(
com::sun::star::table::CellAddress& rAddress,
const char* pStr, size_t nStrLen, sal_Int16 nSheet, bool bTrackOverflow );
const char* pStr, sal_Int16 nSheet, bool bTrackOverflow );
/** Returns a valid cell address by moving it into allowed dimensions.
......
......@@ -226,16 +226,13 @@ bool AddressConverter::parseOoxAddress2d(
return (ornColumn >= 0) && (ornRow >= 0);
}
bool AddressConverter::parseOoxAddress2d(
sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr, sal_Int32 nStrLen )
bool AddressConverter::parseOoxAddress2d( sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr )
{
ornColumn = ornRow = 0;
const char* pStrEnd = pStr + nStrLen;
enum { STATE_COL, STATE_ROW } eState = STATE_COL;
while (pStr < pStrEnd)
while (*pStr)
{
char cChar = *pStr;
switch( eState )
......@@ -356,11 +353,10 @@ bool AddressConverter::convertToCellAddressUnchecked( CellAddress& orAddress,
}
bool AddressConverter::convertToCellAddressUnchecked(
com::sun::star::table::CellAddress& orAddress,
const char* pStr, size_t nStrLen, sal_Int16 nSheet ) const
com::sun::star::table::CellAddress& orAddress, const char* pStr, sal_Int16 nSheet ) const
{
orAddress.Sheet = nSheet;
return parseOoxAddress2d(orAddress.Column, orAddress.Row, pStr, nStrLen);
return parseOoxAddress2d(orAddress.Column, orAddress.Row, pStr);
}
bool AddressConverter::convertToCellAddress( CellAddress& orAddress,
......@@ -373,9 +369,9 @@ bool AddressConverter::convertToCellAddress( CellAddress& orAddress,
bool AddressConverter::convertToCellAddress(
com::sun::star::table::CellAddress& rAddress,
const char* pStr, size_t nStrLen, sal_Int16 nSheet, bool bTrackOverflow )
const char* pStr, sal_Int16 nSheet, bool bTrackOverflow )
{
if (!convertToCellAddressUnchecked(rAddress, pStr, nStrLen, nSheet))
if (!convertToCellAddressUnchecked(rAddress, pStr, nSheet))
return false;
return checkCellAddress(rAddress, bTrackOverflow);
......
......@@ -311,18 +311,16 @@ void SheetDataContext::importRow( const AttributeList& rAttribs )
bool SheetDataContext::importCell( const AttributeList& rAttribs )
{
bool bValid = true;
AttributeList::Char aChar = rAttribs.getChar(XML_r);
const char* p = rAttribs.getChar(XML_r);
if (!aChar.mpPos)
if (!p)
{
++mnCol;
maCellData.maCellAddr = CellAddress( mnSheet, mnCol, mnRow );
}
else
{
bValid = mrAddressConv.convertToCellAddress(
maCellData.maCellAddr, aChar.mpPos, aChar.mnSize, mnSheet, true);
bValid = mrAddressConv.convertToCellAddress(maCellData.maCellAddr, p, mnSheet, true);
mnCol = maCellData.maCellAddr.Column;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment