Extended loplugin:ostr manual changes
[LibreOffice.git] / include / oox / core / relations.hxx
blob190ae55e419e34ff37a1dae5871ccdb43ac0eaad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include <cstddef>
24 #include <map>
25 #include <memory>
26 #include <string_view>
28 #include <oox/dllapi.h>
29 #include <rtl/ustring.hxx>
31 namespace oox::core {
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 ""_ustr )
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 ( u"http://purl.oclc.org/ooxml/officeDocument/relationships/" ascii ""_ustr )
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" )
52 struct Relation
54 OUString maId;
55 OUString maType;
56 OUString maTarget;
57 bool mbExternal;
59 Relation() : mbExternal( false ) {}
63 class Relations;
64 typedef std::shared_ptr< Relations > RelationsRef;
66 class OOX_DLLPUBLIC Relations
68 public:
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
75 return maMap.begin();
77 ::std::map< OUString, Relation >::const_iterator end() const
79 return maMap.end();
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;
110 private:
111 ::std::map< OUString, Relation > maMap;
112 OUString maFragmentPath;
116 } // namespace oox::core
118 #endif
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */