Annotation of /trunk/openoffice/patches/openoffice-3.2.1-system-redland.patch
Parent Directory | Revision Log
Revision 1115 -
(hide annotations)
(download)
Sun Aug 22 18:37:54 2010 UTC (14 years, 1 month ago) by niro
File size: 25200 byte(s)
Sun Aug 22 18:37:54 2010 UTC (14 years, 1 month ago) by niro
File size: 25200 byte(s)
-added
1 | niro | 1115 | Index: configure.in |
2 | =================================================================== | ||
3 | --- configure.in (Revision 277995) | ||
4 | +++ configure.in (Arbeitskopie) | ||
5 | @@ -528,6 +528,9 @@ | ||
6 | AC_ARG_WITH(system-lpsolve, | ||
7 | [ --with-system-lpsolve Use lpsolve already on system | ||
8 | ],,) | ||
9 | +AC_ARG_WITH(system-redland, | ||
10 | +[ --with-system-redland Use redland library already on system | ||
11 | +],,) | ||
12 | AC_ARG_WITH(system-mozilla, | ||
13 | [ --with-system-mozilla Use mozilla already on system. Note that some | ||
14 | components cannot be built against a contemporary | ||
15 | @@ -4889,16 +4892,12 @@ | ||
16 | dnl Check for system redland | ||
17 | dnl =================================================================== | ||
18 | AC_MSG_CHECKING([which redland library to use]) | ||
19 | -dnl if test -n "$with_system_redland" -o -n "$with_system_libs" && \ | ||
20 | -dnl test "$with_system_redland" != "no"; then | ||
21 | -dnl mst: NOTE: right now we need patches against redland | ||
22 | -dnl so we only enable system redland if explicitly requested | ||
23 | -dnl if next version includes patches, insert version check here | ||
24 | -if test -n "$with_system_redland" && \ | ||
25 | +if test -n "$with_system_redland" -o -n "$with_system_libs" && \ | ||
26 | test "$with_system_redland" != "no"; then | ||
27 | AC_MSG_RESULT([external]) | ||
28 | SYSTEM_REDLAND=YES | ||
29 | - PKG_CHECK_MODULES(REDLAND, redland) | ||
30 | + dnl versions before 1.0.8 write RDF/XML that is useless for ODF (@xml:base) | ||
31 | + PKG_CHECK_MODULES(REDLAND, redland >= 1.0.8) | ||
32 | else | ||
33 | AC_MSG_RESULT([internal]) | ||
34 | BUILD_TYPE="$BUILD_TYPE REDLAND" | ||
35 | Index: redland/redland/makefile.mk | ||
36 | =================================================================== | ||
37 | --- redland/redland/makefile.mk (Revision 278035) | ||
38 | +++ redland/redland/makefile.mk (Arbeitskopie) | ||
39 | @@ -62,9 +62,6 @@ | ||
40 | |||
41 | |||
42 | PATCH_FILES=$(OOO_PATCH_FILES) \ | ||
43 | - $(TARFILE_NAME).patch.free_null \ | ||
44 | - $(TARFILE_NAME).patch.storage_hashes_context_serialize_get_statement \ | ||
45 | - $(TARFILE_NAME).patch.storage_hashes_list_duplicates \ | ||
46 | |||
47 | |||
48 | .IF "$(OS)"=="OS2" | ||
49 | Index: redland/README | ||
50 | =================================================================== | ||
51 | --- redland/README (Revision 278035) | ||
52 | +++ redland/README (Arbeitskopie) | ||
53 | @@ -22,7 +22,8 @@ | ||
54 | Patches: | ||
55 | There are several patches, most of which contain only hacks to get it to | ||
56 | build with OOo build system. | ||
57 | -There are also 3 patches that fix bugs in redland and are of general interest: | ||
58 | +There used to be also 3 patches here that fix bugs in redland and ought to be | ||
59 | +of general interest: | ||
60 | - redland-1.0.8.patch.free_null: | ||
61 | redland destructor functions don't check if argument is NULL | ||
62 | - redland-1.0.8.patch.storage_hashes_context_serialize_get_statement: | ||
63 | @@ -31,4 +32,7 @@ | ||
64 | - redland-1.0.8.patch.storage_hashes_list_duplicates: | ||
65 | hashes, list storage: if contexts are enabled, then it is possible to add | ||
66 | duplicate statements | ||
67 | +Attempts to upstream these patches failed for reasons upstream kept to | ||
68 | +themselves. Now these patches are replaced with workarounds in unoxml. | ||
69 | +Note to future maintainers: work around redland bugs in client code. | ||
70 | |||
71 | Index: unoxml/source/rdf/librdf_repository.cxx | ||
72 | =================================================================== | ||
73 | --- unoxml/source/rdf/librdf_repository.cxx (Revision 277995) | ||
74 | +++ unoxml/source/rdf/librdf_repository.cxx (Arbeitskopie) | ||
75 | @@ -128,6 +128,56 @@ | ||
76 | |||
77 | //////////////////////////////////////////////////////////////////////////// | ||
78 | |||
79 | +// n.b.: librdf destructor functions dereference null pointers! | ||
80 | +// so they need to be wrapped to be usable with boost::shared_ptr. | ||
81 | +static void safe_librdf_free_world(librdf_world *const world) | ||
82 | +{ | ||
83 | + if (world) { librdf_free_world(world); } | ||
84 | +} | ||
85 | +static void safe_librdf_free_model(librdf_model *const model) | ||
86 | +{ | ||
87 | + if (model) { librdf_free_model(model); } | ||
88 | +} | ||
89 | +static void safe_librdf_free_node(librdf_node* node) | ||
90 | +{ | ||
91 | + if (node) { librdf_free_node(node); } | ||
92 | +} | ||
93 | +static void safe_librdf_free_parser(librdf_parser *const parser) | ||
94 | +{ | ||
95 | + if (parser) { librdf_free_parser(parser); } | ||
96 | +} | ||
97 | +static void safe_librdf_free_query(librdf_query *const query) | ||
98 | +{ | ||
99 | + if (query) { librdf_free_query(query); } | ||
100 | +} | ||
101 | +static void | ||
102 | +safe_librdf_free_query_results(librdf_query_results *const query_results) | ||
103 | +{ | ||
104 | + if (query_results) { librdf_free_query_results(query_results); } | ||
105 | +} | ||
106 | +static void safe_librdf_free_serializer(librdf_serializer *const serializer) | ||
107 | +{ | ||
108 | + if (serializer) { librdf_free_serializer(serializer); } | ||
109 | +} | ||
110 | +static void safe_librdf_free_statement(librdf_statement *const statement) | ||
111 | +{ | ||
112 | + if (statement) { librdf_free_statement(statement); } | ||
113 | +} | ||
114 | +static void safe_librdf_free_storage(librdf_storage *const storage) | ||
115 | +{ | ||
116 | + if (storage) { librdf_free_storage(storage); } | ||
117 | +} | ||
118 | +static void safe_librdf_free_stream(librdf_stream *const stream) | ||
119 | +{ | ||
120 | + if (stream) { librdf_free_stream(stream); } | ||
121 | +} | ||
122 | +static void safe_librdf_free_uri(librdf_uri *const uri) | ||
123 | +{ | ||
124 | + if (uri) { librdf_free_uri(uri); } | ||
125 | +} | ||
126 | + | ||
127 | +//////////////////////////////////////////////////////////////////////////// | ||
128 | + | ||
129 | #if 0 | ||
130 | class librdf_Statement: | ||
131 | public ::cppu::WeakImplHelper1< | ||
132 | @@ -425,11 +475,13 @@ | ||
133 | librdf_GraphResult(librdf_Repository *i_pRepository, | ||
134 | ::osl::Mutex & i_rMutex, | ||
135 | boost::shared_ptr<librdf_stream> const& i_pStream, | ||
136 | + boost::shared_ptr<librdf_node> const& i_pContext, | ||
137 | boost::shared_ptr<librdf_query> const& i_pQuery = | ||
138 | boost::shared_ptr<librdf_query>() ) | ||
139 | : m_xRep(i_pRepository) | ||
140 | , m_rMutex(i_rMutex) | ||
141 | , m_pQuery(i_pQuery) | ||
142 | + , m_pContext(i_pContext) | ||
143 | , m_pStream(i_pStream) | ||
144 | { }; | ||
145 | |||
146 | @@ -452,8 +504,11 @@ | ||
147 | // the query (in case this is a result of a graph query) | ||
148 | // not that the redland documentation spells this out explicity, but | ||
149 | // queries must be freed only after all the results are completely read | ||
150 | - boost::shared_ptr<librdf_query> m_pQuery; | ||
151 | - boost::shared_ptr<librdf_stream> m_pStream; | ||
152 | + boost::shared_ptr<librdf_query> const m_pQuery; | ||
153 | + boost::shared_ptr<librdf_node> const m_pContext; | ||
154 | + boost::shared_ptr<librdf_stream> const m_pStream; | ||
155 | + | ||
156 | + librdf_node* getContext() const; | ||
157 | }; | ||
158 | |||
159 | |||
160 | @@ -465,6 +520,17 @@ | ||
161 | return m_pStream.get() && !librdf_stream_end(m_pStream.get()); | ||
162 | } | ||
163 | |||
164 | +librdf_node* librdf_GraphResult::getContext() const | ||
165 | +{ | ||
166 | + if (!m_pStream.get() || librdf_stream_end(m_pStream.get())) | ||
167 | + return NULL; | ||
168 | + librdf_node *pCtxt( static_cast<librdf_node *> | ||
169 | + (librdf_stream_get_context(m_pStream.get())) ); | ||
170 | + if (pCtxt) | ||
171 | + return pCtxt; | ||
172 | + return m_pContext.get(); | ||
173 | +} | ||
174 | + | ||
175 | ::com::sun::star::uno::Any SAL_CALL | ||
176 | librdf_GraphResult::nextElement() | ||
177 | throw (uno::RuntimeException, container::NoSuchElementException, | ||
178 | @@ -472,8 +538,8 @@ | ||
179 | { | ||
180 | ::osl::MutexGuard g(m_rMutex); | ||
181 | if (!m_pStream.get() || !librdf_stream_end(m_pStream.get())) { | ||
182 | - librdf_node *pCtxt( static_cast<librdf_node *> | ||
183 | - (librdf_stream_get_context(m_pStream.get())) ); | ||
184 | + librdf_node * pCtxt = getContext(); | ||
185 | + | ||
186 | librdf_statement *pStmt( librdf_stream_get_object(m_pStream.get()) ); | ||
187 | if (!pStmt) { | ||
188 | rdf::QueryException e(::rtl::OUString::createFromAscii( | ||
189 | @@ -568,7 +634,7 @@ | ||
190 | |||
191 | void operator() (librdf_node** io_pArray) const throw () | ||
192 | { | ||
193 | - std::for_each(io_pArray, io_pArray + m_Count, librdf_free_node); | ||
194 | + std::for_each(io_pArray, io_pArray + m_Count, safe_librdf_free_node); | ||
195 | delete[] io_pArray; | ||
196 | } | ||
197 | }; | ||
198 | @@ -781,9 +847,9 @@ | ||
199 | librdf_Repository::librdf_Repository( | ||
200 | uno::Reference< uno::XComponentContext > const & i_xContext) | ||
201 | : /*BaseMutex(),*/ m_xContext(i_xContext) | ||
202 | -// m_pWorld (static_cast<librdf_world *>(0), librdf_free_world ), | ||
203 | - , m_pStorage(static_cast<librdf_storage*>(0), librdf_free_storage) | ||
204 | - , m_pModel (static_cast<librdf_model *>(0), librdf_free_model ) | ||
205 | +// m_pWorld (static_cast<librdf_world *>(0), safe_librdf_free_world ), | ||
206 | + , m_pStorage(static_cast<librdf_storage*>(0), safe_librdf_free_storage) | ||
207 | + , m_pModel (static_cast<librdf_model *>(0), safe_librdf_free_model ) | ||
208 | , m_NamedGraphs() | ||
209 | , m_TypeConverter(i_xContext, *this) | ||
210 | { | ||
211 | @@ -791,7 +857,7 @@ | ||
212 | |||
213 | ::osl::MutexGuard g(m_aMutex); | ||
214 | if (!m_NumInstances++) { | ||
215 | - m_pWorld.reset(m_TypeConverter.createWorld(), librdf_free_world); | ||
216 | + m_pWorld.reset(m_TypeConverter.createWorld(), safe_librdf_free_world); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | @@ -844,7 +910,7 @@ | ||
221 | ::osl::MutexGuard g(m_aMutex); | ||
222 | const boost::shared_ptr<librdf_node> pNode( | ||
223 | librdf_new_node_from_blank_identifier(m_pWorld.get(), NULL), | ||
224 | - librdf_free_node); | ||
225 | + safe_librdf_free_node); | ||
226 | if (!pNode) { | ||
227 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
228 | "librdf_Repository::createBlankNode: " | ||
229 | @@ -933,7 +999,7 @@ | ||
230 | const boost::shared_ptr<librdf_node> pContext( | ||
231 | librdf_new_node_from_uri_string(m_pWorld.get(), | ||
232 | reinterpret_cast<const unsigned char*> (context.getStr())), | ||
233 | - librdf_free_node); | ||
234 | + safe_librdf_free_node); | ||
235 | if (!pContext) { | ||
236 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
237 | "librdf_Repository::importGraph: " | ||
238 | @@ -945,7 +1011,7 @@ | ||
239 | const boost::shared_ptr<librdf_uri> pBaseURI( | ||
240 | librdf_new_uri(m_pWorld.get(), | ||
241 | reinterpret_cast<const unsigned char*> (baseURI.getStr())), | ||
242 | - librdf_free_uri); | ||
243 | + safe_librdf_free_uri); | ||
244 | if (!pBaseURI) { | ||
245 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
246 | "librdf_Repository::importGraph: " | ||
247 | @@ -954,7 +1020,7 @@ | ||
248 | |||
249 | const boost::shared_ptr<librdf_parser> pParser( | ||
250 | librdf_new_parser(m_pWorld.get(), "rdfxml", NULL, NULL), | ||
251 | - librdf_free_parser); | ||
252 | + safe_librdf_free_parser); | ||
253 | if (!pParser) { | ||
254 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
255 | "librdf_Repository::importGraph: " | ||
256 | @@ -971,7 +1037,7 @@ | ||
257 | librdf_parser_parse_counted_string_as_stream(pParser.get(), | ||
258 | reinterpret_cast<const unsigned char*>(buf.getConstArray()), | ||
259 | buf.getLength(), pBaseURI.get()), | ||
260 | - librdf_free_stream); | ||
261 | + safe_librdf_free_stream); | ||
262 | if (!pStream) { | ||
263 | throw rdf::ParseException(::rtl::OUString::createFromAscii( | ||
264 | "librdf_Repository::importGraph: " | ||
265 | @@ -1040,7 +1106,7 @@ | ||
266 | const boost::shared_ptr<librdf_node> pContext( | ||
267 | librdf_new_node_from_uri_string(m_pWorld.get(), | ||
268 | reinterpret_cast<const unsigned char*> (context.getStr())), | ||
269 | - librdf_free_node); | ||
270 | + safe_librdf_free_node); | ||
271 | if (!pContext) { | ||
272 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
273 | "librdf_Repository::exportGraph: " | ||
274 | @@ -1051,7 +1117,7 @@ | ||
275 | const boost::shared_ptr<librdf_uri> pBaseURI( | ||
276 | librdf_new_uri(m_pWorld.get(), | ||
277 | reinterpret_cast<const unsigned char*> (baseURI.getStr())), | ||
278 | - librdf_free_uri); | ||
279 | + safe_librdf_free_uri); | ||
280 | if (!pBaseURI) { | ||
281 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
282 | "librdf_Repository::exportGraph: " | ||
283 | @@ -1060,7 +1126,7 @@ | ||
284 | |||
285 | const boost::shared_ptr<librdf_stream> pStream( | ||
286 | librdf_model_context_as_stream(m_pModel.get(), pContext.get()), | ||
287 | - librdf_free_stream); | ||
288 | + safe_librdf_free_stream); | ||
289 | if (!pStream) { | ||
290 | throw rdf::RepositoryException(::rtl::OUString::createFromAscii( | ||
291 | "librdf_Repository::exportGraph: " | ||
292 | @@ -1070,7 +1136,7 @@ | ||
293 | const char *format("rdfxml-abbrev"); | ||
294 | const boost::shared_ptr<librdf_serializer> pSerializer( | ||
295 | librdf_new_serializer(m_pWorld.get(), format, NULL, NULL), | ||
296 | - librdf_free_serializer); | ||
297 | + safe_librdf_free_serializer); | ||
298 | if (!pSerializer) { | ||
299 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
300 | "librdf_Repository::exportGraph: " | ||
301 | @@ -1080,19 +1146,19 @@ | ||
302 | const boost::shared_ptr<librdf_uri> pRelativeURI( | ||
303 | librdf_new_uri(m_pWorld.get(), reinterpret_cast<const unsigned char*> | ||
304 | ("http://feature.librdf.org/raptor-relativeURIs")), | ||
305 | - librdf_free_uri); | ||
306 | + safe_librdf_free_uri); | ||
307 | const boost::shared_ptr<librdf_uri> pWriteBaseURI( | ||
308 | librdf_new_uri(m_pWorld.get(), reinterpret_cast<const unsigned char*> | ||
309 | ("http://feature.librdf.org/raptor-writeBaseURI")), | ||
310 | - librdf_free_uri); | ||
311 | + safe_librdf_free_uri); | ||
312 | const boost::shared_ptr<librdf_node> p0( | ||
313 | librdf_new_node_from_literal(m_pWorld.get(), | ||
314 | reinterpret_cast<const unsigned char*> ("0"), NULL, 0), | ||
315 | - librdf_free_node); | ||
316 | + safe_librdf_free_node); | ||
317 | const boost::shared_ptr<librdf_node> p1( | ||
318 | librdf_new_node_from_literal(m_pWorld.get(), | ||
319 | reinterpret_cast<const unsigned char*> ("1"), NULL, 0), | ||
320 | - librdf_free_node); | ||
321 | + safe_librdf_free_node); | ||
322 | if (!pWriteBaseURI || !pRelativeURI || !p0 || !p1) { | ||
323 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
324 | "librdf_Repository::exportGraph: " | ||
325 | @@ -1228,26 +1294,28 @@ | ||
326 | isMetadatableWithoutMetadata(i_xObject)) | ||
327 | { | ||
328 | return new librdf_GraphResult(this, m_aMutex, | ||
329 | - ::boost::shared_ptr<librdf_stream>()); | ||
330 | + ::boost::shared_ptr<librdf_stream>(), | ||
331 | + ::boost::shared_ptr<librdf_node>()); | ||
332 | } | ||
333 | |||
334 | ::osl::MutexGuard g(m_aMutex); | ||
335 | const boost::shared_ptr<librdf_statement> pStatement( | ||
336 | m_TypeConverter.mkStatement(m_pWorld.get(), | ||
337 | i_xSubject, i_xPredicate, i_xObject), | ||
338 | - librdf_free_statement); | ||
339 | + safe_librdf_free_statement); | ||
340 | OSL_ENSURE(pStatement, "mkStatement failed"); | ||
341 | |||
342 | const boost::shared_ptr<librdf_stream> pStream( | ||
343 | librdf_model_find_statements(m_pModel.get(), pStatement.get()), | ||
344 | - librdf_free_stream); | ||
345 | + safe_librdf_free_stream); | ||
346 | if (!pStream) { | ||
347 | throw rdf::RepositoryException(::rtl::OUString::createFromAscii( | ||
348 | "librdf_Repository::getStatements: " | ||
349 | "librdf_model_find_statements failed"), *this); | ||
350 | } | ||
351 | |||
352 | - return new librdf_GraphResult(this, m_aMutex, pStream); | ||
353 | + return new librdf_GraphResult(this, m_aMutex, pStream, | ||
354 | + ::boost::shared_ptr<librdf_node>()); | ||
355 | } | ||
356 | |||
357 | |||
358 | @@ -1261,7 +1329,7 @@ | ||
359 | const boost::shared_ptr<librdf_query> pQuery( | ||
360 | librdf_new_query(m_pWorld.get(), s_sparql, NULL, | ||
361 | reinterpret_cast<const unsigned char*> (query.getStr()), NULL), | ||
362 | - librdf_free_query); | ||
363 | + safe_librdf_free_query); | ||
364 | if (!pQuery) { | ||
365 | throw rdf::QueryException(::rtl::OUString::createFromAscii( | ||
366 | "librdf_Repository::querySelect: " | ||
367 | @@ -1269,7 +1337,7 @@ | ||
368 | } | ||
369 | const boost::shared_ptr<librdf_query_results> pResults( | ||
370 | librdf_model_query_execute(m_pModel.get(), pQuery.get()), | ||
371 | - librdf_free_query_results); | ||
372 | + safe_librdf_free_query_results); | ||
373 | if (!pResults || !librdf_query_results_is_bindings(pResults.get())) { | ||
374 | throw rdf::QueryException(::rtl::OUString::createFromAscii( | ||
375 | "librdf_Repository::querySelect: " | ||
376 | @@ -1311,7 +1379,7 @@ | ||
377 | const boost::shared_ptr<librdf_query> pQuery( | ||
378 | librdf_new_query(m_pWorld.get(), s_sparql, NULL, | ||
379 | reinterpret_cast<const unsigned char*> (query.getStr()), NULL), | ||
380 | - librdf_free_query); | ||
381 | + safe_librdf_free_query); | ||
382 | if (!pQuery) { | ||
383 | throw rdf::QueryException(::rtl::OUString::createFromAscii( | ||
384 | "librdf_Repository::queryConstruct: " | ||
385 | @@ -1319,7 +1387,7 @@ | ||
386 | } | ||
387 | const boost::shared_ptr<librdf_query_results> pResults( | ||
388 | librdf_model_query_execute(m_pModel.get(), pQuery.get()), | ||
389 | - librdf_free_query_results); | ||
390 | + safe_librdf_free_query_results); | ||
391 | if (!pResults || !librdf_query_results_is_graph(pResults.get())) { | ||
392 | throw rdf::QueryException(::rtl::OUString::createFromAscii( | ||
393 | "librdf_Repository::queryConstruct: " | ||
394 | @@ -1327,14 +1395,15 @@ | ||
395 | } | ||
396 | const boost::shared_ptr<librdf_stream> pStream( | ||
397 | librdf_query_results_as_stream(pResults.get()), | ||
398 | - librdf_free_stream); | ||
399 | + safe_librdf_free_stream); | ||
400 | if (!pStream) { | ||
401 | throw rdf::QueryException(::rtl::OUString::createFromAscii( | ||
402 | "librdf_Repository::queryConstruct: " | ||
403 | "librdf_query_results_as_stream failed"), *this); | ||
404 | } | ||
405 | |||
406 | - return new librdf_GraphResult(this, m_aMutex, pStream, pQuery); | ||
407 | + return new librdf_GraphResult(this, m_aMutex, pStream, | ||
408 | + ::boost::shared_ptr<librdf_node>(), pQuery); | ||
409 | } | ||
410 | |||
411 | ::sal_Bool SAL_CALL | ||
412 | @@ -1348,7 +1417,7 @@ | ||
413 | const boost::shared_ptr<librdf_query> pQuery( | ||
414 | librdf_new_query(m_pWorld.get(), s_sparql, NULL, | ||
415 | reinterpret_cast<const unsigned char*> (query.getStr()), NULL), | ||
416 | - librdf_free_query); | ||
417 | + safe_librdf_free_query); | ||
418 | if (!pQuery) { | ||
419 | throw rdf::QueryException(::rtl::OUString::createFromAscii( | ||
420 | "librdf_Repository::queryAsk: " | ||
421 | @@ -1356,7 +1425,7 @@ | ||
422 | } | ||
423 | const boost::shared_ptr<librdf_query_results> pResults( | ||
424 | librdf_model_query_execute(m_pModel.get(), pQuery.get()), | ||
425 | - librdf_free_query_results); | ||
426 | + safe_librdf_free_query_results); | ||
427 | if (!pResults || !librdf_query_results_is_boolean(pResults.get())) { | ||
428 | throw rdf::QueryException(::rtl::OUString::createFromAscii( | ||
429 | "librdf_Repository::queryAsk: " | ||
430 | @@ -1611,19 +1680,20 @@ | ||
431 | isMetadatableWithoutMetadata(i_xObject)) | ||
432 | { | ||
433 | return new librdf_GraphResult(this, m_aMutex, | ||
434 | - ::boost::shared_ptr<librdf_stream>()); | ||
435 | + ::boost::shared_ptr<librdf_stream>(), | ||
436 | + ::boost::shared_ptr<librdf_node>()); | ||
437 | } | ||
438 | |||
439 | ::osl::MutexGuard g(m_aMutex); | ||
440 | const boost::shared_ptr<librdf_statement> pStatement( | ||
441 | m_TypeConverter.mkStatement(m_pWorld.get(), | ||
442 | i_xSubject, i_xPredicate, i_xObject), | ||
443 | - librdf_free_statement); | ||
444 | + safe_librdf_free_statement); | ||
445 | OSL_ENSURE(pStatement, "mkStatement failed"); | ||
446 | |||
447 | const boost::shared_ptr<librdf_stream> pStream( | ||
448 | librdf_model_find_statements(m_pModel.get(), pStatement.get()), | ||
449 | - librdf_free_stream); | ||
450 | + safe_librdf_free_stream); | ||
451 | if (!pStream) { | ||
452 | throw rdf::RepositoryException(::rtl::OUString::createFromAscii( | ||
453 | "librdf_Repository::getStatementsRDFa: " | ||
454 | @@ -1637,7 +1707,8 @@ | ||
455 | "librdf_stream_add_map failed"), *this); | ||
456 | } | ||
457 | |||
458 | - return new librdf_GraphResult(this, m_aMutex, pStream); | ||
459 | + return new librdf_GraphResult(this, m_aMutex, pStream, | ||
460 | + ::boost::shared_ptr<librdf_node>()); | ||
461 | } | ||
462 | |||
463 | // ::com::sun::star::lang::XInitialization: | ||
464 | @@ -1649,11 +1720,11 @@ | ||
465 | |||
466 | ::osl::MutexGuard g(m_aMutex); | ||
467 | |||
468 | -// m_pWorld.reset(m_TypeConverter.createWorld(), librdf_free_world); | ||
469 | +// m_pWorld.reset(m_TypeConverter.createWorld(), safe_librdf_free_world); | ||
470 | m_pStorage.reset(m_TypeConverter.createStorage(m_pWorld.get()), | ||
471 | - librdf_free_storage); | ||
472 | + safe_librdf_free_storage); | ||
473 | m_pModel.reset(m_TypeConverter.createModel( | ||
474 | - m_pWorld.get(), m_pStorage.get()), librdf_free_model); | ||
475 | + m_pWorld.get(), m_pStorage.get()), safe_librdf_free_model); | ||
476 | } | ||
477 | |||
478 | const NamedGraphMap_t::iterator SAL_CALL librdf_Repository::clearGraph( | ||
479 | @@ -1680,7 +1751,7 @@ | ||
480 | const boost::shared_ptr<librdf_node> pContext( | ||
481 | librdf_new_node_from_uri_string(m_pWorld.get(), | ||
482 | reinterpret_cast<const unsigned char*> (context.getStr())), | ||
483 | - librdf_free_node); | ||
484 | + safe_librdf_free_node); | ||
485 | if (!pContext) { | ||
486 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
487 | "librdf_Repository::clearGraph: " | ||
488 | @@ -1731,7 +1802,7 @@ | ||
489 | const boost::shared_ptr<librdf_node> pContext( | ||
490 | librdf_new_node_from_uri_string(m_pWorld.get(), | ||
491 | reinterpret_cast<const unsigned char*> (context.getStr())), | ||
492 | - librdf_free_node); | ||
493 | + safe_librdf_free_node); | ||
494 | if (!pContext) { | ||
495 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
496 | "librdf_Repository::addStatement: " | ||
497 | @@ -1740,8 +1811,21 @@ | ||
498 | const boost::shared_ptr<librdf_statement> pStatement( | ||
499 | m_TypeConverter.mkStatement(m_pWorld.get(), | ||
500 | i_xSubject, i_xPredicate, i_xObject), | ||
501 | - librdf_free_statement); | ||
502 | + safe_librdf_free_statement); | ||
503 | OSL_ENSURE(pStatement, "mkStatement failed"); | ||
504 | + | ||
505 | + // Test for duplicate statement | ||
506 | + // librdf_model_add_statement disallows duplicates while | ||
507 | + // librdf_model_context_add_statement allows duplicates | ||
508 | + { | ||
509 | + const boost::shared_ptr<librdf_stream> pStream( | ||
510 | + librdf_model_find_statements_in_context(m_pModel.get(), | ||
511 | + pStatement.get(), pContext.get()), | ||
512 | + safe_librdf_free_stream); | ||
513 | + if (pStream && !librdf_stream_end(pStream.get())) | ||
514 | + return; | ||
515 | + } | ||
516 | + | ||
517 | if (librdf_model_context_add_statement(m_pModel.get(), | ||
518 | pContext.get(), pStatement.get())) { | ||
519 | throw rdf::RepositoryException(::rtl::OUString::createFromAscii( | ||
520 | @@ -1779,7 +1863,7 @@ | ||
521 | const boost::shared_ptr<librdf_node> pContext( | ||
522 | librdf_new_node_from_uri_string(m_pWorld.get(), | ||
523 | reinterpret_cast<const unsigned char*> (context.getStr())), | ||
524 | - librdf_free_node); | ||
525 | + safe_librdf_free_node); | ||
526 | if (!pContext) { | ||
527 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
528 | "librdf_Repository::removeStatements: " | ||
529 | @@ -1788,13 +1872,13 @@ | ||
530 | const boost::shared_ptr<librdf_statement> pStatement( | ||
531 | m_TypeConverter.mkStatement(m_pWorld.get(), | ||
532 | i_xSubject, i_xPredicate, i_xObject), | ||
533 | - librdf_free_statement); | ||
534 | + safe_librdf_free_statement); | ||
535 | OSL_ENSURE(pStatement, "mkStatement failed"); | ||
536 | |||
537 | const boost::shared_ptr<librdf_stream> pStream( | ||
538 | librdf_model_find_statements_in_context(m_pModel.get(), | ||
539 | pStatement.get(), pContext.get()), | ||
540 | - librdf_free_stream); | ||
541 | + safe_librdf_free_stream); | ||
542 | if (!pStream) { | ||
543 | throw rdf::RepositoryException(::rtl::OUString::createFromAscii( | ||
544 | "librdf_Repository::removeStatements: " | ||
545 | @@ -1838,7 +1922,8 @@ | ||
546 | isMetadatableWithoutMetadata(i_xObject)) | ||
547 | { | ||
548 | return new librdf_GraphResult(this, m_aMutex, | ||
549 | - ::boost::shared_ptr<librdf_stream>()); | ||
550 | + ::boost::shared_ptr<librdf_stream>(), | ||
551 | + ::boost::shared_ptr<librdf_node>()); | ||
552 | } | ||
553 | |||
554 | ::osl::MutexGuard g(m_aMutex); | ||
555 | @@ -1855,7 +1940,7 @@ | ||
556 | const boost::shared_ptr<librdf_node> pContext( | ||
557 | librdf_new_node_from_uri_string(m_pWorld.get(), | ||
558 | reinterpret_cast<const unsigned char*> (context.getStr())), | ||
559 | - librdf_free_node); | ||
560 | + safe_librdf_free_node); | ||
561 | if (!pContext) { | ||
562 | throw uno::RuntimeException(::rtl::OUString::createFromAscii( | ||
563 | "librdf_Repository::getStatements: " | ||
564 | @@ -1864,20 +1949,22 @@ | ||
565 | const boost::shared_ptr<librdf_statement> pStatement( | ||
566 | m_TypeConverter.mkStatement(m_pWorld.get(), | ||
567 | i_xSubject, i_xPredicate, i_xObject), | ||
568 | - librdf_free_statement); | ||
569 | + safe_librdf_free_statement); | ||
570 | OSL_ENSURE(pStatement, "mkStatement failed"); | ||
571 | |||
572 | const boost::shared_ptr<librdf_stream> pStream( | ||
573 | librdf_model_find_statements_in_context(m_pModel.get(), | ||
574 | pStatement.get(), pContext.get()), | ||
575 | - librdf_free_stream); | ||
576 | + safe_librdf_free_stream); | ||
577 | if (!pStream) { | ||
578 | throw rdf::RepositoryException(::rtl::OUString::createFromAscii( | ||
579 | "librdf_Repository::getStatements: " | ||
580 | "librdf_model_find_statements_in_context failed"), *this); | ||
581 | } | ||
582 | |||
583 | - return new librdf_GraphResult(this, m_aMutex, pStream); | ||
584 | + // librdf_model_find_statements_in_context is buggy and does not put | ||
585 | + // the context into result statements; pass it to librdf_GraphResult here | ||
586 | + return new librdf_GraphResult(this, m_aMutex, pStream, pContext); | ||
587 | } | ||
588 | |||
589 | librdf_world *librdf_TypeConverter::createWorld() const | ||
590 | @@ -1929,8 +2016,8 @@ | ||
591 | prtNode(contexts); | ||
592 | std::cout << std::endl; | ||
593 | // librdf_model_set_feature(repository, LIBRDF_FEATURE_CONTEXTS, ...); | ||
594 | - librdf_free_node(contexts); | ||
595 | - librdf_free_uri(ctxt); | ||
596 | + safe_librdf_free_node(contexts); | ||
597 | + safe_librdf_free_uri(ctxt); | ||
598 | } | ||
599 | #endif | ||
600 | return pRepository; | ||
601 | @@ -2015,7 +2102,7 @@ | ||
602 | NULL, 0); | ||
603 | } else { | ||
604 | const boost::shared_ptr<librdf_uri> pDatatype( | ||
605 | - mkURI(i_pWorld, xType), librdf_free_uri); | ||
606 | + mkURI(i_pWorld, xType), safe_librdf_free_uri); | ||
607 | ret = librdf_new_node_from_typed_literal(i_pWorld, | ||
608 | reinterpret_cast<const unsigned char*> (val.getStr()), | ||
609 | NULL, pDatatype.get()); | ||
610 | @@ -2054,11 +2141,11 @@ | ||
611 | try { | ||
612 | pObject = mkNode(i_pWorld, i_xObject); | ||
613 | } catch (...) { | ||
614 | - librdf_free_node(pPredicate); | ||
615 | + safe_librdf_free_node(pPredicate); | ||
616 | throw; | ||
617 | } | ||
618 | } catch (...) { | ||
619 | - librdf_free_node(pSubject); | ||
620 | + safe_librdf_free_node(pSubject); | ||
621 | throw; | ||
622 | } | ||
623 | // NB: this takes ownership of the nodes! (which is really ugly) |