xref: /aoo41x/main/unoxml/source/rdf/CBlankNode.cxx (revision e9cbe144)
1*e9cbe144SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*e9cbe144SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*e9cbe144SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*e9cbe144SAndrew Rist  * distributed with this work for additional information
6*e9cbe144SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*e9cbe144SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*e9cbe144SAndrew Rist  * "License"); you may not use this file except in compliance
9*e9cbe144SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*e9cbe144SAndrew Rist  *
11*e9cbe144SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*e9cbe144SAndrew Rist  *
13*e9cbe144SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*e9cbe144SAndrew Rist  * software distributed under the License is distributed on an
15*e9cbe144SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e9cbe144SAndrew Rist  * KIND, either express or implied.  See the License for the
17*e9cbe144SAndrew Rist  * specific language governing permissions and limitations
18*e9cbe144SAndrew Rist  * under the License.
19*e9cbe144SAndrew Rist  *
20*e9cbe144SAndrew Rist  *************************************************************/
21*e9cbe144SAndrew Rist 
22*e9cbe144SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "CNodes.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
27cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
28cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
29cdf0e10cSrcweir #include <com/sun/star/rdf/XBlankNode.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir /// anonymous implementation namespace
35cdf0e10cSrcweir namespace {
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace css = ::com::sun::star;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class CBlankNode:
40cdf0e10cSrcweir     public ::cppu::WeakImplHelper3<
41cdf0e10cSrcweir         css::lang::XServiceInfo,
42cdf0e10cSrcweir         css::lang::XInitialization,
43cdf0e10cSrcweir         css::rdf::XBlankNode>
44cdf0e10cSrcweir {
45cdf0e10cSrcweir public:
46cdf0e10cSrcweir     explicit CBlankNode(css::uno::Reference< css::uno::XComponentContext > const & context);
~CBlankNode()47cdf0e10cSrcweir     virtual ~CBlankNode() {}
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     // ::com::sun::star::lang::XServiceInfo:
50cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException);
51cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException);
52cdf0e10cSrcweir     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException);
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     // ::com::sun::star::lang::XInitialization:
55cdf0e10cSrcweir     virtual void SAL_CALL initialize(const css::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception);
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     // ::com::sun::star::rdf::XNode:
58cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getStringValue() throw (css::uno::RuntimeException);
59cdf0e10cSrcweir 
60cdf0e10cSrcweir private:
61cdf0e10cSrcweir     CBlankNode(const CBlankNode &); // not defined
62cdf0e10cSrcweir     CBlankNode& operator=(const CBlankNode &); // not defined
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     css::uno::Reference< css::uno::XComponentContext > m_xContext;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     ::rtl::OUString m_NodeID;
67cdf0e10cSrcweir };
68cdf0e10cSrcweir 
CBlankNode(css::uno::Reference<css::uno::XComponentContext> const & context)69cdf0e10cSrcweir CBlankNode::CBlankNode(css::uno::Reference< css::uno::XComponentContext > const & context) :
70cdf0e10cSrcweir     m_xContext(context), m_NodeID()
71cdf0e10cSrcweir {}
72cdf0e10cSrcweir 
73cdf0e10cSrcweir // com.sun.star.uno.XServiceInfo:
getImplementationName()74cdf0e10cSrcweir ::rtl::OUString SAL_CALL CBlankNode::getImplementationName() throw (css::uno::RuntimeException)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     return comp_CBlankNode::_getImplementationName();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
supportsService(::rtl::OUString const & serviceName)79cdf0e10cSrcweir ::sal_Bool SAL_CALL CBlankNode::supportsService(::rtl::OUString const & serviceName) throw (css::uno::RuntimeException)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir     css::uno::Sequence< ::rtl::OUString > serviceNames = comp_CBlankNode::_getSupportedServiceNames();
82cdf0e10cSrcweir     for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {
83cdf0e10cSrcweir         if (serviceNames[i] == serviceName)
84cdf0e10cSrcweir             return sal_True;
85cdf0e10cSrcweir     }
86cdf0e10cSrcweir     return sal_False;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
getSupportedServiceNames()89cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL CBlankNode::getSupportedServiceNames() throw (css::uno::RuntimeException)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     return comp_CBlankNode::_getSupportedServiceNames();
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // ::com::sun::star::lang::XInitialization:
initialize(const css::uno::Sequence<::com::sun::star::uno::Any> & aArguments)95cdf0e10cSrcweir void SAL_CALL CBlankNode::initialize(const css::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     if (aArguments.getLength() != 1) {
98cdf0e10cSrcweir         throw css::lang::IllegalArgumentException(
99cdf0e10cSrcweir             ::rtl::OUString::createFromAscii("CBlankNode::initialize: "
100cdf0e10cSrcweir                 "must give exactly 1 argument"), *this, 1);
101cdf0e10cSrcweir     }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     ::rtl::OUString arg;
104cdf0e10cSrcweir     if (!(aArguments[0] >>= arg)) {
105cdf0e10cSrcweir         throw css::lang::IllegalArgumentException(
106cdf0e10cSrcweir             ::rtl::OUString::createFromAscii("CBlankNode::initialize: "
107cdf0e10cSrcweir                 "argument must be string"), *this, 0);
108cdf0e10cSrcweir     }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     //FIXME: what is legal?
111cdf0e10cSrcweir     if (arg.getLength() > 0) {
112cdf0e10cSrcweir         m_NodeID = arg;
113cdf0e10cSrcweir     } else {
114cdf0e10cSrcweir         throw css::lang::IllegalArgumentException(
115cdf0e10cSrcweir             ::rtl::OUString::createFromAscii("CBlankNode::initialize: "
116cdf0e10cSrcweir                 "argument is not valid blank node ID"), *this, 0);
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir // ::com::sun::star::rdf::XNode:
getStringValue()121cdf0e10cSrcweir ::rtl::OUString SAL_CALL CBlankNode::getStringValue() throw (css::uno::RuntimeException)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     return m_NodeID;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir } // closing anonymous implementation namespace
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir // component helper namespace
131cdf0e10cSrcweir namespace comp_CBlankNode {
132cdf0e10cSrcweir 
_getImplementationName()133cdf0e10cSrcweir ::rtl::OUString SAL_CALL _getImplementationName() {
134cdf0e10cSrcweir     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
135cdf0e10cSrcweir         "CBlankNode"));
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
_getSupportedServiceNames()138cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames()
139cdf0e10cSrcweir {
140cdf0e10cSrcweir     css::uno::Sequence< ::rtl::OUString > s(1);
141cdf0e10cSrcweir     s[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
142cdf0e10cSrcweir         "com.sun.star.rdf.BlankNode"));
143cdf0e10cSrcweir     return s;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
_create(const css::uno::Reference<css::uno::XComponentContext> & context)146cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL _create(
147cdf0e10cSrcweir     const css::uno::Reference< css::uno::XComponentContext > & context)
148cdf0e10cSrcweir         SAL_THROW((css::uno::Exception))
149cdf0e10cSrcweir {
150cdf0e10cSrcweir     return static_cast< ::cppu::OWeakObject * >(new CBlankNode(context));
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir } // closing component helper namespace
154cdf0e10cSrcweir 
155