| 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 <mutex> |
| 23 |
#include <rtl/ustring.hxx> |
| 24 |
#include <cppuhelper/implbase.hxx> |
| 25 |
#include <comphelper/interfacecontainer4.hxx> |
| 26 |
#include <com/sun/star/uno/XInterface.hpp> |
| 27 |
#include <com/sun/star/lang/XComponent.hpp> |
| 28 |
#include <com/sun/star/ucb/XCommandProcessor.hpp> |
| 29 |
#include <com/sun/star/beans/XPropertiesChangeNotifier.hpp> |
| 30 |
#include <com/sun/star/ucb/XContent.hpp> |
| 31 |
#include <com/sun/star/ucb/XDynamicResultSet.hpp> |
| 32 |
#include <com/sun/star/lang/XServiceInfo.hpp> |
| 33 |
#include <com/sun/star/sdbc/XRow.hpp> |
| 34 |
#include <com/sun/star/beans/Property.hpp> |
| 35 |
#include <com/sun/star/beans/PropertyValue.hpp> |
| 36 |
#include <com/sun/star/ucb/XCommandInfo.hpp> |
| 37 |
#include <com/sun/star/ucb/InsertCommandArgument.hpp> |
| 38 |
#include <com/sun/star/beans/XPropertySetInfo.hpp> |
| 39 |
#include <com/sun/star/beans/XPropertyContainer.hpp> |
| 40 |
#include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp> |
| 41 |
#include <com/sun/star/beans/XPropertySetInfoChangeListener.hpp> |
| 42 |
#include <com/sun/star/container/XChild.hpp> |
| 43 |
#include <com/sun/star/ucb/XContentCreator.hpp> |
| 44 |
#include <com/sun/star/ucb/OpenCommandArgument2.hpp> |
| 45 |
#include <com/sun/star/ucb/TransferInfo.hpp> |
| 46 |
#include "filtask.hxx" |
| 47 |
|
| 48 |
|
| 49 |
namespace fileaccess { |
| 50 |
|
| 51 |
class PropertyListeners; |
| 52 |
class TaskManager; |
| 53 |
|
| 54 |
class BaseContent: |
| 55 |
public cppu::WeakImplHelper< |
| 56 |
css::lang::XComponent, |
| 57 |
css::lang::XServiceInfo, |
| 58 |
css::ucb::XCommandProcessor, |
| 59 |
css::beans::XPropertiesChangeNotifier, |
| 60 |
css::beans::XPropertyContainer, |
| 61 |
css::beans::XPropertySetInfoChangeNotifier, |
| 62 |
css::ucb::XContentCreator, |
| 63 |
css::container::XChild, |
| 64 |
css::ucb::XContent>, |
| 65 |
public fileaccess::Notifier // implementation class |
| 66 |
{ |
| 67 |
private: |
| 68 |
|
| 69 |
// A special creator for inserted contents; Creates an ugly object |
| 70 |
BaseContent( TaskManager* pMyShell, |
| 71 |
OUString parentName, |
| 72 |
bool bFolder ); |
| 73 |
|
| 74 |
public: |
| 75 |
enum state { NameForInsertionSet = 1, |
| 76 |
JustInserted = 2, |
| 77 |
Deleted = 4, |
| 78 |
FullFeatured = 8 }; |
| 79 |
|
| 80 |
BaseContent( |
| 81 |
TaskManager* pMyShell, |
| 82 |
const css::uno::Reference< css::ucb::XContentIdentifier >& xContentIdentifier, |
| 83 |
OUString aUnqPath, sal_uInt16 nState = FullFeatured); |
| 84 |
|
| 85 |
virtual ~BaseContent() override; |
| 86 |
|
| 87 |
// XComponent |
| 88 |
virtual void SAL_CALL |
| 89 |
dispose() override; |
| 90 |
|
| 91 |
virtual void SAL_CALL |
| 92 |
addEventListener( |
| 93 |
const css::uno::Reference< css::lang::XEventListener >& xListener ) override; |
| 94 |
|
| 95 |
virtual void SAL_CALL |
| 96 |
removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; |
| 97 |
|
| 98 |
|
| 99 |
// XServiceInfo |
| 100 |
virtual OUString SAL_CALL |
| 101 |
getImplementationName() override; |
| 102 |
|
| 103 |
virtual sal_Bool SAL_CALL |
| 104 |
supportsService( const OUString& ServiceName ) override; |
| 105 |
|
| 106 |
virtual css::uno::Sequence< OUString > SAL_CALL |
| 107 |
getSupportedServiceNames() override; |
| 108 |
|
| 109 |
|
| 110 |
// XCommandProcessor |
| 111 |
virtual sal_Int32 SAL_CALL |
| 112 |
createCommandIdentifier() override; |
| 113 |
|
| 114 |
virtual css::uno::Any SAL_CALL |
| 115 |
execute( |
| 116 |
const css::ucb::Command& aCommand, |
| 117 |
sal_Int32 CommandId, |
| 118 |
const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override; |
| 119 |
|
| 120 |
virtual void SAL_CALL |
| 121 |
abort( sal_Int32 CommandId ) override; |
| 122 |
|
| 123 |
|
| 124 |
// XContent |
| 125 |
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL |
| 126 |
getIdentifier() override; |
| 127 |
|
| 128 |
virtual OUString SAL_CALL |
| 129 |
getContentType() override; |
| 130 |
|
| 131 |
virtual void SAL_CALL |
| 132 |
addContentEventListener( |
| 133 |
const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override; |
| 134 |
|
| 135 |
virtual void SAL_CALL |
| 136 |
removeContentEventListener( |
| 137 |
const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override; |
| 138 |
|
| 139 |
// XPropertiesChangeNotifier |
| 140 |
|
| 141 |
virtual void SAL_CALL |
| 142 |
addPropertiesChangeListener( |
| 143 |
const css::uno::Sequence< OUString >& PropertyNames, |
| 144 |
const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override; |
| 145 |
|
| 146 |
virtual void SAL_CALL |
| 147 |
removePropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames, |
| 148 |
const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override; |
| 149 |
|
| 150 |
// XPropertyContainer |
| 151 |
|
| 152 |
virtual void SAL_CALL |
| 153 |
addProperty( |
| 154 |
const OUString& Name, |
| 155 |
sal_Int16 Attributes, |
| 156 |
const css::uno::Any& DefaultValue ) override; |
| 157 |
|
| 158 |
virtual void SAL_CALL |
| 159 |
removeProperty( const OUString& Name ) override; |
| 160 |
|
| 161 |
// XPropertySetInfoChangeNotifier |
| 162 |
|
| 163 |
virtual void SAL_CALL |
| 164 |
addPropertySetInfoChangeListener( |
| 165 |
const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override; |
| 166 |
|
| 167 |
virtual void SAL_CALL |
| 168 |
removePropertySetInfoChangeListener( |
| 169 |
const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override; |
| 170 |
|
| 171 |
|
| 172 |
// XContentCreator |
| 173 |
|
| 174 |
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL |
| 175 |
queryCreatableContentsInfo() override; |
| 176 |
|
| 177 |
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL |
| 178 |
createNewContent( const css::ucb::ContentInfo& Info ) override; |
| 179 |
|
| 180 |
|
| 181 |
// XChild |
| 182 |
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL |
| 183 |
getParent() override; |
| 184 |
|
| 185 |
// Not supported |
| 186 |
virtual void SAL_CALL |
| 187 |
setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override; |
| 188 |
|
| 189 |
|
| 190 |
// Notifier |
| 191 |
|
| 192 |
std::optional<ContentEventNotifier> cDEL() override; |
| 193 |
std::optional<ContentEventNotifier> cEXC( const OUString& aNewName ) override; |
| 194 |
std::optional<ContentEventNotifier> cCEL() override; |
| 195 |
std::optional<PropertySetInfoChangeNotifier> cPSL() override; |
| 196 |
std::optional<PropertyChangeNotifier> cPCL() override; |
| 197 |
|
| 198 |
private: |
| 199 |
// Data members |
| 200 |
TaskManager* m_pMyShell; |
| 201 |
css::uno::Reference< css::ucb::XContentIdentifier > m_xContentIdentifier; |
| 202 |
OUString m_aUncPath; |
| 203 |
bool m_bFolder; |
| 204 |
sal_uInt16 m_nState; |
| 205 |
|
| 206 |
std::mutex m_aMutex; |
| 207 |
comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aDisposeEventListeners; |
| 208 |
comphelper::OInterfaceContainerHelper4<css::ucb::XContentEventListener> m_aContentEventListeners; |
| 209 |
comphelper::OInterfaceContainerHelper4<css::beans::XPropertySetInfoChangeListener> m_aPropertySetInfoChangeListeners; |
| 210 |
std::unique_ptr<PropertyListeners> m_pPropertyListener; |
| 211 |
|
| 212 |
|
| 213 |
// Private Methods |
| 214 |
/// @throws css::uno::RuntimeException |
| 215 |
css::uno::Reference< css::ucb::XCommandInfo > |
| 216 |
getCommandInfo(); |
| 217 |
|
| 218 |
/// @throws css::uno::RuntimeException |
| 219 |
css::uno::Reference< css::beans::XPropertySetInfo > |
| 220 |
getPropertySetInfo(); |
| 221 |
|
| 222 |
/// @throws css::uno::RuntimeException |
| 223 |
css::uno::Reference< css::sdbc::XRow > |
| 224 |
getPropertyValues( |
| 225 |
sal_Int32 nMyCommandIdentifier, |
| 226 |
const css::uno::Sequence< css::beans::Property >& PropertySet ); |
| 227 |
|
| 228 |
css::uno::Sequence< css::uno::Any > |
| 229 |
setPropertyValues( |
| 230 |
sal_Int32 nMyCommandIdentifier, |
| 231 |
const css::uno::Sequence< css::beans::PropertyValue >& Values ); |
| 232 |
|
| 233 |
css::uno::Reference< css::ucb::XDynamicResultSet > |
| 234 |
open( |
| 235 |
sal_Int32 nMyCommandIdentifier, |
| 236 |
const css::ucb::OpenCommandArgument2& aCommandArgument ); |
| 237 |
|
| 238 |
void |
| 239 |
deleteContent( sal_Int32 nMyCommandIdentifier ); |
| 240 |
|
| 241 |
|
| 242 |
void |
| 243 |
transfer( sal_Int32 nMyCommandIdentifier, |
| 244 |
const css::ucb::TransferInfo& aTransferInfo ); |
| 245 |
|
| 246 |
void |
| 247 |
insert( sal_Int32 nMyCommandIdentifier, |
| 248 |
const css::ucb::InsertCommandArgument& aInsertArgument ); |
| 249 |
|
| 250 |
void endTask( sal_Int32 CommandId ); |
| 251 |
}; |
| 252 |
|
| 253 |
} // end namespace fileaccess |
| 254 |
|
| 255 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |