1*ac9096f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ac9096f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ac9096f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ac9096f4SAndrew Rist  * distributed with this work for additional information
6*ac9096f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ac9096f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ac9096f4SAndrew Rist  * "License"); you may not use this file except in compliance
9*ac9096f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ac9096f4SAndrew Rist  *
11*ac9096f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ac9096f4SAndrew Rist  *
13*ac9096f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ac9096f4SAndrew Rist  * software distributed under the License is distributed on an
15*ac9096f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ac9096f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ac9096f4SAndrew Rist  * specific language governing permissions and limitations
18*ac9096f4SAndrew Rist  * under the License.
19*ac9096f4SAndrew Rist  *
20*ac9096f4SAndrew Rist  *************************************************************/
21*ac9096f4SAndrew Rist 
22*ac9096f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_ucbhelper.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /**************************************************************************
28cdf0e10cSrcweir 								TODO
29cdf0e10cSrcweir  **************************************************************************
30cdf0e10cSrcweir 
31cdf0e10cSrcweir  *************************************************************************/
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "osl/diagnose.h"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "com/sun/star/beans/PropertyAttribute.hpp"
36cdf0e10cSrcweir #include "com/sun/star/beans/XPropertyAccess.hpp"
37cdf0e10cSrcweir #include "com/sun/star/lang/IllegalAccessException.hpp"
38cdf0e10cSrcweir #include "com/sun/star/sdbc/XRow.hpp"
39cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandInfo.hpp"
40cdf0e10cSrcweir #include "com/sun/star/ucb/XPersistentPropertySet.hpp"
41cdf0e10cSrcweir #include "ucbhelper/contentidentifier.hxx"
42cdf0e10cSrcweir #include "ucbhelper/propertyvalueset.hxx"
43cdf0e10cSrcweir #include "ucbhelper/cancelcommandexecution.hxx"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include "myucp_content.hxx"
46cdf0e10cSrcweir #include "myucp_provider.hxx"
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_INSERT
49cdf0e10cSrcweir #include "com/sun/star/ucb/InsertCommandArgument.hpp"
50cdf0e10cSrcweir #include "com/sun/star/ucb/MissingInputStreamException.hpp"
51cdf0e10cSrcweir #include "com/sun/star/ucb/MissingPropertiesException.hpp"
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_OPEN
54cdf0e10cSrcweir #include "com/sun/star/io/XOutputStream.hpp"
55cdf0e10cSrcweir #include "com/sun/star/io/XActiveDataSink.hpp"
56cdf0e10cSrcweir #include "com/sun/star/ucb/OpenCommandArgument2.hpp"
57cdf0e10cSrcweir #include "com/sun/star/ucb/OpenMode.hpp"
58cdf0e10cSrcweir #include "com/sun/star/ucb/UnsupportedDataSinkException.hpp"
59cdf0e10cSrcweir #include "com/sun/star/ucb/UnsupportedOpenModeException.hpp"
60cdf0e10cSrcweir #include "myucp_resultset.hxx"
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir 
63cdf0e10cSrcweir using namespace com::sun::star;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // @@@ Adjust namespace name.
66cdf0e10cSrcweir using namespace myucp;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir //=========================================================================
69cdf0e10cSrcweir //=========================================================================
70cdf0e10cSrcweir //
71cdf0e10cSrcweir // Content Implementation.
72cdf0e10cSrcweir //
73cdf0e10cSrcweir //=========================================================================
74cdf0e10cSrcweir //=========================================================================
75cdf0e10cSrcweir 
Content(const uno::Reference<lang::XMultiServiceFactory> & rxSMgr,::ucbhelper::ContentProviderImplHelper * pProvider,const uno::Reference<ucb::XContentIdentifier> & Identifier)76cdf0e10cSrcweir Content::Content( const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
77cdf0e10cSrcweir                   ::ucbhelper::ContentProviderImplHelper* pProvider,
78cdf0e10cSrcweir                   const uno::Reference< ucb::XContentIdentifier >& Identifier )
79cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier )
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	// @@@ Fill m_aProps here or implement lazy evaluation logic for this.
82cdf0e10cSrcweir 	// m_aProps.aTitle       =
83cdf0e10cSrcweir 	// m_aprops.aContentType =
84cdf0e10cSrcweir 	// m_aProps.bIsDocument  =
85cdf0e10cSrcweir 	// m_aProps.bIsFolder    =
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir //=========================================================================
89cdf0e10cSrcweir // virtual
~Content()90cdf0e10cSrcweir Content::~Content()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //=========================================================================
95cdf0e10cSrcweir //
96cdf0e10cSrcweir // XInterface methods.
97cdf0e10cSrcweir //
98cdf0e10cSrcweir //=========================================================================
99cdf0e10cSrcweir 
100cdf0e10cSrcweir // virtual
acquire()101cdf0e10cSrcweir void SAL_CALL Content::acquire()
102cdf0e10cSrcweir     throw()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	ContentImplHelper::acquire();
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //=========================================================================
108cdf0e10cSrcweir // virtual
release()109cdf0e10cSrcweir void SAL_CALL Content::release()
110cdf0e10cSrcweir     throw()
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	ContentImplHelper::release();
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir //=========================================================================
116cdf0e10cSrcweir // virtual
queryInterface(const uno::Type & rType)117cdf0e10cSrcweir uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType )
118cdf0e10cSrcweir     throw ( uno::RuntimeException )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir     uno::Any aRet;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	// @@@ Add support for additional interfaces.
123cdf0e10cSrcweir #if 0
124cdf0e10cSrcweir   	aRet = cppu::queryInterface( rType,
125cdf0e10cSrcweir                                  static_cast< yyy::Xxxxxxxxx * >( this ) );
126cdf0e10cSrcweir #endif
127cdf0e10cSrcweir 
128cdf0e10cSrcweir  	return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface( rType );
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir //=========================================================================
132cdf0e10cSrcweir //
133cdf0e10cSrcweir // XTypeProvider methods.
134cdf0e10cSrcweir //
135cdf0e10cSrcweir //=========================================================================
136cdf0e10cSrcweir 
137cdf0e10cSrcweir XTYPEPROVIDER_COMMON_IMPL( Content );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir //=========================================================================
140cdf0e10cSrcweir // virtual
getTypes()141cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL Content::getTypes()
142cdf0e10cSrcweir     throw( uno::RuntimeException )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir 	// @@@ Add own interfaces.
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     static cppu::OTypeCollection* pCollection = 0;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	if ( !pCollection )
149cdf0e10cSrcweir 	{
150cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
151cdf0e10cSrcweir 	  	if ( !pCollection )
152cdf0e10cSrcweir 	  	{
153cdf0e10cSrcweir             static cppu::OTypeCollection aCollection(
154cdf0e10cSrcweir                 CPPU_TYPE_REF( lang::XTypeProvider ),
155cdf0e10cSrcweir                 CPPU_TYPE_REF( lang::XServiceInfo ),
156cdf0e10cSrcweir                 CPPU_TYPE_REF( lang::XComponent ),
157cdf0e10cSrcweir                 CPPU_TYPE_REF( ucb::XContent ),
158cdf0e10cSrcweir                 CPPU_TYPE_REF( ucb::XCommandProcessor ),
159cdf0e10cSrcweir                 CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ),
160cdf0e10cSrcweir                 CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ),
161cdf0e10cSrcweir                 CPPU_TYPE_REF( beans::XPropertyContainer ),
162cdf0e10cSrcweir                 CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ),
163cdf0e10cSrcweir                 CPPU_TYPE_REF( container::XChild ) );
164cdf0e10cSrcweir 	  		pCollection = &aCollection;
165cdf0e10cSrcweir 		}
166cdf0e10cSrcweir 	}
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	return (*pCollection).getTypes();
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir //=========================================================================
172cdf0e10cSrcweir //
173cdf0e10cSrcweir // XServiceInfo methods.
174cdf0e10cSrcweir //
175cdf0e10cSrcweir //=========================================================================
176cdf0e10cSrcweir 
177cdf0e10cSrcweir // virtual
getImplementationName()178cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getImplementationName()
179cdf0e10cSrcweir     throw( uno::RuntimeException )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     // @@@ Adjust implementation name.
182cdf0e10cSrcweir     // Prefix with reversed company domain name.
183cdf0e10cSrcweir     return rtl::OUString::createFromAscii( "com.sun.star.comp.myucp.Content" );
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir //=========================================================================
187cdf0e10cSrcweir // virtual
getSupportedServiceNames()188cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL Content::getSupportedServiceNames()
189cdf0e10cSrcweir     throw( uno::RuntimeException )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	// @@@ Adjust macro name.
192cdf0e10cSrcweir     uno::Sequence< rtl::OUString > aSNS( 1 );
193cdf0e10cSrcweir 	aSNS.getArray()[ 0 ]
194cdf0e10cSrcweir             = rtl::OUString::createFromAscii( MYUCP_CONTENT_SERVICE_NAME );
195cdf0e10cSrcweir 	return aSNS;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir //=========================================================================
199cdf0e10cSrcweir //
200cdf0e10cSrcweir // XContent methods.
201cdf0e10cSrcweir //
202cdf0e10cSrcweir //=========================================================================
203cdf0e10cSrcweir 
204cdf0e10cSrcweir // virtual
getContentType()205cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getContentType()
206cdf0e10cSrcweir     throw( uno::RuntimeException )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	// @@@ Adjust macro name ( def in myucp_provider.hxx ).
209cdf0e10cSrcweir     return rtl::OUString::createFromAscii( MYUCP_CONTENT_TYPE );
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
212cdf0e10cSrcweir //=========================================================================
213cdf0e10cSrcweir //
214cdf0e10cSrcweir // XCommandProcessor methods.
215cdf0e10cSrcweir //
216cdf0e10cSrcweir //=========================================================================
217cdf0e10cSrcweir 
218cdf0e10cSrcweir // virtual
execute(const ucb::Command & aCommand,sal_Int32,const uno::Reference<ucb::XCommandEnvironment> & Environment)219cdf0e10cSrcweir uno::Any SAL_CALL Content::execute(
220cdf0e10cSrcweir         const ucb::Command& aCommand,
221cdf0e10cSrcweir         sal_Int32 /* CommandId */,
222cdf0e10cSrcweir         const uno::Reference< ucb::XCommandEnvironment >& Environment )
223cdf0e10cSrcweir     throw( uno::Exception,
224cdf0e10cSrcweir            ucb::CommandAbortedException,
225cdf0e10cSrcweir            uno::RuntimeException )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir     uno::Any aRet;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     if ( aCommand.Name.equalsAsciiL(
230cdf0e10cSrcweir 			RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) )
231cdf0e10cSrcweir 	{
232cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
233cdf0e10cSrcweir 		// getPropertyValues
234cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
235cdf0e10cSrcweir 
236cdf0e10cSrcweir         uno::Sequence< beans::Property > Properties;
237cdf0e10cSrcweir 		if ( !( aCommand.Argument >>= Properties ) )
238cdf0e10cSrcweir 		{
239cdf0e10cSrcweir             OSL_ENSURE( sal_False, "Wrong argument type!" );
240cdf0e10cSrcweir             ::ucbhelper::cancelCommandExecution(
241cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
242cdf0e10cSrcweir                                     rtl::OUString(),
243cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
244cdf0e10cSrcweir                                     -1 ) ),
245cdf0e10cSrcweir                 Environment );
246cdf0e10cSrcweir             // Unreachable
247cdf0e10cSrcweir 		}
248cdf0e10cSrcweir 
249cdf0e10cSrcweir         aRet <<= getPropertyValues( Properties, Environment );
250cdf0e10cSrcweir 	}
251cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
252cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "setPropertyValues" ) ) )
253cdf0e10cSrcweir     {
254cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
255cdf0e10cSrcweir 		// setPropertyValues
256cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
257cdf0e10cSrcweir 
258cdf0e10cSrcweir         uno::Sequence< beans::PropertyValue > aProperties;
259cdf0e10cSrcweir 		if ( !( aCommand.Argument >>= aProperties ) )
260cdf0e10cSrcweir 		{
261cdf0e10cSrcweir             OSL_ENSURE( sal_False, "Wrong argument type!" );
262cdf0e10cSrcweir             ::ucbhelper::cancelCommandExecution(
263cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
264cdf0e10cSrcweir                                     rtl::OUString(),
265cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
266cdf0e10cSrcweir                                     -1 ) ),
267cdf0e10cSrcweir                 Environment );
268cdf0e10cSrcweir             // Unreachable
269cdf0e10cSrcweir         }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 		if ( !aProperties.getLength() )
272cdf0e10cSrcweir 		{
273cdf0e10cSrcweir             OSL_ENSURE( sal_False, "No properties!" );
274cdf0e10cSrcweir             ::ucbhelper::cancelCommandExecution(
275cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
276cdf0e10cSrcweir                                     rtl::OUString(),
277cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
278cdf0e10cSrcweir                                     -1 ) ),
279cdf0e10cSrcweir                 Environment );
280cdf0e10cSrcweir             // Unreachable
281cdf0e10cSrcweir         }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir         aRet <<= setPropertyValues( aProperties, Environment );
284cdf0e10cSrcweir 	}
285cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
286cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "getPropertySetInfo" ) ) )
287cdf0e10cSrcweir     {
288cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
289cdf0e10cSrcweir 		// getPropertySetInfo
290cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 		// Note: Implemented by base class.
293cdf0e10cSrcweir 		aRet <<= getPropertySetInfo( Environment );
294cdf0e10cSrcweir 	}
295cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
296cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "getCommandInfo" ) ) )
297cdf0e10cSrcweir     {
298cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
299cdf0e10cSrcweir 		// getCommandInfo
300cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 		// Note: Implemented by base class.
303cdf0e10cSrcweir 		aRet <<= getCommandInfo( Environment );
304cdf0e10cSrcweir 	}
305cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_OPEN
306cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
307cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "open" ) ) )
308cdf0e10cSrcweir     {
309cdf0e10cSrcweir         ucb::OpenCommandArgument2 aOpenCommand;
310cdf0e10cSrcweir       	if ( !( aCommand.Argument >>= aOpenCommand ) )
311cdf0e10cSrcweir 		{
312cdf0e10cSrcweir             OSL_ENSURE( sal_False, "Wrong argument type!" );
313cdf0e10cSrcweir             ::ucbhelper::cancelCommandExecution(
314cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
315cdf0e10cSrcweir                                     rtl::OUString(),
316cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
317cdf0e10cSrcweir                                     -1 ) ),
318cdf0e10cSrcweir                 Environment );
319cdf0e10cSrcweir             // Unreachable
320cdf0e10cSrcweir         }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir         sal_Bool bOpenFolder =
323cdf0e10cSrcweir             ( ( aOpenCommand.Mode == ucb::OpenMode::ALL ) ||
324cdf0e10cSrcweir               ( aOpenCommand.Mode == ucb::OpenMode::FOLDERS ) ||
325cdf0e10cSrcweir               ( aOpenCommand.Mode == ucb::OpenMode::DOCUMENTS ) );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir         if ( bOpenFolder /*&& isFolder( Environment )*/ )
328cdf0e10cSrcweir 		{
329cdf0e10cSrcweir             // open as folder - return result set
330cdf0e10cSrcweir 
331cdf0e10cSrcweir             uno::Reference< ucb::XDynamicResultSet > xSet
332cdf0e10cSrcweir                             = new DynamicResultSet( m_xSMgr,
333cdf0e10cSrcweir 													this,
334cdf0e10cSrcweir 													aOpenCommand,
335cdf0e10cSrcweir 													Environment );
336cdf0e10cSrcweir     		aRet <<= xSet;
337cdf0e10cSrcweir   		}
338cdf0e10cSrcweir 
339cdf0e10cSrcweir         if ( aOpenCommand.Sink.is() )
340cdf0e10cSrcweir         {
341cdf0e10cSrcweir             // Open document - supply document data stream.
342cdf0e10cSrcweir 
343cdf0e10cSrcweir             // Check open mode
344cdf0e10cSrcweir             if ( ( aOpenCommand.Mode
345cdf0e10cSrcweir                     == ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) ||
346cdf0e10cSrcweir                  ( aOpenCommand.Mode
347cdf0e10cSrcweir                     == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE ) )
348cdf0e10cSrcweir             {
349cdf0e10cSrcweir                 // Unsupported.
350cdf0e10cSrcweir                 ::ucbhelper::cancelCommandExecution(
351cdf0e10cSrcweir                     uno::makeAny( ucb::UnsupportedOpenModeException(
352cdf0e10cSrcweir                                     rtl::OUString(),
353cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
354cdf0e10cSrcweir                                     sal_Int16( aOpenCommand.Mode ) ) ),
355cdf0e10cSrcweir                     Environment );
356cdf0e10cSrcweir                 // Unreachable
357cdf0e10cSrcweir             }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 
360cdf0e10cSrcweir             rtl::OUString aURL = m_xIdentifier->getContentIdentifier();
361cdf0e10cSrcweir             uno::Reference< io::XOutputStream > xOut
362cdf0e10cSrcweir                 = uno::Reference< io::XOutputStream >(
363cdf0e10cSrcweir                     aOpenCommand.Sink, uno::UNO_QUERY );
364cdf0e10cSrcweir     		if ( xOut.is() )
365cdf0e10cSrcweir       		{
366cdf0e10cSrcweir 				// @@@ write data into xOut
367cdf0e10cSrcweir       		}
368cdf0e10cSrcweir     		else
369cdf0e10cSrcweir       		{
370cdf0e10cSrcweir                 uno::Reference< io::XActiveDataSink > xDataSink(
371cdf0e10cSrcweir                         aOpenCommand.Sink, uno::UNO_QUERY );
372cdf0e10cSrcweir       			if ( xDataSink.is() )
373cdf0e10cSrcweir 				{
374cdf0e10cSrcweir                     uno::Reference< io::XInputStream > xIn
375cdf0e10cSrcweir 						/* @@@ your XInputStream + XSeekable impl. object */;
376cdf0e10cSrcweir     				xDataSink->setInputStream( xIn );
377cdf0e10cSrcweir 				}
378cdf0e10cSrcweir       			else
379cdf0e10cSrcweir 				{
380cdf0e10cSrcweir                     // Note: aOpenCommand.Sink may contain an XStream
381cdf0e10cSrcweir                     //       implementation. Support for this type of
382cdf0e10cSrcweir                     //       sink is optional...
383cdf0e10cSrcweir                     ::ucbhelper::cancelCommandExecution(
384cdf0e10cSrcweir                         uno::makeAny( ucb::UnsupportedDataSinkException(
385cdf0e10cSrcweir                                 rtl::OUString(),
386cdf0e10cSrcweir                                 static_cast< cppu::OWeakObject * >( this ),
387cdf0e10cSrcweir                                 aOpenCommand.Sink ) ),
388cdf0e10cSrcweir                         Environment );
389cdf0e10cSrcweir                     // Unreachable
390cdf0e10cSrcweir                 }
391cdf0e10cSrcweir 	  		}
392cdf0e10cSrcweir 		}
393cdf0e10cSrcweir 	}
394cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_OPEN
395cdf0e10cSrcweir 
396cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_INSERT
397cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
398cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "insert" ) ) )
399cdf0e10cSrcweir     {
400cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
401cdf0e10cSrcweir 		// insert
402cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
403cdf0e10cSrcweir 
404cdf0e10cSrcweir         ucb::InsertCommandArgument arg;
405cdf0e10cSrcweir       	if ( !( aCommand.Argument >>= arg ) )
406cdf0e10cSrcweir 		{
407cdf0e10cSrcweir 	  		OSL_ENSURE( sal_False, "Wrong argument type!" );
408cdf0e10cSrcweir             ::ucbhelper::cancelCommandExecution(
409cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
410cdf0e10cSrcweir                                     rtl::OUString(),
411cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
412cdf0e10cSrcweir                                     -1 ) ),
413cdf0e10cSrcweir                 Environment );
414cdf0e10cSrcweir             // Unreachable
415cdf0e10cSrcweir 		}
416cdf0e10cSrcweir 
417cdf0e10cSrcweir       	insert( arg.Data, arg.ReplaceExisting, Environment );
418cdf0e10cSrcweir     }
419cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_INSERT
420cdf0e10cSrcweir 
421cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_DELETE
422cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
423cdf0e10cSrcweir 					RTL_CONSTASCII_STRINGPARAM( "delete" ) ) )
424cdf0e10cSrcweir     {
425cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
426cdf0e10cSrcweir 		// delete
427cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 		sal_Bool bDeletePhysical = sal_False;
430cdf0e10cSrcweir 		aCommand.Argument >>= bDeletePhysical;
431cdf0e10cSrcweir 		destroy( bDeletePhysical );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 		// Remove own and all children's Additional Core Properties.
434cdf0e10cSrcweir 		removeAdditionalPropertySet( sal_True );
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 		// Remove own and all childrens(!) persistent data.
437cdf0e10cSrcweir //		removeData();
438cdf0e10cSrcweir 	}
439cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_DELETE
440cdf0e10cSrcweir 	else
441cdf0e10cSrcweir 	{
442cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
443cdf0e10cSrcweir 		// Unsupported command
444cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
445cdf0e10cSrcweir 
446cdf0e10cSrcweir         OSL_ENSURE( sal_False, "Content::execute - unsupported command!" );
447cdf0e10cSrcweir 
448cdf0e10cSrcweir         ::ucbhelper::cancelCommandExecution(
449cdf0e10cSrcweir             uno::makeAny( ucb::UnsupportedCommandException(
450cdf0e10cSrcweir                             rtl::OUString(),
451cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) ) ),
452cdf0e10cSrcweir             Environment );
453cdf0e10cSrcweir         // Unreachable
454cdf0e10cSrcweir     }
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	return aRet;
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
459cdf0e10cSrcweir //=========================================================================
460cdf0e10cSrcweir // virtual
abort(sal_Int32)461cdf0e10cSrcweir void SAL_CALL Content::abort( sal_Int32 )
462cdf0e10cSrcweir     throw( uno::RuntimeException )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir 	// @@@ Implement logic to abort running commands, if this makes
465cdf0e10cSrcweir 	//     sense for your content.
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir //=========================================================================
469cdf0e10cSrcweir //
470cdf0e10cSrcweir // Non-interface methods.
471cdf0e10cSrcweir //
472cdf0e10cSrcweir //=========================================================================
473cdf0e10cSrcweir 
474cdf0e10cSrcweir // virtual
getParentURL()475cdf0e10cSrcweir rtl::OUString Content::getParentURL()
476cdf0e10cSrcweir {
477cdf0e10cSrcweir     rtl::OUString aURL = m_xIdentifier->getContentIdentifier();
478cdf0e10cSrcweir 
479cdf0e10cSrcweir     // @@@ Extract URL of parent from aURL and return it...
480cdf0e10cSrcweir 
481cdf0e10cSrcweir     return rtl::OUString();
482cdf0e10cSrcweir }
483cdf0e10cSrcweir 
484cdf0e10cSrcweir //=========================================================================
485cdf0e10cSrcweir // static
getPropertyValues(const uno::Reference<lang::XMultiServiceFactory> & rSMgr,const uno::Sequence<beans::Property> & rProperties,const ContentProperties & rData,const rtl::Reference<::ucbhelper::ContentProviderImplHelper> & rProvider,const rtl::OUString & rContentId)486cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues(
487cdf0e10cSrcweir             const uno::Reference< lang::XMultiServiceFactory >& rSMgr,
488cdf0e10cSrcweir             const uno::Sequence< beans::Property >& rProperties,
489cdf0e10cSrcweir             const ContentProperties& rData,
490cdf0e10cSrcweir             const rtl::Reference<
491cdf0e10cSrcweir                 ::ucbhelper::ContentProviderImplHelper >& rProvider,
492cdf0e10cSrcweir             const rtl::OUString& rContentId )
493cdf0e10cSrcweir {
494cdf0e10cSrcweir 	// Note: Empty sequence means "get values of all supported properties".
495cdf0e10cSrcweir 
496cdf0e10cSrcweir     rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
497cdf0e10cSrcweir         = new ::ucbhelper::PropertyValueSet( rSMgr );
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 	sal_Int32 nCount = rProperties.getLength();
500cdf0e10cSrcweir 	if ( nCount )
501cdf0e10cSrcweir 	{
502cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xAdditionalPropSet;
503cdf0e10cSrcweir 		sal_Bool bTriedToGetAdditonalPropSet = sal_False;
504cdf0e10cSrcweir 
505cdf0e10cSrcweir         const beans::Property* pProps = rProperties.getConstArray();
506cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
507cdf0e10cSrcweir 		{
508cdf0e10cSrcweir             const beans::Property& rProp = pProps[ n ];
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 			// Process Core properties.
511cdf0e10cSrcweir 
512cdf0e10cSrcweir             if ( rProp.Name.equalsAsciiL(
513cdf0e10cSrcweir 					RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
514cdf0e10cSrcweir             {
515cdf0e10cSrcweir 				xRow->appendString ( rProp, rData.aContentType );
516cdf0e10cSrcweir 			}
517cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL(
518cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
519cdf0e10cSrcweir 			{
520cdf0e10cSrcweir 				xRow->appendString ( rProp, rData.aTitle );
521cdf0e10cSrcweir 			}
522cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL(
523cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
524cdf0e10cSrcweir 			{
525cdf0e10cSrcweir 				xRow->appendBoolean( rProp, rData.bIsDocument );
526cdf0e10cSrcweir 			}
527cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL(
528cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
529cdf0e10cSrcweir 			{
530cdf0e10cSrcweir 				xRow->appendBoolean( rProp, rData.bIsFolder );
531cdf0e10cSrcweir 			}
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 			// @@@ Process other properties supported directly.
534cdf0e10cSrcweir #if 0
535cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL(
536cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
537cdf0e10cSrcweir 			{
538cdf0e10cSrcweir 			}
539cdf0e10cSrcweir #endif
540cdf0e10cSrcweir 			else
541cdf0e10cSrcweir 			{
542cdf0e10cSrcweir 				// @@@ Note: If your data source supports adding/removing
543cdf0e10cSrcweir 				//     properties, you should implement the interface
544cdf0e10cSrcweir 				//     XPropertyContainer by yourself and supply your own
545cdf0e10cSrcweir 				//     logic here. The base class uses the service
546cdf0e10cSrcweir 				//     "com.sun.star.ucb.Store" to maintain Additional Core
547cdf0e10cSrcweir 				//     properties. But using server functionality is preferred!
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 				// Not a Core Property! Maybe it's an Additional Core Property?!
550cdf0e10cSrcweir 
551cdf0e10cSrcweir 				if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() )
552cdf0e10cSrcweir 				{
553cdf0e10cSrcweir 					xAdditionalPropSet
554cdf0e10cSrcweir                         = uno::Reference< beans::XPropertySet >(
555cdf0e10cSrcweir 							rProvider->getAdditionalPropertySet( rContentId,
556cdf0e10cSrcweir 																 sal_False ),
557cdf0e10cSrcweir                             uno::UNO_QUERY );
558cdf0e10cSrcweir 					bTriedToGetAdditonalPropSet = sal_True;
559cdf0e10cSrcweir 				}
560cdf0e10cSrcweir 
561cdf0e10cSrcweir 				if ( xAdditionalPropSet.is() )
562cdf0e10cSrcweir 				{
563cdf0e10cSrcweir 					if ( !xRow->appendPropertySetValue(
564cdf0e10cSrcweir 												xAdditionalPropSet,
565cdf0e10cSrcweir 												rProp ) )
566cdf0e10cSrcweir 					{
567cdf0e10cSrcweir 						// Append empty entry.
568cdf0e10cSrcweir 						xRow->appendVoid( rProp );
569cdf0e10cSrcweir 					}
570cdf0e10cSrcweir 				}
571cdf0e10cSrcweir 				else
572cdf0e10cSrcweir 				{
573cdf0e10cSrcweir 					// Append empty entry.
574cdf0e10cSrcweir 					xRow->appendVoid( rProp );
575cdf0e10cSrcweir 				}
576cdf0e10cSrcweir 			}
577cdf0e10cSrcweir 		}
578cdf0e10cSrcweir 	}
579cdf0e10cSrcweir 	else
580cdf0e10cSrcweir 	{
581cdf0e10cSrcweir 		// Append all Core Properties.
582cdf0e10cSrcweir 		xRow->appendString (
583cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "ContentType" ),
584cdf0e10cSrcweir 					  -1,
585cdf0e10cSrcweir                       getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
586cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND
587cdf0e10cSrcweir                         | beans::PropertyAttribute::READONLY ),
588cdf0e10cSrcweir 			rData.aContentType );
589cdf0e10cSrcweir 		xRow->appendString (
590cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "Title" ),
591cdf0e10cSrcweir 					  -1,
592cdf0e10cSrcweir                       getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
593cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND ),
594cdf0e10cSrcweir 			rData.aTitle );
595cdf0e10cSrcweir 		xRow->appendBoolean(
596cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "IsDocument" ),
597cdf0e10cSrcweir 					  -1,
598cdf0e10cSrcweir 					  getCppuBooleanType(),
599cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND
600cdf0e10cSrcweir                         | beans::PropertyAttribute::READONLY ),
601cdf0e10cSrcweir 			rData.bIsDocument );
602cdf0e10cSrcweir 		xRow->appendBoolean(
603cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "IsFolder" ),
604cdf0e10cSrcweir 					  -1,
605cdf0e10cSrcweir 					  getCppuBooleanType(),
606cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND
607cdf0e10cSrcweir                         | beans::PropertyAttribute::READONLY ),
608cdf0e10cSrcweir 			rData.bIsFolder );
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 		// @@@ Append other properties supported directly.
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 		// @@@ Note: If your data source supports adding/removing
613cdf0e10cSrcweir 		//     properties, you should implement the interface
614cdf0e10cSrcweir 		//     XPropertyContainer by yourself and supply your own
615cdf0e10cSrcweir 		//     logic here. The base class uses the service
616cdf0e10cSrcweir 		//     "com.sun.star.ucb.Store" to maintain Additional Core
617cdf0e10cSrcweir 		//     properties. But using server functionality is preferred!
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 		// Append all Additional Core Properties.
620cdf0e10cSrcweir 
621cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xSet(
622cdf0e10cSrcweir 			rProvider->getAdditionalPropertySet( rContentId, sal_False ),
623cdf0e10cSrcweir             uno::UNO_QUERY );
624cdf0e10cSrcweir 		xRow->appendPropertySet( xSet );
625cdf0e10cSrcweir 	}
626cdf0e10cSrcweir 
627cdf0e10cSrcweir     return uno::Reference< sdbc::XRow >( xRow.get() );
628cdf0e10cSrcweir }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir //=========================================================================
getPropertyValues(const uno::Sequence<beans::Property> & rProperties,const uno::Reference<ucb::XCommandEnvironment> &)631cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues(
632cdf0e10cSrcweir             const uno::Sequence< beans::Property >& rProperties,
633cdf0e10cSrcweir             const uno::Reference< ucb::XCommandEnvironment >& /* xEnv */)
634cdf0e10cSrcweir {
635cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
636cdf0e10cSrcweir 	return getPropertyValues( m_xSMgr,
637cdf0e10cSrcweir 							  rProperties,
638cdf0e10cSrcweir 							  m_aProps,
639cdf0e10cSrcweir                               rtl::Reference<
640cdf0e10cSrcweir                                 ::ucbhelper::ContentProviderImplHelper >(
641cdf0e10cSrcweir                                     m_xProvider.get() ),
642cdf0e10cSrcweir 							  m_xIdentifier->getContentIdentifier() );
643cdf0e10cSrcweir }
644cdf0e10cSrcweir 
645cdf0e10cSrcweir //=========================================================================
setPropertyValues(const uno::Sequence<beans::PropertyValue> & rValues,const uno::Reference<ucb::XCommandEnvironment> &)646cdf0e10cSrcweir uno::Sequence< uno::Any > Content::setPropertyValues(
647cdf0e10cSrcweir             const uno::Sequence< beans::PropertyValue >& rValues,
648cdf0e10cSrcweir             const uno::Reference< ucb::XCommandEnvironment >& /* xEnv */)
649cdf0e10cSrcweir {
650cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
651cdf0e10cSrcweir 
652cdf0e10cSrcweir     uno::Sequence< uno::Any > aRet( rValues.getLength() );
653cdf0e10cSrcweir     uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() );
654cdf0e10cSrcweir 	sal_Int32 nChanged = 0;
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     beans::PropertyChangeEvent aEvent;
657cdf0e10cSrcweir     aEvent.Source         = static_cast< cppu::OWeakObject * >( this );
658cdf0e10cSrcweir 	aEvent.Further 		  = sal_False;
659cdf0e10cSrcweir //	aEvent.PropertyName	  =
660cdf0e10cSrcweir 	aEvent.PropertyHandle = -1;
661cdf0e10cSrcweir //	aEvent.OldValue		  =
662cdf0e10cSrcweir //	aEvent.NewValue       =
663cdf0e10cSrcweir 
664cdf0e10cSrcweir     const beans::PropertyValue* pValues = rValues.getConstArray();
665cdf0e10cSrcweir 	sal_Int32 nCount = rValues.getLength();
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     uno::Reference< ucb::XPersistentPropertySet > xAdditionalPropSet;
668cdf0e10cSrcweir 	sal_Bool bTriedToGetAdditonalPropSet = sal_False;
669cdf0e10cSrcweir 
670cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < nCount; ++n )
671cdf0e10cSrcweir 	{
672cdf0e10cSrcweir         const beans::PropertyValue& rValue = pValues[ n ];
673cdf0e10cSrcweir 
674cdf0e10cSrcweir         if ( rValue.Name.equalsAsciiL(
675cdf0e10cSrcweir                         RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
676cdf0e10cSrcweir         {
677cdf0e10cSrcweir 			// Read-only property!
678cdf0e10cSrcweir             aRet[ n ] <<= lang::IllegalAccessException(
679cdf0e10cSrcweir                             rtl::OUString::createFromAscii(
680cdf0e10cSrcweir                                 "Property is read-only!" ),
681cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) );
682cdf0e10cSrcweir 		}
683cdf0e10cSrcweir         else if ( rValue.Name.equalsAsciiL(
684cdf0e10cSrcweir                         RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
685cdf0e10cSrcweir 		{
686cdf0e10cSrcweir 			// Read-only property!
687cdf0e10cSrcweir             aRet[ n ] <<= lang::IllegalAccessException(
688cdf0e10cSrcweir                             rtl::OUString::createFromAscii(
689cdf0e10cSrcweir                                 "Property is read-only!" ),
690cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) );
691cdf0e10cSrcweir 		}
692cdf0e10cSrcweir         else if ( rValue.Name.equalsAsciiL(
693cdf0e10cSrcweir                         RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
694cdf0e10cSrcweir 		{
695cdf0e10cSrcweir 			// Read-only property!
696cdf0e10cSrcweir             aRet[ n ] <<= lang::IllegalAccessException(
697cdf0e10cSrcweir                             rtl::OUString::createFromAscii(
698cdf0e10cSrcweir                                 "Property is read-only!" ),
699cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) );
700cdf0e10cSrcweir 		}
701cdf0e10cSrcweir         else if ( rValue.Name.equalsAsciiL(
702cdf0e10cSrcweir                         RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
703cdf0e10cSrcweir 		{
704cdf0e10cSrcweir             rtl::OUString aNewValue;
705cdf0e10cSrcweir 			if ( rValue.Value >>= aNewValue )
706cdf0e10cSrcweir 			{
707cdf0e10cSrcweir 				if ( aNewValue != m_aProps.aTitle )
708cdf0e10cSrcweir 				{
709cdf0e10cSrcweir 					aEvent.PropertyName = rValue.Name;
710cdf0e10cSrcweir                     aEvent.OldValue     = uno::makeAny( m_aProps.aTitle );
711cdf0e10cSrcweir                     aEvent.NewValue     = uno::makeAny( aNewValue );
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 					aChanges.getArray()[ nChanged ] = aEvent;
714cdf0e10cSrcweir 
715cdf0e10cSrcweir 					m_aProps.aTitle = aNewValue;
716cdf0e10cSrcweir 					nChanged++;
717cdf0e10cSrcweir 				}
718cdf0e10cSrcweir                 else
719cdf0e10cSrcweir                 {
720cdf0e10cSrcweir                     // Old value equals new value. No error!
721cdf0e10cSrcweir                 }
722cdf0e10cSrcweir 			}
723cdf0e10cSrcweir             else
724cdf0e10cSrcweir             {
725cdf0e10cSrcweir                 aRet[ n ] <<= beans::IllegalTypeException(
726cdf0e10cSrcweir                                 rtl::OUString::createFromAscii(
727cdf0e10cSrcweir                                     "Property value has wrong type!" ),
728cdf0e10cSrcweir                                 static_cast< cppu::OWeakObject * >( this ) );
729cdf0e10cSrcweir             }
730cdf0e10cSrcweir 		}
731cdf0e10cSrcweir 
732cdf0e10cSrcweir 		// @@@ Process other properties supported directly.
733cdf0e10cSrcweir #if 0
734cdf0e10cSrcweir         else if ( rValue.Name.equalsAsciiL(
735cdf0e10cSrcweir                         RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) )
736cdf0e10cSrcweir 		{
737cdf0e10cSrcweir 		}
738cdf0e10cSrcweir #endif
739cdf0e10cSrcweir 		else
740cdf0e10cSrcweir 		{
741cdf0e10cSrcweir 			// @@@ Note: If your data source supports adding/removing
742cdf0e10cSrcweir 			//     properties, you should implement the interface
743cdf0e10cSrcweir 			//     XPropertyContainer by yourself and supply your own
744cdf0e10cSrcweir 			//     logic here. The base class uses the service
745cdf0e10cSrcweir 			//     "com.sun.star.ucb.Store" to maintain Additional Core
746cdf0e10cSrcweir 			//     properties. But using server functionality is preferred!
747cdf0e10cSrcweir 
748cdf0e10cSrcweir 			// Not a Core Property! Maybe it's an Additional Core Property?!
749cdf0e10cSrcweir 
750cdf0e10cSrcweir 			if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() )
751cdf0e10cSrcweir 			{
752cdf0e10cSrcweir 				xAdditionalPropSet = getAdditionalPropertySet( sal_False );
753cdf0e10cSrcweir 				bTriedToGetAdditonalPropSet = sal_True;
754cdf0e10cSrcweir 			}
755cdf0e10cSrcweir 
756cdf0e10cSrcweir 			if ( xAdditionalPropSet.is() )
757cdf0e10cSrcweir 			{
758cdf0e10cSrcweir 				try
759cdf0e10cSrcweir 				{
760cdf0e10cSrcweir                     uno::Any aOldValue
761cdf0e10cSrcweir                         = xAdditionalPropSet->getPropertyValue( rValue.Name );
762cdf0e10cSrcweir 					if ( aOldValue != rValue.Value )
763cdf0e10cSrcweir 					{
764cdf0e10cSrcweir 						xAdditionalPropSet->setPropertyValue(
765cdf0e10cSrcweir 												rValue.Name, rValue.Value );
766cdf0e10cSrcweir 
767cdf0e10cSrcweir 						aEvent.PropertyName = rValue.Name;
768cdf0e10cSrcweir 						aEvent.OldValue		= aOldValue;
769cdf0e10cSrcweir 						aEvent.NewValue     = rValue.Value;
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 						aChanges.getArray()[ nChanged ] = aEvent;
772cdf0e10cSrcweir 						nChanged++;
773cdf0e10cSrcweir 					}
774cdf0e10cSrcweir                     else
775cdf0e10cSrcweir                     {
776cdf0e10cSrcweir                         // Old value equals new value. No error!
777cdf0e10cSrcweir                     }
778cdf0e10cSrcweir 				}
779cdf0e10cSrcweir                 catch ( beans::UnknownPropertyException const & e )
780cdf0e10cSrcweir 				{
781cdf0e10cSrcweir                     aRet[ n ] <<= e;
782cdf0e10cSrcweir 				}
783cdf0e10cSrcweir                 catch ( lang::WrappedTargetException const & e )
784cdf0e10cSrcweir 				{
785cdf0e10cSrcweir                     aRet[ n ] <<= e;
786cdf0e10cSrcweir 				}
787cdf0e10cSrcweir                 catch ( beans::PropertyVetoException const & e )
788cdf0e10cSrcweir 				{
789cdf0e10cSrcweir                     aRet[ n ] <<= e;
790cdf0e10cSrcweir 				}
791cdf0e10cSrcweir                 catch ( lang::IllegalArgumentException const & e )
792cdf0e10cSrcweir 				{
793cdf0e10cSrcweir                     aRet[ n ] <<= e;
794cdf0e10cSrcweir 				}
795cdf0e10cSrcweir 			}
796cdf0e10cSrcweir             else
797cdf0e10cSrcweir             {
798cdf0e10cSrcweir                 aRet[ n ] <<= uno::Exception(
799cdf0e10cSrcweir                                 rtl::OUString::createFromAscii(
800cdf0e10cSrcweir                                     "No property set for storing the value!" ),
801cdf0e10cSrcweir                                 static_cast< cppu::OWeakObject * >( this ) );
802cdf0e10cSrcweir             }
803cdf0e10cSrcweir 		}
804cdf0e10cSrcweir 	}
805cdf0e10cSrcweir 
806cdf0e10cSrcweir 	if ( nChanged > 0 )
807cdf0e10cSrcweir 	{
808cdf0e10cSrcweir 		// @@@ Save changes.
809cdf0e10cSrcweir //		storeData();
810cdf0e10cSrcweir 
811cdf0e10cSrcweir 		aGuard.clear();
812cdf0e10cSrcweir 		aChanges.realloc( nChanged );
813cdf0e10cSrcweir 		notifyPropertiesChange( aChanges );
814cdf0e10cSrcweir 	}
815cdf0e10cSrcweir 
816cdf0e10cSrcweir     return aRet;
817cdf0e10cSrcweir }
818cdf0e10cSrcweir 
819cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_INSERT
820cdf0e10cSrcweir 
821cdf0e10cSrcweir //=========================================================================
queryChildren(ContentRefList & rChildren)822cdf0e10cSrcweir void Content::queryChildren( ContentRefList& rChildren )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir 	// @@@ Adapt method to your URL scheme...
825cdf0e10cSrcweir 
826cdf0e10cSrcweir 	// Obtain a list with a snapshot of all currently instanciated contents
827cdf0e10cSrcweir 	// from provider and extract the contents which are direct children
828cdf0e10cSrcweir 	// of this content.
829cdf0e10cSrcweir 
830cdf0e10cSrcweir 	::ucbhelper::ContentRefList aAllContents;
831cdf0e10cSrcweir 	m_xProvider->queryExistingContents( aAllContents );
832cdf0e10cSrcweir 
833cdf0e10cSrcweir 	::rtl::OUString aURL = m_xIdentifier->getContentIdentifier();
834cdf0e10cSrcweir 	sal_Int32 nPos = aURL.lastIndexOf( '/' );
835cdf0e10cSrcweir 
836cdf0e10cSrcweir 	if ( nPos != ( aURL.getLength() - 1 ) )
837cdf0e10cSrcweir 	{
838cdf0e10cSrcweir 		// No trailing slash found. Append.
839cdf0e10cSrcweir 		aURL += ::rtl::OUString::createFromAscii( "/" );
840cdf0e10cSrcweir 	}
841cdf0e10cSrcweir 
842cdf0e10cSrcweir 	sal_Int32 nLen = aURL.getLength();
843cdf0e10cSrcweir 
844cdf0e10cSrcweir 	::ucbhelper::ContentRefList::const_iterator it  = aAllContents.begin();
845cdf0e10cSrcweir 	::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 	while ( it != end )
848cdf0e10cSrcweir 	{
849cdf0e10cSrcweir 		::ucbhelper::ContentImplHelperRef xChild = (*it);
850cdf0e10cSrcweir 		::rtl::OUString aChildURL
851cdf0e10cSrcweir               = xChild->getIdentifier()->getContentIdentifier();
852cdf0e10cSrcweir 
853cdf0e10cSrcweir 		// Is aURL a prefix of aChildURL?
854cdf0e10cSrcweir 		if ( ( aChildURL.getLength() > nLen ) &&
855cdf0e10cSrcweir 			 ( aChildURL.compareTo( aURL, nLen ) == 0 ) )
856cdf0e10cSrcweir 		{
857cdf0e10cSrcweir 			nPos = aChildURL.indexOf( '/', nLen );
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 			if ( ( nPos == -1 ) ||
860cdf0e10cSrcweir 				 ( nPos == ( aChildURL.getLength() - 1 ) ) )
861cdf0e10cSrcweir 			{
862cdf0e10cSrcweir 				// No further slashes / only a final slash. It's a child!
863cdf0e10cSrcweir 				rChildren.push_back(
864cdf0e10cSrcweir 					ContentRef(
865cdf0e10cSrcweir 						static_cast< Content * >( xChild.get() ) ) );
866cdf0e10cSrcweir 			}
867cdf0e10cSrcweir 		}
868cdf0e10cSrcweir 		++it;
869cdf0e10cSrcweir 	}
870cdf0e10cSrcweir }
871cdf0e10cSrcweir 
872cdf0e10cSrcweir //=========================================================================
insert(const uno::Reference<io::XInputStream> & xInputStream,sal_Bool bReplaceExisting,const uno::Reference<ucb::XCommandEnvironment> & Environment)873cdf0e10cSrcweir void Content::insert(
874cdf0e10cSrcweir         const uno::Reference< io::XInputStream > & xInputStream,
875cdf0e10cSrcweir         sal_Bool bReplaceExisting,
876cdf0e10cSrcweir         const uno::Reference< ucb::XCommandEnvironment >& Environment )
877cdf0e10cSrcweir     throw( uno::Exception )
878cdf0e10cSrcweir {
879cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 	// Check, if all required properties were set.
882cdf0e10cSrcweir 
883cdf0e10cSrcweir #if 0
884cdf0e10cSrcweir     // @@@ add checks for property presence
885cdf0e10cSrcweir 	if ( m_aProps.xxxx == yyyyy )
886cdf0e10cSrcweir 	{
887cdf0e10cSrcweir         OSL_ENSURE( sal_False, "Content::insert - property value missing!" );
888cdf0e10cSrcweir 
889cdf0e10cSrcweir         uno::Sequence< rtl::OUString > aProps( 1 );
890cdf0e10cSrcweir         aProps[ 0 ] = rtl::OUString::createFromAscii( "zzzz" );
891cdf0e10cSrcweir         ::ucbhelper::cancelCommandExecution(
892cdf0e10cSrcweir             uno::makeAny( ucb::MissingPropertiesException(
893cdf0e10cSrcweir                                 rtl::OUString(),
894cdf0e10cSrcweir                                 static_cast< cppu::OWeakObject * >( this ),
895cdf0e10cSrcweir                                 aProps ) ),
896cdf0e10cSrcweir             Environment );
897cdf0e10cSrcweir         // Unreachable
898cdf0e10cSrcweir 	}
899cdf0e10cSrcweir #endif
900cdf0e10cSrcweir 
901cdf0e10cSrcweir     bool bNeedInputStream = true; // @@@ adjust to real requirements
902cdf0e10cSrcweir     if ( bNeedInputStream && !xInputStream.is() )
903cdf0e10cSrcweir     {
904cdf0e10cSrcweir         OSL_ENSURE( sal_False, "Content::insert - No data stream!" );
905cdf0e10cSrcweir 
906cdf0e10cSrcweir         ::ucbhelper::cancelCommandExecution(
907cdf0e10cSrcweir             uno::makeAny( ucb::MissingInputStreamException(
908cdf0e10cSrcweir                             rtl::OUString(),
909cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) ) ),
910cdf0e10cSrcweir             Environment );
911cdf0e10cSrcweir         // Unreachable
912cdf0e10cSrcweir     }
913cdf0e10cSrcweir 
914cdf0e10cSrcweir 	// Assemble new content identifier...
915cdf0e10cSrcweir 
916cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifier > xId /* @@@ create content identifier */;
917cdf0e10cSrcweir 
918cdf0e10cSrcweir     // Fail, if a resource with given id already exists.
919cdf0e10cSrcweir     if ( !bReplaceExisting /*&& hasData( xId ) @@@ impl for hasData() */ )
920cdf0e10cSrcweir     {
921cdf0e10cSrcweir         uno::Any aProps
922cdf0e10cSrcweir             = uno::makeAny( beans::PropertyValue(
923cdf0e10cSrcweir                                   rtl::OUString(
924cdf0e10cSrcweir                                       RTL_CONSTASCII_USTRINGPARAM( "Uri" ) ),
925cdf0e10cSrcweir                                   -1,
926cdf0e10cSrcweir                                   uno::makeAny( xId->getContentIdentifier() ),
927cdf0e10cSrcweir                                   beans::PropertyState_DIRECT_VALUE ) );
928cdf0e10cSrcweir         ucbhelper::cancelCommandExecution(
929cdf0e10cSrcweir             ucb::IOErrorCode_ALREADY_EXISTING,
930cdf0e10cSrcweir             uno::Sequence< uno::Any >(&aProps, 1),
931cdf0e10cSrcweir             Environment,
932cdf0e10cSrcweir             rtl::OUString::createFromAscii( "content already existing!!" ),
933cdf0e10cSrcweir             this );
934cdf0e10cSrcweir         // Unreachable
935cdf0e10cSrcweir     }
936cdf0e10cSrcweir 
937cdf0e10cSrcweir 	m_xIdentifier = xId;
938cdf0e10cSrcweir 
939cdf0e10cSrcweir //  @@@
940cdf0e10cSrcweir //	storeData();
941cdf0e10cSrcweir 
942cdf0e10cSrcweir 	aGuard.clear();
943cdf0e10cSrcweir 	inserted();
944cdf0e10cSrcweir }
945cdf0e10cSrcweir 
946cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_INSERT
947cdf0e10cSrcweir 
948cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_DELETE
949cdf0e10cSrcweir 
950cdf0e10cSrcweir //=========================================================================
destroy(sal_Bool bDeletePhysical)951cdf0e10cSrcweir void Content::destroy( sal_Bool bDeletePhysical )
952cdf0e10cSrcweir     throw( uno::Exception )
953cdf0e10cSrcweir {
954cdf0e10cSrcweir 	// @@@ take care about bDeletePhysical -> trashcan support
955cdf0e10cSrcweir 
956cdf0e10cSrcweir     uno::Reference< ucb::XContent > xThis = this;
957cdf0e10cSrcweir 
958cdf0e10cSrcweir 	deleted();
959cdf0e10cSrcweir 
960cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
961cdf0e10cSrcweir 
962cdf0e10cSrcweir 	// Process instanciated children...
963cdf0e10cSrcweir 
964cdf0e10cSrcweir 	ContentRefList aChildren;
965cdf0e10cSrcweir 	queryChildren( aChildren );
966cdf0e10cSrcweir 
967cdf0e10cSrcweir 	ContentRefList::const_iterator it  = aChildren.begin();
968cdf0e10cSrcweir 	ContentRefList::const_iterator end = aChildren.end();
969cdf0e10cSrcweir 
970cdf0e10cSrcweir 	while ( it != end )
971cdf0e10cSrcweir 	{
972cdf0e10cSrcweir 		(*it)->destroy( bDeletePhysical );
973cdf0e10cSrcweir 		++it;
974cdf0e10cSrcweir 	}
975cdf0e10cSrcweir }
976cdf0e10cSrcweir 
977cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_DELETE
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 
980