32std::u16string_view lclRemoveFileName( std::u16string_view rPath )
34 size_t idx = rPath.rfind(
'/' );
35 if (idx == std::u16string_view::npos)
36 return std::u16string_view();
37 return rPath.substr( 0, idx );
40OUString lclAppendFileName( std::u16string_view rPath,
const OUString& rFileName )
42 return rPath.empty() ? rFileName :
43 rPath + OUStringChar(
'/') + rFileName;
46OUString createOfficeDocRelationTypeTransitional(std::u16string_view rType)
48 return OUString::Concat(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/")
52OUString createOfficeDocRelationTypeStrict(std::u16string_view rType)
54 return OUString::Concat(
"http://purl.oclc.org/ooxml/officeDocument/relationships/") + rType;
60 : maFragmentPath(
std::move( aFragmentPath ))
66 ::std::map< OUString, Relation >::const_iterator aIt =
maMap.find( rId );
67 return (aIt ==
maMap.end()) ? nullptr : &aIt->second;
72 for (
auto const& elem :
maMap)
73 if( elem.second.maType.equalsIgnoreAsciiCase( rType ) )
81 for (
auto const& elem :
maMap)
82 if( elem.second.maType.equalsIgnoreAsciiCase( createOfficeDocRelationTypeTransitional(rType) ) ||
83 elem.second.maType.equalsIgnoreAsciiCase( createOfficeDocRelationTypeStrict(rType) ))
84 xRelations->maMap[ elem.first ] = elem.second;
107 if( rRelation.
maTarget[ 0 ] ==
'/' )
108 return rRelation.
maTarget.copy( 1 );
116 sal_Int32 nStartPos = 0;
117 while( nStartPos < rRelation.
maTarget.getLength() )
119 sal_Int32 nSepPos = rRelation.
maTarget.indexOf(
'/', nStartPos );
120 if( nSepPos < 0 ) nSepPos = rRelation.
maTarget.getLength();
122 if( (nStartPos + 2 == nSepPos) && (rRelation.
maTarget[ nStartPos ] ==
'.') && (rRelation.
maTarget[ nStartPos + 1 ] ==
'.') )
123 aPath = lclRemoveFileName( aPath );
125 aPath = lclAppendFileName( aPath, rRelation.
maTarget.copy( nStartPos, nSepPos - nStartPos ) );
127 nStartPos = nSepPos + 1;
147 OUString aTransitionalType(createOfficeDocRelationTypeTransitional(rType));
151 OUString aStrictType = createOfficeDocRelationTypeStrict(rType);
::std::map< OUString, Relation > maMap
OUString getInternalTargetFromRelId(const OUString &rRelId) const
Returns the internal target of the relation with the passed relation identifier.
const Relation * getRelationFromFirstType(std::u16string_view rType) const
Returns the first relation with the passed type.
OUString getFragmentPathFromRelId(const OUString &rRelId) const
Returns the full fragment path for the passed relation identifier.
OUString getExternalTargetFromRelId(const OUString &rRelId) const
Returns the external target of the relation with the passed relation identifier.
OUString getFragmentPathFromRelation(const Relation &rRelation) const
Returns the full fragment path for the target of the passed relation.
const Relation * getRelationFromRelId(const OUString &rId) const
Returns the relation with the passed relation identifier.
Relations(OUString aFragmentPath)
OUString getFragmentPathFromFirstTypeFromOfficeDoc(std::u16string_view rType) const
OUString getFragmentPathFromFirstType(std::u16string_view rType) const
Returns the full fragment path for the first relation of the passed type.
RelationsRef getRelationsFromTypeFromOfficeDoc(std::u16string_view rType) const
Finds all relations associated with the passed type.
std::shared_ptr< Relations > RelationsRef