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