1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ResourceId.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_FRAMEWORK_RESOURCE_ID_HXX
32 #define SD_FRAMEWORK_RESOURCE_ID_HXX
34 #include <com/sun/star/drawing/framework/XResourceId.hpp>
35 #include <com/sun/star/lang/XInitialization.hpp>
36 #include <com/sun/star/util/XURLTransformer.hpp>
37 #include <cppuhelper/compbase2.hxx>
38 #include <boost/scoped_ptr.hpp>
40 namespace css
= ::com::sun::star
;
45 typedef ::cppu::WeakImplHelper2
<
46 css::drawing::framework::XResourceId
,
47 css::lang::XInitialization
48 > ResourceIdInterfaceBase
;
50 } // end of anonymous namespace.
55 namespace sd
{ namespace framework
{
57 /** Implementation of the css::drawing::framework::ResourceId
58 service and the css::drawing::framework::XResourceId
62 : public ResourceIdInterfaceBase
65 /** Create a new, empty resource id.
69 /** Create a new resource id that is described by the given URLs.
71 The first URL specifies the type of resource. The other URLs
73 The set of URLs may be empty. The result is then the same as
74 returned by ResourceId() default constructor.
76 ResourceId (const ::std::vector
<rtl::OUString
>& rsResourceURLs
);
78 /** Create a new resource id that has an empty anchor.
80 When this resource URL is empty then the resulting ResourceId
81 object is identical to when the ResourceId() default constructor
85 const ::rtl::OUString
& rsResourceURL
);
87 /** Create a new resource id for the given resource type and an anchor
88 that is specified by a single URL. This constructor can be used for
89 example for views that are bound to panes.
91 The URL of the actual resource.
93 The single URL of the anchor.
96 const ::rtl::OUString
& rsResourceURL
,
97 const ::rtl::OUString
& rsAnchorURL
);
99 /** Create a new resource id for the specified resource type and the
100 given list of anchor URLs.
102 The URL of the actual resource.
104 The possibly empty list of anchor URLs.
107 const ::rtl::OUString
& rsResourceURL
,
108 const ::std::vector
<rtl::OUString
>& rAnchorURLs
);
110 /** Create a new resource id with an anchor that consists of a sequence
111 of URLs that is extended by a further URL.
113 The URL of the actual resource.
114 @param rsFirstAnchorURL
115 This URL extends the anchor given by rAnchorURLs.
117 An anchor as it is returned by XResourceId::getAnchorURLs().
120 const ::rtl::OUString
& rsResourceURL
,
121 const ::rtl::OUString
& rsFirstAnchorURL
,
122 const css::uno::Sequence
<rtl::OUString
>& rAnchorURLs
);
124 virtual ~ResourceId (void);
126 /** Return the list of URLs of both the resource URL and the anchor
129 const ::std::vector
<rtl::OUString
>& GetResourceURLs (void) const;
131 //===== XResourceId =======================================================
133 virtual ::rtl::OUString SAL_CALL
134 getResourceURL (void)
135 throw(css::uno::RuntimeException
);
137 virtual css::util::URL SAL_CALL
138 getFullResourceURL (void)
139 throw(css::uno::RuntimeException
);
141 virtual sal_Bool SAL_CALL
143 throw (css::uno::RuntimeException
);
145 virtual css::uno::Reference
<
146 css::drawing::framework::XResourceId
> SAL_CALL
148 throw (css::uno::RuntimeException
);
150 virtual css::uno::Sequence
<rtl::OUString
> SAL_CALL
152 throw (css::uno::RuntimeException
);
154 virtual ::rtl::OUString SAL_CALL
155 getResourceTypePrefix (void)
156 throw (css::uno::RuntimeException
);
158 virtual sal_Int16 SAL_CALL
159 compareTo (const css::uno::Reference
<
160 css::drawing::framework::XResourceId
>& rxResourceId
)
161 throw (css::uno::RuntimeException
);
163 virtual sal_Bool SAL_CALL
165 const css::uno::Reference
<
166 css::drawing::framework::XResourceId
>& rxResourceId
,
167 css::drawing::framework::AnchorBindingMode eMode
)
168 throw(css::uno::RuntimeException
);
170 virtual sal_Bool SAL_CALL
172 const ::rtl::OUString
& rsAnchorURL
,
173 css::drawing::framework::AnchorBindingMode eMode
)
174 throw (css::uno::RuntimeException
);
176 virtual css::uno::Reference
<
177 css::drawing::framework::XResourceId
> SAL_CALL
179 throw(css::uno::RuntimeException
);
181 //===== XInitialization ===================================================
183 void SAL_CALL
initialize (
184 const css::uno::Sequence
<css::uno::Any
>& aArguments
)
185 throw (css::uno::RuntimeException
);
188 /** The set of URLs that consist of the resource URL at index 0 and the
189 anchor URLs and indices 1 and above.
191 ::std::vector
<rtl::OUString
> maResourceURLs
;
193 ::boost::scoped_ptr
<css::util::URL
> mpURL
;
195 static css::uno::WeakReference
<css::util::XURLTransformer
> mxURLTransformerWeak
;
197 /** Compare the called ResourceId object to the given ResourceId object.
198 This uses the implementation of both objects to speed up the
201 sal_Int16
CompareToLocalImplementation (const ResourceId
& rId
) const;
203 /** Compare the called ResourceId object to the given XResourceId object
204 reference. The comparison is done via the UNO interface. Namely,
205 it uses the getResourceURL() and the getAnchorURLs() methods to get
206 access to the URLs of the given objec.
208 sal_Int16
CompareToExternalImplementation (const css::uno::Reference
<
209 css::drawing::framework::XResourceId
>& rxId
) const;
211 /** Return whether the called ResourceId object is bound to the anchor
212 consisting of the URLs given by psFirstAnchorURL and paAnchorURLs.
213 @param psFirstAnchorURL
214 Optional first URL of the anchor. This can be missing or present
215 independently of paAnchorURLs.
217 Optional set of additional anchor URLs. This can be missing or
218 present independently of psFirstAnchorURL.
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 rtl::OUString
* psFirstAnchorURL
,
226 const css::uno::Sequence
<rtl::OUString
>* paAnchorURLs
,
227 css::drawing::framework::AnchorBindingMode eMode
) const;
229 /** Return whether the called ResourceId object is bound to the anchor
230 consisting of the URLs in rResourceURLs.
232 A possibly empty list of anchor URLs.
234 This specifies whether the called resource has to be directly
235 bound to the given anchor in order to return <TRUE/> or whether
236 it can be bound indirectly, too.
238 bool IsBoundToAnchor (
239 const ::std::vector
<rtl::OUString
>& rResourceURLs
,
240 css::drawing::framework::AnchorBindingMode eMode
) const;
242 bool IsValid (void) const;
244 void ParseResourceURL (void);
247 } } // end of namespace sd::framework