merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / inc / framework / ResourceId.hxx
blob0dcc5499e6cce07f982a7be57aa7a591f06483bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ResourceId.hxx,v $
10 * $Revision: 1.4 $
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;
43 namespace {
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
59 interface.
61 class ResourceId
62 : public ResourceIdInterfaceBase
64 public:
65 /** Create a new, empty resource id.
67 ResourceId (void);
69 /** Create a new resource id that is described by the given URLs.
70 @param rsResourceURLs
71 The first URL specifies the type of resource. The other URLs
72 describe its anchor.
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.
79 @param rsResourceURL
80 When this resource URL is empty then the resulting ResourceId
81 object is identical to when the ResourceId() default constructor
82 had been called.
84 ResourceId (
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.
90 @param rsResourceURL
91 The URL of the actual resource.
92 @param rsAnchorURL
93 The single URL of the anchor.
95 ResourceId (
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.
101 @param rsResourceURL
102 The URL of the actual resource.
103 @param rsAnchorURLs
104 The possibly empty list of anchor URLs.
106 ResourceId (
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.
112 @param rsResourceURL
113 The URL of the actual resource.
114 @param rsFirstAnchorURL
115 This URL extends the anchor given by rAnchorURLs.
116 @param rAnchorURLs
117 An anchor as it is returned by XResourceId::getAnchorURLs().
119 ResourceId (
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
127 URLs.
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
142 hasAnchor (void)
143 throw (css::uno::RuntimeException);
145 virtual css::uno::Reference<
146 css::drawing::framework::XResourceId> SAL_CALL
147 getAnchor (void)
148 throw (css::uno::RuntimeException);
150 virtual css::uno::Sequence<rtl::OUString> SAL_CALL
151 getAnchorURLs (void)
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
164 isBoundTo (
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
171 isBoundToURL (
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
178 clone (void)
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);
187 private:
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
199 comparison.
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.
216 @param paAnchorURLs
217 Optional set of additional anchor URLs. This can be missing or
218 present independently of psFirstAnchorURL.
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 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.
231 @param rResourceURLs
232 A possibly empty list of anchor URLs.
233 @param eMode
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
249 #endif