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