1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_OOX_CORE_RELATIONS_HXX
21 #define INCLUDED_OOX_CORE_RELATIONS_HXX
26 #include <string_view>
28 #include <oox/dllapi.h>
29 #include <rtl/ustring.hxx>
34 /** Expands to an OUString containing an 'officeDocument' transitional relation type created
35 from the passed literal(!) ASCII(!) character array. */
36 #define CREATE_OFFICEDOC_RELATION_TYPE( ascii ) \
37 ( u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/" ascii )
39 /** Expands to an OUString containing an 'officeDocument' strict relation type created
40 from the passed literal(!) ASCII(!) character array. */
41 #define CREATE_OFFICEDOC_RELATION_TYPE_STRICT( ascii ) \
42 ( "http://purl.oclc.org/ooxml/officeDocument/relationships/" ascii )
44 /** Expands to an OUString containing an MS Office specific relation type
45 created from the passed literal(!) ASCII(!) character array. */
46 #define CREATE_MSOFFICE_RELATION_TYPE( ascii ) \
47 ( u"http://schemas.microsoft.com/office/2006/relationships/" ascii )
49 #define CREATE_XL_CONTENT_TYPE( ascii ) \
50 ( "application/vnd.openxmlformats-officedocument.spreadsheetml." ascii "+xml" )
59 Relation() : mbExternal( false ) {}
64 typedef std::shared_ptr
< Relations
> RelationsRef
;
66 class OOX_DLLPUBLIC Relations
69 explicit Relations( OUString aFragmentPath
);
71 size_t size() const { return maMap
.size(); }
72 size_t count( const OUString
& rId
) const { return maMap
.count( rId
); }
73 ::std::map
< OUString
, Relation
>::const_iterator
begin() const
77 ::std::map
< OUString
, Relation
>::const_iterator
end() const
81 template<class... Args
>
82 void emplace(Args
&&... args
)
84 maMap
.emplace(std::forward
<Args
>(args
)...);
87 /** Returns the path of the fragment this relations collection is related to. */
88 const OUString
& getFragmentPath() const { return maFragmentPath
; }
90 /** Returns the relation with the passed relation identifier. */
91 const Relation
* getRelationFromRelId( const OUString
& rId
) const;
92 /** Returns the first relation with the passed type. */
93 const Relation
* getRelationFromFirstType( std::u16string_view rType
) const;
94 /** Finds all relations associated with the passed type. */
95 RelationsRef
getRelationsFromTypeFromOfficeDoc( std::u16string_view rType
) const;
97 /** Returns the external target of the relation with the passed relation identifier. */
98 OUString
getExternalTargetFromRelId( const OUString
& rRelId
) const;
99 /** Returns the internal target of the relation with the passed relation identifier. */
100 OUString
getInternalTargetFromRelId( const OUString
& rRelId
) const;
102 /** Returns the full fragment path for the target of the passed relation. */
103 OUString
getFragmentPathFromRelation( const Relation
& rRelation
) const;
104 /** Returns the full fragment path for the passed relation identifier. */
105 OUString
getFragmentPathFromRelId( const OUString
& rRelId
) const;
106 /** Returns the full fragment path for the first relation of the passed type. */
107 OUString
getFragmentPathFromFirstType( std::u16string_view rType
) const;
108 OUString
getFragmentPathFromFirstTypeFromOfficeDoc( std::u16string_view rType
) const;
111 ::std::map
< OUString
, Relation
> maMap
;
112 OUString maFragmentPath
;
116 } // namespace oox::core
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */