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