bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / inc / framework / ResourceId.hxx
blobd048f517a527b30b700b2ad0b58506aae68b8231
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_SD_SOURCE_UI_INC_FRAMEWORK_RESOURCEID_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_FRAMEWORK_RESOURCEID_HXX
23 #include <sal/config.h>
25 #include <vector>
27 #include <com/sun/star/drawing/framework/XResourceId.hpp>
28 #include <com/sun/star/lang/XInitialization.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/util/XURLTransformer.hpp>
31 #include <cppuhelper/implbase.hxx>
32 #include <boost/scoped_ptr.hpp>
34 namespace {
36 typedef ::cppu::WeakImplHelper <
37 css::drawing::framework::XResourceId,
38 css::lang::XInitialization,
39 css::lang::XServiceInfo
40 > ResourceIdInterfaceBase;
42 } // end of anonymous namespace.
44 namespace sd { namespace framework {
46 /** Implementation of the css::drawing::framework::ResourceId
47 service and the css::drawing::framework::XResourceId
48 interface.
50 class ResourceId
51 : public ResourceIdInterfaceBase
53 public:
54 /** Create a new, empty resource id.
56 ResourceId();
58 /** Create a new resource id that is described by the given URLs.
59 @param rsResourceURLs
60 The first URL specifies the type of resource. The other URLs
61 describe its anchor.
62 The set of URLs may be empty. The result is then the same as
63 returned by ResourceId() default constructor.
65 ResourceId (const ::std::vector<OUString>& rsResourceURLs);
67 /** Create a new resource id that has an empty anchor.
68 @param rsResourceURL
69 When this resource URL is empty then the resulting ResourceId
70 object is identical to when the ResourceId() default constructor
71 had been called.
73 ResourceId (
74 const OUString& rsResourceURL);
76 /** Create a new resource id for the given resource type and an anchor
77 that is specified by a single URL. This constructor can be used for
78 example for views that are bound to panes.
79 @param rsResourceURL
80 The URL of the actual resource.
81 @param rsAnchorURL
82 The single URL of the anchor.
84 ResourceId (
85 const OUString& rsResourceURL,
86 const OUString& rsAnchorURL);
88 /** Create a new resource id with an anchor that consists of a sequence
89 of URLs that is extended by a further URL.
90 @param rsResourceURL
91 The URL of the actual resource.
92 @param rsFirstAnchorURL
93 This URL extends the anchor given by rAnchorURLs.
94 @param rAnchorURLs
95 An anchor as it is returned by XResourceId::getAnchorURLs().
97 ResourceId (
98 const OUString& rsResourceURL,
99 const OUString& rsFirstAnchorURL,
100 const css::uno::Sequence<OUString>& rAnchorURLs);
102 virtual ~ResourceId();
104 /** Return the list of URLs of both the resource URL and the anchor
105 URLs.
107 const ::std::vector<OUString>& GetResourceURLs() const;
109 //===== XResourceId =======================================================
111 virtual OUString SAL_CALL
112 getResourceURL()
113 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 virtual css::util::URL SAL_CALL
116 getFullResourceURL()
117 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 virtual sal_Bool SAL_CALL
120 hasAnchor()
121 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 virtual css::uno::Reference<
124 css::drawing::framework::XResourceId> SAL_CALL
125 getAnchor()
126 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 virtual css::uno::Sequence<OUString> SAL_CALL
129 getAnchorURLs()
130 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 virtual OUString SAL_CALL
133 getResourceTypePrefix()
134 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
136 virtual sal_Int16 SAL_CALL
137 compareTo (const css::uno::Reference<
138 css::drawing::framework::XResourceId>& rxResourceId)
139 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 virtual sal_Bool SAL_CALL
142 isBoundTo (
143 const css::uno::Reference<
144 css::drawing::framework::XResourceId>& rxResourceId,
145 css::drawing::framework::AnchorBindingMode eMode)
146 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 virtual sal_Bool SAL_CALL
149 isBoundToURL (
150 const OUString& rsAnchorURL,
151 css::drawing::framework::AnchorBindingMode eMode)
152 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 virtual css::uno::Reference<
155 css::drawing::framework::XResourceId> SAL_CALL
156 clone()
157 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 //===== XInitialization ===================================================
161 void SAL_CALL initialize (
162 const css::uno::Sequence<css::uno::Any>& aArguments)
163 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 OUString SAL_CALL getImplementationName()
166 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
169 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
171 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
172 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 private:
175 /** The set of URLs that consist of the resource URL at index 0 and the
176 anchor URLs and indices 1 and above.
178 ::std::vector<OUString> maResourceURLs;
180 ::boost::scoped_ptr<css::util::URL> mpURL;
182 static css::uno::WeakReference<css::util::XURLTransformer> mxURLTransformerWeak;
184 /** Compare the called ResourceId object to the given ResourceId object.
185 This uses the implementation of both objects to speed up the
186 comparison.
188 sal_Int16 CompareToLocalImplementation (const ResourceId& rId) const;
190 /** Compare the called ResourceId object to the given XResourceId object
191 reference. The comparison is done via the UNO interface. Namely,
192 it uses the getResourceURL() and the getAnchorURLs() methods to get
193 access to the URLs of the given objec.
195 sal_Int16 CompareToExternalImplementation (const css::uno::Reference<
196 css::drawing::framework::XResourceId>& rxId) const;
198 /** Return whether the called ResourceId object is bound to the anchor
199 consisting of the URLs given by psFirstAnchorURL and paAnchorURLs.
200 @param psFirstAnchorURL
201 Optional first URL of the anchor. This can be missing or present
202 independently of paAnchorURLs.
203 @param paAnchorURLs
204 Optional set of additional anchor URLs. This can be missing or
205 present independently of psFirstAnchorURL.
206 @param eMode
207 This specifies whether the called resource has to be directly
208 bound to the given anchor in order to return <TRUE/> or whether
209 it can be bound indirectly, too.
211 bool IsBoundToAnchor (
212 const OUString* psFirstAnchorURL,
213 const css::uno::Sequence<OUString>* paAnchorURLs,
214 css::drawing::framework::AnchorBindingMode eMode) const;
216 /** Return whether the called ResourceId object is bound to the anchor
217 consisting of the URLs in rResourceURLs.
218 @param rResourceURLs
219 A possibly empty list of anchor URLs.
220 @param eMode
221 This specifies whether the called resource has to be directly
222 bound to the given anchor in order to return <TRUE/> or whether
223 it can be bound indirectly, too.
225 bool IsBoundToAnchor (
226 const ::std::vector<OUString>& rResourceURLs,
227 css::drawing::framework::AnchorBindingMode eMode) const;
229 void ParseResourceURL();
232 } } // end of namespace sd::framework
234 #endif
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */