[Libreoffice-commits] core.git: 2 commits - include/sax sax/source

Luboš Luňák l.lunak at collabora.com
Wed Nov 12 07:19:11 PST 2014


 include/sax/fastattribs.hxx      |   12 ++++++------
 sax/source/tools/fastattribs.cxx |   23 +++++++++++++----------
 2 files changed, 19 insertions(+), 16 deletions(-)

New commits:
commit 8a75dafbe19b19fe8b39e4e85f5ffa47da23f41e
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Wed Nov 12 16:09:42 2014 +0100

    make FastAttributeList's unknown attribute value be passed as OString
    
    Since that's how it's internally stored anyway, and I have a use case
    where it's useful to limit the length by passing it to OString ctor.
    
    Change-Id: I5903ea4f1b2cdb48c1bbceac6b8e21eb5882d377

diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx
index 39f5a5f..a2fe1b9 100644
--- a/include/sax/fastattribs.hxx
+++ b/include/sax/fastattribs.hxx
@@ -40,9 +40,8 @@ struct UnknownAttribute
     OString maName;
     OString maValue;
 
-    UnknownAttribute( const OUString& rNamespaceURL, const OString& rName, const sal_Char* pValue );
-
-    UnknownAttribute( const OString& rName, const sal_Char* pValue );
+    UnknownAttribute( const OUString& rNamespaceURL, const OString& rName, const OString& value );
+    UnknownAttribute( const OString& rName, const OString& value );
 
     void FillAttribute( ::com::sun::star::xml::Attribute* pAttrib ) const;
 };
@@ -84,8 +83,8 @@ public:
     void add( sal_Int32 nToken, const sal_Char* pValue, size_t nValueLength );
     void add( sal_Int32 nToken, const OString& rValue );
     void addNS( sal_Int32 nNamespaceToken, sal_Int32 nToken, const OString& rValue );
-    void addUnknown( const OUString& rNamespaceURL, const OString& rName, const sal_Char* pValue );
-    void addUnknown( const OString& rName, const sal_Char* pValue );
+    void addUnknown( const OUString& rNamespaceURL, const OString& rName, const OString& value );
+    void addUnknown( const OString& rName, const OString& value );
     const std::vector< sal_Int32 >&  getFastAttributeTokens() const { return maAttributeTokens; }
     const char* getFastAttributeValue(size_t nIndex) const { return mpChunk + maAttributeValues[nIndex]; }
     sal_Int32 AttributeValueLength(size_t i) const { return maAttributeValues[i + 1] - maAttributeValues[i] - 1; }
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 36277cf..d32f484 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -32,13 +32,13 @@ FastTokenHandlerBase::~FastTokenHandlerBase()
 {
 }
 
-UnknownAttribute::UnknownAttribute( const OUString& rNamespaceURL, const OString& rName, const sal_Char* pValue )
-    : maNamespaceURL( rNamespaceURL ), maName( rName ), maValue( pValue )
+UnknownAttribute::UnknownAttribute( const OUString& rNamespaceURL, const OString& rName, const OString& value )
+    : maNamespaceURL( rNamespaceURL ), maName( rName ), maValue( value )
 {
 }
 
-UnknownAttribute::UnknownAttribute( const OString& rName, const sal_Char* pValue )
-    : maName( rName ), maValue( pValue )
+UnknownAttribute::UnknownAttribute( const OString& rName, const OString& value )
+    : maName( rName ), maValue( value )
 {
 }
 
@@ -106,14 +106,14 @@ void FastAttributeList::addNS( sal_Int32 nNamespaceToken, sal_Int32 nToken, cons
     add( nCombinedToken, rValue );
 }
 
-void FastAttributeList::addUnknown( const OUString& rNamespaceURL, const OString& rName, const sal_Char* pValue )
+void FastAttributeList::addUnknown( const OUString& rNamespaceURL, const OString& rName, const OString& value )
 {
-    maUnknownAttributes.push_back( UnknownAttribute( rNamespaceURL, rName, pValue ) );
+    maUnknownAttributes.push_back( UnknownAttribute( rNamespaceURL, rName, value ) );
 }
 
-void FastAttributeList::addUnknown( const OString& rName, const sal_Char* pValue )
+void FastAttributeList::addUnknown( const OString& rName, const OString& value )
 {
-    maUnknownAttributes.push_back( UnknownAttribute( rName, pValue ) );
+    maUnknownAttributes.push_back( UnknownAttribute( rName, value ) );
 }
 
 // XFastAttributeList
commit 95cec52515a51a96e58fae9aa11ca2459365e66d
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Wed Nov 12 16:08:21 2014 +0100

    allow inserting attributes that have zero length
    
    Otherwise the strlen() might give an incorrect length if the attribute
    value is just a part of a longer string.
    
    Change-Id: I67eb7baecfa928fdee26c5ea9003bd7fc9b96d59

diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx
index 85a1218..39f5a5f 100644
--- a/include/sax/fastattribs.hxx
+++ b/include/sax/fastattribs.hxx
@@ -80,7 +80,8 @@ public:
     virtual ~FastAttributeList();
 
     void clear();
-    void add( sal_Int32 nToken, const sal_Char* pValue, size_t nValueLength = 0 );
+    void add( sal_Int32 nToken, const sal_Char* pValue );
+    void add( sal_Int32 nToken, const sal_Char* pValue, size_t nValueLength );
     void add( sal_Int32 nToken, const OString& rValue );
     void addNS( sal_Int32 nNamespaceToken, sal_Int32 nToken, const OString& rValue );
     void addUnknown( const OUString& rNamespaceURL, const OString& rName, const sal_Char* pValue );
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index e2cbcc6..36277cf 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -79,8 +79,6 @@ void FastAttributeList::clear()
 void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue, size_t nValueLength )
 {
     maAttributeTokens.push_back( nToken );
-    if (nValueLength == 0)
-        nValueLength = strlen(pValue);
     sal_Int32 nWritePosition = maAttributeValues.back();
     maAttributeValues.push_back( maAttributeValues.back() + nValueLength + 1 );
     if (maAttributeValues.back() > mnChunkLength)
@@ -92,6 +90,11 @@ void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue, size_t nV
     mpChunk[nWritePosition + nValueLength] = '\0';
 }
 
+void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue )
+{
+    add( nToken, pValue, strlen( pValue ));
+}
+
 void FastAttributeList::add( sal_Int32 nToken, const OString& rValue )
 {
     add( nToken, rValue.getStr(), rValue.getLength() );


More information about the Libreoffice-commits mailing list