LibreOffice Module oox (master) 1
relations.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_OOX_CORE_RELATIONS_HXX
21#define INCLUDED_OOX_CORE_RELATIONS_HXX
22
23#include <cstddef>
24#include <map>
25#include <memory>
26#include <string_view>
27
28#include <oox/dllapi.h>
29#include <rtl/ustring.hxx>
30
31namespace oox::core {
32
33
36#define CREATE_OFFICEDOC_RELATION_TYPE( ascii ) \
37 ( u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/" ascii )
38
41#define CREATE_OFFICEDOC_RELATION_TYPE_STRICT( ascii ) \
42 ( "http://purl.oclc.org/ooxml/officeDocument/relationships/" ascii )
43
46#define CREATE_MSOFFICE_RELATION_TYPE( ascii ) \
47 ( u"http://schemas.microsoft.com/office/2006/relationships/" ascii )
48
49#define CREATE_XL_CONTENT_TYPE( ascii ) \
50 ( "application/vnd.openxmlformats-officedocument.spreadsheetml." ascii "+xml" )
51
53{
54 OUString maId;
55 OUString maType;
56 OUString maTarget;
58
59 Relation() : mbExternal( false ) {}
60};
61
62
63class Relations;
64typedef std::shared_ptr< Relations > RelationsRef;
65
67{
68public:
69 explicit Relations( OUString aFragmentPath );
70
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
74 {
75 return maMap.begin();
76 }
77 ::std::map< OUString, Relation >::const_iterator end() const
78 {
79 return maMap.end();
80 }
81 template<class... Args>
82 void emplace(Args&&... args)
83 {
84 maMap.emplace(std::forward<Args>(args)...);
85 }
86
88 const OUString& getFragmentPath() const { return maFragmentPath; }
89
91 const Relation* getRelationFromRelId( const OUString& rId ) const;
93 const Relation* getRelationFromFirstType( std::u16string_view rType ) const;
95 RelationsRef getRelationsFromTypeFromOfficeDoc( std::u16string_view rType ) const;
96
98 OUString getExternalTargetFromRelId( const OUString& rRelId ) const;
100 OUString getInternalTargetFromRelId( const OUString& rRelId ) const;
101
103 OUString getFragmentPathFromRelation( const Relation& rRelation ) const;
105 OUString getFragmentPathFromRelId( const OUString& rRelId ) const;
107 OUString getFragmentPathFromFirstType( std::u16string_view rType ) const;
108 OUString getFragmentPathFromFirstTypeFromOfficeDoc( std::u16string_view rType ) const;
109
110private:
111 ::std::map< OUString, Relation > maMap;
113};
114
115
116} // namespace oox::core
117
118#endif
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::map< OUString, Relation > maMap
Definition: relations.hxx:111
const OUString & getFragmentPath() const
Returns the path of the fragment this relations collection is related to.
Definition: relations.hxx:88
size_t count(const OUString &rId) const
Definition: relations.hxx:72
void emplace(Args &&... args)
Definition: relations.hxx:82
::std::map< OUString, Relation >::const_iterator begin() const
Definition: relations.hxx:73
::std::map< OUString, Relation >::const_iterator end() const
Definition: relations.hxx:77
size_t size() const
Definition: relations.hxx:71
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
std::shared_ptr< Relations > RelationsRef
Definition: relations.hxx:63
args