25#include <com/sun/star/beans/PropertyValue.hpp>
26#include <com/sun/star/sdbc/XRow.hpp>
27#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
28#include <com/sun/star/ucb/UnsupportedCommandException.hpp>
29#include <com/sun/star/ucb/XCommandInfo.hpp>
30#include <com/sun/star/io/XActiveDataSink.hpp>
31#include <com/sun/star/io/XOutputStream.hpp>
32#include <com/sun/star/lang/IllegalAccessException.hpp>
33#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
34#include <com/sun/star/io/XActiveDataStreamer.hpp>
53Content::Content(
const uno::Reference< uno::XComponentContext >& rxContext,
55 const uno::Reference< ucb::XContentIdentifier >&
58 : ContentImplHelper( rxContext, pProvider,
Identifier ),
59 m_aURLParameter(
Identifier->getContentIdentifier(),pDatabases ),
60 m_pDatabases( pDatabases )
73 return aRet.
hasValue() ? aRet : ContentImplHelper::queryInterface( rType );
103 return "CHelpContent";
109 return {
"com.sun.star.ucb.CHelpContent" };
129class ResultSetForRootFactory
134 uno::Reference< uno::XComponentContext >
m_xContext;
135 uno::Reference< ucb::XContentProvider > m_xProvider;
136 uno::Sequence< beans::Property > m_seq;
142 ResultSetForRootFactory(
143 uno::Reference< uno::XComponentContext > xContext,
144 uno::Reference< ucb::XContentProvider > xProvider,
145 const uno::Sequence< beans::Property >& seq,
149 m_xProvider(
std::move( xProvider )),
151 m_aURLParameter(rURLParameter),
152 m_pDatabases( pDatabases )
166class ResultSetForQueryFactory
171 uno::Reference< uno::XComponentContext >
m_xContext;
172 uno::Reference< ucb::XContentProvider > m_xProvider;
173 uno::Sequence< beans::Property > m_seq;
179 ResultSetForQueryFactory(
180 uno::Reference< uno::XComponentContext > xContext,
181 uno::Reference< ucb::XContentProvider > xProvider,
182 const uno::Sequence< beans::Property >& seq,
186 m_xProvider(
std::move( xProvider )),
188 m_aURLParameter(rURLParameter),
189 m_pDatabases( pDatabases )
207 const ucb::Command& aCommand,
209 const uno::Reference< ucb::XCommandEnvironment >& Environment )
213 if (
aCommand.Name ==
"getPropertyValues" )
216 if ( !(
aCommand.Argument >>= Properties ) )
218 aRet <<= lang::IllegalArgumentException();
224 else if (
aCommand.Name ==
"setPropertyValues" )
226 uno::Sequence<beans::PropertyValue> propertyValues;
228 if( ! (
aCommand.Argument >>= propertyValues ) ) {
229 aRet <<= lang::IllegalArgumentException();
233 uno::Sequence< uno::Any > ret(propertyValues.getLength());
236 std::transform(std::cbegin(propertyValues), std::cend(propertyValues), ret.getArray(),
237 [&props](
const beans::PropertyValue& rPropVal) {
238 if (std::any_of(props.begin(), props.end(),
239 [&rPropVal](const beans::Property& rProp) { return rProp.Name == rPropVal.Name; }))
240 return css::uno::toAny(lang::IllegalAccessException());
241 return css::uno::toAny(beans::UnknownPropertyException());
246 else if (
aCommand.Name ==
"getPropertySetInfo" )
249 aRet <<= getPropertySetInfo( Environment );
251 else if (
aCommand.Name ==
"getCommandInfo" )
254 aRet <<= getCommandInfo( Environment );
258 ucb::OpenCommandArgument2 aOpenCommand;
259 if ( !(
aCommand.Argument >>= aOpenCommand ) )
261 aRet <<= lang::IllegalArgumentException();
265 uno::Reference< io::XActiveDataSink > xActiveDataSink(
266 aOpenCommand.Sink, uno::UNO_QUERY);
268 if(xActiveDataSink.is())
269 m_aURLParameter.open(xActiveDataSink);
271 uno::Reference< io::XActiveDataStreamer > xActiveDataStreamer(
272 aOpenCommand.Sink, uno::UNO_QUERY);
274 if(xActiveDataStreamer.is()) {
275 aRet <<= ucb::UnsupportedDataSinkException();
279 uno::Reference< io::XOutputStream > xOutputStream(
280 aOpenCommand.Sink, uno::UNO_QUERY);
282 if(xOutputStream.is() )
283 m_aURLParameter.open(xOutputStream);
285 if( m_aURLParameter.isRoot() )
287 uno::Reference< ucb::XDynamicResultSet > xSet
291 std::make_unique<ResultSetForRootFactory>(
294 aOpenCommand.Properties,
299 else if( m_aURLParameter.isQuery() )
301 uno::Reference< ucb::XDynamicResultSet > xSet
305 std::make_unique<ResultSetForQueryFactory>(
308 aOpenCommand.Properties,
317 aRet <<= ucb::UnsupportedCommandException();
325 const uno::Sequence< beans::Property >& rProperties )
330 new ::ucbhelper::PropertyValueSet(
m_xContext );
332 for (
const beans::Property& rProp : rProperties )
334 if ( rProp.Name ==
"ContentType" )
338 "application/vnd.sun.star.help" ) );
339 else if ( rProp.Name ==
"Title" )
341 else if ( rProp.Name ==
"IsReadOnly" )
342 xRow->appendBoolean( rProp,
true );
343 else if ( rProp.Name ==
"IsDocument" )
347 else if ( rProp.Name ==
"IsFolder" )
351 else if ( rProp.Name ==
"IsErrorDocument" )
353 else if ( rProp.Name ==
"MediaType" )
357 OUString(
"text/plain" ) );
360 rProp,OUString(
"text/html" ) );
364 OUString(
"text/css" ) );
366 xRow->appendVoid( rProp );
368 if ( rProp.Name ==
"KeywordList" )
377 xRow->appendObject( rProp,aAny );
379 else if ( rProp.Name ==
"KeywordRef" )
388 xRow->appendObject( rProp,aAny );
390 else if ( rProp.Name ==
"KeywordAnchorForRef" )
399 xRow->appendObject( rProp,aAny );
401 else if ( rProp.Name ==
"KeywordTitleForRef" )
410 xRow->appendObject( rProp,aAny );
412 else if ( rProp.Name ==
"SearchScopes" )
414 uno::Sequence< OUString > seq{
"Heading",
"FullText" };
415 xRow->appendObject( rProp,
uno::Any(seq) );
417 else if ( rProp.Name ==
"Order" )
427 xRow->appendObject( rProp,aAny );
430 xRow->appendVoid( rProp );
431 else if(
"AnchorName" == rProp.Name &&
435 xRow->appendVoid( rProp );
Reference< XComponentContext > m_xContext
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
virtual css::uno::Sequence< css::beans::Property > getProperties(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
URLParameter m_aURLParameter
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual OUString SAL_CALL getContentType() override
virtual void SAL_CALL abort(sal_Int32 CommandId) override
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
KeywordInfo * getKeyword(const OUString &Module, const OUString &Language)
StaticModuleInformation * getStaticInformationForModule(std::u16string_view Module, const OUString &Language)
css::uno::Sequence< css::uno::Sequence< OUString > > & getIdList()
css::uno::Sequence< css::uno::Sequence< OUString > > & getAnchorList()
css::uno::Sequence< css::uno::Sequence< OUString > > & getTitleList()
css::uno::Sequence< OUString > & getKeywordList()
const OUString & get_module() const
OUString const & get_language() const
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
css::uno::Reference< css::uno::XComponentContext > m_xContext
XTYPEPROVIDER_COMMON_IMPL(Content)
constexpr OUStringLiteral MYUCP_CONTENT_TYPE
void cancelCommandExecution(const uno::Any &rException, const uno::Reference< ucb::XCommandEnvironment > &xEnv)