Kaydet (Commit) b3b6ce3f authored tarafından Mohammed Abdul Azeem's avatar Mohammed Abdul Azeem Kaydeden (comit) Michael Meeks

Added find function to FastAttributeList:

It returns a FastAttributeIter, which can be used to
obtain value in different formats directly. Also, avoids
one unnecessary iteration.

Change-Id: Ic28e0177100738bbd71a3a89634cae9f1f7ee996
Reviewed-on: https://gerrit.libreoffice.org/39380Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 8a828ee7
......@@ -164,6 +164,7 @@ public:
};
const FastAttributeIter begin() const { return FastAttributeIter(*this, 0); }
const FastAttributeIter end() const { return FastAttributeIter(*this, maAttributeTokens.size()); }
const FastAttributeIter find( sal_Int32 nToken ) const;
private:
sal_Char *mpChunk; ///< buffer to store all attribute values - null terminated strings
......
......@@ -230,6 +230,14 @@ Sequence< FastAttribute > FastAttributeList::getFastAttributes( )
return aSeq;
}
const FastAttributeList::FastAttributeIter FastAttributeList::find( sal_Int32 nToken ) const
{
for (size_t i = 0; i < maAttributeTokens.size(); ++i)
if( maAttributeTokens[i] == nToken )
return FastAttributeIter(*this, i);
return end();
}
sal_Int32 FastTokenHandlerBase::getTokenFromChars(
const css::uno::Reference< css::xml::sax::XFastTokenHandler > &xTokenHandler,
FastTokenHandlerBase *pTokenHandler,
......
......@@ -227,11 +227,13 @@ ScXMLTableRowsContext::ScXMLTableRowsContext( ScXMLImport& rImport,
{
nGroupStartRow = rImport.GetTables().GetCurrentRow();
++nGroupStartRow;
if ( xAttrList.is() &&
xAttrList->hasAttribute( XML_ELEMENT( TABLE, XML_DISPLAY ) ) )
if ( xAttrList.is() )
{
bGroupDisplay = IsXMLToken( xAttrList->getValue(
XML_ELEMENT( TABLE, XML_DISPLAY ) ), XML_TRUE );
sax_fastparser::FastAttributeList *pAttribList =
static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
auto &aIter( pAttribList->find( XML_ELEMENT( TABLE, XML_DISPLAY ) ) );
if( aIter != pAttribList->end() )
bGroupDisplay = IsXMLToken( aIter.toCString(), XML_TRUE );
}
}
}
......
......@@ -788,17 +788,23 @@ void SAL_CALL SvXMLImport::setDocumentLocator( const uno::Reference< xml::sax::X
void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
{
if ( Attribs.is() && Attribs->hasAttribute( XML_ELEMENT( OFFICE, XML_VERSION ) ) )
if ( Attribs.is() )
{
mpImpl->aODFVersion = Attribs->getValue( XML_ELEMENT( OFFICE, XML_VERSION ) );
// the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2
if ( mpImpl->mStreamName == "content.xml" && !IsODFVersionConsistent( mpImpl->aODFVersion ) )
sax_fastparser::FastAttributeList *pAttribList =
static_cast< sax_fastparser::FastAttributeList *>( Attribs.get() );
auto &aIter( pAttribList->find( XML_ELEMENT( OFFICE, XML_VERSION ) ) );
if( aIter != pAttribList->end() )
{
throw xml::sax::SAXException("Inconsistent ODF versions in content.xml and manifest.xml!",
uno::Reference< uno::XInterface >(),
uno::makeAny(
packages::zip::ZipIOException("Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
mpImpl->aODFVersion = aIter.toString();
// the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2
if ( mpImpl->mStreamName == "content.xml" && !IsODFVersionConsistent( mpImpl->aODFVersion ) )
{
throw xml::sax::SAXException("Inconsistent ODF versions in content.xml and manifest.xml!",
uno::Reference< uno::XInterface >(),
uno::makeAny(
packages::zip::ZipIOException("Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
}
}
}
......
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