blob: 285c4ed947e4b65c390a48f86c42d43e66da857c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef OOX_CORE_RELATIONS
#define OOX_CORE_RELATIONS
#include <map>
#include <boost/shared_ptr.hpp>
#include "oox/helper/helper.hxx"
namespace oox {
namespace core {
// ============================================================================
/** Expands to an OUString containing an 'officeDocument' relation type created
from the passed literal(!) ASCII(!) character array. */
#define CREATE_OFFICEDOC_RELATION_TYPE( ascii ) \
CREATE_OUSTRING( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/" ascii )
/** Expands to an OUString containing a 'package' relation type created from
the passed literal(!) ASCII(!) character array. */
#define CREATE_PACKAGE_RELATION_TYPE( ascii ) \
CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/relationships/" ascii )
/** Expands to an OUString containing an MS Office specific relation type
created from the passed literal(!) ASCII(!) character array. */
#define CREATE_MSOFFICE_RELATION_TYPE( ascii ) \
CREATE_OUSTRING( "http://schemas.microsoft.com/office/2006/relationships/" ascii )
// ============================================================================
struct Relation
{
::rtl::OUString maId;
::rtl::OUString maType;
::rtl::OUString maTarget;
bool mbExternal;
inline explicit Relation() : mbExternal( false ) {}
};
// ============================================================================
class Relations;
typedef ::boost::shared_ptr< Relations > RelationsRef;
class Relations : public ::std::map< ::rtl::OUString, Relation >
{
public:
explicit Relations( const ::rtl::OUString& rFragmentPath );
/** Returns the path of the fragment this relations collection is related to. */
inline const ::rtl::OUString& getFragmentPath() const { return maFragmentPath; }
/** Returns the relation with the passed relation identifier. */
const Relation* getRelationFromRelId( const ::rtl::OUString& rId ) const;
/** Returns the first relation with the passed type. */
const Relation* getRelationFromFirstType( const ::rtl::OUString& rType ) const;
/** Finds all relations associated with the passed type. */
RelationsRef getRelationsFromType( const ::rtl::OUString& rType ) const;
/** Returns the external target of the relation with the passed relation identifier. */
::rtl::OUString getExternalTargetFromRelId( const ::rtl::OUString& rRelId ) const;
/** Returns the external target of the first relation with the passed type. */
::rtl::OUString getExternalTargetFromFirstType( const ::rtl::OUString& rType ) const;
/** Returns the full fragment path for the target of the passed relation. */
::rtl::OUString getFragmentPathFromRelation( const Relation& rRelation ) const;
/** Returns the full fragment path for the passed relation identifier. */
::rtl::OUString getFragmentPathFromRelId( const ::rtl::OUString& rRelId ) const;
/** Returns the full fragment path for the first relation of the passed type. */
::rtl::OUString getFragmentPathFromFirstType( const ::rtl::OUString& rType ) const;
private:
::rtl::OUString maFragmentPath;
};
// ============================================================================
} // namespace core
} // namespace oox
#endif // OOX_CORE_RELATIONS
|