1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
48 : public ResourceIdInterfaceBase
51 /** Create a new, empty resource id.
55 /** Create a new resource id that is described by the given URLs.
57 The first URL specifies the type of resource. The other URLs
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.
66 When this resource URL is empty then the resulting ResourceId
67 object is identical to when the ResourceId() default constructor
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.
77 The URL of the actual resource.
79 The single URL of the anchor.
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.
88 The URL of the actual resource.
90 The possibly empty list of anchor URLs.
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.
99 The URL of the actual resource.
100 @param rsFirstAnchorURL
101 This URL extends the anchor given by rAnchorURLs.
103 An anchor as it is returned by XResourceId::getAnchorURLs().
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
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
129 throw (css::uno::RuntimeException
);
131 virtual css::uno::Reference
<
132 css::drawing::framework::XResourceId
> SAL_CALL
134 throw (css::uno::RuntimeException
);
136 virtual css::uno::Sequence
<OUString
> SAL_CALL
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
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
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
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
);
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
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.
203 Optional set of additional anchor URLs. This can be missing or
204 present independently of psFirstAnchorURL.
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.
218 A possibly empty list of anchor URLs.
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
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */