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/XBlankNode.hpp>
27 :
28 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
29 :
30 :
31 : /// anonymous implementation namespace
32 : namespace {
33 :
34 : class CBlankNode:
35 : public ::cppu::WeakImplHelper3<
36 : css::lang::XServiceInfo,
37 : css::lang::XInitialization,
38 : css::rdf::XBlankNode>
39 : {
40 : public:
41 : explicit CBlankNode(css::uno::Reference< css::uno::XComponentContext > const & context);
42 0 : virtual ~CBlankNode() {}
43 :
44 : // ::com::sun::star::lang::XServiceInfo:
45 : virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
46 : virtual sal_Bool SAL_CALL supportsService(const OUString & ServiceName) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
47 : virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
51 :
52 : // ::com::sun::star::rdf::XNode:
53 : virtual OUString SAL_CALL getStringValue() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
54 :
55 : private:
56 : CBlankNode(const CBlankNode &); // not defined
57 : CBlankNode& operator=(const CBlankNode &); // not defined
58 :
59 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
60 :
61 : OUString m_NodeID;
62 : };
63 :
64 0 : CBlankNode::CBlankNode(css::uno::Reference< css::uno::XComponentContext > const & context) :
65 0 : m_xContext(context), m_NodeID()
66 0 : {}
67 :
68 : // com.sun.star.uno.XServiceInfo:
69 0 : OUString SAL_CALL CBlankNode::getImplementationName() throw (css::uno::RuntimeException, std::exception)
70 : {
71 0 : return comp_CBlankNode::_getImplementationName();
72 : }
73 :
74 0 : sal_Bool SAL_CALL CBlankNode::supportsService(OUString const & serviceName) throw (css::uno::RuntimeException, std::exception)
75 : {
76 0 : return cppu::supportsService(this, serviceName);
77 : }
78 :
79 0 : css::uno::Sequence< OUString > SAL_CALL CBlankNode::getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception)
80 : {
81 0 : return comp_CBlankNode::_getSupportedServiceNames();
82 : }
83 :
84 : // ::com::sun::star::lang::XInitialization:
85 0 : void SAL_CALL CBlankNode::initialize(const css::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception, std::exception)
86 : {
87 0 : if (aArguments.getLength() != 1) {
88 : throw css::lang::IllegalArgumentException(
89 : OUString("CBlankNode::initialize: "
90 0 : "must give exactly 1 argument"), *this, 1);
91 : }
92 :
93 0 : OUString arg;
94 0 : if (!(aArguments[0] >>= arg)) {
95 : throw css::lang::IllegalArgumentException(
96 : OUString("CBlankNode::initialize: "
97 0 : "argument must be string"), *this, 0);
98 : }
99 :
100 : //FIXME: what is legal?
101 0 : if (!arg.isEmpty()) {
102 0 : m_NodeID = arg;
103 : } else {
104 : throw css::lang::IllegalArgumentException(
105 : OUString("CBlankNode::initialize: "
106 0 : "argument is not valid blank node ID"), *this, 0);
107 0 : }
108 0 : }
109 :
110 : // ::com::sun::star::rdf::XNode:
111 0 : OUString SAL_CALL CBlankNode::getStringValue() throw (css::uno::RuntimeException, std::exception)
112 : {
113 0 : return m_NodeID;
114 : }
115 :
116 : } // closing anonymous implementation namespace
117 :
118 :
119 :
120 : // component helper namespace
121 : namespace comp_CBlankNode {
122 :
123 0 : OUString SAL_CALL _getImplementationName() {
124 0 : return OUString( "CBlankNode");
125 : }
126 :
127 0 : css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames()
128 : {
129 0 : css::uno::Sequence< OUString > s(1);
130 0 : s[0] = "com.sun.star.rdf.BlankNode";
131 0 : return s;
132 : }
133 :
134 0 : css::uno::Reference< css::uno::XInterface > SAL_CALL _create(
135 : const css::uno::Reference< css::uno::XComponentContext > & context)
136 : SAL_THROW((css::uno::Exception))
137 : {
138 0 : return static_cast< ::cppu::OWeakObject * >(new CBlankNode(context));
139 : }
140 :
141 : } // closing component helper namespace
142 :
143 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|