LibreOffice Module ucb (master)  1
bc.hxx
Go to the documentation of this file.
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 <osl/mutex.hxx>
23 #include <rtl/ustring.hxx>
24 #include <cppuhelper/implbase.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  const OUString& parentName,
72  bool bFolder );
73 
74  public:
76  TaskManager* pMyShell,
77  const css::uno::Reference< css::ucb::XContentIdentifier >& xContentIdentifier,
78  const OUString& aUnqPath );
79 
80  virtual ~BaseContent() override;
81 
82  // XComponent
83  virtual void SAL_CALL
84  dispose() override;
85 
86  virtual void SAL_CALL
88  const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
89 
90  virtual void SAL_CALL
91  removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
92 
93 
94  // XServiceInfo
95  virtual OUString SAL_CALL
96  getImplementationName() override;
97 
98  virtual sal_Bool SAL_CALL
99  supportsService( const OUString& ServiceName ) override;
100 
101  virtual css::uno::Sequence< OUString > SAL_CALL
102  getSupportedServiceNames() override;
103 
104 
105  // XCommandProcessor
106  virtual sal_Int32 SAL_CALL
107  createCommandIdentifier() override;
108 
109  virtual css::uno::Any SAL_CALL
110  execute(
111  const css::ucb::Command& aCommand,
112  sal_Int32 CommandId,
113  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
114 
115  virtual void SAL_CALL
116  abort( sal_Int32 CommandId ) override;
117 
118 
119  // XContent
120  virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
121  getIdentifier() override;
122 
123  virtual OUString SAL_CALL
124  getContentType() override;
125 
126  virtual void SAL_CALL
128  const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override;
129 
130  virtual void SAL_CALL
132  const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override;
133 
134  // XPropertiesChangeNotifier
135 
136  virtual void SAL_CALL
138  const css::uno::Sequence< OUString >& PropertyNames,
139  const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override;
140 
141  virtual void SAL_CALL
142  removePropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames,
143  const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override;
144 
145  // XPropertyContainer
146 
147  virtual void SAL_CALL
148  addProperty(
149  const OUString& Name,
150  sal_Int16 Attributes,
151  const css::uno::Any& DefaultValue ) override;
152 
153  virtual void SAL_CALL
154  removeProperty( const OUString& Name ) override;
155 
156  // XPropertySetInfoChangeNotifier
157 
158  virtual void SAL_CALL
160  const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override;
161 
162  virtual void SAL_CALL
164  const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override;
165 
166 
167  // XContentCreator
168 
169  virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL
170  queryCreatableContentsInfo() override;
171 
172  virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
173  createNewContent( const css::ucb::ContentInfo& Info ) override;
174 
175 
176  // XChild
177  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
178  getParent() override;
179 
180  // Not supported
181  virtual void SAL_CALL
182  setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
183 
184 
185  // Notifier
186 
187  std::unique_ptr<ContentEventNotifier> cDEL() override;
188  std::unique_ptr<ContentEventNotifier> cEXC( const OUString& aNewName ) override;
189  std::unique_ptr<ContentEventNotifier> cCEL() override;
190  std::unique_ptr<PropertySetInfoChangeNotifier> cPSL() override;
191  std::unique_ptr<PropertyChangeNotifier> cPCL() override;
192 
193  private:
194  // Data members
196  css::uno::Reference< css::ucb::XContentIdentifier > m_xContentIdentifier;
197  OUString m_aUncPath;
198 
201  Deleted = 4,
203  bool m_bFolder;
204  sal_uInt16 m_nState;
205 
206  osl::Mutex m_aMutex;
207 
209  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pDisposeEventListeners;
210  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pContentEventListeners;
211  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pPropertySetInfoChangeListeners;
212  std::unique_ptr<PropertyListeners> m_pPropertyListener;
213 
214 
215  // Private Methods
217  css::uno::Reference< css::ucb::XCommandInfo >
218  getCommandInfo();
219 
221  css::uno::Reference< css::beans::XPropertySetInfo >
223 
225  css::uno::Reference< css::sdbc::XRow >
227  sal_Int32 nMyCommandIdentifier,
228  const css::uno::Sequence< css::beans::Property >& PropertySet );
229 
230  css::uno::Sequence< css::uno::Any >
232  sal_Int32 nMyCommandIdentifier,
233  const css::uno::Sequence< css::beans::PropertyValue >& Values );
234 
235  css::uno::Reference< css::ucb::XDynamicResultSet >
236  open(
237  sal_Int32 nMyCommandIdentifier,
238  const css::ucb::OpenCommandArgument2& aCommandArgument );
239 
240  void
241  deleteContent( sal_Int32 nMyCommandIdentifier );
242 
243 
244  void
245  transfer( sal_Int32 nMyCommandIdentifier,
246  const css::ucb::TransferInfo& aTransferInfo );
247 
248  void
249  insert( sal_Int32 nMyCommandIdentifier,
250  const css::ucb::InsertCommandArgument& aInsertArgument );
251 
252  void endTask( sal_Int32 CommandId );
253 
254  friend class ContentEventNotifier;
255  };
256 
257 } // end namespace fileaccess
258 
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< ContentEventNotifier > cCEL() override
Definition: bc.cxx:1150
css::uno::Reference< css::ucb::XCommandInfo > getCommandInfo()
Definition: bc.cxx:619
css::uno::Reference< css::ucb::XContentIdentifier > m_xContentIdentifier
Definition: bc.hxx:196
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
Definition: bc.cxx:608
void deleteContent(sal_Int32 nMyCommandIdentifier)
Definition: bc.cxx:901
virtual void SAL_CALL abort(sal_Int32 CommandId) override
Definition: bc.cxx:208
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: bc.cxx:185
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
Definition: bc.cxx:214
css::uno::Reference< css::ucb::XDynamicResultSet > open(sal_Int32 nMyCommandIdentifier, const css::ucb::OpenCommandArgument2 &aCommandArgument)
Definition: bc.cxx:825
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pPropertySetInfoChangeListeners
Definition: bc.hxx:211
Info
virtual void SAL_CALL addContentEventListener(const css::uno::Reference< css::ucb::XContentEventListener > &Listener) override
Definition: bc.cxx:433
OUString Name
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override
Definition: bc.cxx:330
virtual void SAL_CALL addProperty(const OUString &Name, sal_Int16 Attributes, const css::uno::Any &DefaultValue) override
Definition: bc.cxx:462
virtual void SAL_CALL dispose() override
Definition: bc.cxx:146
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: bc.cxx:136
virtual sal_Int32 SAL_CALL createCommandIdentifier() override
Definition: bc.cxx:201
std::unique_ptr< PropertyListeners > m_pPropertyListener
Definition: bc.hxx:212
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: bc.cxx:123
virtual void SAL_CALL addPropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: bc.cxx:558
virtual OUString SAL_CALL getContentType() override
Definition: bc.cxx:385
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
Definition: bc.cxx:498
void transfer(sal_Int32 nMyCommandIdentifier, const css::ucb::TransferInfo &aTransferInfo)
Definition: bc.cxx:915
std::unique_ptr< ContentEventNotifier > cDEL() override
Definition: bc.cxx:1109
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pDisposeEventListeners
Definition: bc.hxx:209
virtual OUString SAL_CALL getImplementationName() override
Definition: bc.cxx:179
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: bc.cxx:191
osl::Mutex m_aEventListenerMutex
Definition: bc.hxx:208
unsigned char sal_Bool
sal_uInt16 m_nState
Definition: bc.hxx:204
OUString m_aUncPath
Definition: bc.hxx:197
virtual void SAL_CALL removePropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: bc.cxx:570
void insert(sal_Int32 nMyCommandIdentifier, const css::ucb::InsertCommandArgument &aInsertArgument)
Definition: bc.cxx:984
virtual void SAL_CALL removeContentEventListener(const css::uno::Reference< css::ucb::XContentEventListener > &Listener) override
Definition: bc.cxx:448
virtual ~BaseContent() override
Definition: bc.cxx:109
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
Definition: bc.cxx:584
css::uno::Sequence< css::uno::Any > setPropertyValues(sal_Int32 nMyCommandIdentifier, const css::uno::Sequence< css::beans::PropertyValue > &Values)
Definition: bc.cxx:690
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override
Definition: bc.cxx:491
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pContentEventListeners
Definition: bc.hxx:210
virtual void SAL_CALL removeProperty(const OUString &Name) override
Definition: bc.cxx:477
std::unique_ptr< PropertyChangeNotifier > cPCL() override
Definition: bc.cxx:1177
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL getIdentifier() override
Definition: bc.cxx:378
OUString aCommand
osl::Mutex m_aMutex
Definition: bc.hxx:206
BaseContent(TaskManager *pMyShell, const OUString &parentName, bool bFolder)
Definition: bc.cxx:79
void endTask(sal_Int32 CommandId)
Definition: bc.cxx:1101
css::uno::Reference< css::beans::XPropertySetInfo > getPropertySetInfo()
Definition: bc.cxx:629
css::uno::Reference< css::sdbc::XRow > getPropertyValues(sal_Int32 nMyCommandIdentifier, const css::uno::Sequence< css::beans::Property > &PropertySet)
Definition: bc.cxx:638
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Sequence< OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override
Definition: bc.cxx:356
std::unique_ptr< PropertySetInfoChangeNotifier > cPSL() override
Definition: bc.cxx:1164
std::unique_ptr< ContentEventNotifier > cEXC(const OUString &aNewName) override
Definition: bc.cxx:1129
TaskManager * m_pMyShell
Definition: bc.hxx:195