| 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 |
#pragma once |
| 21 |
|
| 22 |
#include <com/sun/star/sdbc/XRow.hpp> |
| 23 |
#include <com/sun/star/beans/PropertyValue.hpp> |
| 24 |
|
| 25 |
#include <ucbhelper/contenthelper.hxx> |
| 26 |
|
| 27 |
#include <optional> |
| 28 |
|
| 29 |
|
| 30 |
namespace ucb::ucp::ext |
| 31 |
{ |
| 32 |
|
| 33 |
|
| 34 |
//= ExtensionContentType |
| 35 |
|
| 36 |
enum ExtensionContentType |
| 37 |
{ |
| 38 |
E_ROOT, |
| 39 |
E_EXTENSION_ROOT, |
| 40 |
E_EXTENSION_CONTENT, |
| 41 |
|
| 42 |
E_UNKNOWN |
| 43 |
}; |
| 44 |
|
| 45 |
|
| 46 |
//= ContentProvider |
| 47 |
|
| 48 |
typedef ::ucbhelper::ContentImplHelper Content_Base; |
| 49 |
class Content : public Content_Base |
| 50 |
{ |
| 51 |
public: |
| 52 |
Content( |
| 53 |
const css::uno::Reference< css::uno::XComponentContext >& rxContext, |
| 54 |
::ucbhelper::ContentProviderImplHelper* pProvider, |
| 55 |
const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier |
| 56 |
); |
| 57 |
|
| 58 |
static css::uno::Reference< css::sdbc::XRow > |
| 59 |
getArtificialNodePropertyValues( |
| 60 |
const css::uno::Reference< css::uno::XComponentContext >& rxContext, |
| 61 |
const css::uno::Sequence< css::beans::Property >& rProperties, |
| 62 |
const OUString& rTitle |
| 63 |
); |
| 64 |
|
| 65 |
css::uno::Reference< css::sdbc::XRow > |
| 66 |
getPropertyValues( |
| 67 |
const css::uno::Sequence< css::beans::Property >& rProperties, |
| 68 |
const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv |
| 69 |
); |
| 70 |
|
| 71 |
static OUString |
| 72 |
encodeIdentifier( const OUString& i_rIdentifier ); |
| 73 |
static OUString |
| 74 |
decodeIdentifier( const OUString& i_rIdentifier ); |
| 75 |
|
| 76 |
virtual OUString getParentURL() override; |
| 77 |
|
| 78 |
ExtensionContentType getExtensionContentType() const { return m_eExtContentType; } |
| 79 |
|
| 80 |
/** retrieves the URL of the underlying physical content. Not to be called when getExtensionContentType() |
| 81 |
returns E_ROOT. |
| 82 |
*/ |
| 83 |
OUString getPhysicalURL() const; |
| 84 |
|
| 85 |
protected: |
| 86 |
virtual ~Content() override; |
| 87 |
|
| 88 |
// XServiceInfo |
| 89 |
virtual OUString SAL_CALL getImplementationName( ) override; |
| 90 |
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; |
| 91 |
|
| 92 |
// XContent |
| 93 |
virtual OUString SAL_CALL getContentType() override; |
| 94 |
|
| 95 |
// XCommandProcessor |
| 96 |
virtual css::uno::Any SAL_CALL |
| 97 |
execute( |
| 98 |
const css::ucb::Command& aCommand, |
| 99 |
sal_Int32 CommandId, |
| 100 |
const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment |
| 101 |
) override; |
| 102 |
|
| 103 |
virtual void SAL_CALL |
| 104 |
abort( |
| 105 |
sal_Int32 CommandId |
| 106 |
) override; |
| 107 |
|
| 108 |
private: |
| 109 |
virtual css::uno::Sequence< css::beans::Property > getProperties( const css::uno::Reference< css::ucb::XCommandEnvironment >& i_rEnv ) override; |
| 110 |
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands( const css::uno::Reference< css::ucb::XCommandEnvironment >& i_rEnv ) override; |
| 111 |
|
| 112 |
css::uno::Sequence< css::uno::Any > |
| 113 |
setPropertyValues( |
| 114 |
const css::uno::Sequence< css::beans::PropertyValue >& rValues |
| 115 |
); |
| 116 |
|
| 117 |
static bool denotesRootContent( std::u16string_view i_rContentIdentifier ); |
| 118 |
|
| 119 |
bool impl_isFolder(); |
| 120 |
void impl_determineContentType(); |
| 121 |
|
| 122 |
private: |
| 123 |
ExtensionContentType m_eExtContentType; |
| 124 |
::std::optional< bool > m_aIsFolder; |
| 125 |
::std::optional< OUString > m_aContentType; |
| 126 |
OUString m_sExtensionId; |
| 127 |
OUString m_sPathIntoExtension; |
| 128 |
}; |
| 129 |
|
| 130 |
|
| 131 |
} // namespace ucb::ucp::ext |
| 132 |
|
| 133 |
|
| 134 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |