1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include "osl/mutex.hxx"
35 #include "rtl/ustring.hxx"
36 #include <cppuhelper/weak.hxx>
37 #include <ucbhelper/macros.hxx>
38 #include <cppuhelper/interfacecontainer.h>
39 #include <com/sun/star/uno/XInterface.hpp>
40 #include <com/sun/star/lang/XTypeProvider.hpp>
41 #include <com/sun/star/lang/XComponent.hpp>
42 #include <com/sun/star/ucb/XCommandProcessor.hpp>
43 #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
44 #include <com/sun/star/ucb/XContent.hpp>
45 #include <com/sun/star/ucb/XContentProvider.hpp>
46 #ifndef _COM_SUN_STAR_UCB_XRESULTSET_HPP_
47 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
49 #include <com/sun/star/lang/XServiceInfo.hpp>
50 #include <com/sun/star/sdbc/XRow.hpp>
51 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
52 #include <com/sun/star/beans/Property.hpp>
53 #include <com/sun/star/beans/PropertyValue.hpp>
54 #include <com/sun/star/ucb/XCommandInfo.hpp>
55 #include <com/sun/star/ucb/InsertCommandArgument.hpp>
56 #include <com/sun/star/beans/XPropertySetInfo.hpp>
57 #include <com/sun/star/beans/XPropertyContainer.hpp>
58 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp>
59 #include <com/sun/star/beans/XPropertySetInfoChangeListener.hpp>
60 #include <com/sun/star/container/XChild.hpp>
61 #include <com/sun/star/ucb/XContentCreator.hpp>
62 #include <com/sun/star/io/XInputStream.hpp>
63 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
64 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
65 #ifndef _COM_SUN_STAR_UCB_SHELL_HXX_
70 namespace fileaccess
{
72 class PropertyListeners
;
77 public cppu::OWeakObject
,
78 public com::sun::star::lang::XComponent
,
79 public com::sun::star::lang::XServiceInfo
,
80 public com::sun::star::lang::XTypeProvider
,
81 public com::sun::star::ucb::XCommandProcessor
,
82 public com::sun::star::beans::XPropertiesChangeNotifier
,
83 public com::sun::star::beans::XPropertyContainer
,
84 public com::sun::star::beans::XPropertySetInfoChangeNotifier
,
85 public com::sun::star::ucb::XContentCreator
,
86 public com::sun::star::container::XChild
,
87 public com::sun::star::ucb::XContent
,
88 public fileaccess::Notifier
// implementation class
92 // A special creator for inserted contents; Creates an ugly object
93 BaseContent( shell
* pMyShell
,
94 const rtl::OUString
& parentName
,
100 const com::sun::star::uno::Reference
< com::sun::star::ucb::XContentIdentifier
>& xContentIdentifier
,
101 const rtl::OUString
& aUnqPath
);
103 virtual ~BaseContent();
106 virtual com::sun::star::uno::Any SAL_CALL
108 const com::sun::star::uno::Type
& aType
)
109 throw( com::sun::star::uno::RuntimeException
);
111 virtual void SAL_CALL
116 virtual void SAL_CALL
123 virtual void SAL_CALL
126 throw( com::sun::star::uno::RuntimeException
);
128 virtual void SAL_CALL
130 const com::sun::star::uno::Reference
< com::sun::star::lang::XEventListener
>& xListener
)
131 throw( com::sun::star::uno::RuntimeException
);
133 virtual void SAL_CALL
134 removeEventListener( const com::sun::star::uno::Reference
< com::sun::star::lang::XEventListener
>& aListener
)
135 throw( com::sun::star::uno::RuntimeException
);
144 virtual rtl::OUString SAL_CALL
145 getImplementationName()
146 throw( com::sun::star::uno::RuntimeException
);
148 virtual sal_Bool SAL_CALL
149 supportsService( const rtl::OUString
& ServiceName
)
150 throw( com::sun::star::uno::RuntimeException
);
152 virtual com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
153 getSupportedServiceNames()
154 throw( com::sun::star::uno::RuntimeException
);
158 virtual sal_Int32 SAL_CALL
159 createCommandIdentifier(
161 throw( com::sun::star::uno::RuntimeException
);
163 virtual com::sun::star::uno::Any SAL_CALL
165 const com::sun::star::ucb::Command
& aCommand
,
167 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& Environment
)
168 throw( com::sun::star::uno::Exception
,
169 com::sun::star::ucb::CommandAbortedException
,
170 com::sun::star::uno::RuntimeException
);
172 virtual void SAL_CALL
174 sal_Int32 CommandId
)
175 throw( com::sun::star::uno::RuntimeException
);
179 virtual com::sun::star::uno::Reference
< com::sun::star::ucb::XContentIdentifier
> SAL_CALL
182 throw( com::sun::star::uno::RuntimeException
);
184 virtual rtl::OUString SAL_CALL
187 throw( com::sun::star::uno::RuntimeException
);
189 virtual void SAL_CALL
190 addContentEventListener(
191 const com::sun::star::uno::Reference
< com::sun::star::ucb::XContentEventListener
>& Listener
)
192 throw( com::sun::star::uno::RuntimeException
);
194 virtual void SAL_CALL
195 removeContentEventListener(
196 const com::sun::star::uno::Reference
< com::sun::star::ucb::XContentEventListener
>& Listener
)
197 throw( com::sun::star::uno::RuntimeException
);
199 // XPropertiesChangeNotifier
201 virtual void SAL_CALL
202 addPropertiesChangeListener(
203 const com::sun::star::uno::Sequence
< rtl::OUString
>& PropertyNames
,
204 const com::sun::star::uno::Reference
<
205 com::sun::star::beans::XPropertiesChangeListener
>& Listener
)
206 throw( com::sun::star::uno::RuntimeException
);
208 virtual void SAL_CALL
209 removePropertiesChangeListener( const com::sun::star::uno::Sequence
< rtl::OUString
>& PropertyNames
,
210 const com::sun::star::uno::Reference
<
211 com::sun::star::beans::XPropertiesChangeListener
>& Listener
)
212 throw( com::sun::star::uno::RuntimeException
);
214 // XPropertyContainer
216 virtual void SAL_CALL
218 const rtl::OUString
& Name
,
219 sal_Int16 Attributes
,
220 const com::sun::star::uno::Any
& DefaultValue
)
221 throw( com::sun::star::beans::PropertyExistException
,
222 com::sun::star::beans::IllegalTypeException
,
223 com::sun::star::lang::IllegalArgumentException
,
224 com::sun::star::uno::RuntimeException
);
226 virtual void SAL_CALL
228 const rtl::OUString
& Name
)
229 throw( com::sun::star::beans::UnknownPropertyException
,
230 com::sun::star::beans::NotRemoveableException
,
231 com::sun::star::uno::RuntimeException
);
233 // XPropertySetInfoChangeNotifier
235 virtual void SAL_CALL
236 addPropertySetInfoChangeListener(
237 const com::sun::star::uno::Reference
<
238 com::sun::star::beans::XPropertySetInfoChangeListener
>& Listener
)
239 throw( com::sun::star::uno::RuntimeException
);
241 virtual void SAL_CALL
242 removePropertySetInfoChangeListener(
243 const com::sun::star::uno::Reference
<
244 com::sun::star::beans::XPropertySetInfoChangeListener
>& Listener
)
245 throw( com::sun::star::uno::RuntimeException
);
250 virtual com::sun::star::uno::Sequence
< com::sun::star::ucb::ContentInfo
> SAL_CALL
251 queryCreatableContentsInfo(
253 throw( com::sun::star::uno::RuntimeException
);
255 virtual com::sun::star::uno::Reference
< com::sun::star::ucb::XContent
> SAL_CALL
257 const com::sun::star::ucb::ContentInfo
& Info
)
258 throw( com::sun::star::uno::RuntimeException
);
262 virtual com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> SAL_CALL
264 void ) throw( com::sun::star::uno::RuntimeException
);
267 virtual void SAL_CALL
268 setParent( const com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
>& Parent
)
269 throw( com::sun::star::lang::NoSupportException
,
270 com::sun::star::uno::RuntimeException
);
275 ContentEventNotifier
* cDEL( void );
276 ContentEventNotifier
* cEXC( const rtl::OUString aNewName
);
277 ContentEventNotifier
* cCEL( void );
278 PropertySetInfoChangeNotifier
* cPSL( void );
279 PropertyChangeNotifier
* cPCL( void );
280 rtl::OUString
getKey( void );
285 com::sun::star::uno::Reference
< com::sun::star::ucb::XContentIdentifier
> m_xContentIdentifier
;
286 rtl::OUString m_aUncPath
;
288 enum state
{ NameForInsertionSet
= 1,
298 osl::Mutex m_aEventListenerMutex
;
299 cppu::OInterfaceContainerHelper
* m_pDisposeEventListeners
;
300 cppu::OInterfaceContainerHelper
* m_pContentEventListeners
;
301 cppu::OInterfaceContainerHelper
* m_pPropertySetInfoChangeListeners
;
302 PropertyListeners
* m_pPropertyListener
;
306 com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandInfo
> SAL_CALL
308 throw( com::sun::star::uno::RuntimeException
);
310 virtual com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySetInfo
> SAL_CALL
312 sal_Int32 nMyCommandIdentifier
)
313 throw( com::sun::star::uno::RuntimeException
);
315 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XRow
> SAL_CALL
317 sal_Int32 nMyCommandIdentifier
,
318 const com::sun::star::uno::Sequence
< com::sun::star::beans::Property
>& PropertySet
)
319 throw( com::sun::star::uno::RuntimeException
);
321 com::sun::star::uno::Sequence
< com::sun::star::uno::Any
> SAL_CALL
323 sal_Int32 nMyCommandIdentifier
,
324 const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& Values
)
327 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSet
> SAL_CALL
329 sal_Int32 nMyCommandIdentifier
,
330 const com::sun::star::ucb::OpenCommandArgument2
& aCommandArgument
)
334 deleteContent( sal_Int32 nMyCommandIdentifier
)
339 transfer( sal_Int32 nMyCommandIdentifier
,
340 const com::sun::star::ucb::TransferInfo
& aTransferInfo
)
344 insert( sal_Int32 nMyCommandIdentifier
,
345 const com::sun::star::ucb::InsertCommandArgument
& aInsertArgument
)
348 void SAL_CALL
endTask( sal_Int32 CommandId
);
350 friend class ContentEventNotifier
;
353 } // end namespace fileaccess