1*2f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2f86921cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2f86921cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2f86921cSAndrew Rist  * distributed with this work for additional information
6*2f86921cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2f86921cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2f86921cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2f86921cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2f86921cSAndrew Rist  *
11*2f86921cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2f86921cSAndrew Rist  *
13*2f86921cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2f86921cSAndrew Rist  * software distributed under the License is distributed on an
15*2f86921cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2f86921cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2f86921cSAndrew Rist  * specific language governing permissions and limitations
18*2f86921cSAndrew Rist  * under the License.
19*2f86921cSAndrew Rist  *
20*2f86921cSAndrew Rist  *************************************************************/
21*2f86921cSAndrew Rist 
22*2f86921cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "precompiled_ucb.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "ucpext_content.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "ucpext_content.hxx"
29cdf0e10cSrcweir #include "ucpext_provider.hxx"
30cdf0e10cSrcweir #include "ucpext_resultset.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir /** === begin UNO includes === **/
33cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
34cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyAccess.hpp>
35cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp>
36cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
37cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandInfo.hpp>
38cdf0e10cSrcweir #include <com/sun/star/ucb/XPersistentPropertySet.hpp>
39cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
40cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp>
41cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
42cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
43cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
44cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
45cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
46cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
47cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp>
48cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp>
49cdf0e10cSrcweir #include <com/sun/star/deployment/XPackageInformationProvider.hpp>
50cdf0e10cSrcweir /** === end UNO includes === **/
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
53cdf0e10cSrcweir #include <ucbhelper/propertyvalueset.hxx>
54cdf0e10cSrcweir #include <ucbhelper/cancelcommandexecution.hxx>
55cdf0e10cSrcweir #include <ucbhelper/content.hxx>
56cdf0e10cSrcweir #include <tools/diagnose_ex.h>
57cdf0e10cSrcweir #include <comphelper/string.hxx>
58cdf0e10cSrcweir #include <comphelper/componentcontext.hxx>
59cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
60cdf0e10cSrcweir #include <rtl/uri.hxx>
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #include <algorithm>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //......................................................................................................................
65cdf0e10cSrcweir namespace ucb { namespace ucp { namespace ext
66cdf0e10cSrcweir {
67cdf0e10cSrcweir //......................................................................................................................
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	/** === begin UNO using === **/
70cdf0e10cSrcweir 	using ::com::sun::star::uno::Reference;
71cdf0e10cSrcweir 	using ::com::sun::star::uno::XInterface;
72cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_QUERY;
73cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_QUERY_THROW;
74cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_SET_THROW;
75cdf0e10cSrcweir 	using ::com::sun::star::uno::Exception;
76cdf0e10cSrcweir 	using ::com::sun::star::uno::RuntimeException;
77cdf0e10cSrcweir 	using ::com::sun::star::uno::Any;
78cdf0e10cSrcweir 	using ::com::sun::star::uno::makeAny;
79cdf0e10cSrcweir 	using ::com::sun::star::uno::Sequence;
80cdf0e10cSrcweir 	using ::com::sun::star::uno::Type;
81cdf0e10cSrcweir     using ::com::sun::star::lang::XMultiServiceFactory;
82cdf0e10cSrcweir     using ::com::sun::star::ucb::XContentIdentifier;
83cdf0e10cSrcweir     using ::com::sun::star::ucb::IllegalIdentifierException;
84cdf0e10cSrcweir     using ::com::sun::star::ucb::XContent;
85cdf0e10cSrcweir     using ::com::sun::star::ucb::XCommandEnvironment;
86cdf0e10cSrcweir     using ::com::sun::star::ucb::Command;
87cdf0e10cSrcweir     using ::com::sun::star::ucb::CommandAbortedException;
88cdf0e10cSrcweir     using ::com::sun::star::beans::Property;
89cdf0e10cSrcweir     using ::com::sun::star::lang::IllegalArgumentException;
90cdf0e10cSrcweir     using ::com::sun::star::beans::PropertyValue;
91cdf0e10cSrcweir     using ::com::sun::star::ucb::OpenCommandArgument2;
92cdf0e10cSrcweir     using ::com::sun::star::ucb::XDynamicResultSet;
93cdf0e10cSrcweir     using ::com::sun::star::ucb::UnsupportedOpenModeException;
94cdf0e10cSrcweir     using ::com::sun::star::io::XOutputStream;
95cdf0e10cSrcweir     using ::com::sun::star::io::XActiveDataSink;
96cdf0e10cSrcweir     using ::com::sun::star::io::XInputStream;
97cdf0e10cSrcweir     using ::com::sun::star::ucb::UnsupportedDataSinkException;
98cdf0e10cSrcweir     using ::com::sun::star::ucb::UnsupportedCommandException;
99cdf0e10cSrcweir     using ::com::sun::star::sdbc::XRow;
100cdf0e10cSrcweir     using ::com::sun::star::beans::XPropertySet;
101cdf0e10cSrcweir     using ::com::sun::star::beans::PropertyChangeEvent;
102cdf0e10cSrcweir     using ::com::sun::star::lang::IllegalAccessException;
103cdf0e10cSrcweir     using ::com::sun::star::ucb::CommandInfo;
104cdf0e10cSrcweir     using ::com::sun::star::deployment::XPackageInformationProvider;
105cdf0e10cSrcweir 	/** === end UNO using === **/
106cdf0e10cSrcweir     namespace OpenMode = ::com::sun::star::ucb::OpenMode;
107cdf0e10cSrcweir     namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     //==================================================================================================================
110cdf0e10cSrcweir     //= helper
111cdf0e10cSrcweir     //==================================================================================================================
112cdf0e10cSrcweir     namespace
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir         //--------------------------------------------------------------------------------------------------------------
lcl_compose(const::rtl::OUString & i_rBaseURL,const::rtl::OUString & i_rRelativeURL)115cdf0e10cSrcweir         ::rtl::OUString lcl_compose( const ::rtl::OUString& i_rBaseURL, const ::rtl::OUString& i_rRelativeURL )
116cdf0e10cSrcweir         {
117cdf0e10cSrcweir             ENSURE_OR_RETURN( i_rBaseURL.getLength(), "illegal base URL", i_rRelativeURL );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir             ::rtl::OUStringBuffer aComposer( i_rBaseURL );
120cdf0e10cSrcweir             if ( i_rBaseURL.getStr()[ i_rBaseURL.getLength() - 1 ] != '/' )
121cdf0e10cSrcweir                 aComposer.append( sal_Unicode( '/' ) );
122cdf0e10cSrcweir             aComposer.append( i_rRelativeURL );
123cdf0e10cSrcweir             return aComposer.makeStringAndClear();
124cdf0e10cSrcweir         }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir         //--------------------------------------------------------------------------------------------------------------
127cdf0e10cSrcweir         struct SelectPropertyName : public ::std::unary_function< Property, ::rtl::OUString >
128cdf0e10cSrcweir         {
operator ()ucb::ucp::ext::__anon3bcc05aa0111::SelectPropertyName129cdf0e10cSrcweir             const ::rtl::OUString& operator()( const Property& i_rProperty ) const
130cdf0e10cSrcweir             {
131cdf0e10cSrcweir                 return i_rProperty.Name;
132cdf0e10cSrcweir             }
133cdf0e10cSrcweir         };
134cdf0e10cSrcweir     }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     //==================================================================================================================
137cdf0e10cSrcweir     //= Content
138cdf0e10cSrcweir     //==================================================================================================================
139cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
Content(const Reference<XMultiServiceFactory> & i_rORB,::ucbhelper::ContentProviderImplHelper * i_pProvider,const Reference<XContentIdentifier> & i_rIdentifier)140cdf0e10cSrcweir     Content::Content( const Reference< XMultiServiceFactory >& i_rORB, ::ucbhelper::ContentProviderImplHelper* i_pProvider,
141cdf0e10cSrcweir                       const Reference< XContentIdentifier >& i_rIdentifier )
142cdf0e10cSrcweir         :Content_Base( i_rORB, i_pProvider, i_rIdentifier )
143cdf0e10cSrcweir         ,m_eExtContentType( E_UNKNOWN )
144cdf0e10cSrcweir         ,m_aIsFolder()
145cdf0e10cSrcweir         ,m_aContentType()
146cdf0e10cSrcweir         ,m_sExtensionId()
147cdf0e10cSrcweir         ,m_sPathIntoExtension()
148cdf0e10cSrcweir     {
149cdf0e10cSrcweir         const ::rtl::OUString sURL( getIdentifier()->getContentIdentifier() );
150cdf0e10cSrcweir         if ( denotesRootContent( sURL ) )
151cdf0e10cSrcweir         {
152cdf0e10cSrcweir             m_eExtContentType = E_ROOT;
153cdf0e10cSrcweir         }
154cdf0e10cSrcweir         else
155cdf0e10cSrcweir         {
156cdf0e10cSrcweir             const ::rtl::OUString sRelativeURL( sURL.copy( ContentProvider::getRootURL().getLength() ) );
157cdf0e10cSrcweir             const sal_Int32 nSepPos = sRelativeURL.indexOf( '/' );
158cdf0e10cSrcweir             if ( ( nSepPos == -1 ) || ( nSepPos == sRelativeURL.getLength() - 1 ) )
159cdf0e10cSrcweir             {
160cdf0e10cSrcweir                 m_eExtContentType = E_EXTENSION_ROOT;
161cdf0e10cSrcweir             }
162cdf0e10cSrcweir             else
163cdf0e10cSrcweir             {
164cdf0e10cSrcweir                 m_eExtContentType = E_EXTENSION_CONTENT;
165cdf0e10cSrcweir             }
166cdf0e10cSrcweir         }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         if ( m_eExtContentType != E_ROOT )
169cdf0e10cSrcweir         {
170cdf0e10cSrcweir             const ::rtl::OUString sRootURL = ContentProvider::getRootURL();
171cdf0e10cSrcweir             m_sExtensionId = sURL.copy( sRootURL.getLength() );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir             const sal_Int32 nNextSep = m_sExtensionId.indexOf( '/' );
174cdf0e10cSrcweir             if ( nNextSep > -1 )
175cdf0e10cSrcweir             {
176cdf0e10cSrcweir                 m_sPathIntoExtension = m_sExtensionId.copy( nNextSep + 1 );
177cdf0e10cSrcweir                 m_sExtensionId = m_sExtensionId.copy( 0, nNextSep );
178cdf0e10cSrcweir             }
179cdf0e10cSrcweir             m_sExtensionId = Content::decodeIdentifier( m_sExtensionId );
180cdf0e10cSrcweir         }
181cdf0e10cSrcweir     }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
~Content()184cdf0e10cSrcweir     Content::~Content()
185cdf0e10cSrcweir     {
186cdf0e10cSrcweir     }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getImplementationName()189cdf0e10cSrcweir     ::rtl::OUString SAL_CALL Content::getImplementationName() throw( RuntimeException )
190cdf0e10cSrcweir     {
191cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.ucp.ext.Content" ) );
192cdf0e10cSrcweir     }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getSupportedServiceNames()195cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL Content::getSupportedServiceNames() throw( RuntimeException )
196cdf0e10cSrcweir     {
197cdf0e10cSrcweir         Sequence< ::rtl::OUString > aServiceNames(2);
198cdf0e10cSrcweir         aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.Content" ) );
199cdf0e10cSrcweir         aServiceNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.ExtensionContent" ) );
200cdf0e10cSrcweir         return aServiceNames;
201cdf0e10cSrcweir     }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getContentType()204cdf0e10cSrcweir     ::rtl::OUString SAL_CALL Content::getContentType() throw( RuntimeException )
205cdf0e10cSrcweir     {
206cdf0e10cSrcweir         impl_determineContentType();
207cdf0e10cSrcweir         return *m_aContentType;
208cdf0e10cSrcweir     }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
execute(const Command & aCommand,sal_Int32,const Reference<XCommandEnvironment> & i_rEvironment)211cdf0e10cSrcweir     Any SAL_CALL Content::execute( const Command& aCommand, sal_Int32 /* CommandId */, const Reference< XCommandEnvironment >& i_rEvironment )
212cdf0e10cSrcweir         throw( Exception, CommandAbortedException, RuntimeException )
213cdf0e10cSrcweir     {
214cdf0e10cSrcweir         Any aRet;
215cdf0e10cSrcweir 
216cdf0e10cSrcweir         if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) )
217cdf0e10cSrcweir 	    {
218cdf0e10cSrcweir             Sequence< Property > Properties;
219cdf0e10cSrcweir 		    if ( !( aCommand.Argument >>= Properties ) )
220cdf0e10cSrcweir 		    {
221cdf0e10cSrcweir                 ::ucbhelper::cancelCommandExecution( makeAny( IllegalArgumentException(
222cdf0e10cSrcweir                     ::rtl::OUString(), *this, -1 ) ),
223cdf0e10cSrcweir                     i_rEvironment );
224cdf0e10cSrcweir                 // unreachable
225cdf0e10cSrcweir 		    }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir             aRet <<= getPropertyValues( Properties, i_rEvironment );
228cdf0e10cSrcweir 	    }
229cdf0e10cSrcweir         else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "setPropertyValues" ) ) )
230cdf0e10cSrcweir         {
231cdf0e10cSrcweir             Sequence< PropertyValue > aProperties;
232cdf0e10cSrcweir 		    if ( !( aCommand.Argument >>= aProperties ) )
233cdf0e10cSrcweir 		    {
234cdf0e10cSrcweir                 ::ucbhelper::cancelCommandExecution( makeAny( IllegalArgumentException(
235cdf0e10cSrcweir                     ::rtl::OUString(), *this, -1 ) ),
236cdf0e10cSrcweir                     i_rEvironment );
237cdf0e10cSrcweir                 // unreachable
238cdf0e10cSrcweir             }
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 		    if ( !aProperties.getLength() )
241cdf0e10cSrcweir 		    {
242cdf0e10cSrcweir                 ::ucbhelper::cancelCommandExecution( makeAny( IllegalArgumentException(
243cdf0e10cSrcweir                     ::rtl::OUString(), *this, -1 ) ),
244cdf0e10cSrcweir                     i_rEvironment );
245cdf0e10cSrcweir                 // unreachable
246cdf0e10cSrcweir             }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir             aRet <<= setPropertyValues( aProperties, i_rEvironment );
249cdf0e10cSrcweir 	    }
250cdf0e10cSrcweir         else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getPropertySetInfo" ) ) )
251cdf0e10cSrcweir         {
252cdf0e10cSrcweir 		    // implemented by base class.
253cdf0e10cSrcweir 		    aRet <<= getPropertySetInfo( i_rEvironment );
254cdf0e10cSrcweir 	    }
255cdf0e10cSrcweir         else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getCommandInfo" ) ) )
256cdf0e10cSrcweir         {
257cdf0e10cSrcweir 		    // implemented by base class.
258cdf0e10cSrcweir 		    aRet <<= getCommandInfo( i_rEvironment );
259cdf0e10cSrcweir 	    }
260cdf0e10cSrcweir         else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "open" ) ) )
261cdf0e10cSrcweir         {
262cdf0e10cSrcweir             OpenCommandArgument2 aOpenCommand;
263cdf0e10cSrcweir       	    if ( !( aCommand.Argument >>= aOpenCommand ) )
264cdf0e10cSrcweir 		    {
265cdf0e10cSrcweir                 ::ucbhelper::cancelCommandExecution( makeAny( IllegalArgumentException(
266cdf0e10cSrcweir                     ::rtl::OUString(), *this, -1 ) ),
267cdf0e10cSrcweir                     i_rEvironment );
268cdf0e10cSrcweir                 // unreachable
269cdf0e10cSrcweir             }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir             sal_Bool bOpenFolder =
272cdf0e10cSrcweir                 ( ( aOpenCommand.Mode == OpenMode::ALL ) ||
273cdf0e10cSrcweir                   ( aOpenCommand.Mode == OpenMode::FOLDERS ) ||
274cdf0e10cSrcweir                   ( aOpenCommand.Mode == OpenMode::DOCUMENTS ) );
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 
277cdf0e10cSrcweir             if ( bOpenFolder && impl_isFolder() )
278cdf0e10cSrcweir 		    {
279cdf0e10cSrcweir                 Reference< XDynamicResultSet > xSet = new ResultSet(
280cdf0e10cSrcweir                     m_xSMgr, this, aOpenCommand, i_rEvironment );
281cdf0e10cSrcweir     		    aRet <<= xSet;
282cdf0e10cSrcweir   		    }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir             if ( aOpenCommand.Sink.is() )
285cdf0e10cSrcweir             {
286cdf0e10cSrcweir                 const ::rtl::OUString sPhysicalContentURL( getPhysicalURL() );
287cdf0e10cSrcweir                 ::ucbhelper::Content aRequestedContent( sPhysicalContentURL, i_rEvironment );
288cdf0e10cSrcweir                 aRet = aRequestedContent.executeCommand( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), makeAny( aOpenCommand ) );
289cdf0e10cSrcweir 		    }
290cdf0e10cSrcweir 	    }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 	    else
293cdf0e10cSrcweir 	    {
294cdf0e10cSrcweir             ::ucbhelper::cancelCommandExecution( makeAny( UnsupportedCommandException(
295cdf0e10cSrcweir                 ::rtl::OUString(), *this ) ),
296cdf0e10cSrcweir                 i_rEvironment );
297cdf0e10cSrcweir             // unreachable
298cdf0e10cSrcweir         }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	    return aRet;
301cdf0e10cSrcweir     }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
abort(sal_Int32)304cdf0e10cSrcweir     void SAL_CALL Content::abort( sal_Int32 ) throw( RuntimeException )
305cdf0e10cSrcweir     {
306cdf0e10cSrcweir     }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
encodeIdentifier(const::rtl::OUString & i_rIdentifier)309cdf0e10cSrcweir     ::rtl::OUString Content::encodeIdentifier( const ::rtl::OUString& i_rIdentifier )
310cdf0e10cSrcweir     {
311cdf0e10cSrcweir         return ::rtl::Uri::encode( i_rIdentifier, rtl_UriCharClassRegName, rtl_UriEncodeIgnoreEscapes,
312cdf0e10cSrcweir             RTL_TEXTENCODING_UTF8 );
313cdf0e10cSrcweir     }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
decodeIdentifier(const::rtl::OUString & i_rIdentifier)316cdf0e10cSrcweir     ::rtl::OUString Content::decodeIdentifier( const ::rtl::OUString& i_rIdentifier )
317cdf0e10cSrcweir     {
318cdf0e10cSrcweir         return ::rtl::Uri::decode( i_rIdentifier, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
319cdf0e10cSrcweir     }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
denotesRootContent(const::rtl::OUString & i_rContentIdentifier)322cdf0e10cSrcweir     bool Content::denotesRootContent( const ::rtl::OUString& i_rContentIdentifier )
323cdf0e10cSrcweir     {
324cdf0e10cSrcweir         const ::rtl::OUString sRootURL( ContentProvider::getRootURL() );
325cdf0e10cSrcweir         if ( i_rContentIdentifier == sRootURL )
326cdf0e10cSrcweir             return true;
327cdf0e10cSrcweir 
328cdf0e10cSrcweir         // the root URL contains only two trailing /, but we also recognize 3 of them as denoting the root URL
329cdf0e10cSrcweir         if  (   i_rContentIdentifier.match( sRootURL )
330cdf0e10cSrcweir             &&  ( i_rContentIdentifier.getLength() == sRootURL.getLength() + 1 )
331cdf0e10cSrcweir             &&  ( i_rContentIdentifier[ i_rContentIdentifier.getLength() - 1 ] == '/' )
332cdf0e10cSrcweir             )
333cdf0e10cSrcweir             return true;
334cdf0e10cSrcweir 
335cdf0e10cSrcweir         return false;
336cdf0e10cSrcweir     }
337cdf0e10cSrcweir 
338cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getParentURL()339cdf0e10cSrcweir     ::rtl::OUString Content::getParentURL()
340cdf0e10cSrcweir     {
341cdf0e10cSrcweir         const ::rtl::OUString sRootURL( ContentProvider::getRootURL() );
342cdf0e10cSrcweir 
343cdf0e10cSrcweir         switch ( m_eExtContentType )
344cdf0e10cSrcweir         {
345cdf0e10cSrcweir         case E_ROOT:
346cdf0e10cSrcweir             // don't have a parent
347cdf0e10cSrcweir             return sRootURL;
348cdf0e10cSrcweir 
349cdf0e10cSrcweir         case E_EXTENSION_ROOT:
350cdf0e10cSrcweir             // our parent is the root itself
351cdf0e10cSrcweir             return sRootURL;
352cdf0e10cSrcweir 
353cdf0e10cSrcweir         case E_EXTENSION_CONTENT:
354cdf0e10cSrcweir         {
355cdf0e10cSrcweir             const ::rtl::OUString sURL = m_xIdentifier->getContentIdentifier();
356cdf0e10cSrcweir 
357cdf0e10cSrcweir             // cut the root URL
358cdf0e10cSrcweir             ENSURE_OR_BREAK( sURL.match( sRootURL, 0 ), "illegal URL structure - no root" );
359cdf0e10cSrcweir             ::rtl::OUString sRelativeURL( sURL.copy( sRootURL.getLength() ) );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir             // cut the extension ID
362cdf0e10cSrcweir             const ::rtl::OUString sSeparatedExtensionId( encodeIdentifier( m_sExtensionId ) + ::rtl::OUString( sal_Unicode( '/' ) ) );
363cdf0e10cSrcweir             ENSURE_OR_BREAK( sRelativeURL.match( sSeparatedExtensionId ), "illegal URL structure - no extension ID" );
364cdf0e10cSrcweir             sRelativeURL = sRelativeURL.copy( sSeparatedExtensionId.getLength() );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir             // cut the final slash (if any)
367cdf0e10cSrcweir             ENSURE_OR_BREAK( sRelativeURL.getLength(), "illegal URL structure - ExtensionContent should have a level below the extension ID" );
368cdf0e10cSrcweir             if ( sRelativeURL.getStr()[ sRelativeURL.getLength() - 1 ] == '/' )
369cdf0e10cSrcweir                 sRelativeURL = sRelativeURL.copy( 0, sRelativeURL.getLength() - 1 );
370cdf0e10cSrcweir 
371cdf0e10cSrcweir             // remove the last segment
372cdf0e10cSrcweir             const sal_Int32 nLastSep = sRelativeURL.lastIndexOf( '/' );
373cdf0e10cSrcweir             sRelativeURL = sRelativeURL.copy( 0, nLastSep != -1 ? nLastSep : 0 );
374cdf0e10cSrcweir 
375cdf0e10cSrcweir             ::rtl::OUStringBuffer aComposer;
376cdf0e10cSrcweir             aComposer.append( sRootURL );
377cdf0e10cSrcweir             aComposer.append( sSeparatedExtensionId );
378cdf0e10cSrcweir             aComposer.append( sRelativeURL );
379cdf0e10cSrcweir             return aComposer.makeStringAndClear();
380cdf0e10cSrcweir         }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir         default:
383cdf0e10cSrcweir             OSL_ENSURE( false, "Content::getParentURL: unhandled case!" );
384cdf0e10cSrcweir             break;
385cdf0e10cSrcweir         }
386cdf0e10cSrcweir         return ::rtl::OUString();
387cdf0e10cSrcweir     }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getArtificialNodePropertyValues(const Reference<XMultiServiceFactory> & i_rORB,const Sequence<Property> & i_rProperties,const::rtl::OUString & i_rTitle)390cdf0e10cSrcweir     Reference< XRow > Content::getArtificialNodePropertyValues( const Reference< XMultiServiceFactory >& i_rORB,
391cdf0e10cSrcweir         const Sequence< Property >& i_rProperties, const ::rtl::OUString& i_rTitle )
392cdf0e10cSrcweir     {
393cdf0e10cSrcweir 	    // note: empty sequence means "get values of all supported properties".
394cdf0e10cSrcweir         ::rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( i_rORB );
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 	    const sal_Int32 nCount = i_rProperties.getLength();
397cdf0e10cSrcweir 	    if ( nCount )
398cdf0e10cSrcweir 	    {
399cdf0e10cSrcweir             Reference< XPropertySet > xAdditionalPropSet;
400cdf0e10cSrcweir 
401cdf0e10cSrcweir             const Property* pProps = i_rProperties.getConstArray();
402cdf0e10cSrcweir 		    for ( sal_Int32 n = 0; n < nCount; ++n )
403cdf0e10cSrcweir 		    {
404cdf0e10cSrcweir                 const Property& rProp = pProps[ n ];
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 			    // Process Core properties.
407cdf0e10cSrcweir                 if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
408cdf0e10cSrcweir                 {
409cdf0e10cSrcweir                     xRow->appendString ( rProp, ContentProvider::getArtificialNodeContentType() );
410cdf0e10cSrcweir 			    }
411cdf0e10cSrcweir                 else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
412cdf0e10cSrcweir 			    {
413cdf0e10cSrcweir 				    xRow->appendString ( rProp, i_rTitle );
414cdf0e10cSrcweir 			    }
415cdf0e10cSrcweir                 else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
416cdf0e10cSrcweir 			    {
417cdf0e10cSrcweir 				    xRow->appendBoolean( rProp, sal_False );
418cdf0e10cSrcweir 			    }
419cdf0e10cSrcweir                 else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
420cdf0e10cSrcweir 			    {
421cdf0e10cSrcweir 				    xRow->appendBoolean( rProp, sal_True );
422cdf0e10cSrcweir 			    }
423cdf0e10cSrcweir 			    else
424cdf0e10cSrcweir 			    {
425cdf0e10cSrcweir 				    // append empty entry.
426cdf0e10cSrcweir 				    xRow->appendVoid( rProp );
427cdf0e10cSrcweir 			    }
428cdf0e10cSrcweir 		    }
429cdf0e10cSrcweir 	    }
430cdf0e10cSrcweir 	    else
431cdf0e10cSrcweir 	    {
432cdf0e10cSrcweir 		    // Append all Core Properties.
433cdf0e10cSrcweir 		    xRow->appendString ( Property( ::rtl::OUString::createFromAscii( "ContentType" ),
434cdf0e10cSrcweir 					      -1,
435cdf0e10cSrcweir                           getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ),
436cdf0e10cSrcweir                           PropertyAttribute::BOUND | PropertyAttribute::READONLY ),
437cdf0e10cSrcweir 			    ContentProvider::getArtificialNodeContentType() );
438cdf0e10cSrcweir 		    xRow->appendString ( Property( ::rtl::OUString::createFromAscii( "Title" ),
439cdf0e10cSrcweir 					      -1,
440cdf0e10cSrcweir                           getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ),
441cdf0e10cSrcweir                           PropertyAttribute::BOUND | PropertyAttribute::READONLY ),
442cdf0e10cSrcweir 			    i_rTitle );
443cdf0e10cSrcweir 		    xRow->appendBoolean( Property( ::rtl::OUString::createFromAscii( "IsDocument" ),
444cdf0e10cSrcweir 					      -1,
445cdf0e10cSrcweir 					      getCppuBooleanType(),
446cdf0e10cSrcweir                           PropertyAttribute::BOUND | PropertyAttribute::READONLY ),
447cdf0e10cSrcweir 			    sal_False );
448cdf0e10cSrcweir 		    xRow->appendBoolean( Property( ::rtl::OUString::createFromAscii( "IsFolder" ),
449cdf0e10cSrcweir 					      -1,
450cdf0e10cSrcweir 					      getCppuBooleanType(),
451cdf0e10cSrcweir                           PropertyAttribute::BOUND | PropertyAttribute::READONLY ),
452cdf0e10cSrcweir 			    sal_True );
453cdf0e10cSrcweir 	    }
454cdf0e10cSrcweir 
455cdf0e10cSrcweir         return Reference< XRow >( xRow.get() );
456cdf0e10cSrcweir     }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getPhysicalURL() const459cdf0e10cSrcweir     ::rtl::OUString Content::getPhysicalURL() const
460cdf0e10cSrcweir     {
461cdf0e10cSrcweir         ENSURE_OR_RETURN( m_eExtContentType != E_ROOT, "illegal call", ::rtl::OUString() );
462cdf0e10cSrcweir 
463cdf0e10cSrcweir         // create an ucb::XContent for the physical file within the deployed extension
464cdf0e10cSrcweir         const ::comphelper::ComponentContext aContext( m_xSMgr );
465cdf0e10cSrcweir         const Reference< XPackageInformationProvider > xPackageInfo(
466cdf0e10cSrcweir             aContext.getSingleton( "com.sun.star.deployment.PackageInformationProvider" ), UNO_QUERY_THROW );
467cdf0e10cSrcweir         const ::rtl::OUString sPackageLocation( xPackageInfo->getPackageLocation( m_sExtensionId ) );
468cdf0e10cSrcweir 
469cdf0e10cSrcweir         if ( m_sPathIntoExtension.getLength() == 0 )
470cdf0e10cSrcweir             return sPackageLocation;
471cdf0e10cSrcweir         return lcl_compose( sPackageLocation, m_sPathIntoExtension );
472cdf0e10cSrcweir     }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getPropertyValues(const Sequence<Property> & i_rProperties,const Reference<XCommandEnvironment> & i_rEnv)475cdf0e10cSrcweir     Reference< XRow > Content::getPropertyValues( const Sequence< Property >& i_rProperties, const Reference< XCommandEnvironment >& i_rEnv )
476cdf0e10cSrcweir     {
477cdf0e10cSrcweir         ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
478cdf0e10cSrcweir 
479cdf0e10cSrcweir         switch ( m_eExtContentType )
480cdf0e10cSrcweir         {
481cdf0e10cSrcweir         case E_ROOT:
482cdf0e10cSrcweir 	        return getArtificialNodePropertyValues( m_xSMgr, i_rProperties, ContentProvider::getRootURL() );
483cdf0e10cSrcweir         case E_EXTENSION_ROOT:
484cdf0e10cSrcweir 	        return getArtificialNodePropertyValues( m_xSMgr, i_rProperties, m_sExtensionId );
485cdf0e10cSrcweir         case E_EXTENSION_CONTENT:
486cdf0e10cSrcweir         {
487cdf0e10cSrcweir             const ::rtl::OUString sPhysicalContentURL( getPhysicalURL() );
488cdf0e10cSrcweir             ::ucbhelper::Content aRequestedContent( sPhysicalContentURL, i_rEnv );
489cdf0e10cSrcweir 
490cdf0e10cSrcweir             // translate the property request
491cdf0e10cSrcweir             Sequence< ::rtl::OUString > aPropertyNames( i_rProperties.getLength() );
492cdf0e10cSrcweir             ::std::transform(
493cdf0e10cSrcweir                 i_rProperties.getConstArray(),
494cdf0e10cSrcweir                 i_rProperties.getConstArray() + i_rProperties.getLength(),
495cdf0e10cSrcweir                 aPropertyNames.getArray(),
496cdf0e10cSrcweir                 SelectPropertyName()
497cdf0e10cSrcweir             );
498cdf0e10cSrcweir             const Sequence< Any > aPropertyValues = aRequestedContent.getPropertyValues( aPropertyNames );
499cdf0e10cSrcweir             const ::rtl::Reference< ::ucbhelper::PropertyValueSet > xValueRow = new ::ucbhelper::PropertyValueSet( m_xSMgr );
500cdf0e10cSrcweir             sal_Int32 i=0;
501cdf0e10cSrcweir             for (   const Any* value = aPropertyValues.getConstArray();
502cdf0e10cSrcweir                     value != aPropertyValues.getConstArray() + aPropertyValues.getLength();
503cdf0e10cSrcweir                     ++value, ++i
504cdf0e10cSrcweir                 )
505cdf0e10cSrcweir             {
506cdf0e10cSrcweir                 xValueRow->appendObject( aPropertyNames[i], *value );
507cdf0e10cSrcweir             }
508cdf0e10cSrcweir             return xValueRow.get();
509cdf0e10cSrcweir         }
510cdf0e10cSrcweir 
511cdf0e10cSrcweir         default:
512cdf0e10cSrcweir             OSL_ENSURE( false, "Content::getPropertyValues: unhandled case!" );
513cdf0e10cSrcweir             break;
514cdf0e10cSrcweir         }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir         OSL_ENSURE( false, "Content::getPropertyValues: unreachable!" );
517cdf0e10cSrcweir         return NULL;
518cdf0e10cSrcweir     }
519cdf0e10cSrcweir 
520cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
setPropertyValues(const Sequence<PropertyValue> & i_rValues,const Reference<XCommandEnvironment> &)521cdf0e10cSrcweir     Sequence< Any > Content::setPropertyValues( const Sequence< PropertyValue >& i_rValues, const Reference< XCommandEnvironment >& /* xEnv */)
522cdf0e10cSrcweir     {
523cdf0e10cSrcweir         ::osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
524cdf0e10cSrcweir 
525cdf0e10cSrcweir         Sequence< Any > aRet( i_rValues.getLength() );
526cdf0e10cSrcweir         Sequence< PropertyChangeEvent > aChanges( i_rValues.getLength() );
527cdf0e10cSrcweir 
528cdf0e10cSrcweir         PropertyChangeEvent aEvent;
529cdf0e10cSrcweir         aEvent.Source         = static_cast< cppu::OWeakObject * >( this );
530cdf0e10cSrcweir 	    aEvent.Further 		  = sal_False;
531cdf0e10cSrcweir         aEvent.PropertyHandle = -1;
532cdf0e10cSrcweir 
533cdf0e10cSrcweir         const PropertyValue* pValues = i_rValues.getConstArray();
534cdf0e10cSrcweir 	    const sal_Int32 nCount = i_rValues.getLength();
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 	    for ( sal_Int32 n = 0; n < nCount; ++n, ++pValues )
537cdf0e10cSrcweir 	    {
538cdf0e10cSrcweir 		    // all our properties are read-only ...
539cdf0e10cSrcweir             aRet[ n ] <<= IllegalAccessException( ::rtl::OUString::createFromAscii( "property is read-only." ), *this );
540cdf0e10cSrcweir 	    }
541cdf0e10cSrcweir 
542cdf0e10cSrcweir         return aRet;
543cdf0e10cSrcweir     }
544cdf0e10cSrcweir 
545cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getCommands(const Reference<XCommandEnvironment> &)546cdf0e10cSrcweir     Sequence< CommandInfo > Content::getCommands( const Reference< XCommandEnvironment > & /*xEnv*/ )
547cdf0e10cSrcweir     {
548cdf0e10cSrcweir 	    sal_uInt32 nCommandCount = 5;
549cdf0e10cSrcweir         static const CommandInfo aCommandInfoTable[] =
550cdf0e10cSrcweir 	    {
551cdf0e10cSrcweir 		    ///////////////////////////////////////////////////////////////
552cdf0e10cSrcweir 		    // Mandatory commands
553cdf0e10cSrcweir 		    ///////////////////////////////////////////////////////////////
554cdf0e10cSrcweir             CommandInfo(
555cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
556cdf0e10cSrcweir 			    -1,
557cdf0e10cSrcweir 			    getCppuVoidType()
558cdf0e10cSrcweir 		    ),
559cdf0e10cSrcweir             CommandInfo(
560cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
561cdf0e10cSrcweir 			    -1,
562cdf0e10cSrcweir 			    getCppuVoidType()
563cdf0e10cSrcweir 		    ),
564cdf0e10cSrcweir             CommandInfo(
565cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
566cdf0e10cSrcweir 			    -1,
567cdf0e10cSrcweir                 getCppuType(
568cdf0e10cSrcweir                     static_cast< Sequence< Property > * >( 0 ) )
569cdf0e10cSrcweir 		    ),
570cdf0e10cSrcweir             CommandInfo(
571cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
572cdf0e10cSrcweir 			    -1,
573cdf0e10cSrcweir                 getCppuType(
574cdf0e10cSrcweir                     static_cast< Sequence< PropertyValue > * >( 0 ) )
575cdf0e10cSrcweir 		    )
576cdf0e10cSrcweir 		    ///////////////////////////////////////////////////////////////
577cdf0e10cSrcweir 		    // Optional standard commands
578cdf0e10cSrcweir 		    ///////////////////////////////////////////////////////////////
579cdf0e10cSrcweir             , CommandInfo(
580cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
581cdf0e10cSrcweir 			    -1,
582cdf0e10cSrcweir                 getCppuType( static_cast< OpenCommandArgument2 * >( 0 ) )
583cdf0e10cSrcweir 		    )
584cdf0e10cSrcweir 	    };
585cdf0e10cSrcweir 
586cdf0e10cSrcweir         return Sequence< CommandInfo >( aCommandInfoTable, nCommandCount );
587cdf0e10cSrcweir     }
588cdf0e10cSrcweir 
589cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getProperties(const Reference<XCommandEnvironment> &)590cdf0e10cSrcweir     Sequence< Property > Content::getProperties( const Reference< XCommandEnvironment > & /*xEnv*/ )
591cdf0e10cSrcweir     {
592cdf0e10cSrcweir         static Property aProperties[] =
593cdf0e10cSrcweir 	    {
594cdf0e10cSrcweir             Property(
595cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
596cdf0e10cSrcweir 			    -1,
597cdf0e10cSrcweir                 getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ),
598cdf0e10cSrcweir                 PropertyAttribute::BOUND | PropertyAttribute::READONLY
599cdf0e10cSrcweir 		    ),
600cdf0e10cSrcweir             Property(
601cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
602cdf0e10cSrcweir 			    -1,
603cdf0e10cSrcweir 			    getCppuBooleanType(),
604cdf0e10cSrcweir                 PropertyAttribute::BOUND | PropertyAttribute::READONLY
605cdf0e10cSrcweir 		    ),
606cdf0e10cSrcweir             Property(
607cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
608cdf0e10cSrcweir 			    -1,
609cdf0e10cSrcweir 			    getCppuBooleanType(),
610cdf0e10cSrcweir                 PropertyAttribute::BOUND | PropertyAttribute::READONLY
611cdf0e10cSrcweir 		    ),
612cdf0e10cSrcweir             Property(
613cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
614cdf0e10cSrcweir 			    -1,
615cdf0e10cSrcweir                 getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ),
616cdf0e10cSrcweir                 PropertyAttribute::BOUND | PropertyAttribute::READONLY
617cdf0e10cSrcweir 		    )
618cdf0e10cSrcweir 	    };
619cdf0e10cSrcweir         return Sequence< Property >( aProperties, sizeof( aProperties ) / sizeof( aProperties[0] ) );
620cdf0e10cSrcweir     }
621cdf0e10cSrcweir 
622cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
impl_isFolder()623cdf0e10cSrcweir     bool Content::impl_isFolder()
624cdf0e10cSrcweir     {
625cdf0e10cSrcweir         if ( !!m_aIsFolder )
626cdf0e10cSrcweir             return *m_aIsFolder;
627cdf0e10cSrcweir 
628cdf0e10cSrcweir         bool bIsFolder = false;
629cdf0e10cSrcweir         try
630cdf0e10cSrcweir         {
631cdf0e10cSrcweir             Sequence< Property > aProps(1);
632cdf0e10cSrcweir             aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) );
633cdf0e10cSrcweir             Reference< XRow > xRow( getPropertyValues( aProps, NULL ), UNO_SET_THROW );
634cdf0e10cSrcweir             bIsFolder = xRow->getBoolean(1);
635cdf0e10cSrcweir         }
636cdf0e10cSrcweir         catch( const Exception& )
637cdf0e10cSrcweir         {
638cdf0e10cSrcweir         	DBG_UNHANDLED_EXCEPTION();
639cdf0e10cSrcweir         }
640cdf0e10cSrcweir         m_aIsFolder.reset( bIsFolder );
641cdf0e10cSrcweir         return *m_aIsFolder;
642cdf0e10cSrcweir     }
643cdf0e10cSrcweir 
644cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
impl_determineContentType()645cdf0e10cSrcweir     void Content::impl_determineContentType()
646cdf0e10cSrcweir     {
647cdf0e10cSrcweir         if ( !!m_aContentType )
648cdf0e10cSrcweir             return;
649cdf0e10cSrcweir 
650cdf0e10cSrcweir         m_aContentType.reset( ContentProvider::getArtificialNodeContentType() );
651cdf0e10cSrcweir         if ( m_eExtContentType == E_EXTENSION_CONTENT )
652cdf0e10cSrcweir         {
653cdf0e10cSrcweir             try
654cdf0e10cSrcweir             {
655cdf0e10cSrcweir                 Sequence< Property > aProps(1);
656cdf0e10cSrcweir                 aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) );
657cdf0e10cSrcweir                 Reference< XRow > xRow( getPropertyValues( aProps, NULL ), UNO_SET_THROW );
658cdf0e10cSrcweir                 m_aContentType.reset( xRow->getString(1) );
659cdf0e10cSrcweir             }
660cdf0e10cSrcweir             catch( const Exception& )
661cdf0e10cSrcweir             {
662cdf0e10cSrcweir         	    DBG_UNHANDLED_EXCEPTION();
663cdf0e10cSrcweir             }
664cdf0e10cSrcweir         }
665cdf0e10cSrcweir     }
666cdf0e10cSrcweir 
667cdf0e10cSrcweir //......................................................................................................................
668cdf0e10cSrcweir } } }   // namespace ucp::ext
669cdf0e10cSrcweir //......................................................................................................................
670