Line data Source code
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 <map>
24 : #include <boost/shared_ptr.hpp>
25 : #include <oox/helper/helper.hxx>
26 : #include <oox/dllapi.h>
27 :
28 : namespace oox {
29 : namespace core {
30 :
31 :
32 :
33 : /** Expands to an OUString containing an 'officeDocument' transitional relation type created
34 : from the passed literal(!) ASCII(!) character array. */
35 : #define CREATE_OFFICEDOC_RELATION_TYPE( ascii ) \
36 : ( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/" ascii )
37 :
38 : /** Expands to an OUString containing an 'officeDocument' strict relation type created
39 : from the passed literal(!) ASCII(!) character array. */
40 : #define CREATE_OFFICEDOC_RELATION_TYPE_STRICT( ascii ) \
41 : ( "http://purl.oclc.org/ooxml/officeDocument/relationships/" ascii )
42 :
43 : /** Expands to an OUString containing a 'package' relation type created from
44 : the passed literal(!) ASCII(!) character array. */
45 : #define CREATE_PACKAGE_RELATION_TYPE( ascii ) \
46 : ( "http://schemas.openxmlformats.org/package/2006/relationships/" ascii )
47 :
48 : /** Expands to an OUString containing an MS Office specific relation type
49 : created from the passed literal(!) ASCII(!) character array. */
50 : #define CREATE_MSOFFICE_RELATION_TYPE( ascii ) \
51 : ( "http://schemas.microsoft.com/office/2006/relationships/" ascii )
52 :
53 :
54 :
55 0 : struct Relation
56 : {
57 : OUString maId;
58 : OUString maType;
59 : OUString maTarget;
60 : bool mbExternal;
61 :
62 0 : Relation() : mbExternal( false ) {}
63 : };
64 :
65 :
66 :
67 : class Relations;
68 : typedef ::boost::shared_ptr< Relations > RelationsRef;
69 :
70 0 : class OOX_DLLPUBLIC Relations : public ::std::map< OUString, Relation >
71 : {
72 : public:
73 : explicit Relations( const OUString& rFragmentPath );
74 :
75 : /** Returns the path of the fragment this relations collection is related to. */
76 0 : const OUString& getFragmentPath() const { return maFragmentPath; }
77 :
78 : /** Returns the relation with the passed relation identifier. */
79 : const Relation* getRelationFromRelId( const OUString& rId ) const;
80 : /** Returns the first relation with the passed type. */
81 : const Relation* getRelationFromFirstType( const OUString& rType ) const;
82 : /** Returns the first relation with the passed type. */
83 : const Relation* getRelationFromFirstTypeFromOfficeDoc( const OUString& rType ) const;
84 : /** Finds all relations associated with the passed type. */
85 : RelationsRef getRelationsFromTypeFromOfficeDoc( const OUString& rType ) const;
86 :
87 : /** Returns the external target of the relation with the passed relation identifier. */
88 : OUString getExternalTargetFromRelId( const OUString& rRelId ) const;
89 : /** Returns the internal target of the relation with the passed relation identifier. */
90 : OUString getInternalTargetFromRelId( const OUString& rRelId ) const;
91 :
92 : /** Returns the full fragment path for the target of the passed relation. */
93 : OUString getFragmentPathFromRelation( const Relation& rRelation ) const;
94 : /** Returns the full fragment path for the passed relation identifier. */
95 : OUString getFragmentPathFromRelId( const OUString& rRelId ) const;
96 : /** Returns the full fragment path for the first relation of the passed type. */
97 : OUString getFragmentPathFromFirstType( const OUString& rType ) const;
98 : OUString getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rType ) const;
99 :
100 : private:
101 : OUString maFragmentPath;
102 : };
103 :
104 :
105 :
106 : } // namespace core
107 : } // namespace oox
108 :
109 : #endif
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|