[Libreoffice-commits] core.git: include/xmloff xmloff/source
Noel (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 22 16:58:53 UTC 2020
include/xmloff/xmlimp.hxx | 2 +-
xmloff/source/core/xmlimp.cxx | 18 +++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
New commits:
commit 7b2d10068d43bf14efbe3ad18a15e0536e03a15e
Author: Noel <noelgrandin at gmail.com>
AuthorDate: Thu Oct 22 10:53:49 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Oct 22 18:58:12 2020 +0200
only need to check the version once
Change-Id: Ie02ce5e7823a7564da919525f9cbdf4fc92072dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104649
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index edb437b8fa94..43a5b5ca729a 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -460,7 +460,7 @@ public:
bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
- OUString const & GetODFVersion() const;
+ OUString GetODFVersion() const;
bool IsOOoXML() const; // legacy non-ODF format?
/**
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 40d947bb87cf..fc79f79992b7 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -274,7 +274,7 @@ public:
/// name of stream in package, e.g., "content.xml"
OUString mStreamName;
- OUString aODFVersion;
+ std::optional<OUString> mxODFVersion;
bool mbIsOOoXML;
@@ -669,12 +669,12 @@ std::unique_ptr<SvXMLNamespaceMap> SvXMLImport::processNSAttributes(
for( sal_Int16 i=0; i < nAttrCount; i++ )
{
const OUString& rAttrName = xAttrList->getNameByIndex( i );
- if ( rAttrName == "office:version" )
+ if ( rAttrName == "office:version" && !mpImpl->mxODFVersion )
{
- mpImpl->aODFVersion = xAttrList->getValueByIndex( i );
+ mpImpl->mxODFVersion = xAttrList->getValueByIndex( i );
// 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 ) )
+ if ( mpImpl->mStreamName == "content.xml" && !IsODFVersionConsistent( *mpImpl->mxODFVersion ) )
{
throw xml::sax::SAXException("Inconsistent ODF versions in content.xml and manifest.xml!",
uno::Reference< uno::XInterface >(),
@@ -844,17 +844,17 @@ 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() )
+ if ( Attribs.is() && !mpImpl->mxODFVersion)
{
sax_fastparser::FastAttributeList& rAttribList =
sax_fastparser::castToFastAttributeList( Attribs );
auto aIter( rAttribList.find( XML_ELEMENT( OFFICE, XML_VERSION ) ) );
if( aIter != rAttribList.end() )
{
- mpImpl->aODFVersion = aIter.toString();
+ mpImpl->mxODFVersion = 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 ) )
+ if ( mpImpl->mStreamName == "content.xml" && !IsODFVersionConsistent( *mpImpl->mxODFVersion ) )
{
throw xml::sax::SAXException("Inconsistent ODF versions in content.xml and manifest.xml!",
uno::Reference< uno::XInterface >(),
@@ -1925,9 +1925,9 @@ bool SvXMLImport::isGeneratorVersionOlderThan(
}
-OUString const & SvXMLImport::GetODFVersion() const
+OUString SvXMLImport::GetODFVersion() const
{
- return mpImpl->aODFVersion;
+ return mpImpl->mxODFVersion ? *mpImpl->mxODFVersion : OUString();
}
bool SvXMLImport::IsOOoXML() const
More information about the Libreoffice-commits
mailing list