1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
31 #include <cppuhelper/implbase3.hxx>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/lang/XInitialization.hpp>
34 #include <com/sun/star/rdf/XBlankNode.hpp>
36 #include <com/sun/star/lang/IllegalArgumentException.hpp>
39 /// anonymous implementation namespace
42 namespace css
= ::com::sun::star
;
45 public ::cppu::WeakImplHelper3
<
46 css::lang::XServiceInfo
,
47 css::lang::XInitialization
,
51 explicit CBlankNode(css::uno::Reference
< css::uno::XComponentContext
> const & context
);
52 virtual ~CBlankNode() {}
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
);
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
);
62 // ::com::sun::star::rdf::XNode:
63 virtual ::rtl::OUString SAL_CALL
getStringValue() throw (css::uno::RuntimeException
);
66 CBlankNode(const CBlankNode
&); // not defined
67 CBlankNode
& operator=(const CBlankNode
&); // not defined
69 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
71 ::rtl::OUString m_NodeID
;
74 CBlankNode::CBlankNode(css::uno::Reference
< css::uno::XComponentContext
> const & context
) :
75 m_xContext(context
), m_NodeID()
78 // com.sun.star.uno.XServiceInfo:
79 ::rtl::OUString SAL_CALL
CBlankNode::getImplementationName() throw (css::uno::RuntimeException
)
81 return comp_CBlankNode::_getImplementationName();
84 ::sal_Bool SAL_CALL
CBlankNode::supportsService(::rtl::OUString
const & serviceName
) throw (css::uno::RuntimeException
)
86 css::uno::Sequence
< ::rtl::OUString
> serviceNames
= comp_CBlankNode::_getSupportedServiceNames();
87 for (::sal_Int32 i
= 0; i
< serviceNames
.getLength(); ++i
) {
88 if (serviceNames
[i
] == serviceName
)
94 css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
CBlankNode::getSupportedServiceNames() throw (css::uno::RuntimeException
)
96 return comp_CBlankNode::_getSupportedServiceNames();
99 // ::com::sun::star::lang::XInitialization:
100 void SAL_CALL
CBlankNode::initialize(const css::uno::Sequence
< ::com::sun::star::uno::Any
> & aArguments
) throw (css::uno::RuntimeException
, css::uno::Exception
)
102 if (aArguments
.getLength() != 1) {
103 throw css::lang::IllegalArgumentException(
104 ::rtl::OUString("CBlankNode::initialize: "
105 "must give exactly 1 argument"), *this, 1);
109 if (!(aArguments
[0] >>= arg
)) {
110 throw css::lang::IllegalArgumentException(
111 ::rtl::OUString("CBlankNode::initialize: "
112 "argument must be string"), *this, 0);
115 //FIXME: what is legal?
116 if (!arg
.isEmpty()) {
119 throw css::lang::IllegalArgumentException(
120 ::rtl::OUString("CBlankNode::initialize: "
121 "argument is not valid blank node ID"), *this, 0);
125 // ::com::sun::star::rdf::XNode:
126 ::rtl::OUString SAL_CALL
CBlankNode::getStringValue() throw (css::uno::RuntimeException
)
131 } // closing anonymous implementation namespace
135 // component helper namespace
136 namespace comp_CBlankNode
{
138 ::rtl::OUString SAL_CALL
_getImplementationName() {
139 return ::rtl::OUString( "CBlankNode");
142 css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
_getSupportedServiceNames()
144 css::uno::Sequence
< ::rtl::OUString
> s(1);
145 s
[0] = ::rtl::OUString( "com.sun.star.rdf.BlankNode");
149 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
_create(
150 const css::uno::Reference
< css::uno::XComponentContext
> & context
)
151 SAL_THROW((css::uno::Exception
))
153 return static_cast< ::cppu::OWeakObject
* >(new CBlankNode(context
));
156 } // closing component helper namespace
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */