diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-03-01 12:44:03 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-03-01 16:23:09 +0100 |
commit | e34870c2396db160c15e3e9bbf3efabf55ee2839 (patch) | |
tree | efcdb1fe313e793ba14999e34eac4d6ade8c596e /oox | |
parent | handle OOXML strict namespaces (diff) | |
download | core-e34870c2396db160c15e3e9bbf3efabf55ee2839.tar.gz core-e34870c2396db160c15e3e9bbf3efabf55ee2839.zip |
support OOXML strict documents in Calc
Change-Id: I277d76aeec28e173d913ccc1506464afe4d09c6d
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/core/contexthandler.cxx | 5 | ||||
-rw-r--r-- | oox/source/core/relations.cxx | 37 | ||||
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 30 |
3 files changed, 70 insertions, 2 deletions
diff --git a/oox/source/core/contexthandler.cxx b/oox/source/core/contexthandler.cxx index 296ed71b9132..806d97503330 100644 --- a/oox/source/core/contexthandler.cxx +++ b/oox/source/core/contexthandler.cxx @@ -77,6 +77,11 @@ OUString ContextHandler::getFragmentPathFromFirstType( const OUString& rType ) c return mxBaseData->mxRelations->getFragmentPathFromFirstType( rType ); } +OUString ContextHandler::getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rType ) const +{ + return mxBaseData->mxRelations->getFragmentPathFromFirstTypeFromOfficeDoc( rType ); +} + void ContextHandler::implSetLocator( const Reference< XLocator >& rxLocator ) { mxBaseData->mxLocator = rxLocator; diff --git a/oox/source/core/relations.cxx b/oox/source/core/relations.cxx index 5b726a514e06..37425317ca76 100644 --- a/oox/source/core/relations.cxx +++ b/oox/source/core/relations.cxx @@ -43,7 +43,20 @@ OUString lclAppendFileName( const OUString& rPath, const OUString& rFileName ) OUStringBuffer( rPath ).append( '/' ).append( rFileName ).makeStringAndClear(); } -} // namespace +OUString createOfficeDocRelationTypeTransitional(const OUString& rType) +{ + static const OUString aTransitionalBase("http://schemas.openxmlformats.org/officeDocument/2006/relationships/"); + return aTransitionalBase + rType; +} + +OUString createOfficeDocRelationTypeStrict(const OUString& rType) +{ + static const OUString aStrictBase("http://purl.oclc.org/ooxml/officeDocument/relationships/"); + return aStrictBase + rType; +} + +} + @@ -75,6 +88,16 @@ RelationsRef Relations::getRelationsFromType( const OUString& rType ) const return xRelations; } +RelationsRef Relations::getRelationsFromTypeFromOfficeDoc( const OUString& rType ) const +{ + RelationsRef xRelations( new Relations( maFragmentPath ) ); + for( const_iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt ) + if( aIt->second.maType.equalsIgnoreAsciiCase( createOfficeDocRelationTypeTransitional(rType) ) || + aIt->second.maType.equalsIgnoreAsciiCase( createOfficeDocRelationTypeStrict(rType) )) + (*xRelations)[ aIt->first ] = aIt->second; + return xRelations; +} + OUString Relations::getExternalTargetFromRelId( const OUString& rRelId ) const { const Relation* pRelation = getRelationFromRelId( rRelId ); @@ -132,7 +155,17 @@ OUString Relations::getFragmentPathFromFirstType( const OUString& rType ) const return pRelation ? getFragmentPathFromRelation( *pRelation ) : OUString(); } - +OUString Relations::getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rType ) const +{ + OUString aTransitionalType(createOfficeDocRelationTypeTransitional(rType)); + const Relation* pRelation = getRelationFromFirstType( aTransitionalType ); + if(!pRelation) + { + OUString aStrictType = createOfficeDocRelationTypeStrict(rType); + pRelation = getRelationFromFirstType( aStrictType ); + } + return pRelation ? getFragmentPathFromRelation( *pRelation ) : OUString(); +} } // namespace core } // namespace oox diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index adbecaa4fdb6..ecf902e52f53 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -233,6 +233,36 @@ OUString XmlFilterBase::getFragmentPathFromFirstType( const OUString& rType ) return importRelations( OUString() )->getFragmentPathFromFirstType( rType ); } +namespace { + +OUString getTransitionalRelationshipOfficeDocType(const OUString& rPart) +{ + static const OUString aBase("http://schemas.openxmlformats.org/officeDocument/2006/relationships/"); + return aBase + rPart; +} + +OUString getStrictRelationshipOfficeDocType(const OUString& rPart) +{ + static const OUString aBase("http://purl.oclc.org/ooxml/officeDocument/relationships/"); + return aBase + rPart; +} + +} + +OUString XmlFilterBase::getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rPart ) +{ + // importRelations() caches the relations map for subsequence calls + const OUString aTransitionalRelationshipType = getTransitionalRelationshipOfficeDocType(rPart); + OUString aFragment = importRelations( OUString() )->getFragmentPathFromFirstType( aTransitionalRelationshipType ); + if(aFragment.isEmpty()) + { + const OUString aStrictRelationshipType = getStrictRelationshipOfficeDocType(rPart); + aFragment = importRelations( OUString() )->getFragmentPathFromFirstType( aStrictRelationshipType ); + } + + return aFragment; +} + bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHandler ) { return importFragment(rxHandler, mxImpl->maFastParser); |