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