bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / inc / framework / ResourceId.hxx
bloba0f763fbc8b23537a040e64f4713a75debf076c2
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 SD_FRAMEWORK_RESOURCE_ID_HXX
21 #define SD_FRAMEWORK_RESOURCE_ID_HXX
23 #include <com/sun/star/drawing/framework/XResourceId.hpp>
24 #include <com/sun/star/lang/XInitialization.hpp>
25 #include <com/sun/star/util/XURLTransformer.hpp>
26 #include <cppuhelper/compbase2.hxx>
27 #include <boost/scoped_ptr.hpp>
29 namespace {
31 typedef ::cppu::WeakImplHelper2 <
32 css::drawing::framework::XResourceId,
33 css::lang::XInitialization
34 > ResourceIdInterfaceBase;
36 } // end of anonymous namespace.
41 namespace sd { namespace framework {
43 /** Implementation of the css::drawing::framework::ResourceId
44 service and the css::drawing::framework::XResourceId
45 interface.
47 class ResourceId
48 : public ResourceIdInterfaceBase
50 public:
51 /** Create a new, empty resource id.
53 ResourceId (void);
55 /** Create a new resource id that is described by the given URLs.
56 @param rsResourceURLs
57 The first URL specifies the type of resource. The other URLs
58 describe its anchor.
59 The set of URLs may be empty. The result is then the same as
60 returned by ResourceId() default constructor.
62 ResourceId (const ::std::vector<OUString>& rsResourceURLs);
64 /** Create a new resource id that has an empty anchor.
65 @param rsResourceURL
66 When this resource URL is empty then the resulting ResourceId
67 object is identical to when the ResourceId() default constructor
68 had been called.
70 ResourceId (
71 const OUString& rsResourceURL);
73 /** Create a new resource id for the given resource type and an anchor
74 that is specified by a single URL. This constructor can be used for
75 example for views that are bound to panes.
76 @param rsResourceURL
77 The URL of the actual resource.
78 @param rsAnchorURL
79 The single URL of the anchor.
81 ResourceId (
82 const OUString& rsResourceURL,
83 const OUString& rsAnchorURL);
85 /** Create a new resource id for the specified resource type and the
86 given list of anchor URLs.
87 @param rsResourceURL
88 The URL of the actual resource.
89 @param rsAnchorURLs
90 The possibly empty list of anchor URLs.
92 ResourceId (
93 const OUString& rsResourceURL,
94 const ::std::vector<OUString>& rAnchorURLs);
96 /** Create a new resource id with an anchor that consists of a sequence
97 of URLs that is extended by a further URL.
98 @param rsResourceURL
99 The URL of the actual resource.
100 @param rsFirstAnchorURL
101 This URL extends the anchor given by rAnchorURLs.
102 @param rAnchorURLs
103 An anchor as it is returned by XResourceId::getAnchorURLs().
105 ResourceId (
106 const OUString& rsResourceURL,
107 const OUString& rsFirstAnchorURL,
108 const css::uno::Sequence<OUString>& rAnchorURLs);
110 virtual ~ResourceId (void);
112 /** Return the list of URLs of both the resource URL and the anchor
113 URLs.
115 const ::std::vector<OUString>& GetResourceURLs (void) const;
117 //===== XResourceId =======================================================
119 virtual OUString SAL_CALL
120 getResourceURL (void)
121 throw(css::uno::RuntimeException);
123 virtual css::util::URL SAL_CALL
124 getFullResourceURL (void)
125 throw(css::uno::RuntimeException);
127 virtual sal_Bool SAL_CALL
128 hasAnchor (void)
129 throw (css::uno::RuntimeException);
131 virtual css::uno::Reference<
132 css::drawing::framework::XResourceId> SAL_CALL
133 getAnchor (void)
134 throw (css::uno::RuntimeException);
136 virtual css::uno::Sequence<OUString> SAL_CALL
137 getAnchorURLs (void)
138 throw (css::uno::RuntimeException);
140 virtual OUString SAL_CALL
141 getResourceTypePrefix (void)
142 throw (css::uno::RuntimeException);
144 virtual sal_Int16 SAL_CALL
145 compareTo (const css::uno::Reference<
146 css::drawing::framework::XResourceId>& rxResourceId)
147 throw (css::uno::RuntimeException);
149 virtual sal_Bool SAL_CALL
150 isBoundTo (
151 const css::uno::Reference<
152 css::drawing::framework::XResourceId>& rxResourceId,
153 css::drawing::framework::AnchorBindingMode eMode)
154 throw(css::uno::RuntimeException);
156 virtual sal_Bool SAL_CALL
157 isBoundToURL (
158 const OUString& rsAnchorURL,
159 css::drawing::framework::AnchorBindingMode eMode)
160 throw (css::uno::RuntimeException);
162 virtual css::uno::Reference<
163 css::drawing::framework::XResourceId> SAL_CALL
164 clone (void)
165 throw(css::uno::RuntimeException);
167 //===== XInitialization ===================================================
169 void SAL_CALL initialize (
170 const css::uno::Sequence<css::uno::Any>& aArguments)
171 throw (css::uno::RuntimeException);
173 private:
174 /** The set of URLs that consist of the resource URL at index 0 and the
175 anchor URLs and indices 1 and above.
177 ::std::vector<OUString> maResourceURLs;
179 ::boost::scoped_ptr<css::util::URL> mpURL;
181 static css::uno::WeakReference<css::util::XURLTransformer> mxURLTransformerWeak;
183 /** Compare the called ResourceId object to the given ResourceId object.
184 This uses the implementation of both objects to speed up the
185 comparison.
187 sal_Int16 CompareToLocalImplementation (const ResourceId& rId) const;
189 /** Compare the called ResourceId object to the given XResourceId object
190 reference. The comparison is done via the UNO interface. Namely,
191 it uses the getResourceURL() and the getAnchorURLs() methods to get
192 access to the URLs of the given objec.
194 sal_Int16 CompareToExternalImplementation (const css::uno::Reference<
195 css::drawing::framework::XResourceId>& rxId) const;
197 /** Return whether the called ResourceId object is bound to the anchor
198 consisting of the URLs given by psFirstAnchorURL and paAnchorURLs.
199 @param psFirstAnchorURL
200 Optional first URL of the anchor. This can be missing or present
201 independently of paAnchorURLs.
202 @param paAnchorURLs
203 Optional set of additional anchor URLs. This can be missing or
204 present independently of psFirstAnchorURL.
205 @param eMode
206 This specifies whether the called resource has to be directly
207 bound to the given anchor in order to return <TRUE/> or whether
208 it can be bound indirectly, too.
210 bool IsBoundToAnchor (
211 const OUString* psFirstAnchorURL,
212 const css::uno::Sequence<OUString>* paAnchorURLs,
213 css::drawing::framework::AnchorBindingMode eMode) const;
215 /** Return whether the called ResourceId object is bound to the anchor
216 consisting of the URLs in rResourceURLs.
217 @param rResourceURLs
218 A possibly empty list of anchor URLs.
219 @param eMode
220 This specifies whether the called resource has to be directly
221 bound to the given anchor in order to return <TRUE/> or whether
222 it can be bound indirectly, too.
224 bool IsBoundToAnchor (
225 const ::std::vector<OUString>& rResourceURLs,
226 css::drawing::framework::AnchorBindingMode eMode) const;
228 void ParseResourceURL (void);
231 } } // end of namespace sd::framework
233 #endif
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */