xref: /trunk/main/ucb/source/ucp/odma/odma_content.cxx (revision 86e1cf34)
12f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32f86921cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42f86921cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52f86921cSAndrew Rist  * distributed with this work for additional information
62f86921cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72f86921cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
82f86921cSAndrew Rist  * "License"); you may not use this file except in compliance
92f86921cSAndrew Rist  * with the License.  You may obtain a copy of the License at
102f86921cSAndrew Rist  *
112f86921cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122f86921cSAndrew Rist  *
132f86921cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
142f86921cSAndrew Rist  * software distributed under the License is distributed on an
152f86921cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162f86921cSAndrew Rist  * KIND, either express or implied.  See the License for the
172f86921cSAndrew Rist  * specific language governing permissions and limitations
182f86921cSAndrew Rist  * under the License.
192f86921cSAndrew Rist  *
202f86921cSAndrew Rist  *************************************************************/
212f86921cSAndrew Rist 
222f86921cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_ucb.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /**************************************************************************
28cdf0e10cSrcweir 								TODO
29cdf0e10cSrcweir  **************************************************************************
30cdf0e10cSrcweir 
31cdf0e10cSrcweir  *************************************************************************/
32cdf0e10cSrcweir #include <osl/diagnose.h>
33cdf0e10cSrcweir #include "odma_contentprops.hxx"
34cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp>
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/ucb/UnsupportedDataSinkException.hpp>
39cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
40cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
41cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp>
42cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
43cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
44cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandInfo.hpp>
45cdf0e10cSrcweir #include <com/sun/star/ucb/XPersistentPropertySet.hpp>
46cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
47cdf0e10cSrcweir #include <ucbhelper/propertyvalueset.hxx>
48cdf0e10cSrcweir #include <ucbhelper/cancelcommandexecution.hxx>
49cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
50cdf0e10cSrcweir #include <com/sun/star/ucb/MissingInputStreamException.hpp>
51cdf0e10cSrcweir #include <com/sun/star/ucb/InsertCommandArgument.hpp>
52cdf0e10cSrcweir #include <com/sun/star/ucb/MissingPropertiesException.hpp>
53cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataStreamer.hpp>
54cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp>
55cdf0e10cSrcweir #include <com/sun/star/ucb/NameClash.hpp>
56cdf0e10cSrcweir #include "odma_content.hxx"
57cdf0e10cSrcweir #include "odma_provider.hxx"
58cdf0e10cSrcweir #include "odma_resultset.hxx"
59cdf0e10cSrcweir #include "odma_inputstream.hxx"
60cdf0e10cSrcweir #include <ucbhelper/content.hxx>
61cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp>
62cdf0e10cSrcweir #include <rtl/ref.hxx>
63cdf0e10cSrcweir #include <osl/file.hxx>
64cdf0e10cSrcweir 
65cdf0e10cSrcweir using namespace com::sun::star;
66cdf0e10cSrcweir using namespace odma;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir //=========================================================================
69cdf0e10cSrcweir //=========================================================================
70cdf0e10cSrcweir //
71cdf0e10cSrcweir // Content Implementation.
72cdf0e10cSrcweir //
73cdf0e10cSrcweir //=========================================================================
74cdf0e10cSrcweir //=========================================================================
75cdf0e10cSrcweir 
Content(const uno::Reference<lang::XMultiServiceFactory> & rxSMgr,ContentProvider * pProvider,const uno::Reference<ucb::XContentIdentifier> & Identifier,const::rtl::Reference<ContentProperties> & _rProps)76cdf0e10cSrcweir Content::Content( const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
77cdf0e10cSrcweir                   ContentProvider* pProvider,
78cdf0e10cSrcweir                   const uno::Reference< ucb::XContentIdentifier >& Identifier,
79cdf0e10cSrcweir 				  const ::rtl::Reference<ContentProperties>& _rProps)
80cdf0e10cSrcweir 	: ContentImplHelper( rxSMgr, pProvider, Identifier )
81cdf0e10cSrcweir 	,m_aProps(_rProps)
82cdf0e10cSrcweir 	,m_pProvider(pProvider)
83cdf0e10cSrcweir 	,m_pContent(NULL)
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	OSL_ENSURE(m_aProps.is(),"No valid ContentPropeties!");
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir //=========================================================================
89cdf0e10cSrcweir // virtual
~Content()90cdf0e10cSrcweir Content::~Content()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	delete m_pContent;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir //=========================================================================
96cdf0e10cSrcweir //
97cdf0e10cSrcweir // XInterface methods.
98cdf0e10cSrcweir //
99cdf0e10cSrcweir //=========================================================================
100cdf0e10cSrcweir 
101cdf0e10cSrcweir // virtual
acquire()102cdf0e10cSrcweir void SAL_CALL Content::acquire() throw()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	ContentImplHelper::acquire();
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //=========================================================================
108cdf0e10cSrcweir // virtual
release()109cdf0e10cSrcweir void SAL_CALL Content::release() throw()
110cdf0e10cSrcweir {
111cdf0e10cSrcweir 	ContentImplHelper::release();
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir //=========================================================================
115cdf0e10cSrcweir // virtual
queryInterface(const uno::Type & rType)116cdf0e10cSrcweir uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType )
117cdf0e10cSrcweir     throw ( uno::RuntimeException )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir     uno::Any aRet;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	// @@@ Add support for additional interfaces.
122cdf0e10cSrcweir #if 0
123cdf0e10cSrcweir   	aRet = cppu::queryInterface( rType,
124cdf0e10cSrcweir                                  static_cast< yyy::Xxxxxxxxx * >( this ) );
125cdf0e10cSrcweir #endif
126cdf0e10cSrcweir 
127cdf0e10cSrcweir  	return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface( rType );
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir //=========================================================================
131cdf0e10cSrcweir //
132cdf0e10cSrcweir // XTypeProvider methods.
133cdf0e10cSrcweir //
134cdf0e10cSrcweir //=========================================================================
135cdf0e10cSrcweir 
136cdf0e10cSrcweir XTYPEPROVIDER_COMMON_IMPL( Content );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir //=========================================================================
139cdf0e10cSrcweir // virtual
getTypes()140cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL Content::getTypes()
141cdf0e10cSrcweir     throw( uno::RuntimeException )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir 	// @@@ Add own interfaces.
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     static cppu::OTypeCollection* pCollection = 0;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	if ( !pCollection )
148cdf0e10cSrcweir 	{
149cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
150cdf0e10cSrcweir 	  	if ( !pCollection )
151cdf0e10cSrcweir 	  	{
152cdf0e10cSrcweir             static cppu::OTypeCollection aCollection(
153cdf0e10cSrcweir                 CPPU_TYPE_REF( lang::XTypeProvider ),
154cdf0e10cSrcweir                 CPPU_TYPE_REF( lang::XServiceInfo ),
155cdf0e10cSrcweir                 CPPU_TYPE_REF( lang::XComponent ),
156cdf0e10cSrcweir                 CPPU_TYPE_REF( ucb::XContent ),
157cdf0e10cSrcweir                 CPPU_TYPE_REF( ucb::XCommandProcessor ),
158cdf0e10cSrcweir                 CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ),
159cdf0e10cSrcweir                 CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ),
160cdf0e10cSrcweir                 CPPU_TYPE_REF( beans::XPropertyContainer ),
161cdf0e10cSrcweir                 CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ),
162cdf0e10cSrcweir                 CPPU_TYPE_REF( container::XChild ) );
163cdf0e10cSrcweir 	  		pCollection = &aCollection;
164cdf0e10cSrcweir 		}
165cdf0e10cSrcweir 	}
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	return (*pCollection).getTypes();
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir //=========================================================================
171cdf0e10cSrcweir //
172cdf0e10cSrcweir // XServiceInfo methods.
173cdf0e10cSrcweir //
174cdf0e10cSrcweir //=========================================================================
175cdf0e10cSrcweir 
176cdf0e10cSrcweir // virtual
getImplementationName()177cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getImplementationName()
178cdf0e10cSrcweir     throw( uno::RuntimeException )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir     // @@@ Adjust implementation name. Keep the prefix "com.sun.star.comp."!
181cdf0e10cSrcweir     return rtl::OUString::createFromAscii( "com.sun.star.comp.odma.Content" );
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir //=========================================================================
185cdf0e10cSrcweir // virtual
getSupportedServiceNames()186cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL Content::getSupportedServiceNames()
187cdf0e10cSrcweir     throw( uno::RuntimeException )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir 	// @@@ Adjust macro name.
190cdf0e10cSrcweir     uno::Sequence< rtl::OUString > aSNS( 1 );
191cdf0e10cSrcweir 	aSNS.getArray()[ 0 ]
192cdf0e10cSrcweir             = rtl::OUString::createFromAscii( ODMA_CONTENT_SERVICE_NAME );
193cdf0e10cSrcweir 	return aSNS;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir 
196cdf0e10cSrcweir //=========================================================================
197cdf0e10cSrcweir //
198cdf0e10cSrcweir // XContent methods.
199cdf0e10cSrcweir //
200cdf0e10cSrcweir //=========================================================================
201cdf0e10cSrcweir 
202cdf0e10cSrcweir // virtual
getContentType()203cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getContentType()
204cdf0e10cSrcweir     throw( uno::RuntimeException )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir 	// @@@ Adjust macro name ( def in odma_provider.hxx ).
207cdf0e10cSrcweir     return rtl::OUString::createFromAscii( ODMA_CONTENT_TYPE );
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir //=========================================================================
211cdf0e10cSrcweir //
212cdf0e10cSrcweir // XCommandProcessor methods.
213cdf0e10cSrcweir //
214cdf0e10cSrcweir //=========================================================================
215cdf0e10cSrcweir 
216cdf0e10cSrcweir // virtual
execute(const ucb::Command & aCommand,sal_Int32,const uno::Reference<ucb::XCommandEnvironment> & Environment)217cdf0e10cSrcweir uno::Any SAL_CALL Content::execute(
218cdf0e10cSrcweir         const ucb::Command& aCommand,
219cdf0e10cSrcweir         sal_Int32 /*CommandId*/,
220cdf0e10cSrcweir         const uno::Reference< ucb::XCommandEnvironment >& Environment )
221cdf0e10cSrcweir     throw( uno::Exception,
222cdf0e10cSrcweir            ucb::CommandAbortedException,
223cdf0e10cSrcweir            uno::RuntimeException )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir     uno::Any aRet;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     if ( aCommand.Name.equalsAsciiL(
228cdf0e10cSrcweir 			RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) )
229cdf0e10cSrcweir 	{
230cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
231cdf0e10cSrcweir 		// getPropertyValues
232cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
233cdf0e10cSrcweir 
234cdf0e10cSrcweir         uno::Sequence< beans::Property > Properties;
235cdf0e10cSrcweir 		if ( !( aCommand.Argument >>= Properties ) )
236cdf0e10cSrcweir 		{
237cdf0e10cSrcweir             OSL_ENSURE( sal_False, "Wrong argument type!" );
238cdf0e10cSrcweir             ucbhelper::cancelCommandExecution(
239cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
240cdf0e10cSrcweir                                     rtl::OUString(),
241cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
242cdf0e10cSrcweir                                     -1 ) ),
243cdf0e10cSrcweir                 Environment );
244cdf0e10cSrcweir             // Unreachable
245cdf0e10cSrcweir 		}
246cdf0e10cSrcweir 
247cdf0e10cSrcweir         aRet <<= getPropertyValues( Properties, Environment );
248cdf0e10cSrcweir 	}
249cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
250cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "setPropertyValues" ) ) )
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
253cdf0e10cSrcweir 		// setPropertyValues
254cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         uno::Sequence< beans::PropertyValue > aProperties;
257cdf0e10cSrcweir 		if ( !( aCommand.Argument >>= aProperties ) )
258cdf0e10cSrcweir 		{
259cdf0e10cSrcweir             OSL_ENSURE( sal_False, "Wrong argument type!" );
260cdf0e10cSrcweir             ucbhelper::cancelCommandExecution(
261cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
262cdf0e10cSrcweir                                     rtl::OUString(),
263cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
264cdf0e10cSrcweir                                     -1 ) ),
265cdf0e10cSrcweir                 Environment );
266cdf0e10cSrcweir             // Unreachable
267cdf0e10cSrcweir         }
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 		if ( !aProperties.getLength() )
270cdf0e10cSrcweir 		{
271cdf0e10cSrcweir             OSL_ENSURE( sal_False, "No properties!" );
272cdf0e10cSrcweir             ucbhelper::cancelCommandExecution(
273cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
274cdf0e10cSrcweir                                     rtl::OUString(),
275cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
276cdf0e10cSrcweir                                     -1 ) ),
277cdf0e10cSrcweir                 Environment );
278cdf0e10cSrcweir             // Unreachable
279cdf0e10cSrcweir         }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir         aRet <<= setPropertyValues( aProperties, Environment );
282cdf0e10cSrcweir 	}
283cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
284cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "getPropertySetInfo" ) ) )
285cdf0e10cSrcweir     {
286cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
287cdf0e10cSrcweir 		// getPropertySetInfo
288cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 		// Note: Implemented by base class.
291cdf0e10cSrcweir 		aRet <<= getPropertySetInfo( Environment );
292cdf0e10cSrcweir 	}
293cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
294cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "getCommandInfo" ) ) )
295cdf0e10cSrcweir     {
296cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
297cdf0e10cSrcweir 		// getCommandInfo
298cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		// Note: Implemented by base class.
301cdf0e10cSrcweir 		aRet <<= getCommandInfo( Environment );
302cdf0e10cSrcweir 	}
303cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
304cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "open" ) ) )
305cdf0e10cSrcweir     {
306cdf0e10cSrcweir         ucb::OpenCommandArgument2 aOpenCommand;
307cdf0e10cSrcweir       	if ( !( aCommand.Argument >>= aOpenCommand ) )
308cdf0e10cSrcweir 		{
309cdf0e10cSrcweir             OSL_ENSURE( sal_False, "Wrong argument type!" );
310cdf0e10cSrcweir             ucbhelper::cancelCommandExecution(
311cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
312cdf0e10cSrcweir                                     rtl::OUString(),
313cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
314cdf0e10cSrcweir                                     -1 ) ),
315cdf0e10cSrcweir                 Environment );
316cdf0e10cSrcweir             // Unreachable
317cdf0e10cSrcweir         }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir         sal_Bool bOpenFolder =
320cdf0e10cSrcweir             ( ( aOpenCommand.Mode == ucb::OpenMode::ALL ) ||
321cdf0e10cSrcweir               ( aOpenCommand.Mode == ucb::OpenMode::FOLDERS ) ||
322cdf0e10cSrcweir               ( aOpenCommand.Mode == ucb::OpenMode::DOCUMENTS ) );
323cdf0e10cSrcweir 
324cdf0e10cSrcweir         if ( bOpenFolder)
325cdf0e10cSrcweir 		{
326cdf0e10cSrcweir             // open as folder - return result set
327cdf0e10cSrcweir 
328cdf0e10cSrcweir             uno::Reference< ucb::XDynamicResultSet > xSet
329cdf0e10cSrcweir                             = new DynamicResultSet( m_xSMgr,
330cdf0e10cSrcweir 													this,
331cdf0e10cSrcweir 													aOpenCommand,
332cdf0e10cSrcweir 													Environment );
333cdf0e10cSrcweir     		aRet <<= xSet;
334cdf0e10cSrcweir   		}
335cdf0e10cSrcweir 
336cdf0e10cSrcweir         if ( aOpenCommand.Sink.is() )
337cdf0e10cSrcweir         {
338cdf0e10cSrcweir             // Open document - supply document data stream.
339cdf0e10cSrcweir 
340cdf0e10cSrcweir             // Check open mode
341cdf0e10cSrcweir             if ( ( aOpenCommand.Mode
342cdf0e10cSrcweir                     == ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) ||
343cdf0e10cSrcweir                  ( aOpenCommand.Mode
344cdf0e10cSrcweir                     == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE ) )
345cdf0e10cSrcweir             {
346cdf0e10cSrcweir                 // Unsupported.
347cdf0e10cSrcweir                 ucbhelper::cancelCommandExecution(
348cdf0e10cSrcweir                     uno::makeAny( ucb::UnsupportedOpenModeException(
349cdf0e10cSrcweir                                     rtl::OUString(),
350cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
351cdf0e10cSrcweir                                     sal_Int16( aOpenCommand.Mode ) ) ),
352cdf0e10cSrcweir                     Environment );
353cdf0e10cSrcweir                 // Unreachable
354cdf0e10cSrcweir             }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 
357cdf0e10cSrcweir             rtl::OUString aURL = m_xIdentifier->getContentIdentifier();
358cdf0e10cSrcweir 			rtl::OUString sFileURL = openDoc();
359cdf0e10cSrcweir 			delete m_pContent;
360cdf0e10cSrcweir 			m_pContent = new ::ucbhelper::Content(sFileURL,NULL);
361cdf0e10cSrcweir 			if(!m_pContent->isDocument())
362cdf0e10cSrcweir 			{
363cdf0e10cSrcweir 				rtl::OUString sErrorMsg(RTL_CONSTASCII_USTRINGPARAM("File: "));
364cdf0e10cSrcweir 				sErrorMsg += sFileURL;
365cdf0e10cSrcweir 				sErrorMsg += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" could not be found."));
366cdf0e10cSrcweir 				ucbhelper::cancelCommandExecution(
367cdf0e10cSrcweir 						uno::makeAny( io::IOException(
368cdf0e10cSrcweir 										sErrorMsg,
369cdf0e10cSrcweir 										static_cast< cppu::OWeakObject * >( this )) ),
370cdf0e10cSrcweir 						Environment );
371cdf0e10cSrcweir 			}
372cdf0e10cSrcweir 
373cdf0e10cSrcweir             uno::Reference< io::XOutputStream > xOut
374cdf0e10cSrcweir                 = uno::Reference< io::XOutputStream >(
375cdf0e10cSrcweir                     aOpenCommand.Sink, uno::UNO_QUERY );
376cdf0e10cSrcweir     		if ( xOut.is() )
377cdf0e10cSrcweir       		{
378cdf0e10cSrcweir 				// @@@ PUSH: write data into xOut
379cdf0e10cSrcweir 				m_pContent->openStream(xOut);
380cdf0e10cSrcweir       		}
381cdf0e10cSrcweir     		else
382cdf0e10cSrcweir       		{
383cdf0e10cSrcweir                 uno::Reference< io::XActiveDataSink > xDataSink
384cdf0e10cSrcweir                     = uno::Reference< io::XActiveDataSink >(
385cdf0e10cSrcweir                         aOpenCommand.Sink, uno::UNO_QUERY );
386cdf0e10cSrcweir       			if ( xDataSink.is() )
387cdf0e10cSrcweir 				{
388cdf0e10cSrcweir 	  				// @@@ PULL: wait for client read
389cdf0e10cSrcweir 					uno::Reference< io::XInputStream > xIn;
390cdf0e10cSrcweir 					try
391cdf0e10cSrcweir 					{
392cdf0e10cSrcweir 						xIn = m_pContent->openStream();
393cdf0e10cSrcweir 					}
394cdf0e10cSrcweir 					catch(uno::Exception&)
395cdf0e10cSrcweir 					{
396*86e1cf34SPedro Giffuni 						OSL_ENSURE(0,"Exception occurred while creating the file content!");
397cdf0e10cSrcweir 					}
398cdf0e10cSrcweir     				xDataSink->setInputStream( xIn );
399cdf0e10cSrcweir 				}
400cdf0e10cSrcweir       			else
401cdf0e10cSrcweir 				{
402cdf0e10cSrcweir 					uno::Reference< io::XActiveDataStreamer > activeDataStreamer( aOpenCommand.Sink,uno::UNO_QUERY );
403cdf0e10cSrcweir 					if(activeDataStreamer.is())
404cdf0e10cSrcweir 					{
405cdf0e10cSrcweir 						activeDataStreamer->setStream(new OOdmaStream(m_pContent,getContentProvider(),m_aProps));
406cdf0e10cSrcweir 						m_pContent = NULL; // don't delete here because the stream is now the owner
407cdf0e10cSrcweir 					}
408cdf0e10cSrcweir 					else
409cdf0e10cSrcweir 					{
410cdf0e10cSrcweir 						// Note: aOpenCommand.Sink may contain an XStream
411cdf0e10cSrcweir 						//       implementation. Support for this type of
412cdf0e10cSrcweir 						//       sink is optional...
413cdf0e10cSrcweir 						ucbhelper::cancelCommandExecution(
414cdf0e10cSrcweir 							uno::makeAny( ucb::UnsupportedDataSinkException(
415cdf0e10cSrcweir 									rtl::OUString(),
416cdf0e10cSrcweir 									static_cast< cppu::OWeakObject * >( this ),
417cdf0e10cSrcweir 									aOpenCommand.Sink ) ),
418cdf0e10cSrcweir 							Environment );
419cdf0e10cSrcweir 						// Unreachable
420cdf0e10cSrcweir 					}
421cdf0e10cSrcweir                 }
422cdf0e10cSrcweir 	  		}
423cdf0e10cSrcweir 		}
424cdf0e10cSrcweir 	}
425cdf0e10cSrcweir 	else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "close" ) ) )
426cdf0e10cSrcweir     {
427cdf0e10cSrcweir 		getContentProvider()->closeDocument(m_aProps->m_sDocumentId);
428cdf0e10cSrcweir 	}
429cdf0e10cSrcweir 	else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "delete" ) ) )
430cdf0e10cSrcweir     {
431cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
432cdf0e10cSrcweir 		// delete
433cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 		// Remove own and all children's Additional Core Properties.
436cdf0e10cSrcweir 		removeAdditionalPropertySet( sal_True );
437cdf0e10cSrcweir 		// Remove own and all childrens(!) persistent data.
438cdf0e10cSrcweir 		if(!getContentProvider()->deleteDocument(m_aProps))
439cdf0e10cSrcweir 			ucbhelper::cancelCommandExecution(
440cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
441cdf0e10cSrcweir                                     rtl::OUString(),
442cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
443cdf0e10cSrcweir                                     -1 ) ),
444cdf0e10cSrcweir                 Environment );
445cdf0e10cSrcweir 	}
446cdf0e10cSrcweir     else if ( aCommand.Name.equalsAsciiL(
447cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "insert" ) ) )
448cdf0e10cSrcweir     {
449cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
450cdf0e10cSrcweir 		// insert
451cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
452cdf0e10cSrcweir 
453cdf0e10cSrcweir         ucb::InsertCommandArgument arg;
454cdf0e10cSrcweir       	if ( !( aCommand.Argument >>= arg ) )
455cdf0e10cSrcweir 		{
456cdf0e10cSrcweir 	  		OSL_ENSURE( sal_False, "Wrong argument type!" );
457cdf0e10cSrcweir             ucbhelper::cancelCommandExecution(
458cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
459cdf0e10cSrcweir                                     rtl::OUString(),
460cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
461cdf0e10cSrcweir                                     -1 ) ),
462cdf0e10cSrcweir                 Environment );
463cdf0e10cSrcweir             // Unreachable
464cdf0e10cSrcweir 		}
465cdf0e10cSrcweir 
466cdf0e10cSrcweir       	insert( arg.Data, arg.ReplaceExisting, Environment );
467cdf0e10cSrcweir     }
468cdf0e10cSrcweir 	else if( ! aCommand.Name.compareToAscii( "transfer" ) )
469cdf0e10cSrcweir 	{
470cdf0e10cSrcweir 		ucb::TransferInfo aTransferInfo;
471cdf0e10cSrcweir 		if( ! ( aCommand.Argument >>= aTransferInfo ) )
472cdf0e10cSrcweir 		{
473cdf0e10cSrcweir 			OSL_ENSURE( sal_False, "Wrong argument type!" );
474cdf0e10cSrcweir             ucbhelper::cancelCommandExecution(
475cdf0e10cSrcweir                 uno::makeAny( lang::IllegalArgumentException(
476cdf0e10cSrcweir                                     rtl::OUString(),
477cdf0e10cSrcweir                                     static_cast< cppu::OWeakObject * >( this ),
478cdf0e10cSrcweir                                     -1 ) ),
479cdf0e10cSrcweir                 Environment );
480cdf0e10cSrcweir             // Unreachable
481cdf0e10cSrcweir 		}
482cdf0e10cSrcweir 		::rtl::Reference<ContentProperties> aProp = m_aProps;
483cdf0e10cSrcweir 		if(aProp->m_bIsFolder)
484cdf0e10cSrcweir 		{
485cdf0e10cSrcweir 			aProp = getContentProvider()->getContentPropertyWithTitle(aTransferInfo.NewTitle);
486cdf0e10cSrcweir 			if(!aProp.is())
487cdf0e10cSrcweir 				aProp = getContentProvider()->getContentPropertyWithSavedAsName(aTransferInfo.NewTitle);
488cdf0e10cSrcweir 			sal_Bool bError = !aProp.is();
489cdf0e10cSrcweir 			if(bError)
490cdf0e10cSrcweir 			{
491cdf0e10cSrcweir 				sal_Char* pExtension = NULL;
492cdf0e10cSrcweir 				::rtl::OString sExt;
493cdf0e10cSrcweir 				sal_Int32 nPos = aTransferInfo.NewTitle.lastIndexOf('.');
494cdf0e10cSrcweir 				if(nPos != -1)
495cdf0e10cSrcweir 				{
496cdf0e10cSrcweir 					sExt = ::rtl::OUStringToOString(aTransferInfo.NewTitle.copy(nPos+1),RTL_TEXTENCODING_ASCII_US);
497cdf0e10cSrcweir 					if(sExt.equalsIgnoreAsciiCase("txt"))
498cdf0e10cSrcweir 						pExtension = ODM_FORMAT_TEXT;
499cdf0e10cSrcweir 					else if(sExt.equalsIgnoreAsciiCase("rtf"))
500cdf0e10cSrcweir 						pExtension = ODM_FORMAT_RTF;
501cdf0e10cSrcweir 					else if(sExt.equalsIgnoreAsciiCase("ps"))
502cdf0e10cSrcweir 						pExtension = ODM_FORMAT_PS;
503cdf0e10cSrcweir 					else
504cdf0e10cSrcweir 						pExtension = const_cast<sal_Char*>(sExt.getStr());
505cdf0e10cSrcweir 				}
506cdf0e10cSrcweir 				else
507cdf0e10cSrcweir 					pExtension = ODM_FORMAT_TEXT;
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 				sal_Char* lpszNewDocId = new sal_Char[ODM_DOCID_MAX];
510cdf0e10cSrcweir 				void *pData = NULL;
511cdf0e10cSrcweir 				DWORD dwFlags = ODM_SILENT;
512cdf0e10cSrcweir 				ODMSTATUS odm = NODMSaveAsEx(ContentProvider::getHandle(),
513cdf0e10cSrcweir 											 NULL, // means it is saved the first time
514cdf0e10cSrcweir 											 lpszNewDocId,
515cdf0e10cSrcweir 											 pExtension,
516cdf0e10cSrcweir 											 NULL, // no callback function here
517cdf0e10cSrcweir 											 pData,
518cdf0e10cSrcweir 											 &dwFlags);
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 				// check if we have to call the DMS dialog
521cdf0e10cSrcweir 				if(odm == ODM_E_USERINT)
522cdf0e10cSrcweir 				{
523cdf0e10cSrcweir 					dwFlags = 0;
524cdf0e10cSrcweir 					odm = NODMSaveAsEx(ContentProvider::getHandle(),
525cdf0e10cSrcweir 											 NULL, // means it is saved the first time
526cdf0e10cSrcweir 											 lpszNewDocId,
527cdf0e10cSrcweir 											 pExtension,
528cdf0e10cSrcweir 											 NULL, // no callback function here
529cdf0e10cSrcweir 											 pData,
530cdf0e10cSrcweir 											 &dwFlags);
531cdf0e10cSrcweir 				}
532cdf0e10cSrcweir 				bError = odm != ODM_SUCCESS;
533cdf0e10cSrcweir 				if(!bError)
534cdf0e10cSrcweir 				{
535cdf0e10cSrcweir 					aProp = new ContentProperties();
536cdf0e10cSrcweir 					aProp->m_sDocumentId	= ::rtl::OString(lpszNewDocId);
537cdf0e10cSrcweir 					aProp->m_sContentType	= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODMA_CONTENT_TYPE));
538cdf0e10cSrcweir 					aProp->m_sSavedAsName	= aTransferInfo.NewTitle;
539cdf0e10cSrcweir 					getContentProvider()->append(aProp);
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 					// now set the title
542cdf0e10cSrcweir 					WORD nDocInfo = ODM_NAME;
543cdf0e10cSrcweir 					::rtl::OUString sFileName = aTransferInfo.NewTitle;
544cdf0e10cSrcweir 					sal_Int32 nIndex = aTransferInfo.NewTitle.lastIndexOf( sal_Unicode('.') );
545cdf0e10cSrcweir 					if(nIndex != -1)
546cdf0e10cSrcweir 						sFileName = aTransferInfo.NewTitle.copy(0,nIndex);
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 					::rtl::OString sDocInfoValue = ::rtl::OUStringToOString(sFileName,RTL_TEXTENCODING_ASCII_US);
549cdf0e10cSrcweir 					odm = NODMSetDocInfo(	ContentProvider::getHandle(),
550cdf0e10cSrcweir 											lpszNewDocId,
551cdf0e10cSrcweir 											nDocInfo,
552cdf0e10cSrcweir 											const_cast<sal_Char*>(sDocInfoValue.getStr())
553cdf0e10cSrcweir 											);
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 				}
556cdf0e10cSrcweir 				else if ( odm == ODM_E_CANCEL)
557cdf0e10cSrcweir                     NODMActivate(ContentProvider::getHandle(),
558cdf0e10cSrcweir                                  ODM_DELETE,
559cdf0e10cSrcweir                                  lpszNewDocId);
560cdf0e10cSrcweir 
561cdf0e10cSrcweir 				delete [] lpszNewDocId;
562cdf0e10cSrcweir 			}
563cdf0e10cSrcweir 			if(bError)
564cdf0e10cSrcweir 				ucbhelper::cancelCommandExecution(
565cdf0e10cSrcweir 						uno::makeAny( lang::IllegalArgumentException(
566cdf0e10cSrcweir 											rtl::OUString(),
567cdf0e10cSrcweir 											static_cast< cppu::OWeakObject * >( this ),
568cdf0e10cSrcweir 											-1 ) ),
569cdf0e10cSrcweir 						Environment );
570cdf0e10cSrcweir 		}
571cdf0e10cSrcweir 		rtl::OUString sFileURL = ContentProvider::openDoc(aProp);
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 		sal_Int32 nLastIndex = sFileURL.lastIndexOf( sal_Unicode('/') );
574cdf0e10cSrcweir 		::ucbhelper::Content aContent(sFileURL.copy(0,nLastIndex),NULL);
575cdf0e10cSrcweir 		//	aTransferInfo.NameClash = ucb::NameClash::OVERWRITE;
576cdf0e10cSrcweir 		aTransferInfo.NewTitle = sFileURL.copy( 1 + nLastIndex );
577cdf0e10cSrcweir 		aContent.executeCommand(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("transfer")),uno::makeAny(aTransferInfo));
578cdf0e10cSrcweir 		getContentProvider()->saveDocument(aProp->m_sDocumentId);
579cdf0e10cSrcweir 	}
580cdf0e10cSrcweir 	else
581cdf0e10cSrcweir 	{
582cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
583cdf0e10cSrcweir 		// Unsupported command
584cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////
585cdf0e10cSrcweir 
586cdf0e10cSrcweir         OSL_ENSURE( sal_False, "Content::execute - unsupported command!" );
587cdf0e10cSrcweir 
588cdf0e10cSrcweir         ucbhelper::cancelCommandExecution(
589cdf0e10cSrcweir             uno::makeAny( ucb::UnsupportedCommandException(
590cdf0e10cSrcweir                             rtl::OUString(),
591cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) ) ),
592cdf0e10cSrcweir             Environment );
593cdf0e10cSrcweir         // Unreachable
594cdf0e10cSrcweir     }
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	return aRet;
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir //=========================================================================
600cdf0e10cSrcweir // virtual
abort(sal_Int32)601cdf0e10cSrcweir void SAL_CALL Content::abort( sal_Int32 /*CommandId*/ )
602cdf0e10cSrcweir     throw( uno::RuntimeException )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir 	// @@@ Implement logic to abort running commands, if this makes
605cdf0e10cSrcweir 	//     sense for your content.
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir //=========================================================================
609cdf0e10cSrcweir //
610cdf0e10cSrcweir // Non-interface methods.
611cdf0e10cSrcweir //
612cdf0e10cSrcweir //=========================================================================
613cdf0e10cSrcweir 
614cdf0e10cSrcweir // virtual
getParentURL()615cdf0e10cSrcweir ::rtl::OUString Content::getParentURL()
616cdf0e10cSrcweir {
617cdf0e10cSrcweir     ::rtl::OUString sURL = m_xIdentifier->getContentIdentifier();
618cdf0e10cSrcweir 
619cdf0e10cSrcweir     // @@@ Extract URL of parent from aURL and return it...
620cdf0e10cSrcweir 	static ::rtl::OUString sScheme1(RTL_CONSTASCII_USTRINGPARAM(ODMA_URL_SCHEME ODMA_URL_SHORT "/"));
621cdf0e10cSrcweir 	static ::rtl::OUString sScheme2(RTL_CONSTASCII_USTRINGPARAM(ODMA_URL_SCHEME ODMA_URL_SHORT));
622cdf0e10cSrcweir 	if(sURL == sScheme1 || sURL == sScheme2)
623cdf0e10cSrcweir 		sURL = ::rtl::OUString();
624cdf0e10cSrcweir 	else
625cdf0e10cSrcweir 		sURL = sScheme1;
626cdf0e10cSrcweir 
627cdf0e10cSrcweir     return sURL;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir //=========================================================================
631cdf0e10cSrcweir // static
getPropertyValues(const uno::Reference<lang::XMultiServiceFactory> & rSMgr,const uno::Sequence<beans::Property> & rProperties,const rtl::Reference<ContentProperties> & rData,const rtl::Reference<::ucbhelper::ContentProviderImplHelper> & rProvider,const rtl::OUString & rContentId)632cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues(
633cdf0e10cSrcweir             const uno::Reference< lang::XMultiServiceFactory >& rSMgr,
634cdf0e10cSrcweir             const uno::Sequence< beans::Property >& rProperties,
635cdf0e10cSrcweir             const rtl::Reference<ContentProperties>& rData,
636cdf0e10cSrcweir             const rtl::Reference< ::ucbhelper::ContentProviderImplHelper >& rProvider,
637cdf0e10cSrcweir             const rtl::OUString& rContentId )
638cdf0e10cSrcweir {
639cdf0e10cSrcweir 	// Note: Empty sequence means "get values of all supported properties".
640cdf0e10cSrcweir 
641cdf0e10cSrcweir     rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
642cdf0e10cSrcweir                                 = new ::ucbhelper::PropertyValueSet( rSMgr );
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 	sal_Int32 nCount = rProperties.getLength();
645cdf0e10cSrcweir 	if ( nCount )
646cdf0e10cSrcweir 	{
647cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xAdditionalPropSet;
648cdf0e10cSrcweir 		sal_Bool bTriedToGetAdditonalPropSet = sal_False;
649cdf0e10cSrcweir 
650cdf0e10cSrcweir         const beans::Property* pProps = rProperties.getConstArray();
651cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
652cdf0e10cSrcweir 		{
653cdf0e10cSrcweir             const beans::Property& rProp = pProps[ n ];
654cdf0e10cSrcweir 
655cdf0e10cSrcweir 			// Process Core properties.
656cdf0e10cSrcweir 
657cdf0e10cSrcweir             if ( rProp.Name.equalsAsciiL(
658cdf0e10cSrcweir 					RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
659cdf0e10cSrcweir             {
660cdf0e10cSrcweir 				xRow->appendString ( rProp, rData->m_sContentType );
661cdf0e10cSrcweir 			}
662cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL(
663cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
664cdf0e10cSrcweir 			{
665cdf0e10cSrcweir 				xRow->appendString ( rProp, rData->m_sTitle );
666cdf0e10cSrcweir 			}
667cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL(
668cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
669cdf0e10cSrcweir 			{
670cdf0e10cSrcweir 				xRow->appendBoolean( rProp, rData->m_bIsDocument );
671cdf0e10cSrcweir 			}
672cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL(
673cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
674cdf0e10cSrcweir 			{
675cdf0e10cSrcweir 				xRow->appendBoolean( rProp, rData->m_bIsFolder );
676cdf0e10cSrcweir 			}
677cdf0e10cSrcweir             else if ( rProp.Name.equalsAsciiL(
678cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) )
679cdf0e10cSrcweir 			{
680cdf0e10cSrcweir 				xRow->appendTimestamp( rProp, rData->m_aDateCreated );
681cdf0e10cSrcweir 			}
682cdf0e10cSrcweir 			else if ( rProp.Name.equalsAsciiL(
683cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) )
684cdf0e10cSrcweir 			{
685cdf0e10cSrcweir 				xRow->appendTimestamp( rProp, rData->m_aDateModified );
686cdf0e10cSrcweir 			}
687cdf0e10cSrcweir 			else if ( rProp.Name.equalsAsciiL(
688cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "IsReadOnly" ) ) )
689cdf0e10cSrcweir 			{
690cdf0e10cSrcweir 				xRow->appendBoolean( rProp, rData->m_bIsReadOnly );
691cdf0e10cSrcweir 			}
692cdf0e10cSrcweir 			else if ( rProp.Name.equalsAsciiL(
693cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "Author" ) ) )
694cdf0e10cSrcweir 			{
695cdf0e10cSrcweir 				xRow->appendString ( rProp, rData->m_sAuthor );
696cdf0e10cSrcweir 			}
697cdf0e10cSrcweir 			else if ( rProp.Name.equalsAsciiL(
698cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "Subject" ) ) )
699cdf0e10cSrcweir 			{
700cdf0e10cSrcweir 				xRow->appendString ( rProp, rData->m_sSubject );
701cdf0e10cSrcweir 			}
702cdf0e10cSrcweir 			else if ( rProp.Name.equalsAsciiL(
703cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM( "Keywords" ) ) )
704cdf0e10cSrcweir 			{
705cdf0e10cSrcweir 				xRow->appendString ( rProp, rData->m_sKeywords );
706cdf0e10cSrcweir 			}
707cdf0e10cSrcweir 			else
708cdf0e10cSrcweir 			{
709cdf0e10cSrcweir 				// @@@ Note: If your data source supports adding/removing
710cdf0e10cSrcweir 				//     properties, you should implement the interface
711cdf0e10cSrcweir 				//     XPropertyContainer by yourself and supply your own
712cdf0e10cSrcweir 				//     logic here. The base class uses the service
713cdf0e10cSrcweir 				//     "com.sun.star.ucb.Store" to maintain Additional Core
714cdf0e10cSrcweir 				//     properties. But using server functionality is preferred!
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 				// Not a Core Property! Maybe it's an Additional Core Property?!
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 				if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() )
719cdf0e10cSrcweir 				{
720cdf0e10cSrcweir 					xAdditionalPropSet
721cdf0e10cSrcweir                         = uno::Reference< beans::XPropertySet >(
722cdf0e10cSrcweir 							rProvider->getAdditionalPropertySet( rContentId,
723cdf0e10cSrcweir 																 sal_False ),
724cdf0e10cSrcweir                             uno::UNO_QUERY );
725cdf0e10cSrcweir 					bTriedToGetAdditonalPropSet = sal_True;
726cdf0e10cSrcweir 				}
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 				if ( xAdditionalPropSet.is() )
729cdf0e10cSrcweir 				{
730cdf0e10cSrcweir 					if ( !xRow->appendPropertySetValue(
731cdf0e10cSrcweir 												xAdditionalPropSet,
732cdf0e10cSrcweir 												rProp ) )
733cdf0e10cSrcweir 					{
734cdf0e10cSrcweir 						// Append empty entry.
735cdf0e10cSrcweir 						xRow->appendVoid( rProp );
736cdf0e10cSrcweir 					}
737cdf0e10cSrcweir 				}
738cdf0e10cSrcweir 				else
739cdf0e10cSrcweir 				{
740cdf0e10cSrcweir 					// Append empty entry.
741cdf0e10cSrcweir 					xRow->appendVoid( rProp );
742cdf0e10cSrcweir 				}
743cdf0e10cSrcweir 			}
744cdf0e10cSrcweir 		}
745cdf0e10cSrcweir 	}
746cdf0e10cSrcweir 	else
747cdf0e10cSrcweir 	{
748cdf0e10cSrcweir 		// Append all Core Properties.
749cdf0e10cSrcweir 		xRow->appendString (
750cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "ContentType" ),
751cdf0e10cSrcweir 					  -1,
752cdf0e10cSrcweir                       getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
753cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND
754cdf0e10cSrcweir                         | beans::PropertyAttribute::READONLY ),
755cdf0e10cSrcweir 			rData->m_sContentType );
756cdf0e10cSrcweir 		xRow->appendString (
757cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "Title" ),
758cdf0e10cSrcweir 					  -1,
759cdf0e10cSrcweir                       getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
760cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND ),
761cdf0e10cSrcweir 			rData->m_sTitle );
762cdf0e10cSrcweir 		xRow->appendBoolean(
763cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "IsDocument" ),
764cdf0e10cSrcweir 					  -1,
765cdf0e10cSrcweir 					  getCppuBooleanType(),
766cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND
767cdf0e10cSrcweir                         | beans::PropertyAttribute::READONLY ),
768cdf0e10cSrcweir 			rData->m_bIsDocument );
769cdf0e10cSrcweir 		xRow->appendBoolean(
770cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "IsFolder" ),
771cdf0e10cSrcweir 					  -1,
772cdf0e10cSrcweir 					  getCppuBooleanType(),
773cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND
774cdf0e10cSrcweir                         | beans::PropertyAttribute::READONLY ),
775cdf0e10cSrcweir 			rData->m_bIsFolder );
776cdf0e10cSrcweir 
777cdf0e10cSrcweir 		// @@@ Append other properties supported directly.
778cdf0e10cSrcweir 		xRow->appendTimestamp(
779cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "DateCreated" ),
780cdf0e10cSrcweir 					  -1,
781cdf0e10cSrcweir 					  getCppuType(static_cast< const util::DateTime * >( 0 ) ),
782cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND
783cdf0e10cSrcweir                         | beans::PropertyAttribute::READONLY ),
784cdf0e10cSrcweir 			rData->m_aDateCreated );
785cdf0e10cSrcweir 		xRow->appendTimestamp(
786cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "DateModified" ),
787cdf0e10cSrcweir 					  -1,
788cdf0e10cSrcweir 					  getCppuType(static_cast< const util::DateTime * >( 0 ) ),
789cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND
790cdf0e10cSrcweir                         | beans::PropertyAttribute::READONLY ),
791cdf0e10cSrcweir 			rData->m_aDateModified );
792cdf0e10cSrcweir 		xRow->appendBoolean(
793cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "IsReadOnly" ),
794cdf0e10cSrcweir 					  -1,
795cdf0e10cSrcweir 					  getCppuBooleanType(),
796cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND
797cdf0e10cSrcweir                         | beans::PropertyAttribute::READONLY ),
798cdf0e10cSrcweir 			rData->m_bIsReadOnly );
799cdf0e10cSrcweir 		xRow->appendString (
800cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "Author" ),
801cdf0e10cSrcweir 					  -1,
802cdf0e10cSrcweir                       getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
803cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND ),
804cdf0e10cSrcweir 			rData->m_sAuthor );
805cdf0e10cSrcweir 		xRow->appendString (
806cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "Subject" ),
807cdf0e10cSrcweir 					  -1,
808cdf0e10cSrcweir                       getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
809cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND ),
810cdf0e10cSrcweir 			rData->m_sSubject );
811cdf0e10cSrcweir 		xRow->appendString (
812cdf0e10cSrcweir             beans::Property( rtl::OUString::createFromAscii( "Keywords" ),
813cdf0e10cSrcweir 					  -1,
814cdf0e10cSrcweir                       getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
815cdf0e10cSrcweir                       beans::PropertyAttribute::BOUND ),
816cdf0e10cSrcweir 			rData->m_sKeywords );
817cdf0e10cSrcweir 
818cdf0e10cSrcweir 		// @@@ Note: If your data source supports adding/removing
819cdf0e10cSrcweir 		//     properties, you should implement the interface
820cdf0e10cSrcweir 		//     XPropertyContainer by yourself and supply your own
821cdf0e10cSrcweir 		//     logic here. The base class uses the service
822cdf0e10cSrcweir 		//     "com.sun.star.ucb.Store" to maintain Additional Core
823cdf0e10cSrcweir 		//     properties. But using server functionality is preferred!
824cdf0e10cSrcweir 
825cdf0e10cSrcweir 		// Append all Additional Core Properties.
826cdf0e10cSrcweir 
827cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xSet(
828cdf0e10cSrcweir 			rProvider->getAdditionalPropertySet( rContentId, sal_False ),
829cdf0e10cSrcweir             uno::UNO_QUERY );
830cdf0e10cSrcweir 		xRow->appendPropertySet( xSet );
831cdf0e10cSrcweir 	}
832cdf0e10cSrcweir 
833cdf0e10cSrcweir     return uno::Reference< sdbc::XRow >( xRow.get() );
834cdf0e10cSrcweir }
835cdf0e10cSrcweir 
836cdf0e10cSrcweir //=========================================================================
getPropertyValues(const uno::Sequence<beans::Property> & rProperties,const uno::Reference<ucb::XCommandEnvironment> &)837cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues(
838cdf0e10cSrcweir             const uno::Sequence< beans::Property >& rProperties,
839cdf0e10cSrcweir             const uno::Reference< ucb::XCommandEnvironment >& /*xEnv*/ )
840cdf0e10cSrcweir {
841cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
842cdf0e10cSrcweir 	return getPropertyValues( m_xSMgr,
843cdf0e10cSrcweir 							  rProperties,
844cdf0e10cSrcweir 							  m_aProps,
845cdf0e10cSrcweir                               rtl::Reference<
846cdf0e10cSrcweir                                 ::ucbhelper::ContentProviderImplHelper >(
847cdf0e10cSrcweir                                     m_xProvider.get() ),
848cdf0e10cSrcweir 							  m_xIdentifier->getContentIdentifier() );
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
851cdf0e10cSrcweir //=========================================================================
setPropertyValues(const uno::Sequence<beans::PropertyValue> & rValues,const uno::Reference<ucb::XCommandEnvironment> &)852cdf0e10cSrcweir uno::Sequence< uno::Any > Content::setPropertyValues(
853cdf0e10cSrcweir             const uno::Sequence< beans::PropertyValue >& rValues,
854cdf0e10cSrcweir             const uno::Reference< ucb::XCommandEnvironment >& /*xEnv*/ )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
857cdf0e10cSrcweir 
858cdf0e10cSrcweir     uno::Sequence< uno::Any > aRet( rValues.getLength() );
859cdf0e10cSrcweir     uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() );
860cdf0e10cSrcweir 	sal_Int32 nChanged = 0;
861cdf0e10cSrcweir 
862cdf0e10cSrcweir     beans::PropertyChangeEvent aEvent;
863cdf0e10cSrcweir     aEvent.Source         = static_cast< cppu::OWeakObject * >( this );
864cdf0e10cSrcweir 	aEvent.Further 		  = sal_False;
865cdf0e10cSrcweir //	aEvent.PropertyName	  =
866cdf0e10cSrcweir 	aEvent.PropertyHandle = -1;
867cdf0e10cSrcweir //	aEvent.OldValue		  =
868cdf0e10cSrcweir //	aEvent.NewValue       =
869cdf0e10cSrcweir 
870cdf0e10cSrcweir     const beans::PropertyValue* pValues = rValues.getConstArray();
871cdf0e10cSrcweir 	sal_Int32 nCount = rValues.getLength();
872cdf0e10cSrcweir 
873cdf0e10cSrcweir     uno::Reference< ucb::XPersistentPropertySet > xAdditionalPropSet;
874cdf0e10cSrcweir 	sal_Bool bTriedToGetAdditonalPropSet = sal_False;
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < nCount; ++n )
877cdf0e10cSrcweir 	{
878cdf0e10cSrcweir         const beans::PropertyValue& rValue = pValues[ n ];
879cdf0e10cSrcweir 
880cdf0e10cSrcweir         if ( rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
881cdf0e10cSrcweir 		{
882cdf0e10cSrcweir 			changePropertyValue(rValue,n,m_aProps->m_sTitle,nChanged,aRet,aChanges);
883cdf0e10cSrcweir 		}
884cdf0e10cSrcweir 		else if ( rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "Author") ) )
885cdf0e10cSrcweir 		{
886cdf0e10cSrcweir 			changePropertyValue(rValue,n,m_aProps->m_sAuthor,nChanged,aRet,aChanges);
887cdf0e10cSrcweir 		}
888cdf0e10cSrcweir 		else if ( rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "Keywords") ) )
889cdf0e10cSrcweir 		{
890cdf0e10cSrcweir 			changePropertyValue(rValue,n,m_aProps->m_sKeywords,nChanged,aRet,aChanges);
891cdf0e10cSrcweir 		}
892cdf0e10cSrcweir 		else if ( rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "Subject") ) )
893cdf0e10cSrcweir 		{
894cdf0e10cSrcweir 			changePropertyValue(rValue,n,m_aProps->m_sSubject,nChanged,aRet,aChanges);
895cdf0e10cSrcweir 		}
896cdf0e10cSrcweir 		else if (	rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "ContentType" ) )	||
897cdf0e10cSrcweir 					rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) )	||
898cdf0e10cSrcweir 					rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) )		||
899cdf0e10cSrcweir 					rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) )	||
900cdf0e10cSrcweir 					rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "DateModified" ) )	||
901cdf0e10cSrcweir 					rValue.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "IsReadOnly" ) ) )
902cdf0e10cSrcweir         {
903cdf0e10cSrcweir 			// Read-only property!
904cdf0e10cSrcweir             aRet[ n ] <<= lang::IllegalAccessException(
905cdf0e10cSrcweir                             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
906cdf0e10cSrcweir                                 "Property is read-only!") ),
907cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) );
908cdf0e10cSrcweir 		}
909cdf0e10cSrcweir 		else
910cdf0e10cSrcweir 		{
911cdf0e10cSrcweir 			// @@@ Note: If your data source supports adding/removing
912cdf0e10cSrcweir 			//     properties, you should implement the interface
913cdf0e10cSrcweir 			//     XPropertyContainer by yourself and supply your own
914cdf0e10cSrcweir 			//     logic here. The base class uses the service
915cdf0e10cSrcweir 			//     "com.sun.star.ucb.Store" to maintain Additional Core
916cdf0e10cSrcweir 			//     properties. But using server functionality is preferred!
917cdf0e10cSrcweir 
918cdf0e10cSrcweir 			// Not a Core Property! Maybe it's an Additional Core Property?!
919cdf0e10cSrcweir 
920cdf0e10cSrcweir 			if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() )
921cdf0e10cSrcweir 			{
922cdf0e10cSrcweir 				xAdditionalPropSet = getAdditionalPropertySet( sal_False );
923cdf0e10cSrcweir 				bTriedToGetAdditonalPropSet = sal_True;
924cdf0e10cSrcweir 			}
925cdf0e10cSrcweir 
926cdf0e10cSrcweir 			if ( xAdditionalPropSet.is() )
927cdf0e10cSrcweir 			{
928cdf0e10cSrcweir 				try
929cdf0e10cSrcweir 				{
930cdf0e10cSrcweir                     uno::Any aOldValue
931cdf0e10cSrcweir                         = xAdditionalPropSet->getPropertyValue( rValue.Name );
932cdf0e10cSrcweir 					if ( aOldValue != rValue.Value )
933cdf0e10cSrcweir 					{
934cdf0e10cSrcweir 						xAdditionalPropSet->setPropertyValue(
935cdf0e10cSrcweir 												rValue.Name, rValue.Value );
936cdf0e10cSrcweir 
937cdf0e10cSrcweir 						aEvent.PropertyName = rValue.Name;
938cdf0e10cSrcweir 						aEvent.OldValue		= aOldValue;
939cdf0e10cSrcweir 						aEvent.NewValue     = rValue.Value;
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 						aChanges.getArray()[ nChanged ] = aEvent;
942cdf0e10cSrcweir 						nChanged++;
943cdf0e10cSrcweir 					}
944cdf0e10cSrcweir                     else
945cdf0e10cSrcweir                     {
946cdf0e10cSrcweir                         // Old value equals new value. No error!
947cdf0e10cSrcweir                     }
948cdf0e10cSrcweir 				}
949cdf0e10cSrcweir                 catch ( beans::UnknownPropertyException const & e )
950cdf0e10cSrcweir 				{
951cdf0e10cSrcweir                     aRet[ n ] <<= e;
952cdf0e10cSrcweir 				}
953cdf0e10cSrcweir                 catch ( lang::WrappedTargetException const & e )
954cdf0e10cSrcweir 				{
955cdf0e10cSrcweir                     aRet[ n ] <<= e;
956cdf0e10cSrcweir 				}
957cdf0e10cSrcweir                 catch ( beans::PropertyVetoException const & e )
958cdf0e10cSrcweir 				{
959cdf0e10cSrcweir                     aRet[ n ] <<= e;
960cdf0e10cSrcweir 				}
961cdf0e10cSrcweir                 catch ( lang::IllegalArgumentException const & e )
962cdf0e10cSrcweir 				{
963cdf0e10cSrcweir                     aRet[ n ] <<= e;
964cdf0e10cSrcweir 				}
965cdf0e10cSrcweir 			}
966cdf0e10cSrcweir             else
967cdf0e10cSrcweir             {
968cdf0e10cSrcweir                 aRet[ n ] <<= uno::Exception(
969cdf0e10cSrcweir                                 rtl::OUString::createFromAscii(
970cdf0e10cSrcweir                                     "No property set for storing the value!" ),
971cdf0e10cSrcweir                                 static_cast< cppu::OWeakObject * >( this ) );
972cdf0e10cSrcweir             }
973cdf0e10cSrcweir 		}
974cdf0e10cSrcweir 	}
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 	if ( nChanged > 0 )
977cdf0e10cSrcweir 	{
978cdf0e10cSrcweir 		// @@@ Save changes.
979cdf0e10cSrcweir //		storeData();
980cdf0e10cSrcweir 
981cdf0e10cSrcweir 		aGuard.clear();
982cdf0e10cSrcweir 		aChanges.realloc( nChanged );
983cdf0e10cSrcweir 		notifyPropertiesChange( aChanges );
984cdf0e10cSrcweir 	}
985cdf0e10cSrcweir 
986cdf0e10cSrcweir     return aRet;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir 
989cdf0e10cSrcweir #if 0
990cdf0e10cSrcweir //=========================================================================
991cdf0e10cSrcweir void Content::queryChildren( ContentRefList& rChildren )
992cdf0e10cSrcweir {
993cdf0e10cSrcweir 	// @@@ Adapt method to your URL scheme...
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 	// Obtain a list with a snapshot of all currently instanciated contents
996cdf0e10cSrcweir 	// from provider and extract the contents which are direct children
997cdf0e10cSrcweir 	// of this content.
998cdf0e10cSrcweir 
999cdf0e10cSrcweir 	::ucbhelper::ContentRefList aAllContents;
1000cdf0e10cSrcweir 	m_xProvider->queryExistingContents( aAllContents );
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir 	OUString aURL = m_xIdentifier->getContentIdentifier();
1003cdf0e10cSrcweir 	sal_Int32 nPos = aURL.lastIndexOf( '/' );
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir 	if ( nPos != ( aURL.getLength() - 1 ) )
1006cdf0e10cSrcweir 	{
1007cdf0e10cSrcweir 		// No trailing slash found. Append.
1008cdf0e10cSrcweir 		aURL += OUString::createFromAscii( "/" );
1009cdf0e10cSrcweir 	}
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir 	sal_Int32 nLen = aURL.getLength();
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir 	::ucbhelper::ContentRefList::const_iterator it  = aAllContents.begin();
1014cdf0e10cSrcweir 	::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir 	while ( it != end )
1017cdf0e10cSrcweir 	{
1018cdf0e10cSrcweir 		::ucbhelper::ContentImplHelperRef xChild = (*it);
1019cdf0e10cSrcweir 		OUString aChildURL = xChild->getIdentifier()->getContentIdentifier();
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir 		// Is aURL a prefix of aChildURL?
1022cdf0e10cSrcweir 		if ( ( aChildURL.getLength() > nLen ) &&
1023cdf0e10cSrcweir 			 ( aChildURL.compareTo( aURL, nLen ) == 0 ) )
1024cdf0e10cSrcweir 		{
1025cdf0e10cSrcweir 			sal_Int32 nPos = nLen;
1026cdf0e10cSrcweir 			nPos = aChildURL.indexOf( '/', nPos );
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 			if ( ( nPos == -1 ) ||
1029cdf0e10cSrcweir 				 ( nPos == ( aChildURL.getLength() - 1 ) ) )
1030cdf0e10cSrcweir 			{
1031cdf0e10cSrcweir 				// No further slashes / only a final slash. It's a child!
1032cdf0e10cSrcweir 				rChildren.push_back(
1033cdf0e10cSrcweir 					ContentRef(
1034cdf0e10cSrcweir 						static_cast< Content * >( xChild.get() ) ) );
1035cdf0e10cSrcweir 			}
1036cdf0e10cSrcweir 		}
1037cdf0e10cSrcweir 		++it;
1038cdf0e10cSrcweir 	}
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir #endif
1041cdf0e10cSrcweir //=========================================================================
insert(const uno::Reference<io::XInputStream> & xInputStream,sal_Bool bReplaceExisting,const uno::Reference<ucb::XCommandEnvironment> & Environment)1042cdf0e10cSrcweir void Content::insert(
1043cdf0e10cSrcweir         const uno::Reference< io::XInputStream > & xInputStream,
1044cdf0e10cSrcweir         sal_Bool bReplaceExisting,
1045cdf0e10cSrcweir         const uno::Reference< ucb::XCommandEnvironment >& Environment )
1046cdf0e10cSrcweir     throw( uno::Exception )
1047cdf0e10cSrcweir {
1048cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir 	// Check, if all required properties were set.
1051cdf0e10cSrcweir 	if ( !m_aProps->m_sTitle.getLength())
1052cdf0e10cSrcweir 	{
1053cdf0e10cSrcweir         OSL_ENSURE( sal_False, "Content::insert - property value missing!" );
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir         uno::Sequence< rtl::OUString > aProps( 1 );
1056cdf0e10cSrcweir         aProps[ 0 ] = rtl::OUString::createFromAscii( "zzzz" );
1057cdf0e10cSrcweir         ucbhelper::cancelCommandExecution(
1058cdf0e10cSrcweir             uno::makeAny( ucb::MissingPropertiesException(
1059cdf0e10cSrcweir                                 rtl::OUString(),
1060cdf0e10cSrcweir                                 static_cast< cppu::OWeakObject * >( this ),
1061cdf0e10cSrcweir                                 aProps ) ),
1062cdf0e10cSrcweir             Environment );
1063cdf0e10cSrcweir         // Unreachable
1064cdf0e10cSrcweir 	}
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir     if ( !xInputStream.is() )
1067cdf0e10cSrcweir     {
1068cdf0e10cSrcweir         OSL_ENSURE( sal_False, "Content::insert - No data stream!" );
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir         ucbhelper::cancelCommandExecution(
1071cdf0e10cSrcweir             uno::makeAny( ucb::MissingInputStreamException(
1072cdf0e10cSrcweir                             rtl::OUString(),
1073cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) ) ),
1074cdf0e10cSrcweir             Environment );
1075cdf0e10cSrcweir         // Unreachable
1076cdf0e10cSrcweir     }
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 	// Assemble new content identifier...
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir     //	uno::Reference< ucb::XContentIdentifier > xId = ...;
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir     // Fail, if a resource with given id already exists.
1083cdf0e10cSrcweir     if ( !bReplaceExisting ) // && hasData( m_xIdentifier ) )
1084cdf0e10cSrcweir     {
1085cdf0e10cSrcweir 		ucbhelper::cancelCommandExecution(
1086cdf0e10cSrcweir             uno::makeAny( ucb::UnsupportedCommandException(
1087cdf0e10cSrcweir                             rtl::OUString(),
1088cdf0e10cSrcweir                             static_cast< cppu::OWeakObject * >( this ) ) ),
1089cdf0e10cSrcweir             Environment );
1090cdf0e10cSrcweir //        ucbhelper::cancelCommandExecution(
1091cdf0e10cSrcweir //						ucb::IOErrorCode_ALREADY_EXISTING,
1092cdf0e10cSrcweir //						Environment,
1093cdf0e10cSrcweir //						uno::makeAny(static_cast< cppu::OWeakObject * >( this ))
1094cdf0e10cSrcweir //                         );
1095cdf0e10cSrcweir         // Unreachable
1096cdf0e10cSrcweir     }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 	//	m_xIdentifier = xId;
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir //  @@@
1101cdf0e10cSrcweir //	storeData();
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir 	aGuard.clear();
1104cdf0e10cSrcweir 	inserted();
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir #if 0
1107cdf0e10cSrcweir //=========================================================================
1108cdf0e10cSrcweir void Content::destroy( sal_Bool bDeletePhysical )
1109cdf0e10cSrcweir     throw( uno::Exception )
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir 	// @@@ take care about bDeletePhysical -> trashcan support
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir     uno::Reference< ucb::XContent > xThis = this;
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir 	deleted();
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir 	// Process instanciated children...
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir 	ContentRefList aChildren;
1122cdf0e10cSrcweir 	queryChildren( aChildren );
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir 	ContentRefList::const_iterator it  = aChildren.begin();
1125cdf0e10cSrcweir 	ContentRefList::const_iterator end = aChildren.end();
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir 	while ( it != end )
1128cdf0e10cSrcweir 	{
1129cdf0e10cSrcweir 		(*it)->destroy( bDeletePhysical );
1130cdf0e10cSrcweir 		++it;
1131cdf0e10cSrcweir 	}
1132cdf0e10cSrcweir }
1133cdf0e10cSrcweir #endif
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir // -----------------------------------------------------------------------------
openDoc()1136cdf0e10cSrcweir ::rtl::OUString Content::openDoc()
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir 	OSL_ENSURE(m_aProps.is(),"No valid content properties!");
1139cdf0e10cSrcweir 	return ContentProvider::openDoc(m_aProps);
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir // -----------------------------------------------------------------------------
changePropertyValue(const beans::PropertyValue & _rValue,sal_Int32 _rnCurrentPos,::rtl::OUString & _rsMemberValue,sal_Int32 & _rnChanged,uno::Sequence<uno::Any> & _rRet,uno::Sequence<beans::PropertyChangeEvent> & _rChanges)1142cdf0e10cSrcweir void Content::changePropertyValue(const beans::PropertyValue& _rValue,
1143cdf0e10cSrcweir 								  sal_Int32 _rnCurrentPos,
1144cdf0e10cSrcweir 								  ::rtl::OUString& _rsMemberValue,
1145cdf0e10cSrcweir 								  sal_Int32& _rnChanged,
1146cdf0e10cSrcweir 								  uno::Sequence< uno::Any >& _rRet,
1147cdf0e10cSrcweir 								  uno::Sequence< beans::PropertyChangeEvent >& _rChanges) throw (beans::IllegalTypeException)
1148cdf0e10cSrcweir {
1149cdf0e10cSrcweir     rtl::OUString sNewValue;
1150cdf0e10cSrcweir 	sal_Bool bError = sal_False;
1151cdf0e10cSrcweir 	if ( _rValue.Value >>= sNewValue )
1152cdf0e10cSrcweir 	{
1153cdf0e10cSrcweir 		if ( sNewValue != _rsMemberValue )
1154cdf0e10cSrcweir 		{
1155cdf0e10cSrcweir 			osl::Guard< osl::Mutex > aGuard( m_aMutex );
1156cdf0e10cSrcweir 			// first we have to check if we could change the property inside the DMS
1157cdf0e10cSrcweir 			::rtl::OString sDocInfoValue = ::rtl::OUStringToOString(sNewValue,RTL_TEXTENCODING_ASCII_US);
1158cdf0e10cSrcweir 			WORD nDocInfo = 0;
1159cdf0e10cSrcweir 			if(&_rsMemberValue == &m_aProps->m_sTitle)
1160cdf0e10cSrcweir 				nDocInfo = ODM_TITLETEXT;
1161cdf0e10cSrcweir 			else if(&_rsMemberValue == &m_aProps->m_sAuthor)
1162cdf0e10cSrcweir 				nDocInfo = ODM_AUTHOR;
1163cdf0e10cSrcweir 			else if(&_rsMemberValue == &m_aProps->m_sSubject)
1164cdf0e10cSrcweir 				nDocInfo = ODM_SUBJECT;
1165cdf0e10cSrcweir 			else if(&_rsMemberValue == &m_aProps->m_sKeywords)
1166cdf0e10cSrcweir 				nDocInfo = ODM_KEYWORDS;
1167cdf0e10cSrcweir 			else
1168cdf0e10cSrcweir 				bError = sal_True;
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir 			if(!bError)
1171cdf0e10cSrcweir 			{
1172cdf0e10cSrcweir 				ODMSTATUS odm = NODMSetDocInfo(	ContentProvider::getHandle(),
1173cdf0e10cSrcweir 												const_cast<sal_Char*>(m_aProps->m_sDocumentId.getStr()),
1174cdf0e10cSrcweir 												nDocInfo,
1175cdf0e10cSrcweir 												const_cast<sal_Char*>(sDocInfoValue.getStr())
1176cdf0e10cSrcweir 												);
1177cdf0e10cSrcweir 				if(odm == ODM_SUCCESS)
1178cdf0e10cSrcweir 				{
1179cdf0e10cSrcweir 					beans::PropertyChangeEvent aEvent;
1180cdf0e10cSrcweir 					aEvent.Source			= static_cast< cppu::OWeakObject * >( this );
1181cdf0e10cSrcweir 					aEvent.Further 			= sal_False;
1182cdf0e10cSrcweir 					aEvent.PropertyHandle	= -1;
1183cdf0e10cSrcweir 					aEvent.PropertyName		= _rValue.Name;
1184cdf0e10cSrcweir 					aEvent.OldValue			= uno::makeAny( _rsMemberValue );
1185cdf0e10cSrcweir 					aEvent.NewValue			= uno::makeAny( sNewValue );
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 					_rChanges.getArray()[ _rnChanged ] = aEvent;
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir 					_rsMemberValue = sNewValue;
1190cdf0e10cSrcweir 					++_rnChanged;
1191cdf0e10cSrcweir 				}
1192cdf0e10cSrcweir 			}
1193cdf0e10cSrcweir 		}
1194cdf0e10cSrcweir         else
1195cdf0e10cSrcweir         {
1196cdf0e10cSrcweir             // Old value equals new value. No error!
1197cdf0e10cSrcweir         }
1198cdf0e10cSrcweir 	}
1199cdf0e10cSrcweir     else
1200cdf0e10cSrcweir 		bError = sal_True;
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir 	if(bError)
1203cdf0e10cSrcweir     {
1204cdf0e10cSrcweir         _rRet[ _rnCurrentPos ] <<= beans::IllegalTypeException(
1205cdf0e10cSrcweir                         rtl::OUString::createFromAscii(
1206cdf0e10cSrcweir                             "Property value has wrong type!" ),
1207cdf0e10cSrcweir                         static_cast< cppu::OWeakObject * >( this ) );
1208cdf0e10cSrcweir     }
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir // -----------------------------------------------------------------------------
1211cdf0e10cSrcweir 
1212