1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CBlankNode.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include <cppuhelper/implbase3.hxx>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/lang/XInitialization.hpp>
36 #include <com/sun/star/rdf/XBlankNode.hpp>
38 #include <com/sun/star/lang/IllegalArgumentException.hpp>
41 /// anonymous implementation namespace
44 namespace css
= ::com::sun::star
;
47 public ::cppu::WeakImplHelper3
<
48 css::lang::XServiceInfo
,
49 css::lang::XInitialization
,
53 explicit CBlankNode(css::uno::Reference
< css::uno::XComponentContext
> const & context
);
54 virtual ~CBlankNode() {}
56 // ::com::sun::star::lang::XServiceInfo:
57 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw (css::uno::RuntimeException
);
58 virtual ::sal_Bool SAL_CALL
supportsService(const ::rtl::OUString
& ServiceName
) throw (css::uno::RuntimeException
);
59 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw (css::uno::RuntimeException
);
61 // ::com::sun::star::lang::XInitialization:
62 virtual void SAL_CALL
initialize(const css::uno::Sequence
< ::com::sun::star::uno::Any
> & aArguments
) throw (css::uno::RuntimeException
, css::uno::Exception
);
64 // ::com::sun::star::rdf::XNode:
65 virtual ::rtl::OUString SAL_CALL
getStringValue() throw (css::uno::RuntimeException
);
68 CBlankNode(const CBlankNode
&); // not defined
69 CBlankNode
& operator=(const CBlankNode
&); // not defined
71 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
73 ::rtl::OUString m_NodeID
;
76 CBlankNode::CBlankNode(css::uno::Reference
< css::uno::XComponentContext
> const & context
) :
77 m_xContext(context
), m_NodeID()
80 // com.sun.star.uno.XServiceInfo:
81 ::rtl::OUString SAL_CALL
CBlankNode::getImplementationName() throw (css::uno::RuntimeException
)
83 return comp_CBlankNode::_getImplementationName();
86 ::sal_Bool SAL_CALL
CBlankNode::supportsService(::rtl::OUString
const & serviceName
) throw (css::uno::RuntimeException
)
88 css::uno::Sequence
< ::rtl::OUString
> serviceNames
= comp_CBlankNode::_getSupportedServiceNames();
89 for (::sal_Int32 i
= 0; i
< serviceNames
.getLength(); ++i
) {
90 if (serviceNames
[i
] == serviceName
)
96 css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
CBlankNode::getSupportedServiceNames() throw (css::uno::RuntimeException
)
98 return comp_CBlankNode::_getSupportedServiceNames();
101 // ::com::sun::star::lang::XInitialization:
102 void SAL_CALL
CBlankNode::initialize(const css::uno::Sequence
< ::com::sun::star::uno::Any
> & aArguments
) throw (css::uno::RuntimeException
, css::uno::Exception
)
104 if (aArguments
.getLength() != 1) {
105 throw css::lang::IllegalArgumentException(
106 ::rtl::OUString::createFromAscii("CBlankNode::initialize: "
107 "must give exactly 1 argument"), *this, 1);
111 if (!(aArguments
[0] >>= arg
)) {
112 throw css::lang::IllegalArgumentException(
113 ::rtl::OUString::createFromAscii("CBlankNode::initialize: "
114 "argument must be string"), *this, 0);
117 //FIXME: what is legal?
118 if (arg
.getLength() > 0) {
121 throw css::lang::IllegalArgumentException(
122 ::rtl::OUString::createFromAscii("CBlankNode::initialize: "
123 "argument is not valid blank node ID"), *this, 0);
127 // ::com::sun::star::rdf::XNode:
128 ::rtl::OUString SAL_CALL
CBlankNode::getStringValue() throw (css::uno::RuntimeException
)
133 } // closing anonymous implementation namespace
137 // component helper namespace
138 namespace comp_CBlankNode
{
140 ::rtl::OUString SAL_CALL
_getImplementationName() {
141 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
145 css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
_getSupportedServiceNames()
147 css::uno::Sequence
< ::rtl::OUString
> s(1);
148 s
[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
149 "com.sun.star.rdf.BlankNode"));
153 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
_create(
154 const css::uno::Reference
< css::uno::XComponentContext
> & context
)
155 SAL_THROW((css::uno::Exception
))
157 return static_cast< ::cppu::OWeakObject
* >(new CBlankNode(context
));
160 } // closing component helper namespace