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