Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "CNodes.hxx"
21 :
22 : #include <cppuhelper/implbase3.hxx>
23 : #include <com/sun/star/lang/XServiceInfo.hpp>
24 : #include <com/sun/star/lang/XInitialization.hpp>
25 : #include <com/sun/star/rdf/XURI.hpp>
26 : #include <com/sun/star/rdf/URIs.hpp>
27 :
28 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
29 :
30 :
31 : /// anonymous implementation namespace
32 : namespace {
33 :
34 : class CURI:
35 : public ::cppu::WeakImplHelper3<
36 : css::lang::XServiceInfo,
37 : css::lang::XInitialization,
38 : css::rdf::XURI>
39 : {
40 : public:
41 : explicit CURI(css::uno::Reference< css::uno::XComponentContext > const & context);
42 0 : virtual ~CURI() {}
43 :
44 : // ::com::sun::star::lang::XServiceInfo:
45 : virtual ::rtl::OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException);
46 : virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException);
47 : virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException);
48 :
49 : // ::com::sun::star::lang::XInitialization:
50 : virtual void SAL_CALL initialize(const css::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception);
51 :
52 : // ::com::sun::star::rdf::XNode:
53 : virtual ::rtl::OUString SAL_CALL getStringValue() throw (css::uno::RuntimeException);
54 :
55 : // ::com::sun::star::rdf::XURI:
56 : virtual ::rtl::OUString SAL_CALL getLocalName() throw (css::uno::RuntimeException);
57 : virtual ::rtl::OUString SAL_CALL getNamespace() throw (css::uno::RuntimeException);
58 :
59 : private:
60 : CURI(const CURI &); // not defined
61 : CURI& operator=(const CURI &); // not defined
62 :
63 : /// handle css.rdf.URIs
64 : void SAL_CALL initFromConstant(const sal_Int16 i_Constant);
65 :
66 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
67 :
68 : ::rtl::OUString m_Namespace;
69 : ::rtl::OUString m_LocalName;
70 : };
71 :
72 0 : CURI::CURI(css::uno::Reference< css::uno::XComponentContext > const & context) :
73 0 : m_xContext(context), m_Namespace(), m_LocalName()
74 0 : {}
75 :
76 : // com.sun.star.uno.XServiceInfo:
77 0 : ::rtl::OUString SAL_CALL CURI::getImplementationName() throw (css::uno::RuntimeException)
78 : {
79 0 : return comp_CURI::_getImplementationName();
80 : }
81 :
82 0 : ::sal_Bool SAL_CALL CURI::supportsService(::rtl::OUString const & serviceName) throw (css::uno::RuntimeException)
83 : {
84 0 : css::uno::Sequence< ::rtl::OUString > serviceNames = comp_CURI::_getSupportedServiceNames();
85 0 : for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {
86 0 : if (serviceNames[i] == serviceName)
87 0 : return sal_True;
88 : }
89 0 : return sal_False;
90 : }
91 :
92 0 : css::uno::Sequence< ::rtl::OUString > SAL_CALL CURI::getSupportedServiceNames() throw (css::uno::RuntimeException)
93 : {
94 0 : return comp_CURI::_getSupportedServiceNames();
95 : }
96 :
97 : const char s_nsXS [] = "http://www.w3.org/2001/XMLSchema#";
98 : const char s_nsXSD [] = "http://www.w3.org/2001/XMLSchema-datatypes#";
99 : const char s_nsRDF [] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
100 : const char s_nsRDFs [] = "http://www.w3.org/2000/01/rdf-schema#";
101 : const char s_nsOWL [] = "http://www.w3.org/2002/07/owl#";
102 : const char s_nsPkg [] =
103 : "http://docs.oasis-open.org/ns/office/1.2/meta/pkg#";
104 : const char s_nsODF [] =
105 : "http://docs.oasis-open.org/ns/office/1.2/meta/odf#";
106 :
107 0 : void SAL_CALL CURI::initFromConstant(const sal_Int16 i_Constant)
108 : {
109 0 : const char *ns(0);
110 0 : const char *ln(0);
111 0 : switch (i_Constant)
112 : {
113 : case css::rdf::URIs::XSD_NCNAME:
114 0 : ns = s_nsXSD;
115 0 : ln = "NCName";
116 0 : break;
117 :
118 : case css::rdf::URIs::XSD_STRING:
119 0 : ns = s_nsXSD;
120 0 : ln = "string";
121 0 : break;
122 :
123 : case css::rdf::URIs::XSD_NORMALIZEDSTRING:
124 0 : ns = s_nsXSD;
125 0 : ln = "normalizedString";
126 0 : break;
127 :
128 : case css::rdf::URIs::XSD_BOOLEAN:
129 0 : ns = s_nsXSD;
130 0 : ln = "boolean";
131 0 : break;
132 :
133 : case css::rdf::URIs::XSD_DECIMAL:
134 0 : ns = s_nsXSD;
135 0 : ln = "decimal";
136 0 : break;
137 :
138 : case css::rdf::URIs::XSD_FLOAT:
139 0 : ns = s_nsXSD;
140 0 : ln = "float";
141 0 : break;
142 :
143 : case css::rdf::URIs::XSD_DOUBLE:
144 0 : ns = s_nsXSD;
145 0 : ln = "double";
146 0 : break;
147 :
148 : case css::rdf::URIs::XSD_INTEGER:
149 0 : ns = s_nsXSD;
150 0 : ln = "integer";
151 0 : break;
152 :
153 : case css::rdf::URIs::XSD_NONNEGATIVEINTEGER:
154 0 : ns = s_nsXSD;
155 0 : ln = "nonNegativeInteger";
156 0 : break;
157 :
158 : case css::rdf::URIs::XSD_POSITIVEINTEGER:
159 0 : ns = s_nsXSD;
160 0 : ln = "positiveInteger";
161 0 : break;
162 :
163 : case css::rdf::URIs::XSD_NONPOSITIVEINTEGER:
164 0 : ns = s_nsXSD;
165 0 : ln = "nonPositiveInteger";
166 0 : break;
167 :
168 : case css::rdf::URIs::XSD_NEGATIVEINTEGER:
169 0 : ns = s_nsXSD;
170 0 : ln = "negativeInteger";
171 0 : break;
172 :
173 : case css::rdf::URIs::XSD_LONG:
174 0 : ns = s_nsXSD;
175 0 : ln = "long";
176 0 : break;
177 :
178 : case css::rdf::URIs::XSD_INT:
179 0 : ns = s_nsXSD;
180 0 : ln = "int";
181 0 : break;
182 :
183 : case css::rdf::URIs::XSD_SHORT:
184 0 : ns = s_nsXSD;
185 0 : ln = "short";
186 0 : break;
187 :
188 : case css::rdf::URIs::XSD_BYTE:
189 0 : ns = s_nsXSD;
190 0 : ln = "byte";
191 0 : break;
192 :
193 : case css::rdf::URIs::XSD_UNSIGNEDLONG:
194 0 : ns = s_nsXSD;
195 0 : ln = "unsignedLong";
196 0 : break;
197 :
198 : case css::rdf::URIs::XSD_UNSIGNEDINT:
199 0 : ns = s_nsXSD;
200 0 : ln = "unsignedInt";
201 0 : break;
202 :
203 : case css::rdf::URIs::XSD_UNSIGNEDSHORT:
204 0 : ns = s_nsXSD;
205 0 : ln = "unsignedShort";
206 0 : break;
207 :
208 : case css::rdf::URIs::XSD_UNSIGNEDBYTE:
209 0 : ns = s_nsXSD;
210 0 : ln = "unsignedByte";
211 0 : break;
212 :
213 : case css::rdf::URIs::XSD_HEXBINARY:
214 0 : ns = s_nsXSD;
215 0 : ln = "hexBinary";
216 0 : break;
217 :
218 : case css::rdf::URIs::XSD_BASE64BINARY:
219 0 : ns = s_nsXSD;
220 0 : ln = "base64Binary";
221 0 : break;
222 :
223 : case css::rdf::URIs::XSD_DATETIME:
224 0 : ns = s_nsXSD;
225 0 : ln = "dateTime";
226 0 : break;
227 :
228 : case css::rdf::URIs::XSD_TIME:
229 0 : ns = s_nsXSD;
230 0 : ln = "time";
231 0 : break;
232 :
233 : case css::rdf::URIs::XSD_DATE:
234 0 : ns = s_nsXSD;
235 0 : ln = "date";
236 0 : break;
237 :
238 : case css::rdf::URIs::XSD_GYEARMONTH:
239 0 : ns = s_nsXSD;
240 0 : ln = "gYearMonth";
241 0 : break;
242 :
243 : case css::rdf::URIs::XSD_GYEAR:
244 0 : ns = s_nsXSD;
245 0 : ln = "gYear";
246 0 : break;
247 :
248 : case css::rdf::URIs::XSD_GMONTHDAY:
249 0 : ns = s_nsXSD;
250 0 : ln = "gMonthDay";
251 0 : break;
252 :
253 : case css::rdf::URIs::XSD_GDAY:
254 0 : ns = s_nsXSD;
255 0 : ln = "gDay";
256 0 : break;
257 :
258 : case css::rdf::URIs::XSD_GMONTH:
259 0 : ns = s_nsXSD;
260 0 : ln = "gMonth";
261 0 : break;
262 :
263 : case css::rdf::URIs::XSD_ANYURI:
264 0 : ns = s_nsXSD;
265 0 : ln = "anyURI";
266 0 : break;
267 :
268 : case css::rdf::URIs::XSD_TOKEN:
269 0 : ns = s_nsXSD;
270 0 : ln = "token";
271 0 : break;
272 :
273 : case css::rdf::URIs::XSD_LANGUAGE:
274 0 : ns = s_nsXSD;
275 0 : ln = "language";
276 0 : break;
277 :
278 : case css::rdf::URIs::XSD_NMTOKEN:
279 0 : ns = s_nsXSD;
280 0 : ln = "NMTOKEN";
281 0 : break;
282 :
283 : case css::rdf::URIs::XSD_NAME:
284 0 : ns = s_nsXSD;
285 0 : ln = "Name";
286 0 : break;
287 :
288 : case css::rdf::URIs::XSD_DURATION:
289 0 : ns = s_nsXSD;
290 0 : ln = "duration";
291 0 : break;
292 :
293 : case css::rdf::URIs::XSD_QNAME:
294 0 : ns = s_nsXSD;
295 0 : ln = "QName";
296 0 : break;
297 :
298 : case css::rdf::URIs::XSD_NOTATION:
299 0 : ns = s_nsXSD;
300 0 : ln = "NOTATION";
301 0 : break;
302 :
303 : case css::rdf::URIs::XSD_NMTOKENS:
304 0 : ns = s_nsXSD;
305 0 : ln = "NMTOKENS";
306 0 : break;
307 :
308 : case css::rdf::URIs::XSD_ID:
309 0 : ns = s_nsXSD;
310 0 : ln = "ID";
311 0 : break;
312 :
313 : case css::rdf::URIs::XSD_IDREF:
314 0 : ns = s_nsXSD;
315 0 : ln = "IDREF";
316 0 : break;
317 :
318 : case css::rdf::URIs::XSD_IDREFS:
319 0 : ns = s_nsXSD;
320 0 : ln = "IDREFS";
321 0 : break;
322 :
323 : case css::rdf::URIs::XSD_ENTITY:
324 0 : ns = s_nsXSD;
325 0 : ln = "ENTITY";
326 0 : break;
327 :
328 : case css::rdf::URIs::XSD_ENTITIES:
329 0 : ns = s_nsXSD;
330 0 : ln = "ENTITIES";
331 0 : break;
332 :
333 : case css::rdf::URIs::RDF_TYPE:
334 0 : ns = s_nsRDF;
335 0 : ln = "type";
336 0 : break;
337 :
338 : case css::rdf::URIs::RDF_SUBJECT:
339 0 : ns = s_nsRDF;
340 0 : ln = "subject";
341 0 : break;
342 :
343 : case css::rdf::URIs::RDF_PREDICATE:
344 0 : ns = s_nsRDF;
345 0 : ln = "predicate";
346 0 : break;
347 :
348 : case css::rdf::URIs::RDF_OBJECT:
349 0 : ns = s_nsRDF;
350 0 : ln = "object";
351 0 : break;
352 :
353 : case css::rdf::URIs::RDF_PROPERTY:
354 0 : ns = s_nsRDF;
355 0 : ln = "Property";
356 0 : break;
357 :
358 : case css::rdf::URIs::RDF_STATEMENT:
359 0 : ns = s_nsRDF;
360 0 : ln = "Statement";
361 0 : break;
362 :
363 : case css::rdf::URIs::RDF_VALUE:
364 0 : ns = s_nsRDF;
365 0 : ln = "value";
366 0 : break;
367 :
368 : case css::rdf::URIs::RDF_FIRST:
369 0 : ns = s_nsRDF;
370 0 : ln = "first";
371 0 : break;
372 :
373 : case css::rdf::URIs::RDF_REST:
374 0 : ns = s_nsRDF;
375 0 : ln = "rest";
376 0 : break;
377 :
378 : case css::rdf::URIs::RDF_NIL:
379 0 : ns = s_nsRDF;
380 0 : ln = "nil";
381 0 : break;
382 :
383 : case css::rdf::URIs::RDF_XMLLITERAL:
384 0 : ns = s_nsRDF;
385 0 : ln = "XMLLiteral";
386 0 : break;
387 :
388 : case css::rdf::URIs::RDF_ALT:
389 0 : ns = s_nsRDF;
390 0 : ln = "Alt";
391 0 : break;
392 :
393 : case css::rdf::URIs::RDF_BAG:
394 0 : ns = s_nsRDF;
395 0 : ln = "Bag";
396 0 : break;
397 :
398 : case css::rdf::URIs::RDF_LIST:
399 0 : ns = s_nsRDF;
400 0 : ln = "List";
401 0 : break;
402 :
403 : case css::rdf::URIs::RDF_SEQ:
404 0 : ns = s_nsRDF;
405 0 : ln = "Seq";
406 0 : break;
407 :
408 : case css::rdf::URIs::RDF_1:
409 0 : ns = s_nsRDF;
410 0 : ln = "_1";
411 0 : break;
412 :
413 : case css::rdf::URIs::RDFS_COMMENT:
414 0 : ns = s_nsRDFs;
415 0 : ln = "comment";
416 0 : break;
417 :
418 : case css::rdf::URIs::RDFS_LABEL:
419 0 : ns = s_nsRDFs;
420 0 : ln = "label";
421 0 : break;
422 :
423 : case css::rdf::URIs::RDFS_DOMAIN:
424 0 : ns = s_nsRDFs;
425 0 : ln = "domain";
426 0 : break;
427 :
428 : case css::rdf::URIs::RDFS_RANGE:
429 0 : ns = s_nsRDFs;
430 0 : ln = "range";
431 0 : break;
432 :
433 : case css::rdf::URIs::RDFS_SUBCLASSOF:
434 0 : ns = s_nsRDFs;
435 0 : ln = "subClassOf";
436 0 : break;
437 :
438 : case css::rdf::URIs::RDFS_LITERAL:
439 0 : ns = s_nsRDFs;
440 0 : ln = "Literal";
441 0 : break;
442 :
443 : case css::rdf::URIs::OWL_CLASS:
444 0 : ns = s_nsOWL;
445 0 : ln = "Class";
446 0 : break;
447 :
448 : case css::rdf::URIs::OWL_OBJECTPROPERTY:
449 0 : ns = s_nsOWL;
450 0 : ln = "ObjectProperty";
451 0 : break;
452 :
453 : case css::rdf::URIs::OWL_DATATYPEPROPERTY:
454 0 : ns = s_nsOWL;
455 0 : ln = "DatatypeProperty";
456 0 : break;
457 :
458 : case css::rdf::URIs::OWL_FUNCTIONALPROPERTY:
459 0 : ns = s_nsOWL;
460 0 : ln = "FunctionalProperty";
461 0 : break;
462 :
463 : case css::rdf::URIs::OWL_THING:
464 0 : ns = s_nsOWL;
465 0 : ln = "Thing";
466 0 : break;
467 :
468 : case css::rdf::URIs::OWL_NOTHING:
469 0 : ns = s_nsOWL;
470 0 : ln = "Nothing";
471 0 : break;
472 :
473 : case css::rdf::URIs::OWL_INDIVIDUAL:
474 0 : ns = s_nsOWL;
475 0 : ln = "Individual";
476 0 : break;
477 :
478 : case css::rdf::URIs::OWL_EQUIVALENTCLASS:
479 0 : ns = s_nsOWL;
480 0 : ln = "equivalentClass";
481 0 : break;
482 :
483 : case css::rdf::URIs::OWL_EQUIVALENTPROPERTY:
484 0 : ns = s_nsOWL;
485 0 : ln = "equivalentProperty";
486 0 : break;
487 :
488 : case css::rdf::URIs::OWL_SAMEAS:
489 0 : ns = s_nsOWL;
490 0 : ln = "sameAs";
491 0 : break;
492 :
493 : case css::rdf::URIs::OWL_DIFFERENTFROM:
494 0 : ns = s_nsOWL;
495 0 : ln = "differentFrom";
496 0 : break;
497 :
498 : case css::rdf::URIs::OWL_ALLDIFFERENT:
499 0 : ns = s_nsOWL;
500 0 : ln = "AllDifferent";
501 0 : break;
502 :
503 : case css::rdf::URIs::OWL_DISTINCTMEMBERS:
504 0 : ns = s_nsOWL;
505 0 : ln = "distinctMembers";
506 0 : break;
507 :
508 : case css::rdf::URIs::OWL_INVERSEOF:
509 0 : ns = s_nsOWL;
510 0 : ln = "inverseOf";
511 0 : break;
512 :
513 : case css::rdf::URIs::OWL_TRANSITIVEPROPERTY:
514 0 : ns = s_nsOWL;
515 0 : ln = "TransitiveProperty";
516 0 : break;
517 :
518 : case css::rdf::URIs::OWL_SYMMETRICPROPERTY:
519 0 : ns = s_nsOWL;
520 0 : ln = "SymmetricProperty";
521 0 : break;
522 :
523 : case css::rdf::URIs::OWL_INVERSEFUNCTIONALPROPERTY:
524 0 : ns = s_nsOWL;
525 0 : ln = "InverseFunctionalProperty";
526 0 : break;
527 :
528 : case css::rdf::URIs::OWL_RESTRICTION:
529 0 : ns = s_nsOWL;
530 0 : ln = "Restriction";
531 0 : break;
532 :
533 : case css::rdf::URIs::OWL_ONPROPERTY:
534 0 : ns = s_nsOWL;
535 0 : ln = "onProperty";
536 0 : break;
537 :
538 : case css::rdf::URIs::OWL_ALLVALUESFROM:
539 0 : ns = s_nsOWL;
540 0 : ln = "allValuesFrom";
541 0 : break;
542 :
543 : case css::rdf::URIs::OWL_SOMEVALUESFROM:
544 0 : ns = s_nsOWL;
545 0 : ln = "someValuesFrom";
546 0 : break;
547 :
548 : case css::rdf::URIs::OWL_MINCARDINALITY:
549 0 : ns = s_nsOWL;
550 0 : ln = "minCardinality";
551 0 : break;
552 :
553 : case css::rdf::URIs::OWL_MAXCARDINALITY:
554 0 : ns = s_nsOWL;
555 0 : ln = "maxCardinality";
556 0 : break;
557 :
558 : case css::rdf::URIs::OWL_CARDINALITY:
559 0 : ns = s_nsOWL;
560 0 : ln = "cardinality";
561 0 : break;
562 :
563 : case css::rdf::URIs::OWL_ONTOLOGY:
564 0 : ns = s_nsOWL;
565 0 : ln = "Ontology";
566 0 : break;
567 :
568 : case css::rdf::URIs::OWL_IMPORTS:
569 0 : ns = s_nsOWL;
570 0 : ln = "imports";
571 0 : break;
572 :
573 : case css::rdf::URIs::OWL_VERSIONINFO:
574 0 : ns = s_nsOWL;
575 0 : ln = "versionInfo";
576 0 : break;
577 :
578 : case css::rdf::URIs::OWL_PRIORVERSION:
579 0 : ns = s_nsOWL;
580 0 : ln = "priorVersion";
581 0 : break;
582 :
583 : case css::rdf::URIs::OWL_BACKWARDCOMPATIBLEWITH:
584 0 : ns = s_nsOWL;
585 0 : ln = "backwardCompatibleWith";
586 0 : break;
587 :
588 : case css::rdf::URIs::OWL_INCOMPATIBLEWITH:
589 0 : ns = s_nsOWL;
590 0 : ln = "incompatibleWith";
591 0 : break;
592 :
593 : case css::rdf::URIs::OWL_DEPRECATEDCLASS:
594 0 : ns = s_nsOWL;
595 0 : ln = "DeprecatedClass";
596 0 : break;
597 :
598 : case css::rdf::URIs::OWL_DEPRECATEDPROPERTY:
599 0 : ns = s_nsOWL;
600 0 : ln = "DeprecatedProperty";
601 0 : break;
602 :
603 : case css::rdf::URIs::OWL_ANNOTATIONPROPERTY:
604 0 : ns = s_nsOWL;
605 0 : ln = "AnnotationProperty";
606 0 : break;
607 :
608 : case css::rdf::URIs::OWL_ONTOLOGYPROPERTY:
609 0 : ns = s_nsOWL;
610 0 : ln = "OntologyProperty";
611 0 : break;
612 :
613 : case css::rdf::URIs::OWL_ONEOF:
614 0 : ns = s_nsOWL;
615 0 : ln = "oneOf";
616 0 : break;
617 :
618 : case css::rdf::URIs::OWL_DATARANGE:
619 0 : ns = s_nsOWL;
620 0 : ln = "dataRange";
621 0 : break;
622 :
623 : case css::rdf::URIs::OWL_DISJOINTWITH:
624 0 : ns = s_nsOWL;
625 0 : ln = "disjointWith";
626 0 : break;
627 :
628 : case css::rdf::URIs::OWL_UNIONOF:
629 0 : ns = s_nsOWL;
630 0 : ln = "unionOf";
631 0 : break;
632 :
633 : case css::rdf::URIs::OWL_COMPLEMENTOF:
634 0 : ns = s_nsOWL;
635 0 : ln = "complementOf";
636 0 : break;
637 :
638 : case css::rdf::URIs::OWL_INTERSECTIONOF:
639 0 : ns = s_nsOWL;
640 0 : ln = "intersectionOf";
641 0 : break;
642 :
643 : case css::rdf::URIs::OWL_HASVALUE:
644 0 : ns = s_nsOWL;
645 0 : ln = "hasValue";
646 0 : break;
647 :
648 :
649 : case css::rdf::URIs::PKG_HASPART:
650 0 : ns = s_nsPkg;
651 0 : ln = "hasPart";
652 0 : break;
653 :
654 : case css::rdf::URIs::PKG_MIMETYPE:
655 0 : ns = s_nsPkg;
656 0 : ln = "mimeType";
657 0 : break;
658 :
659 : case css::rdf::URIs::PKG_PACKAGE:
660 0 : ns = s_nsPkg;
661 0 : ln = "Package";
662 0 : break;
663 :
664 : case css::rdf::URIs::PKG_ELEMENT:
665 0 : ns = s_nsPkg;
666 0 : ln = "Element";
667 0 : break;
668 :
669 : case css::rdf::URIs::PKG_FILE:
670 0 : ns = s_nsPkg;
671 0 : ln = "File";
672 0 : break;
673 :
674 : case css::rdf::URIs::PKG_METADATAFILE:
675 0 : ns = s_nsPkg;
676 0 : ln = "MetadataFile";
677 0 : break;
678 :
679 : case css::rdf::URIs::PKG_DOCUMENT:
680 0 : ns = s_nsPkg;
681 0 : ln = "Document";
682 0 : break;
683 :
684 : case css::rdf::URIs::ODF_PREFIX:
685 0 : ns = s_nsODF;
686 0 : ln = "prefix";
687 0 : break;
688 :
689 : case css::rdf::URIs::ODF_SUFFIX:
690 0 : ns = s_nsODF;
691 0 : ln = "suffix";
692 0 : break;
693 :
694 : case css::rdf::URIs::ODF_ELEMENT:
695 0 : ns = s_nsODF;
696 0 : ln = "Element";
697 0 : break;
698 :
699 : case css::rdf::URIs::ODF_CONTENTFILE:
700 0 : ns = s_nsODF;
701 0 : ln = "ContentFile";
702 0 : break;
703 :
704 : case css::rdf::URIs::ODF_STYLESFILE:
705 0 : ns = s_nsODF;
706 0 : ln = "StylesFile";
707 0 : break;
708 :
709 : default:
710 : throw css::lang::IllegalArgumentException(
711 : ::rtl::OUString("CURI::initialize: "
712 0 : "invalid URIs constant argument"), *this, 0);
713 : }
714 0 : m_Namespace = ::rtl::OUString::createFromAscii(ns).intern();
715 0 : m_LocalName = ::rtl::OUString::createFromAscii(ln).intern();
716 0 : return;
717 : }
718 :
719 : // ::com::sun::star::lang::XInitialization:
720 0 : void SAL_CALL CURI::initialize(const css::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception)
721 : {
722 0 : sal_Int32 len = aArguments.getLength();
723 0 : if ((len < 1) || (len > 2)) {
724 : throw css::lang::IllegalArgumentException(
725 : ::rtl::OUString("CURI::initialize: "
726 0 : "must give 1 or 2 argument(s)"), *this, 2);
727 : }
728 :
729 0 : sal_Int16 arg(0);
730 0 : ::rtl::OUString arg0;
731 0 : ::rtl::OUString arg1;
732 0 : if ((aArguments[0] >>= arg)) {
733 : // integer argument: constant from rdf::URIs
734 0 : if (len != 1) {
735 : throw css::lang::IllegalArgumentException(
736 : ::rtl::OUString("CURI::initialize: "
737 0 : "must give 1 int argument"), *this, 1);
738 : }
739 0 : initFromConstant(arg);
740 0 : return;
741 : }
742 0 : if (!(aArguments[0] >>= arg0)) {
743 : throw css::lang::IllegalArgumentException(
744 : ::rtl::OUString("CURI::initialize: "
745 0 : "argument must be string or short"), *this, 0);
746 : }
747 0 : if (len > 1) {
748 0 : if (!(aArguments[1] >>= arg1)) {
749 : throw css::lang::IllegalArgumentException(
750 : ::rtl::OUString("CURI::initialize: "
751 0 : "argument must be string"), *this, 1);
752 : }
753 : // just append the parameters and then split them again; seems simplest
754 0 : arg0 = arg0 + arg1;
755 0 : arg1 = ::rtl::OUString();
756 : }
757 :
758 : // split parameter
759 : sal_Int32 idx;
760 0 : if ( ((idx = arg0.indexOf ('#')) >= 0)
761 : || ((idx = arg0.lastIndexOf('/')) >= 0)
762 : || ((idx = arg0.lastIndexOf(':')) >= 0))
763 : {
764 :
765 0 : if (idx < arg0.getLength() - 1) {
766 0 : arg1 = arg0.copy(idx+1);
767 0 : arg0 = arg0.copy(0, idx+1);
768 : }
769 : } else {
770 : throw css::lang::IllegalArgumentException(
771 : ::rtl::OUString("CURI::initialize: "
772 0 : "argument not splittable: no separator [#/:]"), *this, 0);
773 : }
774 :
775 : //FIXME: what is legal?
776 0 : if (!arg0.isEmpty()) {
777 0 : m_Namespace = arg0;
778 : } else {
779 : throw css::lang::IllegalArgumentException(
780 : ::rtl::OUString("CURI::initialize: "
781 0 : "argument is not valid namespace"), *this, 0);
782 : }
783 : //FIXME: what is legal?
784 : if (true) {
785 0 : m_LocalName = arg1;
786 : } else {
787 : throw css::lang::IllegalArgumentException(
788 : ::rtl::OUString("CURI::initialize: "
789 : "argument is not valid local name"), *this, 1);
790 0 : }
791 : }
792 :
793 : // ::com::sun::star::rdf::XNode:
794 0 : ::rtl::OUString SAL_CALL CURI::getStringValue() throw (css::uno::RuntimeException)
795 : {
796 0 : return m_Namespace + m_LocalName;
797 : }
798 :
799 : // ::com::sun::star::rdf::XURI:
800 0 : ::rtl::OUString SAL_CALL CURI::getNamespace() throw (css::uno::RuntimeException)
801 : {
802 0 : return m_Namespace;
803 : }
804 :
805 0 : ::rtl::OUString SAL_CALL CURI::getLocalName() throw (css::uno::RuntimeException)
806 : {
807 0 : return m_LocalName;
808 : }
809 :
810 : } // closing anonymous implementation namespace
811 :
812 :
813 :
814 : // component helper namespace
815 : namespace comp_CURI {
816 :
817 0 : ::rtl::OUString SAL_CALL _getImplementationName() {
818 : return ::rtl::OUString(
819 0 : "CURI");
820 : }
821 :
822 0 : css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames()
823 : {
824 0 : css::uno::Sequence< ::rtl::OUString > s(1);
825 0 : s[0] = ::rtl::OUString( "com.sun.star.rdf.URI");
826 0 : return s;
827 : }
828 :
829 0 : css::uno::Reference< css::uno::XInterface > SAL_CALL _create(
830 : const css::uno::Reference< css::uno::XComponentContext > & context)
831 : SAL_THROW((css::uno::Exception))
832 : {
833 0 : return static_cast< ::cppu::OWeakObject * >(new CURI(context));
834 : }
835 :
836 : } // closing component helper namespace
837 :
838 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|