summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/oox/helper/attributelist.hxx6
-rw-r--r--include/sax/fastattribs.hxx4
-rw-r--r--offapi/com/sun/star/xml/sax/XFastAttributeList.idl8
-rw-r--r--oox/source/helper/attributelist.cxx27
-rw-r--r--sax/source/tools/fastattribs.cxx25
-rw-r--r--sc/source/filter/oox/sheetdatacontext.cxx2
6 files changed, 60 insertions, 12 deletions
diff --git a/include/oox/helper/attributelist.hxx b/include/oox/helper/attributelist.hxx
index 3fb6e8df113c..6aa035a0b331 100644
--- a/include/oox/helper/attributelist.hxx
+++ b/include/oox/helper/attributelist.hxx
@@ -27,6 +27,10 @@
#include <oox/token/tokens.hxx>
#include <oox/dllapi.h>
+namespace sax_fastparser {
+ class FastAttributeList;
+};
+
namespace oox {
// ============================================================================
@@ -159,6 +163,8 @@ public:
private:
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >
mxAttribs;
+ mutable sax_fastparser::FastAttributeList *mpAttribList;
+ sax_fastparser::FastAttributeList *getAttribList() const;
};
// ============================================================================
diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx
index c7806039eed4..fd87a946ea5a 100644
--- a/include/sax/fastattribs.hxx
+++ b/include/sax/fastattribs.hxx
@@ -73,6 +73,10 @@ public:
void addUnknown( const OUString& rNamespaceURL, const OString& rName, const sal_Char* pValue );
void addUnknown( const OString& rName, const sal_Char* pValue );
+ // performance sensitive shortcuts to avoid allocation ...
+ bool getAsInteger( sal_Int32 nToken, sal_Int32 &rInt);
+ bool getAsDouble( sal_Int32 nToken, double &rDouble);
+
// XFastAttributeList
virtual ::sal_Bool SAL_CALL hasAttribute( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getValueToken( ::sal_Int32 Token ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
diff --git a/offapi/com/sun/star/xml/sax/XFastAttributeList.idl b/offapi/com/sun/star/xml/sax/XFastAttributeList.idl
index 509bcf823061..840fc920b1b0 100644
--- a/offapi/com/sun/star/xml/sax/XFastAttributeList.idl
+++ b/offapi/com/sun/star/xml/sax/XFastAttributeList.idl
@@ -56,7 +56,7 @@ interface XFastAttributeList: com::sun::star::uno::XInterface
*/
boolean hasAttribute( [in] long Token );
- /** retrieves the token of an attributes value.<br>
+ /** retrieves the token of an attribute value.<br>
@param Token
contains the integer token from the XFastTokenHandler
@@ -78,7 +78,7 @@ interface XFastAttributeList: com::sun::star::uno::XInterface
long getValueToken( [in] long Token )
raises( SAXException );
- /**retrieves the token of an attributes value.<br>
+ /**retrieves the token of an attribute value.<br>
@param Token
contains the integer token from the XFastTokenHandler
@@ -101,7 +101,7 @@ interface XFastAttributeList: com::sun::star::uno::XInterface
*/
long getOptionalValueToken( [in] long Token, [in] long Default );
- /** retrieves the value of an attributes.<br>
+ /** retrieves the value of an attribute.<br>
@param Token
contains the integer token from the XFastTokenHandler
@@ -123,7 +123,7 @@ interface XFastAttributeList: com::sun::star::uno::XInterface
string getValue( [in] long Token )
raises( SAXException );
- /** retrieves the value of an attributes.<br>
+ /** retrieves the value of an attribute.<br>
@param Token
contains the integer token from the XFastTokenHandler
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx
index 2c0eb23fc85f..7c41d8e967d2 100644
--- a/oox/source/helper/attributelist.cxx
+++ b/oox/source/helper/attributelist.cxx
@@ -19,8 +19,10 @@
#include "oox/helper/attributelist.hxx"
+#include <cassert>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
+#include <sax/fastattribs.hxx>
#include "oox/token/tokenmap.hxx"
namespace oox {
@@ -117,11 +119,22 @@ sal_Int32 AttributeConversion::decodeIntegerHex( const OUString& rValue )
// ============================================================================
AttributeList::AttributeList( const Reference< XFastAttributeList >& rxAttribs ) :
- mxAttribs( rxAttribs )
+ mxAttribs( rxAttribs ),
+ mpAttribList( NULL )
{
OSL_ENSURE( mxAttribs.is(), "AttributeList::AttributeList - missing attribute list interface" );
}
+sax_fastparser::FastAttributeList *AttributeList::getAttribList() const
+{
+ if( mpAttribList == NULL )
+ {
+ assert( dynamic_cast< sax_fastparser::FastAttributeList *>( mxAttribs.get() ) != NULL );
+ mpAttribList = static_cast< sax_fastparser::FastAttributeList *>( mxAttribs.get() );
+ }
+ return mpAttribList;
+}
+
bool AttributeList::hasAttribute( sal_Int32 nAttrToken ) const
{
return mxAttribs->hasAttribute( nAttrToken );
@@ -153,16 +166,16 @@ OptValue< OUString > AttributeList::getXString( sal_Int32 nAttrToken ) const
OptValue< double > AttributeList::getDouble( sal_Int32 nAttrToken ) const
{
- OUString aValue = mxAttribs->getOptionalValue( nAttrToken );
- bool bValid = !aValue.isEmpty();
- return OptValue< double >( bValid, bValid ? AttributeConversion::decodeDouble( aValue ) : 0.0 );
+ double nValue;
+ bool bValid = getAttribList()->getAsDouble( nAttrToken, nValue );
+ return OptValue< double >( bValid, nValue );
}
OptValue< sal_Int32 > AttributeList::getInteger( sal_Int32 nAttrToken ) const
{
- OUString aValue = mxAttribs->getOptionalValue( nAttrToken );
- bool bValid = !aValue.isEmpty();
- return OptValue< sal_Int32 >( bValid, bValid ? AttributeConversion::decodeInteger( aValue ) : 0 );
+ sal_Int32 nValue;
+ bool bValid = getAttribList()->getAsInteger( nAttrToken, nValue );
+ return OptValue< sal_Int32 >( bValid, nValue );
}
OptValue< sal_uInt32 > AttributeList::getUnsigned( sal_Int32 nAttrToken ) const
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 2297b1d53fc1..1705c3089dd4 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -132,6 +132,31 @@ sal_Int32 FastAttributeList::getOptionalValueToken( ::sal_Int32 Token, ::sal_Int
return Default;
}
+// performance sensitive shortcuts to avoid allocation ...
+bool FastAttributeList::getAsInteger( sal_Int32 nToken, sal_Int32 &rInt)
+{
+ rInt = 0;
+ for (size_t i = 0; i < maAttributeTokens.size(); ++i)
+ if (maAttributeTokens[i] == nToken)
+ {
+ rInt = rtl_str_toInt32( mpChunk + maAttributeValues[i], 10 );
+ return true;
+ }
+ return false;
+}
+
+bool FastAttributeList::getAsDouble( sal_Int32 nToken, double &rDouble)
+{
+ rDouble = 0.0;
+ for (size_t i = 0; i < maAttributeTokens.size(); ++i)
+ if (maAttributeTokens[i] == nToken)
+ {
+ rDouble = rtl_str_toDouble( mpChunk + maAttributeValues[i] );
+ return true;
+ }
+ return false;
+}
+
OUString FastAttributeList::getValue( ::sal_Int32 Token ) throw (SAXException, RuntimeException)
{
for (size_t i = 0; i < maAttributeTokens.size(); ++i)
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx
index 1a1d5740e645..da234c13a609 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -310,7 +310,7 @@ void SheetDataContext::importRow( const AttributeList& rAttribs )
bool SheetDataContext::importCell( const AttributeList& rAttribs )
{
- OUString aCellAddrStr = rAttribs.getString( XML_r, OUString() );
+ OUString aCellAddrStr = rAttribs.getString( XML_r, OUString() );
bool bValid = true;
if(aCellAddrStr.isEmpty())
{