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