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 #ifndef INCLUDED_UCB_SOURCE_UCP_FILE_BC_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_FILE_BC_HXX
22 
23 #include <osl/mutex.hxx>
24 #include <rtl/ustring.hxx>
25 #include <cppuhelper/weak.hxx>
26 #include <ucbhelper/macros.hxx>
28 #include <com/sun/star/uno/XInterface.hpp>
29 #include <com/sun/star/lang/XTypeProvider.hpp>
30 #include <com/sun/star/lang/XComponent.hpp>
31 #include <com/sun/star/ucb/XCommandProcessor.hpp>
32 #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
33 #include <com/sun/star/ucb/XContent.hpp>
34 #include <com/sun/star/ucb/XContentProvider.hpp>
35 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/sdbc/XRow.hpp>
38 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
39 #include <com/sun/star/beans/Property.hpp>
40 #include <com/sun/star/beans/PropertyValue.hpp>
41 #include <com/sun/star/ucb/XCommandInfo.hpp>
42 #include <com/sun/star/ucb/InsertCommandArgument.hpp>
43 #include <com/sun/star/beans/XPropertySetInfo.hpp>
44 #include <com/sun/star/beans/XPropertyContainer.hpp>
45 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp>
46 #include <com/sun/star/beans/XPropertySetInfoChangeListener.hpp>
47 #include <com/sun/star/container/XChild.hpp>
48 #include <com/sun/star/ucb/XContentCreator.hpp>
49 #include <com/sun/star/io/XInputStream.hpp>
50 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
51 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
52 #include "filtask.hxx"
53 
54 
55 namespace fileaccess {
56 
57  class PropertyListeners;
58  class TaskManager;
59 
60  class BaseContent:
61  public cppu::OWeakObject,
62  public css::lang::XComponent,
63  public css::lang::XServiceInfo,
64  public css::lang::XTypeProvider,
65  public css::ucb::XCommandProcessor,
66  public css::beans::XPropertiesChangeNotifier,
67  public css::beans::XPropertyContainer,
68  public css::beans::XPropertySetInfoChangeNotifier,
69  public css::ucb::XContentCreator,
70  public css::container::XChild,
71  public css::ucb::XContent,
72  public fileaccess::Notifier // implementation class
73  {
74  private:
75 
76  // A special creator for inserted contents; Creates an ugly object
77  BaseContent( TaskManager* pMyShell,
78  const OUString& parentName,
79  bool bFolder );
80 
81  public:
83  TaskManager* pMyShell,
84  const css::uno::Reference< css::ucb::XContentIdentifier >& xContentIdentifier,
85  const OUString& aUnqPath );
86 
87  virtual ~BaseContent() override;
88 
89  // XInterface
90  virtual css::uno::Any SAL_CALL
91  queryInterface( const css::uno::Type& aType ) override;
92 
93  virtual void SAL_CALL
94  acquire()
95  throw() override;
96 
97  virtual void SAL_CALL
98  release()
99  throw() override;
100 
101 
102  // XComponent
103  virtual void SAL_CALL
104  dispose() override;
105 
106  virtual void SAL_CALL
108  const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
109 
110  virtual void SAL_CALL
111  removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
112 
113 
114  // XTypeProvider
115 
116  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
117  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
118 
119 
120  // XServiceInfo
121  virtual OUString SAL_CALL
122  getImplementationName() override;
123 
124  virtual sal_Bool SAL_CALL
125  supportsService( const OUString& ServiceName ) override;
126 
127  virtual css::uno::Sequence< OUString > SAL_CALL
128  getSupportedServiceNames() override;
129 
130 
131  // XCommandProcessor
132  virtual sal_Int32 SAL_CALL
133  createCommandIdentifier() override;
134 
135  virtual css::uno::Any SAL_CALL
136  execute(
137  const css::ucb::Command& aCommand,
138  sal_Int32 CommandId,
139  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
140 
141  virtual void SAL_CALL
142  abort( sal_Int32 CommandId ) override;
143 
144 
145  // XContent
146  virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
147  getIdentifier() override;
148 
149  virtual OUString SAL_CALL
150  getContentType() override;
151 
152  virtual void SAL_CALL
154  const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override;
155 
156  virtual void SAL_CALL
158  const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override;
159 
160  // XPropertiesChangeNotifier
161 
162  virtual void SAL_CALL
164  const css::uno::Sequence< OUString >& PropertyNames,
165  const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override;
166 
167  virtual void SAL_CALL
168  removePropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames,
169  const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override;
170 
171  // XPropertyContainer
172 
173  virtual void SAL_CALL
174  addProperty(
175  const OUString& Name,
176  sal_Int16 Attributes,
177  const css::uno::Any& DefaultValue ) override;
178 
179  virtual void SAL_CALL
180  removeProperty( const OUString& Name ) override;
181 
182  // XPropertySetInfoChangeNotifier
183 
184  virtual void SAL_CALL
186  const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override;
187 
188  virtual void SAL_CALL
190  const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override;
191 
192 
193  // XContentCreator
194 
195  virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL
196  queryCreatableContentsInfo() override;
197 
198  virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
199  createNewContent( const css::ucb::ContentInfo& Info ) override;
200 
201 
202  // XChild
203  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
204  getParent() override;
205 
206  // Not supported
207  virtual void SAL_CALL
208  setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
209 
210 
211  // Notifier
212 
213  std::unique_ptr<ContentEventNotifier> cDEL() override;
214  std::unique_ptr<ContentEventNotifier> cEXC( const OUString& aNewName ) override;
215  std::unique_ptr<ContentEventNotifier> cCEL() override;
216  std::unique_ptr<PropertySetInfoChangeNotifier> cPSL() override;
217  std::unique_ptr<PropertyChangeNotifier> cPCL() override;
218 
219  private:
220  // Data members
222  css::uno::Reference< css::ucb::XContentIdentifier > m_xContentIdentifier;
223  OUString m_aUncPath;
224 
227  Deleted = 4,
229  bool const m_bFolder;
230  sal_uInt16 m_nState;
231 
232  osl::Mutex m_aMutex;
233 
235  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pDisposeEventListeners;
236  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pContentEventListeners;
237  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pPropertySetInfoChangeListeners;
238  std::unique_ptr<PropertyListeners> m_pPropertyListener;
239 
240 
241  // Private Methods
243  css::uno::Reference< css::ucb::XCommandInfo >
244  getCommandInfo();
245 
247  css::uno::Reference< css::beans::XPropertySetInfo >
249 
251  css::uno::Reference< css::sdbc::XRow >
253  sal_Int32 nMyCommandIdentifier,
254  const css::uno::Sequence< css::beans::Property >& PropertySet );
255 
256  css::uno::Sequence< css::uno::Any >
258  sal_Int32 nMyCommandIdentifier,
259  const css::uno::Sequence< css::beans::PropertyValue >& Values );
260 
261  css::uno::Reference< css::ucb::XDynamicResultSet >
262  open(
263  sal_Int32 nMyCommandIdentifier,
264  const css::ucb::OpenCommandArgument2& aCommandArgument );
265 
266  void
267  deleteContent( sal_Int32 nMyCommandIdentifier );
268 
269 
270  void
271  transfer( sal_Int32 nMyCommandIdentifier,
272  const css::ucb::TransferInfo& aTransferInfo );
273 
274  void
275  insert( sal_Int32 nMyCommandIdentifier,
276  const css::ucb::InsertCommandArgument& aInsertArgument );
277 
278  void endTask( sal_Int32 CommandId );
279 
280  friend class ContentEventNotifier;
281  };
282 
283 } // end namespace fileaccess
284 
285 #endif
286 
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< ContentEventNotifier > cCEL() override
Definition: bc.cxx:1212
css::uno::Reference< css::ucb::XCommandInfo > getCommandInfo()
Definition: bc.cxx:680
css::uno::Reference< css::ucb::XContentIdentifier > m_xContentIdentifier
Definition: bc.hxx:222
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
Definition: bc.cxx:669
void deleteContent(sal_Int32 nMyCommandIdentifier)
Definition: bc.cxx:962
virtual void SAL_CALL abort(sal_Int32 CommandId) override
Definition: bc.cxx:267
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: bc.cxx:230
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:273
css::uno::Reference< css::ucb::XDynamicResultSet > open(sal_Int32 nMyCommandIdentifier, const css::ucb::OpenCommandArgument2 &aCommandArgument)
Definition: bc.cxx:886
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pPropertySetInfoChangeListeners
Definition: bc.hxx:237
Info
virtual void SAL_CALL addContentEventListener(const css::uno::Reference< css::ucb::XContentEventListener > &Listener) override
Definition: bc.cxx:492
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:389
virtual void SAL_CALL acquire() override
Definition: bc.cxx:131
virtual void SAL_CALL addProperty(const OUString &Name, sal_Int16 Attributes, const css::uno::Any &DefaultValue) override
Definition: bc.cxx:521
virtual void SAL_CALL dispose() override
Definition: bc.cxx:191
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: bc.cxx:181
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
std::unique_ptr< PropertyListeners > m_pPropertyListener
Definition: bc.hxx:238
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: bc.cxx:168
virtual void SAL_CALL addPropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: bc.cxx:618
virtual OUString SAL_CALL getContentType() override
Definition: bc.cxx:444
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
Definition: bc.cxx:557
void transfer(sal_Int32 nMyCommandIdentifier, const css::ucb::TransferInfo &aTransferInfo)
Definition: bc.cxx:976
std::unique_ptr< ContentEventNotifier > cDEL() override
Definition: bc.cxx:1170
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pDisposeEventListeners
Definition: bc.hxx:235
virtual OUString SAL_CALL getImplementationName() override
Definition: bc.cxx:224
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: bc.cxx:236
osl::Mutex m_aEventListenerMutex
Definition: bc.hxx:234
unsigned char sal_Bool
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: bc.cxx:147
sal_uInt16 m_nState
Definition: bc.hxx:230
OUString m_aUncPath
Definition: bc.hxx:223
virtual void SAL_CALL removePropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: bc.cxx:630
void insert(sal_Int32 nMyCommandIdentifier, const css::ucb::InsertCommandArgument &aInsertArgument)
Definition: bc.cxx:1045
virtual void SAL_CALL release() override
Definition: bc.cxx:139
virtual void SAL_CALL removeContentEventListener(const css::uno::Reference< css::ucb::XContentEventListener > &Listener) override
Definition: bc.cxx:507
virtual ~BaseContent() override
Definition: bc.cxx:117
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
Definition: bc.cxx:644
css::uno::Sequence< css::uno::Any > setPropertyValues(sal_Int32 nMyCommandIdentifier, const css::uno::Sequence< css::beans::PropertyValue > &Values)
Definition: bc.cxx:751
virtual sal_Int32 SAL_CALL createCommandIdentifier() override
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override
Definition: bc.cxx:550
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pContentEventListeners
Definition: bc.hxx:236
virtual void SAL_CALL removeProperty(const OUString &Name) override
Definition: bc.cxx:536
bool const m_bFolder
Definition: bc.hxx:229
std::unique_ptr< PropertyChangeNotifier > cPCL() override
Definition: bc.cxx:1239
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL getIdentifier() override
Definition: bc.cxx:437
osl::Mutex m_aMutex
Definition: bc.hxx:232
BaseContent(TaskManager *pMyShell, const OUString &parentName, bool bFolder)
Definition: bc.cxx:87
void endTask(sal_Int32 CommandId)
Definition: bc.cxx:1162
css::uno::Reference< css::beans::XPropertySetInfo > getPropertySetInfo()
Definition: bc.cxx:690
css::uno::Reference< css::sdbc::XRow > getPropertyValues(sal_Int32 nMyCommandIdentifier, const css::uno::Sequence< css::beans::Property > &PropertySet)
Definition: bc.cxx:699
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Sequence< OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override
Definition: bc.cxx:415
std::unique_ptr< PropertySetInfoChangeNotifier > cPSL() override
Definition: bc.cxx:1226
std::unique_ptr< ContentEventNotifier > cEXC(const OUString &aNewName) override
Definition: bc.cxx:1190
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
TaskManager * m_pMyShell
Definition: bc.hxx:221