From ad195dcdbcb178b2df5602babb825863096f1c7a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 24 Mar 2010 12:05:06 +0100 Subject: slidecopy: initial version of an UCP for browsing the content of the deployed extensions --- ucb/prj/build.lst | 1 + ucb/source/ucp/ext/makefile.mk | 65 ++++ ucb/source/ucp/ext/ucpext.uno.map | 8 + ucb/source/ucp/ext/ucpext_content.cxx | 489 +++++++++++++++++++++++++++++ ucb/source/ucp/ext/ucpext_content.hxx | 144 +++++++++ ucb/source/ucp/ext/ucpext_datasupplier.cxx | 295 +++++++++++++++++ ucb/source/ucp/ext/ucpext_datasupplier.hxx | 84 +++++ ucb/source/ucp/ext/ucpext_provider.cxx | 147 +++++++++ ucb/source/ucp/ext/ucpext_provider.hxx | 64 ++++ ucb/source/ucp/ext/ucpext_resultset.cxx | 97 ++++++ ucb/source/ucp/ext/ucpext_resultset.hxx | 66 ++++ ucb/source/ucp/ext/ucpext_services.cxx | 93 ++++++ 12 files changed, 1553 insertions(+) create mode 100644 ucb/source/ucp/ext/makefile.mk create mode 100644 ucb/source/ucp/ext/ucpext.uno.map create mode 100644 ucb/source/ucp/ext/ucpext_content.cxx create mode 100644 ucb/source/ucp/ext/ucpext_content.hxx create mode 100644 ucb/source/ucp/ext/ucpext_datasupplier.cxx create mode 100644 ucb/source/ucp/ext/ucpext_datasupplier.hxx create mode 100644 ucb/source/ucp/ext/ucpext_provider.cxx create mode 100644 ucb/source/ucp/ext/ucpext_provider.hxx create mode 100644 ucb/source/ucp/ext/ucpext_resultset.cxx create mode 100644 ucb/source/ucp/ext/ucpext_resultset.hxx create mode 100644 ucb/source/ucp/ext/ucpext_services.cxx (limited to 'ucb') diff --git a/ucb/prj/build.lst b/ucb/prj/build.lst index f0eb0da8395e..f97493acb0e8 100644 --- a/ucb/prj/build.lst +++ b/ucb/prj/build.lst @@ -14,3 +14,4 @@ uc ucb\source\ucp\webdav nmake - all uc_webdav uc_inc NULL uc ucb\source\ucp\package nmake - all uc_package uc_inc NULL uc ucb\source\ucp\tdoc nmake - all uc_tdoc uc_inc NULL uc ucb\source\ucp\expand nmake - all uc_expand uc_inc NULL +uc ucb\source\ucp\ext nmake - all uc_ext uc_inc NULL diff --git a/ucb/source/ucp/ext/makefile.mk b/ucb/source/ucp/ext/makefile.mk new file mode 100644 index 000000000000..f8919e50e594 --- /dev/null +++ b/ucb/source/ucp/ext/makefile.mk @@ -0,0 +1,65 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.4 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = ..$/..$/.. +PRJNAME = ucb +TARGET = ucpext.uno +ENABLE_EXCEPTIONS = TRUE + +.INCLUDE : settings.mk +DLLPRE = + +SLOFILES= \ + $(SLO)$/ucpext_provider.obj \ + $(SLO)$/ucpext_content.obj \ + $(SLO)$/ucpext_services.obj \ + $(SLO)$/ucpext_resultset.obj \ + $(SLO)$/ucpext_datasupplier.obj + +SHL1STDLIBS = \ + $(UCBHELPERLIB) \ + $(COMPHELPERLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(SALLIB) \ + $(SALHELPERLIB) + +SHL1VERSIONMAP = $(TARGET).map +SHL1TARGET = $(TARGET) + +SHL1DEPN = +SHL1IMPLIB = i$(TARGET) +SHL1LIBS = $(SLB)$/$(TARGET).lib +SHL1DEF = $(MISC)$/$(SHL1TARGET).def + +DEF1NAME = $(SHL1TARGET) + +.INCLUDE : target.mk diff --git a/ucb/source/ucp/ext/ucpext.uno.map b/ucb/source/ucp/ext/ucpext.uno.map new file mode 100644 index 000000000000..f4ed78b9e970 --- /dev/null +++ b/ucb/source/ucp/ext/ucpext.uno.map @@ -0,0 +1,8 @@ +UDK_3_0_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + local: + *; +}; diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx new file mode 100644 index 000000000000..27579f2a1d9f --- /dev/null +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -0,0 +1,489 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_ucb.hxx" + +#include "ucpext_content.hxx" + +#include "ucpext_content.hxx" +#include "ucpext_provider.hxx" +#include "ucpext_resultset.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include +#include +#include +#include + +//...................................................................................................................... +namespace ucb { namespace ucp { namespace ext +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::ucb::XContentIdentifier; + using ::com::sun::star::ucb::IllegalIdentifierException; + using ::com::sun::star::ucb::XContent; + using ::com::sun::star::ucb::XCommandEnvironment; + using ::com::sun::star::ucb::Command; + using ::com::sun::star::ucb::CommandAbortedException; + using ::com::sun::star::beans::Property; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::beans::PropertyValue; + using ::com::sun::star::ucb::OpenCommandArgument2; + using ::com::sun::star::ucb::XDynamicResultSet; + using ::com::sun::star::ucb::UnsupportedOpenModeException; + using ::com::sun::star::io::XOutputStream; + using ::com::sun::star::io::XActiveDataSink; + using ::com::sun::star::io::XInputStream; + using ::com::sun::star::ucb::UnsupportedDataSinkException; + using ::com::sun::star::ucb::UnsupportedCommandException; + using ::com::sun::star::sdbc::XRow; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::beans::PropertyChangeEvent; + using ::com::sun::star::lang::IllegalAccessException; + using ::com::sun::star::ucb::CommandInfo; + /** === end UNO using === **/ + namespace OpenMode = ::com::sun::star::ucb::OpenMode; + namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; + + //================================================================================================================== + //= Content + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + Content::Content( const Reference< XMultiServiceFactory >& i_rORB, ::ucbhelper::ContentProviderImplHelper* i_pProvider, + const Reference< XContentIdentifier >& i_rIdentifier ) + :Content_Base( i_rORB, i_pProvider, i_rIdentifier ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + Content::~Content() + { + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL Content::getImplementationName() throw( RuntimeException ) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.ucp.ext.Content" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL Content::getSupportedServiceNames() throw( RuntimeException ) + { + Sequence< ::rtl::OUString > aServiceNames(2); + aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.Content" ) ); + aServiceNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.ExtensionContent" ) ); + return aServiceNames; + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL Content::getContentType() throw( RuntimeException ) + { + return m_aProps.aContentType; + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL Content::execute( const Command& aCommand, sal_Int32 /* CommandId */, const Reference< XCommandEnvironment >& i_rEvironment ) + throw( Exception, CommandAbortedException, RuntimeException ) + { + Any aRet; + + if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) ) + { + Sequence< Property > Properties; + if ( !( aCommand.Argument >>= Properties ) ) + { + ::ucbhelper::cancelCommandExecution( makeAny( IllegalArgumentException( + ::rtl::OUString(), *this, -1 ) ), + i_rEvironment ); + // unreachable + } + + aRet <<= getPropertyValues( Properties, i_rEvironment ); + } + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "setPropertyValues" ) ) ) + { + Sequence< PropertyValue > aProperties; + if ( !( aCommand.Argument >>= aProperties ) ) + { + ::ucbhelper::cancelCommandExecution( makeAny( IllegalArgumentException( + ::rtl::OUString(), *this, -1 ) ), + i_rEvironment ); + // unreachable + } + + if ( !aProperties.getLength() ) + { + ::ucbhelper::cancelCommandExecution( makeAny( IllegalArgumentException( + ::rtl::OUString(), *this, -1 ) ), + i_rEvironment ); + // unreachable + } + + aRet <<= setPropertyValues( aProperties, i_rEvironment ); + } + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getPropertySetInfo" ) ) ) + { + // implemented by base class. + aRet <<= getPropertySetInfo( i_rEvironment ); + } + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getCommandInfo" ) ) ) + { + // implemented by base class. + aRet <<= getCommandInfo( i_rEvironment ); + } + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "open" ) ) ) + { + OpenCommandArgument2 aOpenCommand; + if ( !( aCommand.Argument >>= aOpenCommand ) ) + { + ::ucbhelper::cancelCommandExecution( makeAny( IllegalArgumentException( + ::rtl::OUString(), *this, -1 ) ), + i_rEvironment ); + // unreachable + } + + sal_Bool bOpenFolder = + ( ( aOpenCommand.Mode == OpenMode::ALL ) || + ( aOpenCommand.Mode == OpenMode::FOLDERS ) || + ( aOpenCommand.Mode == OpenMode::DOCUMENTS ) ); + + + if ( bOpenFolder && m_aProps.bIsFolder ) + { + Reference< XDynamicResultSet > xSet = new ResultSet( + m_xSMgr, this, aOpenCommand, i_rEvironment ); + aRet <<= xSet; + } + + if ( aOpenCommand.Sink.is() ) + { + // Open document - supply document data stream. + + // Check open mode + if ( ( aOpenCommand.Mode == OpenMode::DOCUMENT_SHARE_DENY_NONE ) + || ( aOpenCommand.Mode == OpenMode::DOCUMENT_SHARE_DENY_WRITE ) + ) + { + // unsupported. + ::ucbhelper::cancelCommandExecution( makeAny( UnsupportedOpenModeException( + ::rtl::OUString(), *this, sal_Int16( aOpenCommand.Mode ) ) ), + i_rEvironment ); + // unreachable + } + + ::rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); + Reference< XOutputStream > xOut( aOpenCommand.Sink, UNO_QUERY ); + if ( xOut.is() ) + { + // TODO: write data into xOut + } + else + { + Reference< XActiveDataSink > xDataSink( aOpenCommand.Sink, UNO_QUERY ); + if ( xDataSink.is() ) + { + Reference< XInputStream > xIn + /* @@@ your XInputStream + XSeekable impl. object */; + // TODO + xDataSink->setInputStream( xIn ); + } + else + { + // Note: aOpenCommand.Sink may contain an XStream + // implementation. Support for this type of + // sink is optional... + ::ucbhelper::cancelCommandExecution( makeAny( UnsupportedDataSinkException( + ::rtl::OUString(), *this, aOpenCommand.Sink ) ), + i_rEvironment ); + // unreachable + } + } + } + } + + else + { + ::ucbhelper::cancelCommandExecution( makeAny( UnsupportedCommandException( + ::rtl::OUString(), *this ) ), + i_rEvironment ); + // unreachable + } + + return aRet; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL Content::abort( sal_Int32 ) throw( RuntimeException ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString Content::escapeIdentifier( const ::rtl::OUString& i_rIdentifier ) + { + const ::rtl::OUString sQuoteQuotes = ::comphelper::string::searchAndReplaceAllAsciiWithAscii( + i_rIdentifier, "%", "%%" ); + const ::rtl::OUString sQuoteSlashes = ::comphelper::string::searchAndReplaceAllAsciiWithAscii( + i_rIdentifier, "/", "%47" ); + return sQuoteSlashes; + } + + //------------------------------------------------------------------------------------------------------------------ + bool Content::denotesRootContent( const Reference< XContentIdentifier >& i_rIdentifier ) + { + const sal_Char* pScheme = "vnd.oracle.ooo.extension"; + const sal_Int32 nSchemeLength = sizeof( "vnd.oracle.ooo.extension" ) - 1; + const ::rtl::OUString sIdentifier( i_rIdentifier->getContentIdentifier() ); + ENSURE_OR_RETURN_FALSE( sIdentifier.matchAsciiL( pScheme, nSchemeLength ), "illegal content URL" ); + return sIdentifier.copy( nSchemeLength ).equalsAsciiL( ":/", 2 ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString Content::getParentURL() + { + const ::rtl::OUString sURL = m_xIdentifier->getContentIdentifier(); + const ::rtl::OUString sParentURL( sURL.copy( 0, sURL.lastIndexOf( '/' ) + 1 ) ); + return sParentURL; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XRow > Content::getPropertyValues( const Reference< XMultiServiceFactory >& i_rORB, + const Sequence< Property >& i_rProperties, const ContentProperties& i_rData ) + { + // note: empty sequence means "get values of all supported properties". + ::rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( i_rORB ); + + const sal_Int32 nCount = i_rProperties.getLength(); + if ( nCount ) + { + Reference< XPropertySet > xAdditionalPropSet; + + const Property* pProps = i_rProperties.getConstArray(); + for ( sal_Int32 n = 0; n < nCount; ++n ) + { + const Property& rProp = pProps[ n ]; + + // Process Core properties. + if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) + { + xRow->appendString ( rProp, i_rData.aContentType ); + } + else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) + { + xRow->appendString ( rProp, i_rData.aTitle ); + } + else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) + { + xRow->appendBoolean( rProp, i_rData.bIsDocument ); + } + else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) + { + xRow->appendBoolean( rProp, i_rData.bIsFolder ); + } + else + { + // append empty entry. + xRow->appendVoid( rProp ); + } + } + } + else + { + // Append all Core Properties. + xRow->appendString ( Property( ::rtl::OUString::createFromAscii( "ContentType" ), + -1, + getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ), + PropertyAttribute::BOUND | PropertyAttribute::READONLY ), + i_rData.aContentType ); + xRow->appendString ( Property( ::rtl::OUString::createFromAscii( "Title" ), + -1, + getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ), + PropertyAttribute::BOUND | PropertyAttribute::READONLY ), + i_rData.aTitle ); + xRow->appendBoolean( Property( ::rtl::OUString::createFromAscii( "IsDocument" ), + -1, + getCppuBooleanType(), + PropertyAttribute::BOUND | PropertyAttribute::READONLY ), + i_rData.bIsDocument ); + xRow->appendBoolean( Property( ::rtl::OUString::createFromAscii( "IsFolder" ), + -1, + getCppuBooleanType(), + PropertyAttribute::BOUND | PropertyAttribute::READONLY ), + i_rData.bIsFolder ); + } + + return Reference< XRow >( xRow.get() ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XRow > Content::getPropertyValues( const Sequence< Property >& i_rProperties, const Reference< XCommandEnvironment >& /* xEnv */) + { + osl::Guard< osl::Mutex > aGuard( m_aMutex ); + return getPropertyValues( m_xSMgr, + i_rProperties, + m_aProps ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< Any > Content::setPropertyValues( const Sequence< PropertyValue >& i_rValues, const Reference< XCommandEnvironment >& /* xEnv */) + { + ::osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); + + Sequence< Any > aRet( i_rValues.getLength() ); + Sequence< PropertyChangeEvent > aChanges( i_rValues.getLength() ); + + PropertyChangeEvent aEvent; + aEvent.Source = static_cast< cppu::OWeakObject * >( this ); + aEvent.Further = sal_False; + aEvent.PropertyHandle = -1; + + const PropertyValue* pValues = i_rValues.getConstArray(); + const sal_Int32 nCount = i_rValues.getLength(); + + for ( sal_Int32 n = 0; n < nCount; ++n, ++pValues ) + { + // all our properties are read-only ... + aRet[ n ] <<= IllegalAccessException( ::rtl::OUString::createFromAscii( "property is read-only." ), *this ); + } + + return aRet; + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< CommandInfo > Content::getCommands( const Reference< XCommandEnvironment > & /*xEnv*/ ) + { + sal_uInt32 nCommandCount = 5; + static const CommandInfo aCommandInfoTable[] = + { + /////////////////////////////////////////////////////////////// + // Mandatory commands + /////////////////////////////////////////////////////////////// + CommandInfo( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ), + -1, + getCppuVoidType() + ), + CommandInfo( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ), + -1, + getCppuVoidType() + ), + CommandInfo( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ), + -1, + getCppuType( + static_cast< Sequence< Property > * >( 0 ) ) + ), + CommandInfo( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ), + -1, + getCppuType( + static_cast< Sequence< PropertyValue > * >( 0 ) ) + ) + /////////////////////////////////////////////////////////////// + // Optional standard commands + /////////////////////////////////////////////////////////////// + + #ifdef IMPLEMENT_COMMAND_OPEN + , CommandInfo( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), + -1, + getCppuType( static_cast< OpenCommandArgument2 * >( 0 ) ) + ) + #endif + }; + + return Sequence< CommandInfo >( aCommandInfoTable, nCommandCount ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< Property > Content::getProperties( const Reference< XCommandEnvironment > & /*xEnv*/ ) + { + static Property aProperties[] = + { + Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), + -1, + getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ), + PropertyAttribute::BOUND | PropertyAttribute::READONLY + ), + Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), + -1, + getCppuBooleanType(), + PropertyAttribute::BOUND | PropertyAttribute::READONLY + ), + Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), + -1, + getCppuBooleanType(), + PropertyAttribute::BOUND | PropertyAttribute::READONLY + ), + Property( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), + -1, + getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ), + PropertyAttribute::BOUND | PropertyAttribute::READONLY + ) + }; + return Sequence< Property >( aProperties, sizeof( aProperties ) / sizeof( aProperties[0] ) ); + } + +//...................................................................................................................... +} } } // namespace ucp::ext +//...................................................................................................................... diff --git a/ucb/source/ucp/ext/ucpext_content.hxx b/ucb/source/ucp/ext/ucpext_content.hxx new file mode 100644 index 000000000000..9b5667a1d641 --- /dev/null +++ b/ucb/source/ucp/ext/ucpext_content.hxx @@ -0,0 +1,144 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef UCB_UCPEXT_CONTENT_HXX +#define UCB_UCPEXT_CONTENT_HXX + +/** === begin UNO includes === **/ +#include +#include +/** === end UNO includes === **/ + +#include +#include + +#include + +//...................................................................................................................... +namespace ucb { namespace ucp { namespace ext +{ +//...................................................................................................................... + + //================================================================================================================== + //= ContentProvider + //================================================================================================================== + struct ContentProperties + { + ::rtl::OUString aTitle; // Title + ::rtl::OUString aContentType; // ContentType + bool bIsDocument; // IsDocument + bool bIsFolder; // IsFolder + + ContentProperties() + :bIsDocument( false ) + ,bIsFolder( true ) + { + } + }; + + //================================================================================================================== + //= ContentProvider + //================================================================================================================== + typedef ::ucbhelper::ContentImplHelper Content_Base; + class Content : public Content_Base + { + public: + static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > + getPropertyValues( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties, + const ContentProperties& rData + ); + + Content( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr, + ::ucbhelper::ContentProviderImplHelper* pProvider, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& Identifier + ); + + static bool denotesRootContent( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& i_rIdentifier ); + + static ::rtl::OUString + escapeIdentifier( const ::rtl::OUString& i_rIdentifier ); + + protected: + virtual ~Content(); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + + // XContent + virtual rtl::OUString SAL_CALL getContentType() throw( com::sun::star::uno::RuntimeException ); + + // XCommandProcessor + virtual com::sun::star::uno::Any SAL_CALL + execute( + const com::sun::star::ucb::Command& aCommand, + sal_Int32 CommandId, + const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment + ) + throw ( ::com::sun::star::uno::Exception + , ::com::sun::star::ucb::CommandAbortedException + , ::com::sun::star::uno::RuntimeException + ); + + virtual void SAL_CALL + abort( + sal_Int32 CommandId + ) + throw ( ::com::sun::star::uno::RuntimeException + ); + + protected: + const ContentProperties& getProperties() const { return m_aProps; } + ContentProperties& getProperties() { return m_aProps; } + + private: + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > getProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& i_rEnv ); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::CommandInfo > getCommands( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& i_rEnv ); + virtual ::rtl::OUString getParentURL(); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > + getPropertyValues( + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv + ); + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + setPropertyValues( + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rValues, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv + ); + + private: + ContentProperties m_aProps; + }; + +//...................................................................................................................... +} } } // namespace ucb::ucp::ext +//...................................................................................................................... + +#endif // UCB_UCPEXT_CONTENT_HXX diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx b/ucb/source/ucp/ext/ucpext_datasupplier.cxx new file mode 100644 index 000000000000..d40e2339fe70 --- /dev/null +++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx @@ -0,0 +1,295 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_ucb.hxx" + +#include "ucpext_datasupplier.hxx" +#include "ucpext_content.hxx" + +/** === begin UNO includes === **/ +#include +/** === end UNO includes === **/ + +#include +#include +#include +#include + +#include + +//...................................................................................................................... +namespace ucb { namespace ucp { namespace ext +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::ucb::XContent; + using ::com::sun::star::ucb::XContentIdentifier; + using ::com::sun::star::sdbc::XRow; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::ucb::IllegalIdentifierException; + using ::com::sun::star::ucb::ResultSetException; + using ::com::sun::star::deployment::XPackageInformationProvider; + using ::com::sun::star::beans::Property; + /** === end UNO using === **/ + + //================================================================================================================== + //= ResultListEntry + //================================================================================================================== + struct ResultListEntry + { + ::rtl::OUString sId; + Reference< XContentIdentifier > xId; + ContentProperties aProperties; + Reference< XContent > xContent; + Reference< XRow > xRow; + + ResultListEntry( const ::rtl::OUString& i_rParentId, const ::rtl::OUString& i_rLocalId ) + { + aProperties.aTitle = i_rLocalId; + sId = i_rParentId + Content::escapeIdentifier( i_rLocalId ); + } + }; + + typedef ::std::vector< ResultListEntry > ResultList; + + //================================================================================================================== + //= DataSupplier_Impl + //================================================================================================================== + struct DataSupplier_Impl + { + ::osl::Mutex m_aMutex; + ResultList m_aResults; + ::rtl::Reference< Content > m_xContent; + Reference< XMultiServiceFactory > m_xSMgr; + sal_Int32 m_nOpenMode; + + DataSupplier_Impl( const Reference< XMultiServiceFactory >& i_rORB, const ::rtl::Reference< Content >& i_rContent, + const sal_Int32 i_nOpenMode ) + :m_xContent( i_rContent ) + ,m_xSMgr( i_rORB ) + ,m_nOpenMode( i_nOpenMode ) + { + } + ~DataSupplier_Impl(); + }; + + //------------------------------------------------------------------------------------------------------------------ + DataSupplier_Impl::~DataSupplier_Impl() + { + } + + //================================================================================================================== + //= DataSupplier + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + DataSupplier::DataSupplier( const Reference< XMultiServiceFactory >& i_rORB, + const ::rtl::Reference< Content >& i_rContent, + const sal_Int32 i_nOpenMode ) + :m_pImpl( new DataSupplier_Impl( i_rORB, i_rContent, i_nOpenMode ) ) + { + try + { + if ( Content::denotesRootContent( m_pImpl->m_xContent->getIdentifier() ) ) + { + const ::rtl::OUString sContentId( m_pImpl->m_xContent->getIdentifier()->getContentIdentifier() ); + + const ::comphelper::ComponentContext aContext( i_rORB ); + Reference< XPackageInformationProvider > xPackageInfo( + aContext.getSingleton( "com.sun.star.deployment.PackageInformationProvider" ), UNO_QUERY_THROW ); + + Sequence< Sequence< ::rtl::OUString > > aExtensionInfo( xPackageInfo->getExtensionList() ); + for ( const Sequence< ::rtl::OUString >* pExtInfo = aExtensionInfo.getConstArray(); + pExtInfo != aExtensionInfo.getConstArray() + aExtensionInfo.getLength(); + ++pExtInfo + ) + { + ENSURE_OR_CONTINUE( pExtInfo->getLength() > 0, "illegal extension info" ); + + ResultListEntry aEntry( sContentId, (*pExtInfo)[0] ); + aEntry.aProperties.aContentType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.oracle.ooo.extension-content" ) ); + m_pImpl->m_aResults.push_back( ResultListEntry( aEntry ) ); + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + DataSupplier::~DataSupplier() + { + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 i_nIndex ) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_pImpl->m_aMutex ); + + if ( i_nIndex < m_pImpl->m_aResults.size() ) + { + const ::rtl::OUString sId = m_pImpl->m_aResults[ i_nIndex ].sId; + if ( sId.getLength() ) + return sId; + } + + OSL_ENSURE( false, "DataSupplier::queryContentIdentifierString: illegal index, or illegal result entry id!" ); + return ::rtl::OUString(); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XContentIdentifier > DataSupplier::queryContentIdentifier( sal_uInt32 i_nIndex ) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_pImpl->m_aMutex ); + + if ( i_nIndex < m_pImpl->m_aResults.size() ) + { + Reference< XContentIdentifier > xId( m_pImpl->m_aResults[ i_nIndex ].xId ); + if ( xId.is() ) + return xId; + } + + ::rtl::OUString sId = queryContentIdentifierString( i_nIndex ); + if ( sId.getLength() ) + { + Reference< XContentIdentifier > xId = new ::ucbhelper::ContentIdentifier( sId ); + m_pImpl->m_aResults[ i_nIndex ].xId = xId; + return xId; + } + + return Reference< XContentIdentifier >(); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XContent > DataSupplier::queryContent( sal_uInt32 i_nIndex ) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_pImpl->m_aMutex ); + ENSURE_OR_RETURN( i_nIndex < m_pImpl->m_aResults.size(), "illegal index!", NULL ); + + Reference< XContent > xContent( m_pImpl->m_aResults[ i_nIndex ].xContent ); + if ( xContent.is() ) + return xContent; + + Reference< XContentIdentifier > xId( queryContentIdentifier( i_nIndex ) ); + if ( xId.is() ) + { + try + { + Reference< XContent > xContent( m_pImpl->m_xContent->getProvider()->queryContent( xId ) ); + m_pImpl->m_aResults[ i_nIndex ].xContent = xContent; + return xContent; + + } + catch ( const IllegalIdentifierException& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + return Reference< XContent >(); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool DataSupplier::getResult( sal_uInt32 i_nIndex ) + { + ::osl::ClearableGuard< ::osl::Mutex > aGuard( m_pImpl->m_aMutex ); + + if ( m_pImpl->m_aResults.size() > i_nIndex ) + // result already present. + return sal_True; + + return sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + sal_uInt32 DataSupplier::totalCount() + { + ::osl::ClearableGuard< ::osl::Mutex > aGuard( m_pImpl->m_aMutex ); + return m_pImpl->m_aResults.size(); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_uInt32 DataSupplier::currentCount() + { + return m_pImpl->m_aResults.size(); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool DataSupplier::isCountFinal() + { + return sal_True; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XRow > DataSupplier::queryPropertyValues( sal_uInt32 i_nIndex ) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_pImpl->m_aMutex ); + ENSURE_OR_RETURN( i_nIndex < m_pImpl->m_aResults.size(), "DataSupplier::queryPropertyValues: illegal index!", NULL ); + + Reference< XRow > xRow = m_pImpl->m_aResults[ i_nIndex ].xRow; + if ( xRow.is() ) + return xRow; + + xRow = Content::getPropertyValues( m_pImpl->m_xSMgr, getResultSet()->getProperties(), + m_pImpl->m_aResults[ i_nIndex ].aProperties ); + return xRow; + } + + //------------------------------------------------------------------------------------------------------------------ + void DataSupplier::releasePropertyValues( sal_uInt32 i_nIndex ) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_pImpl->m_aMutex ); + + if ( i_nIndex < m_pImpl->m_aResults.size() ) + m_pImpl->m_aResults[ i_nIndex ].xRow.clear(); + } + + //------------------------------------------------------------------------------------------------------------------ + void DataSupplier::close() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void DataSupplier::validate() throw( ResultSetException ) + { + } + +//...................................................................................................................... +} } } // namespace ucp::ext +//...................................................................................................................... diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.hxx b/ucb/source/ucp/ext/ucpext_datasupplier.hxx new file mode 100644 index 000000000000..7957a318aa36 --- /dev/null +++ b/ucb/source/ucp/ext/ucpext_datasupplier.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef UCB_UCPEXT_DATA_SUPPLIER_HXX +#define UCB_UCPEXT_DATA_SUPPLIER_HXX + +#include +#include + +#include + +//...................................................................................................................... +namespace ucb { namespace ucp { namespace ext +{ +//...................................................................................................................... + + struct DataSupplier_Impl; + class Content; + + //================================================================================================================== + //= DataSupplier + //================================================================================================================== + typedef ::ucbhelper::ResultSetDataSupplier DataSupplier_Base; + class DataSupplier : public ::ucbhelper::ResultSetDataSupplier + { + public: + DataSupplier( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& i_rORB, + const rtl::Reference< Content >& rContent, + const sal_Int32 nOpenMode + ); + + protected: + virtual ~DataSupplier(); + + virtual rtl::OUString queryContentIdentifierString( sal_uInt32 nIndex ); + virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > queryContentIdentifier( sal_uInt32 nIndex ); + virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > queryContent( sal_uInt32 nIndex ); + + virtual sal_Bool getResult( sal_uInt32 nIndex ); + + virtual sal_uInt32 totalCount(); + virtual sal_uInt32 currentCount(); + virtual sal_Bool isCountFinal(); + + virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > queryPropertyValues( sal_uInt32 nIndex ); + virtual void releasePropertyValues( sal_uInt32 nIndex ); + + virtual void close(); + + virtual void validate() throw( com::sun::star::ucb::ResultSetException ); + + private: + ::boost::scoped_ptr< DataSupplier_Impl > m_pImpl; + }; + +//...................................................................................................................... +} } } // namespace ucp::ext +//...................................................................................................................... + +#endif // UCB_UCPEXT_DATA_SUPPLIER_HXX diff --git a/ucb/source/ucp/ext/ucpext_provider.cxx b/ucb/source/ucp/ext/ucpext_provider.cxx new file mode 100644 index 000000000000..4e26dacf229c --- /dev/null +++ b/ucb/source/ucp/ext/ucpext_provider.cxx @@ -0,0 +1,147 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_ucb.hxx" + +#include "ucpext_provider.hxx" +#include "ucpext_content.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include +#include +#include +#include +#include + +//...................................................................................................................... +namespace ucb { namespace ucp { namespace ext +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::ucb::XContentIdentifier; + using ::com::sun::star::ucb::IllegalIdentifierException; + using ::com::sun::star::ucb::XContent; + using ::com::sun::star::uno::XComponentContext; + /** === end UNO using === **/ + + //================================================================================================================== + //= ContentProvider + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + ContentProvider::ContentProvider( const Reference< XMultiServiceFactory >& i_rServiceManager ) + :ContentProvider_Base( i_rServiceManager ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + ContentProvider::~ContentProvider() + { + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL ContentProvider::getImplementationName_static() throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.ucp.ext.ContentProvider" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL ContentProvider::getImplementationName() throw (RuntimeException) + { + return getImplementationName_static(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL ContentProvider::getSupportedServiceNames_static( ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aServiceNames(2); + aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.ContentProvider" ) ); + aServiceNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.ExtensionContentProvider" ) ); + return aServiceNames; + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL ContentProvider::getSupportedServiceNames( ) throw (RuntimeException) + { + return getSupportedServiceNames_static(); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XInterface > ContentProvider::Create( const Reference< XComponentContext >& i_rContext ) + { + const ::comphelper::ComponentContext aContext( i_rContext ); + return *( new ContentProvider( aContext.getLegacyServiceFactory() ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XContent > SAL_CALL ContentProvider::queryContent( const Reference< XContentIdentifier >& i_rIdentifier ) + throw( IllegalIdentifierException, RuntimeException ) + { + // Check URL scheme... + const ::rtl::OUString aScheme( rtl::OUString::createFromAscii( "vnd.oracle.ooo.extension" ) ); + if ( !i_rIdentifier->getContentProviderScheme().equalsIgnoreAsciiCase( aScheme ) ) + throw IllegalIdentifierException(); + + // normalize the scheme + const ::rtl::OUString sIdentifier( i_rIdentifier->getContentIdentifier() ); + ::rtl::OUStringBuffer aComposer; + aComposer.append( sIdentifier.copy( 0, aScheme.getLength() ).toAsciiLowerCase() ); + aComposer.append( sIdentifier.copy( aScheme.getLength() ) ); + const Reference< XContentIdentifier > xNormalizedIdentifier( new ::ucbhelper::ContentIdentifier( m_xSMgr, aComposer.makeStringAndClear() ) ); + + ::osl::MutexGuard aGuard( m_aMutex ); + + // check if a content with given id already exists... + Reference< XContent > xContent( queryExistingContent( xNormalizedIdentifier ).get() ); + if ( xContent.is() ) + return xContent; + + // create a new content + xContent = new Content( m_xSMgr, this, xNormalizedIdentifier ); + if ( !xContent->getIdentifier().is() ) + throw IllegalIdentifierException(); + + registerNewContent( xContent ); + return xContent; + } + +//...................................................................................................................... +} } } // namespace ucb::ucp::ext +//...................................................................................................................... diff --git a/ucb/source/ucp/ext/ucpext_provider.hxx b/ucb/source/ucp/ext/ucpext_provider.hxx new file mode 100644 index 000000000000..1e9090dab2e0 --- /dev/null +++ b/ucb/source/ucp/ext/ucpext_provider.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef UCB_UCPEXT_CONTENT_PROVIDER_HXX +#define UCB_UCPEXT_CONTENT_PROVIDER_HXX + +#include + +//...................................................................................................................... +namespace ucb { namespace ucp { namespace ext +{ +//...................................................................................................................... + + //================================================================================================================== + //= ContentProvider + //================================================================================================================== + typedef ::ucbhelper::ContentProviderImplHelper ContentProvider_Base; + class ContentProvider : public ContentProvider_Base + { + public: + ContentProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rServiceManager ); + virtual ~ContentProvider(); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo - static versions + static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static() throw (::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext ); + + // XContentProvider + virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > SAL_CALL queryContent( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& Identifier ) throw (::com::sun::star::ucb::IllegalIdentifierException, ::com::sun::star::uno::RuntimeException); + }; + +//...................................................................................................................... +} } } // namespace ucb::ucp::ext +//...................................................................................................................... + +#endif // UCB_UCPEXT_CONTENT_PROVIDER_HXX diff --git a/ucb/source/ucp/ext/ucpext_resultset.cxx b/ucb/source/ucp/ext/ucpext_resultset.cxx new file mode 100644 index 000000000000..6d5e79d61902 --- /dev/null +++ b/ucb/source/ucp/ext/ucpext_resultset.cxx @@ -0,0 +1,97 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_ucb.hxx" + +#include "ucpext_resultset.hxx" +#include "ucpext_content.hxx" +#include "ucpext_datasupplier.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include + +//...................................................................................................................... +namespace ucb { namespace ucp { namespace ext +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::ucb::XContentIdentifier; + using ::com::sun::star::ucb::OpenCommandArgument2; + using ::com::sun::star::ucb::XCommandEnvironment; + /** === end UNO using === **/ + + //================================================================================================================== + //= ResultSet + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + ResultSet::ResultSet( const Reference< XMultiServiceFactory >& i_rORB, const ::rtl::Reference< Content >& i_rContent, + const OpenCommandArgument2& i_rCommand, const Reference< XCommandEnvironment >& i_rEnv ) + :ResultSetImplHelper( i_rORB, i_rCommand ) + ,m_xEnvironment( i_rEnv ) + ,m_xContent( i_rContent ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + void ResultSet::initStatic() + { + m_xResultSet1 = new ::ucbhelper::ResultSet( + m_xSMgr, + m_aCommand.Properties, + new DataSupplier( + m_xSMgr, + m_xContent, + m_aCommand.Mode + ), + m_xEnvironment + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void ResultSet::initDynamic() + { + initStatic(); + m_xResultSet2 = m_xResultSet1; + } + +//...................................................................................................................... +} } } // namespace ucp::ext +//...................................................................................................................... diff --git a/ucb/source/ucp/ext/ucpext_resultset.hxx b/ucb/source/ucp/ext/ucpext_resultset.hxx new file mode 100644 index 000000000000..2924197a0fdc --- /dev/null +++ b/ucb/source/ucp/ext/ucpext_resultset.hxx @@ -0,0 +1,66 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef UCB_UCPEXT_RESULT_SET_HXX +#define UCB_UCPEXT_RESULT_SET_HXX + +#include +#include + +//...................................................................................................................... +namespace ucb { namespace ucp { namespace ext +{ +//...................................................................................................................... + + class Content; + + //================================================================================================================== + //= ResultSet + //================================================================================================================== + class ResultSet : public ::ucbhelper::ResultSetImplHelper + { + public: + ResultSet( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& i_rORB, + const rtl::Reference< Content >& i_rContent, + const com::sun::star::ucb::OpenCommandArgument2& i_rCommand, + const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& i_rEnv + ); + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > m_xEnvironment; + ::rtl::Reference< Content > m_xContent; + + private: + virtual void initStatic(); + virtual void initDynamic(); + }; + +//...................................................................................................................... +} } } // namespace ucp::ext +//...................................................................................................................... + +#endif // UCB_UCPEXT_RESULT_SET_HXX diff --git a/ucb/source/ucp/ext/ucpext_services.cxx b/ucb/source/ucp/ext/ucpext_services.cxx new file mode 100644 index 000000000000..8daa33f5cf8c --- /dev/null +++ b/ucb/source/ucp/ext/ucpext_services.cxx @@ -0,0 +1,93 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_ucb.hxx" + +#include "ucpext_provider.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include + +//...................................................................................................................... +namespace ucb { namespace ucp { namespace ext +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::XSingleComponentFactory; + /** === end UNO using === **/ + + //================================================================================================================== + //= descriptors for the services implemented in this component + //================================================================================================================== + static struct ::cppu::ImplementationEntry s_aServiceEntries[] = + { + { + ContentProvider::Create, + ContentProvider::getImplementationName_static, + ContentProvider::getSupportedServiceNames_static, + ::cppu::createOneInstanceComponentFactory, NULL, 0 + }, + { 0, 0, 0, 0, 0, 0 } + }; + +//...................................................................................................................... +} } } // namespace ucb::ucp::ext +//...................................................................................................................... + +extern "C" +{ + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ) + { + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey ) + { + return ::cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, ::ucb::ucp::ext::s_aServiceEntries ); + } + + //------------------------------------------------------------------------------------------------------------------ + void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) + { + return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , ::ucb::ucp::ext::s_aServiceEntries ); + } +} -- cgit From 667e864a12c4a0c2c90e49080e3000fc9cb26cb2 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 25 Mar 2010 08:49:40 +0100 Subject: slidecopy: extended the Extensions-UCP so it now allows browsing the complete hierarchy. File access still missing --- ucb/source/ucp/ext/ucpext_content.cxx | 229 +++++++++++++++++++++++++---- ucb/source/ucp/ext/ucpext_content.hxx | 76 ++++++---- ucb/source/ucp/ext/ucpext_datasupplier.cxx | 129 ++++++++++++---- ucb/source/ucp/ext/ucpext_datasupplier.hxx | 4 +- ucb/source/ucp/ext/ucpext_provider.cxx | 12 ++ ucb/source/ucp/ext/ucpext_provider.hxx | 4 + ucb/source/ucp/ext/ucpext_resultset.cxx | 12 +- 7 files changed, 378 insertions(+), 88 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 27579f2a1d9f..1611fe579dbd 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -49,13 +49,19 @@ #include #include #include +#include /** === end UNO includes === **/ #include #include #include +#include #include #include +#include +#include + +#include //...................................................................................................................... namespace ucb { namespace ucp { namespace ext @@ -97,10 +103,38 @@ namespace ucb { namespace ucp { namespace ext using ::com::sun::star::beans::PropertyChangeEvent; using ::com::sun::star::lang::IllegalAccessException; using ::com::sun::star::ucb::CommandInfo; + using ::com::sun::star::deployment::XPackageInformationProvider; /** === end UNO using === **/ namespace OpenMode = ::com::sun::star::ucb::OpenMode; namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; + //================================================================================================================== + //= helper + //================================================================================================================== + namespace + { + //-------------------------------------------------------------------------------------------------------------- + ::rtl::OUString lcl_compose( const ::rtl::OUString& i_rBaseURL, const ::rtl::OUString& i_rRelativeURL ) + { + ENSURE_OR_RETURN( i_rBaseURL.getLength(), "illegal base URL", i_rRelativeURL ); + + ::rtl::OUStringBuffer aComposer( i_rBaseURL ); + if ( i_rBaseURL.getStr()[ i_rBaseURL.getLength() - 1 ] != '/' ) + aComposer.append( sal_Unicode( '/' ) ); + aComposer.append( i_rRelativeURL ); + return aComposer.makeStringAndClear(); + } + + //-------------------------------------------------------------------------------------------------------------- + struct SelectPropertyName : public ::std::unary_function< Property, ::rtl::OUString > + { + const ::rtl::OUString& operator()( const Property& i_rProperty ) const + { + return i_rProperty.Name; + } + }; + } + //================================================================================================================== //= Content //================================================================================================================== @@ -108,7 +142,38 @@ namespace ucb { namespace ucp { namespace ext Content::Content( const Reference< XMultiServiceFactory >& i_rORB, ::ucbhelper::ContentProviderImplHelper* i_pProvider, const Reference< XContentIdentifier >& i_rIdentifier ) :Content_Base( i_rORB, i_pProvider, i_rIdentifier ) + ,m_eExtContentType( E_UNKNOWN ) + ,m_aIsFolder() + ,m_aContentType() + ,m_sExtensionId() + ,m_sPathIntoExtension() { + if ( denotesRootContent( getIdentifier() ) ) + { + m_eExtContentType = E_ROOT; + } + else if ( denotesRootContent( getParentURL() ) ) + { + m_eExtContentType = E_EXTENSION_ROOT; + } + else + { + m_eExtContentType = E_EXTENSION_CONTENT; + } + + if ( m_eExtContentType != E_ROOT ) + { + const ::rtl::OUString sRootURL = ContentProvider::getRootURL(); + m_sExtensionId = getIdentifier()->getContentIdentifier().copy( sRootURL.getLength() ); + + const sal_Int32 nNextSep = m_sExtensionId.indexOf( '/' ); + if ( nNextSep > -1 ) + { + m_sPathIntoExtension = m_sExtensionId.copy( nNextSep + 1 ); + m_sExtensionId = m_sExtensionId.copy( 0, nNextSep ); + } + m_sExtensionId = Content::deescapeIdentifier( m_sExtensionId ); + } } //------------------------------------------------------------------------------------------------------------------ @@ -134,7 +199,8 @@ namespace ucb { namespace ucp { namespace ext //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL Content::getContentType() throw( RuntimeException ) { - return m_aProps.aContentType; + impl_determineContentType(); + return *m_aContentType; } //------------------------------------------------------------------------------------------------------------------ @@ -204,7 +270,7 @@ namespace ucb { namespace ucp { namespace ext ( aOpenCommand.Mode == OpenMode::DOCUMENTS ) ); - if ( bOpenFolder && m_aProps.bIsFolder ) + if ( bOpenFolder && impl_isFolder() ) { Reference< XDynamicResultSet > xSet = new ResultSet( m_xSMgr, this, aOpenCommand, i_rEvironment ); @@ -231,6 +297,7 @@ namespace ucb { namespace ucp { namespace ext Reference< XOutputStream > xOut( aOpenCommand.Sink, UNO_QUERY ); if ( xOut.is() ) { + OSL_ENSURE( false, "Content::execute( open->out ): not implemented!" ); // TODO: write data into xOut } else @@ -241,6 +308,7 @@ namespace ucb { namespace ucp { namespace ext Reference< XInputStream > xIn /* @@@ your XInputStream + XSeekable impl. object */; // TODO + OSL_ENSURE( false, "Content::execute( open->sink ): not implemented!" ); xDataSink->setInputStream( xIn ); } else @@ -284,26 +352,43 @@ namespace ucb { namespace ucp { namespace ext } //------------------------------------------------------------------------------------------------------------------ - bool Content::denotesRootContent( const Reference< XContentIdentifier >& i_rIdentifier ) + ::rtl::OUString Content::deescapeIdentifier( const ::rtl::OUString& i_rIdentifier ) + { + const ::rtl::OUString sQuoteQuotes = ::comphelper::string::searchAndReplaceAllAsciiWithAscii( + i_rIdentifier, "%%", "%" ); + const ::rtl::OUString sQuoteSlashes = ::comphelper::string::searchAndReplaceAllAsciiWithAscii( + i_rIdentifier, "%47", "/" ); + return sQuoteSlashes; + } + + //------------------------------------------------------------------------------------------------------------------ + bool Content::denotesRootContent( const ::rtl::OUString& i_rContentIdentifier ) { const sal_Char* pScheme = "vnd.oracle.ooo.extension"; const sal_Int32 nSchemeLength = sizeof( "vnd.oracle.ooo.extension" ) - 1; - const ::rtl::OUString sIdentifier( i_rIdentifier->getContentIdentifier() ); - ENSURE_OR_RETURN_FALSE( sIdentifier.matchAsciiL( pScheme, nSchemeLength ), "illegal content URL" ); - return sIdentifier.copy( nSchemeLength ).equalsAsciiL( ":/", 2 ); + ENSURE_OR_RETURN_FALSE( i_rContentIdentifier.matchAsciiL( pScheme, nSchemeLength ), "illegal content URL" ); + return i_rContentIdentifier.copy( nSchemeLength ).equalsAsciiL( ":/", 2 ); } //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString Content::getParentURL() { const ::rtl::OUString sURL = m_xIdentifier->getContentIdentifier(); - const ::rtl::OUString sParentURL( sURL.copy( 0, sURL.lastIndexOf( '/' ) + 1 ) ); + ENSURE_OR_RETURN( sURL.getLength(), "unexpected content URL", ::rtl::OUString() ); + sal_Int32 nCopyUpTo = sURL.lastIndexOf( '/' ) + 1; + if ( ( nCopyUpTo == sURL.getLength() ) && ( nCopyUpTo > 1 ) ) + { + nCopyUpTo = sURL.lastIndexOf( '/', nCopyUpTo - 2 ) + 1; + if ( nCopyUpTo == 0 ) + nCopyUpTo = sURL.getLength(); + } + const ::rtl::OUString sParentURL( sURL.copy( 0, nCopyUpTo ) ); return sParentURL; } //------------------------------------------------------------------------------------------------------------------ - Reference< XRow > Content::getPropertyValues( const Reference< XMultiServiceFactory >& i_rORB, - const Sequence< Property >& i_rProperties, const ContentProperties& i_rData ) + Reference< XRow > Content::getArtificialNodePropertyValues( const Reference< XMultiServiceFactory >& i_rORB, + const Sequence< Property >& i_rProperties, const ::rtl::OUString& i_rTitle ) { // note: empty sequence means "get values of all supported properties". ::rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( i_rORB ); @@ -321,19 +406,19 @@ namespace ucb { namespace ucp { namespace ext // Process Core properties. if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) { - xRow->appendString ( rProp, i_rData.aContentType ); + xRow->appendString ( rProp, ContentProvider::getArtificialNodeContentType() ); } else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { - xRow->appendString ( rProp, i_rData.aTitle ); + xRow->appendString ( rProp, i_rTitle ); } else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) { - xRow->appendBoolean( rProp, i_rData.bIsDocument ); + xRow->appendBoolean( rProp, sal_False ); } else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) { - xRow->appendBoolean( rProp, i_rData.bIsFolder ); + xRow->appendBoolean( rProp, sal_True ); } else { @@ -349,34 +434,86 @@ namespace ucb { namespace ucp { namespace ext -1, getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ), PropertyAttribute::BOUND | PropertyAttribute::READONLY ), - i_rData.aContentType ); + ContentProvider::getArtificialNodeContentType() ); xRow->appendString ( Property( ::rtl::OUString::createFromAscii( "Title" ), -1, getCppuType( static_cast< const ::rtl::OUString * >( 0 ) ), PropertyAttribute::BOUND | PropertyAttribute::READONLY ), - i_rData.aTitle ); + i_rTitle ); xRow->appendBoolean( Property( ::rtl::OUString::createFromAscii( "IsDocument" ), -1, getCppuBooleanType(), PropertyAttribute::BOUND | PropertyAttribute::READONLY ), - i_rData.bIsDocument ); + sal_False ); xRow->appendBoolean( Property( ::rtl::OUString::createFromAscii( "IsFolder" ), -1, getCppuBooleanType(), PropertyAttribute::BOUND | PropertyAttribute::READONLY ), - i_rData.bIsFolder ); + sal_True ); } return Reference< XRow >( xRow.get() ); } //------------------------------------------------------------------------------------------------------------------ - Reference< XRow > Content::getPropertyValues( const Sequence< Property >& i_rProperties, const Reference< XCommandEnvironment >& /* xEnv */) + ::rtl::OUString Content::getPhysicalURL() const { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); - return getPropertyValues( m_xSMgr, - i_rProperties, - m_aProps ); + ENSURE_OR_RETURN( m_eExtContentType != E_ROOT, "illegal call", ::rtl::OUString() ); + + // create an ucb::XContent for the physical file within the deployed extension + const ::comphelper::ComponentContext aContext( m_xSMgr ); + const Reference< XPackageInformationProvider > xPackageInfo( + aContext.getSingleton( "com.sun.star.deployment.PackageInformationProvider" ), UNO_QUERY_THROW ); + const ::rtl::OUString sPackageLocation( xPackageInfo->getPackageLocation( m_sExtensionId ) ); + + if ( m_sPathIntoExtension.getLength() == 0 ) + return sPackageLocation; + return lcl_compose( sPackageLocation, m_sPathIntoExtension ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XRow > Content::getPropertyValues( const Sequence< Property >& i_rProperties, const Reference< XCommandEnvironment >& i_rEnv ) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + + switch ( m_eExtContentType ) + { + case E_ROOT: + return getArtificialNodePropertyValues( m_xSMgr, i_rProperties, ContentProvider::getRootURL() ); + case E_EXTENSION_ROOT: + return getArtificialNodePropertyValues( m_xSMgr, i_rProperties, m_sExtensionId ); + case E_EXTENSION_CONTENT: + { + const ::rtl::OUString sPhysicalContentURL( getPhysicalURL() ); + ::ucbhelper::Content aRequestedContent( sPhysicalContentURL, i_rEnv ); + + // translate the property request + Sequence< ::rtl::OUString > aPropertyNames( i_rProperties.getLength() ); + ::std::transform( + i_rProperties.getConstArray(), + i_rProperties.getConstArray() + i_rProperties.getLength(), + aPropertyNames.getArray(), + SelectPropertyName() + ); + const Sequence< Any > aPropertyValues = aRequestedContent.getPropertyValues( aPropertyNames ); + const ::rtl::Reference< ::ucbhelper::PropertyValueSet > xValueRow = new ::ucbhelper::PropertyValueSet( m_xSMgr ); + sal_Int32 i=0; + for ( const Any* value = aPropertyValues.getConstArray(); + value != aPropertyValues.getConstArray() + aPropertyValues.getLength(); + ++value, ++i + ) + { + xValueRow->appendObject( aPropertyNames[i], *value ); + } + return xValueRow.get(); + } + break; + default: + OSL_ENSURE( false, "Content::getPropertyValues: unhandled case!" ); + } + + OSL_ENSURE( false, "Content::getPropertyValues: unreachable!" ); + return NULL; } //------------------------------------------------------------------------------------------------------------------ @@ -438,14 +575,11 @@ namespace ucb { namespace ucp { namespace ext /////////////////////////////////////////////////////////////// // Optional standard commands /////////////////////////////////////////////////////////////// - - #ifdef IMPLEMENT_COMMAND_OPEN , CommandInfo( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), -1, getCppuType( static_cast< OpenCommandArgument2 * >( 0 ) ) ) - #endif }; return Sequence< CommandInfo >( aCommandInfoTable, nCommandCount ); @@ -484,6 +618,51 @@ namespace ucb { namespace ucp { namespace ext return Sequence< Property >( aProperties, sizeof( aProperties ) / sizeof( aProperties[0] ) ); } + //------------------------------------------------------------------------------------------------------------------ + bool Content::impl_isFolder() + { + if ( !!m_aIsFolder ) + return *m_aIsFolder; + + bool bIsFolder = false; + try + { + Sequence< Property > aProps(1); + aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ); + Reference< XRow > xRow( getPropertyValues( aProps, NULL ), UNO_SET_THROW ); + bIsFolder = xRow->getBoolean(1); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + m_aIsFolder.reset( bIsFolder ); + return *m_aIsFolder; + } + + //------------------------------------------------------------------------------------------------------------------ + void Content::impl_determineContentType() + { + if ( !!m_aContentType ) + return; + + m_aContentType.reset( ContentProvider::getArtificialNodeContentType() ); + if ( m_eExtContentType == E_EXTENSION_CONTENT ) + { + try + { + Sequence< Property > aProps(1); + aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ); + Reference< XRow > xRow( getPropertyValues( aProps, NULL ), UNO_SET_THROW ); + m_aContentType.reset( xRow->getString(1) ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + //...................................................................................................................... } } } // namespace ucp::ext //...................................................................................................................... diff --git a/ucb/source/ucp/ext/ucpext_content.hxx b/ucb/source/ucp/ext/ucpext_content.hxx index 9b5667a1d641..8e3e8fa386c7 100644 --- a/ucb/source/ucp/ext/ucpext_content.hxx +++ b/ucb/source/ucp/ext/ucpext_content.hxx @@ -36,6 +36,7 @@ #include #include +#include //...................................................................................................................... namespace ucb { namespace ucp { namespace ext @@ -43,20 +44,15 @@ namespace ucb { namespace ucp { namespace ext //...................................................................................................................... //================================================================================================================== - //= ContentProvider + //= ExtensionContentType //================================================================================================================== - struct ContentProperties + enum ExtensionContentType { - ::rtl::OUString aTitle; // Title - ::rtl::OUString aContentType; // ContentType - bool bIsDocument; // IsDocument - bool bIsFolder; // IsFolder - - ContentProperties() - :bIsDocument( false ) - ,bIsFolder( true ) - { - } + E_ROOT, + E_EXTENSION_ROOT, + E_EXTENSION_CONTENT, + + E_UNKNOWN }; //================================================================================================================== @@ -66,23 +62,38 @@ namespace ucb { namespace ucp { namespace ext class Content : public Content_Base { public: - static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > - getPropertyValues( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties, - const ContentProperties& rData - ); - Content( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ::ucbhelper::ContentProviderImplHelper* pProvider, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& Identifier ); - static bool denotesRootContent( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& i_rIdentifier ); + static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > + getArtificialNodePropertyValues( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties, + const ::rtl::OUString& rTitle + ); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > + getPropertyValues( + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv + ); static ::rtl::OUString escapeIdentifier( const ::rtl::OUString& i_rIdentifier ); + static ::rtl::OUString + deescapeIdentifier( const ::rtl::OUString& i_rIdentifier ); + + virtual ::rtl::OUString getParentURL(); + + ExtensionContentType getExtensionContentType() const { return m_eExtContentType; } + + /** retrieves the URL of the underlying physical content. Not to be called when getExtensionContentType() + returns E_ROOT. + */ + ::rtl::OUString getPhysicalURL() const; protected: virtual ~Content(); @@ -113,28 +124,31 @@ namespace ucb { namespace ucp { namespace ext throw ( ::com::sun::star::uno::RuntimeException ); - protected: - const ContentProperties& getProperties() const { return m_aProps; } - ContentProperties& getProperties() { return m_aProps; } - private: virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > getProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& i_rEnv ); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::CommandInfo > getCommands( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& i_rEnv ); - virtual ::rtl::OUString getParentURL(); - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > - getPropertyValues( - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties, - const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv - ); ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rValues, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv ); + static bool denotesRootContent( const ::rtl::OUString& i_rContentIdentifier ); + static bool denotesRootContent( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& i_rIdentifier ) + { + return denotesRootContent( i_rIdentifier->getContentIdentifier() ); + } + + bool impl_isFolder(); + void impl_determineContentType(); + private: - ContentProperties m_aProps; + ExtensionContentType m_eExtContentType; + ::boost::optional< bool > m_aIsFolder; + ::boost::optional< ::rtl::OUString > m_aContentType; + ::rtl::OUString m_sExtensionId; + ::rtl::OUString m_sPathIntoExtension; }; //...................................................................................................................... diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx b/ucb/source/ucp/ext/ucpext_datasupplier.cxx index d40e2339fe70..3c99c95197ee 100644 --- a/ucb/source/ucp/ext/ucpext_datasupplier.cxx +++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx @@ -28,6 +28,7 @@ #include "ucpext_datasupplier.hxx" #include "ucpext_content.hxx" +#include "ucpext_provider.hxx" /** === begin UNO includes === **/ #include @@ -36,9 +37,13 @@ #include #include #include +#include +#include #include +#include #include +#include //...................................................................................................................... namespace ucb { namespace ucp { namespace ext @@ -65,8 +70,10 @@ namespace ucb { namespace ucp { namespace ext using ::com::sun::star::ucb::ResultSetException; using ::com::sun::star::deployment::XPackageInformationProvider; using ::com::sun::star::beans::Property; + using ::com::sun::star::sdbc::XResultSet; + using ::com::sun::star::sdbc::XRow; + using ::com::sun::star::ucb::XCommandEnvironment; /** === end UNO using === **/ - //================================================================================================================== //= ResultListEntry //================================================================================================================== @@ -74,15 +81,8 @@ namespace ucb { namespace ucp { namespace ext { ::rtl::OUString sId; Reference< XContentIdentifier > xId; - ContentProperties aProperties; - Reference< XContent > xContent; + ::rtl::Reference< Content > pContent; Reference< XRow > xRow; - - ResultListEntry( const ::rtl::OUString& i_rParentId, const ::rtl::OUString& i_rLocalId ) - { - aProperties.aTitle = i_rLocalId; - sId = i_rParentId + Content::escapeIdentifier( i_rLocalId ); - } }; typedef ::std::vector< ResultListEntry > ResultList; @@ -113,6 +113,24 @@ namespace ucb { namespace ucp { namespace ext { } + //================================================================================================================== + //= helper + //================================================================================================================== + namespace + { + ::rtl::OUString lcl_compose( const ::rtl::OUString& i_rBaseURL, const ::rtl::OUString& i_rRelativeURL ) + { + ENSURE_OR_RETURN( i_rBaseURL.getLength(), "illegal base URL", i_rRelativeURL ); + + ::rtl::OUStringBuffer aComposer( i_rBaseURL ); + if ( i_rBaseURL.getStr()[ i_rBaseURL.getLength() - 1 ] != '/' ) + aComposer.append( sal_Unicode( '/' ) ); + aComposer.append( i_rRelativeURL ); + return aComposer.makeStringAndClear(); + } + } + + //================================================================================================================== //= DataSupplier //================================================================================================================== @@ -121,17 +139,24 @@ namespace ucb { namespace ucp { namespace ext const ::rtl::Reference< Content >& i_rContent, const sal_Int32 i_nOpenMode ) :m_pImpl( new DataSupplier_Impl( i_rORB, i_rContent, i_nOpenMode ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + void DataSupplier::fetchData() { try { - if ( Content::denotesRootContent( m_pImpl->m_xContent->getIdentifier() ) ) - { - const ::rtl::OUString sContentId( m_pImpl->m_xContent->getIdentifier()->getContentIdentifier() ); + const ::comphelper::ComponentContext aContext( m_pImpl->m_xSMgr ); + const Reference< XPackageInformationProvider > xPackageInfo( + aContext.getSingleton( "com.sun.star.deployment.PackageInformationProvider" ), UNO_QUERY_THROW ); - const ::comphelper::ComponentContext aContext( i_rORB ); - Reference< XPackageInformationProvider > xPackageInfo( - aContext.getSingleton( "com.sun.star.deployment.PackageInformationProvider" ), UNO_QUERY_THROW ); + const ::rtl::OUString sContentIdentifier( m_pImpl->m_xContent->getIdentifier()->getContentIdentifier() ); + switch ( m_pImpl->m_xContent->getExtensionContentType() ) + { + case E_ROOT: + { Sequence< Sequence< ::rtl::OUString > > aExtensionInfo( xPackageInfo->getExtensionList() ); for ( const Sequence< ::rtl::OUString >* pExtInfo = aExtensionInfo.getConstArray(); pExtInfo != aExtensionInfo.getConstArray() + aExtensionInfo.getLength(); @@ -140,11 +165,37 @@ namespace ucb { namespace ucp { namespace ext { ENSURE_OR_CONTINUE( pExtInfo->getLength() > 0, "illegal extension info" ); - ResultListEntry aEntry( sContentId, (*pExtInfo)[0] ); - aEntry.aProperties.aContentType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.oracle.ooo.extension-content" ) ); - m_pImpl->m_aResults.push_back( ResultListEntry( aEntry ) ); + const ::rtl::OUString& rLocalId = (*pExtInfo)[0]; + ResultListEntry aEntry; + aEntry.sId = lcl_compose( sContentIdentifier, Content::escapeIdentifier( rLocalId ) ); + m_pImpl->m_aResults.push_back( aEntry ); + } + } + break; + case E_EXTENSION_ROOT: + case E_EXTENSION_CONTENT: + { + const ::rtl::OUString sPackageLocation( m_pImpl->m_xContent->getPhysicalURL() ); + ::ucbhelper::Content aWrappedContent( sPackageLocation, getResultSet()->getEnvironment() ); + + // obtain the properties which our result set is set up for from the wrapped content + Sequence< ::rtl::OUString > aPropertyNames(1); + aPropertyNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ); + + const Reference< XResultSet > xFolderContent( aWrappedContent.createCursor( aPropertyNames ), UNO_SET_THROW ); + const Reference< XRow > xContentRow( xFolderContent, UNO_QUERY_THROW ); + while ( xFolderContent->next() ) + { + ResultListEntry aEntry; + aEntry.sId = lcl_compose( sContentIdentifier, xContentRow->getString( 1 ) ); + m_pImpl->m_aResults.push_back( aEntry ); } } + break; + default: + OSL_ENSURE( false, "DataSupplier::fetchData: unimplemented content type!" ); + break; + } } catch( const Exception& ) { @@ -202,9 +253,10 @@ namespace ucb { namespace ucp { namespace ext ::osl::Guard< ::osl::Mutex > aGuard( m_pImpl->m_aMutex ); ENSURE_OR_RETURN( i_nIndex < m_pImpl->m_aResults.size(), "illegal index!", NULL ); - Reference< XContent > xContent( m_pImpl->m_aResults[ i_nIndex ].xContent ); - if ( xContent.is() ) - return xContent; + + ::rtl::Reference< Content > pContent( m_pImpl->m_aResults[ i_nIndex ].pContent ); + if ( pContent.is() ) + return pContent.get(); Reference< XContentIdentifier > xId( queryContentIdentifier( i_nIndex ) ); if ( xId.is() ) @@ -212,8 +264,10 @@ namespace ucb { namespace ucp { namespace ext try { Reference< XContent > xContent( m_pImpl->m_xContent->getProvider()->queryContent( xId ) ); - m_pImpl->m_aResults[ i_nIndex ].xContent = xContent; - return xContent; + ::rtl::Reference< Content > pContent( dynamic_cast< Content* >( xContent.get() ) ); + OSL_ENSURE( pContent.is() || !xContent.is(), "DataSupplier::queryContent: invalid content implementation!" ); + m_pImpl->m_aResults[ i_nIndex ].pContent = pContent; + return pContent.get(); } catch ( const IllegalIdentifierException& ) @@ -259,15 +313,38 @@ namespace ucb { namespace ucp { namespace ext //------------------------------------------------------------------------------------------------------------------ Reference< XRow > DataSupplier::queryPropertyValues( sal_uInt32 i_nIndex ) { - ::osl::Guard< ::osl::Mutex > aGuard( m_pImpl->m_aMutex ); + ::osl::MutexGuard aGuard( m_pImpl->m_aMutex ); ENSURE_OR_RETURN( i_nIndex < m_pImpl->m_aResults.size(), "DataSupplier::queryPropertyValues: illegal index!", NULL ); Reference< XRow > xRow = m_pImpl->m_aResults[ i_nIndex ].xRow; if ( xRow.is() ) return xRow; - xRow = Content::getPropertyValues( m_pImpl->m_xSMgr, getResultSet()->getProperties(), - m_pImpl->m_aResults[ i_nIndex ].aProperties ); + ENSURE_OR_RETURN( queryContent( i_nIndex ).is(), "could not retrieve the content", NULL ); + + switch ( m_pImpl->m_xContent->getExtensionContentType() ) + { + case E_ROOT: + { + const ::rtl::OUString& rId( m_pImpl->m_aResults[ i_nIndex ].sId ); + const ::rtl::OUString sTitle = Content::deescapeIdentifier( rId.copy( rId.indexOf( '/' ) + 1 ) ); + xRow = Content::getArtificialNodePropertyValues( m_pImpl->m_xSMgr, getResultSet()->getProperties(), sTitle ); + } + break; + + case E_EXTENSION_ROOT: + case E_EXTENSION_CONTENT: + { + xRow = m_pImpl->m_aResults[ i_nIndex ].pContent->getPropertyValues( + getResultSet()->getProperties(), getResultSet()->getEnvironment() ); + } + break; + default: + OSL_ENSURE( false, "DataSupplier::queryPropertyValues: unhandled case!" ); + break; + } + + m_pImpl->m_aResults[ i_nIndex ].xRow = xRow; return xRow; } diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.hxx b/ucb/source/ucp/ext/ucpext_datasupplier.hxx index 7957a318aa36..526491cd678b 100644 --- a/ucb/source/ucp/ext/ucpext_datasupplier.hxx +++ b/ucb/source/ucp/ext/ucpext_datasupplier.hxx @@ -48,11 +48,13 @@ namespace ucb { namespace ucp { namespace ext { public: DataSupplier( - const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& i_rORB, + const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& i_rORB, const rtl::Reference< Content >& rContent, const sal_Int32 nOpenMode ); + void fetchData(); + protected: virtual ~DataSupplier(); diff --git a/ucb/source/ucp/ext/ucpext_provider.cxx b/ucb/source/ucp/ext/ucpext_provider.cxx index 4e26dacf229c..c7da555d6c28 100644 --- a/ucb/source/ucp/ext/ucpext_provider.cxx +++ b/ucb/source/ucp/ext/ucpext_provider.cxx @@ -110,6 +110,18 @@ namespace ucb { namespace ucp { namespace ext return *( new ContentProvider( aContext.getLegacyServiceFactory() ) ); } + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString ContentProvider::getRootURL() + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.oracle.ooo.extension:/" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString ContentProvider::getArtificialNodeContentType() + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.oracle.ooo.extension-content" ) ); + } + //------------------------------------------------------------------------------------------------------------------ Reference< XContent > SAL_CALL ContentProvider::queryContent( const Reference< XContentIdentifier >& i_rIdentifier ) throw( IllegalIdentifierException, RuntimeException ) diff --git a/ucb/source/ucp/ext/ucpext_provider.hxx b/ucb/source/ucp/ext/ucpext_provider.hxx index 1e9090dab2e0..1f41fdd0f084 100644 --- a/ucb/source/ucp/ext/ucpext_provider.hxx +++ b/ucb/source/ucp/ext/ucpext_provider.hxx @@ -55,6 +55,10 @@ namespace ucb { namespace ucp { namespace ext // XContentProvider virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > SAL_CALL queryContent( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& Identifier ) throw (::com::sun::star::ucb::IllegalIdentifierException, ::com::sun::star::uno::RuntimeException); + + public: + static ::rtl::OUString getRootURL(); + static ::rtl::OUString getArtificialNodeContentType(); }; //...................................................................................................................... diff --git a/ucb/source/ucp/ext/ucpext_resultset.cxx b/ucb/source/ucp/ext/ucpext_resultset.cxx index 6d5e79d61902..d8a2eb8e9914 100644 --- a/ucb/source/ucp/ext/ucpext_resultset.cxx +++ b/ucb/source/ucp/ext/ucpext_resultset.cxx @@ -73,16 +73,18 @@ namespace ucb { namespace ucp { namespace ext //------------------------------------------------------------------------------------------------------------------ void ResultSet::initStatic() { + ::rtl::Reference< DataSupplier > pDataSupplier( new DataSupplier( + m_xSMgr, + m_xContent, + m_aCommand.Mode + ) ); m_xResultSet1 = new ::ucbhelper::ResultSet( m_xSMgr, m_aCommand.Properties, - new DataSupplier( - m_xSMgr, - m_xContent, - m_aCommand.Mode - ), + pDataSupplier.get(), m_xEnvironment ); + pDataSupplier->fetchData(); } //------------------------------------------------------------------------------------------------------------------ -- cgit From f372e6625bf10b5233fa204da4291131371cf3c3 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 25 Mar 2010 08:56:23 +0100 Subject: slidecopy: delegate the request to open a document content to the wrapped content --- ucb/source/ucp/ext/ucpext_content.cxx | 46 +++-------------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 1611fe579dbd..1dc49990c73d 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -279,49 +279,9 @@ namespace ucb { namespace ucp { namespace ext if ( aOpenCommand.Sink.is() ) { - // Open document - supply document data stream. - - // Check open mode - if ( ( aOpenCommand.Mode == OpenMode::DOCUMENT_SHARE_DENY_NONE ) - || ( aOpenCommand.Mode == OpenMode::DOCUMENT_SHARE_DENY_WRITE ) - ) - { - // unsupported. - ::ucbhelper::cancelCommandExecution( makeAny( UnsupportedOpenModeException( - ::rtl::OUString(), *this, sal_Int16( aOpenCommand.Mode ) ) ), - i_rEvironment ); - // unreachable - } - - ::rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); - Reference< XOutputStream > xOut( aOpenCommand.Sink, UNO_QUERY ); - if ( xOut.is() ) - { - OSL_ENSURE( false, "Content::execute( open->out ): not implemented!" ); - // TODO: write data into xOut - } - else - { - Reference< XActiveDataSink > xDataSink( aOpenCommand.Sink, UNO_QUERY ); - if ( xDataSink.is() ) - { - Reference< XInputStream > xIn - /* @@@ your XInputStream + XSeekable impl. object */; - // TODO - OSL_ENSURE( false, "Content::execute( open->sink ): not implemented!" ); - xDataSink->setInputStream( xIn ); - } - else - { - // Note: aOpenCommand.Sink may contain an XStream - // implementation. Support for this type of - // sink is optional... - ::ucbhelper::cancelCommandExecution( makeAny( UnsupportedDataSinkException( - ::rtl::OUString(), *this, aOpenCommand.Sink ) ), - i_rEvironment ); - // unreachable - } - } + const ::rtl::OUString sPhysicalContentURL( getPhysicalURL() ); + ::ucbhelper::Content aRequestedContent( sPhysicalContentURL, i_rEvironment ); + aRet = aRequestedContent.executeCommand( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), makeAny( aOpenCommand ) ); } } -- cgit From 642ef423f580142583911019b92cbfc38c756c24 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 25 Mar 2010 09:25:22 +0100 Subject: slidecopy: use vnd.sun.star.extension URL scheme for the extension UCP --- ucb/source/ucp/ext/ucpext_content.cxx | 4 ++-- ucb/source/ucp/ext/ucpext_provider.cxx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 1dc49990c73d..df04798b2c56 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -324,8 +324,8 @@ namespace ucb { namespace ucp { namespace ext //------------------------------------------------------------------------------------------------------------------ bool Content::denotesRootContent( const ::rtl::OUString& i_rContentIdentifier ) { - const sal_Char* pScheme = "vnd.oracle.ooo.extension"; - const sal_Int32 nSchemeLength = sizeof( "vnd.oracle.ooo.extension" ) - 1; + const sal_Char* pScheme = "vnd.sun.star.extension"; + const sal_Int32 nSchemeLength = sizeof( "vnd.sun.star.extension" ) - 1; ENSURE_OR_RETURN_FALSE( i_rContentIdentifier.matchAsciiL( pScheme, nSchemeLength ), "illegal content URL" ); return i_rContentIdentifier.copy( nSchemeLength ).equalsAsciiL( ":/", 2 ); } diff --git a/ucb/source/ucp/ext/ucpext_provider.cxx b/ucb/source/ucp/ext/ucpext_provider.cxx index c7da555d6c28..b626999b66b5 100644 --- a/ucb/source/ucp/ext/ucpext_provider.cxx +++ b/ucb/source/ucp/ext/ucpext_provider.cxx @@ -113,13 +113,13 @@ namespace ucb { namespace ucp { namespace ext //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString ContentProvider::getRootURL() { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.oracle.ooo.extension:/" ) ); + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.extension:/" ) ); } //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString ContentProvider::getArtificialNodeContentType() { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.oracle.ooo.extension-content" ) ); + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.extension-content" ) ); } //------------------------------------------------------------------------------------------------------------------ @@ -127,7 +127,7 @@ namespace ucb { namespace ucp { namespace ext throw( IllegalIdentifierException, RuntimeException ) { // Check URL scheme... - const ::rtl::OUString aScheme( rtl::OUString::createFromAscii( "vnd.oracle.ooo.extension" ) ); + const ::rtl::OUString aScheme( rtl::OUString::createFromAscii( "vnd.sun.star.extension" ) ); if ( !i_rIdentifier->getContentProviderScheme().equalsIgnoreAsciiCase( aScheme ) ) throw IllegalIdentifierException(); -- cgit From 22b13738ef17f9850d79a573343cc44d7396235b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 25 Mar 2010 11:24:13 +0100 Subject: slidecopy: use g:/dev/o_slidecopy/DEV300/ooo/solenv/src/component.map --- ucb/source/ucp/ext/makefile.mk | 2 +- ucb/source/ucp/ext/ucpext.uno.map | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 ucb/source/ucp/ext/ucpext.uno.map (limited to 'ucb') diff --git a/ucb/source/ucp/ext/makefile.mk b/ucb/source/ucp/ext/makefile.mk index f8919e50e594..23c30b3bda5b 100644 --- a/ucb/source/ucp/ext/makefile.mk +++ b/ucb/source/ucp/ext/makefile.mk @@ -52,7 +52,7 @@ SHL1STDLIBS = \ $(SALLIB) \ $(SALHELPERLIB) -SHL1VERSIONMAP = $(TARGET).map +SHL1VERSIONMAP = $(SOLARENV)/src/component.map SHL1TARGET = $(TARGET) SHL1DEPN = diff --git a/ucb/source/ucp/ext/ucpext.uno.map b/ucb/source/ucp/ext/ucpext.uno.map deleted file mode 100644 index f4ed78b9e970..000000000000 --- a/ucb/source/ucp/ext/ucpext.uno.map +++ /dev/null @@ -1,8 +0,0 @@ -UDK_3_0_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; -- cgit From 902c2a5a1dffe4db1637ec4eb2c6cbd7efb14ffd Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 25 Mar 2010 11:50:52 +0100 Subject: slidecopy: proper en/decoding of extension IDs --- ucb/source/ucp/ext/ucpext_content.cxx | 24 +++++++++++------------- ucb/source/ucp/ext/ucpext_content.hxx | 4 ++-- ucb/source/ucp/ext/ucpext_datasupplier.cxx | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index df04798b2c56..d8076db33ae2 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -60,6 +60,7 @@ #include #include #include +#include #include @@ -172,7 +173,7 @@ namespace ucb { namespace ucp { namespace ext m_sPathIntoExtension = m_sExtensionId.copy( nNextSep + 1 ); m_sExtensionId = m_sExtensionId.copy( 0, nNextSep ); } - m_sExtensionId = Content::deescapeIdentifier( m_sExtensionId ); + m_sExtensionId = Content::decodeIdentifier( m_sExtensionId ); } } @@ -302,23 +303,20 @@ namespace ucb { namespace ucp { namespace ext } //------------------------------------------------------------------------------------------------------------------ - ::rtl::OUString Content::escapeIdentifier( const ::rtl::OUString& i_rIdentifier ) + ::rtl::OUString Content::encodeIdentifier( const ::rtl::OUString& i_rIdentifier ) { - const ::rtl::OUString sQuoteQuotes = ::comphelper::string::searchAndReplaceAllAsciiWithAscii( - i_rIdentifier, "%", "%%" ); - const ::rtl::OUString sQuoteSlashes = ::comphelper::string::searchAndReplaceAllAsciiWithAscii( - i_rIdentifier, "/", "%47" ); - return sQuoteSlashes; + ::rtl::OUString sEncoded; + rtl_uriEncode( i_rIdentifier.pData, rtl_getUriCharClass( rtl_UriCharClassUricNoSlash ), + rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8, &sEncoded.pData ); + return sEncoded; } //------------------------------------------------------------------------------------------------------------------ - ::rtl::OUString Content::deescapeIdentifier( const ::rtl::OUString& i_rIdentifier ) + ::rtl::OUString Content::decodeIdentifier( const ::rtl::OUString& i_rIdentifier ) { - const ::rtl::OUString sQuoteQuotes = ::comphelper::string::searchAndReplaceAllAsciiWithAscii( - i_rIdentifier, "%%", "%" ); - const ::rtl::OUString sQuoteSlashes = ::comphelper::string::searchAndReplaceAllAsciiWithAscii( - i_rIdentifier, "%47", "/" ); - return sQuoteSlashes; + ::rtl::OUString sDecoded; + rtl_uriDecode( i_rIdentifier.pData, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8, &sDecoded.pData ); + return sDecoded; } //------------------------------------------------------------------------------------------------------------------ diff --git a/ucb/source/ucp/ext/ucpext_content.hxx b/ucb/source/ucp/ext/ucpext_content.hxx index 8e3e8fa386c7..a9ee22ca8078 100644 --- a/ucb/source/ucp/ext/ucpext_content.hxx +++ b/ucb/source/ucp/ext/ucpext_content.hxx @@ -82,9 +82,9 @@ namespace ucb { namespace ucp { namespace ext ); static ::rtl::OUString - escapeIdentifier( const ::rtl::OUString& i_rIdentifier ); + encodeIdentifier( const ::rtl::OUString& i_rIdentifier ); static ::rtl::OUString - deescapeIdentifier( const ::rtl::OUString& i_rIdentifier ); + decodeIdentifier( const ::rtl::OUString& i_rIdentifier ); virtual ::rtl::OUString getParentURL(); diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx b/ucb/source/ucp/ext/ucpext_datasupplier.cxx index 3c99c95197ee..dcc1c117befa 100644 --- a/ucb/source/ucp/ext/ucpext_datasupplier.cxx +++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx @@ -167,7 +167,7 @@ namespace ucb { namespace ucp { namespace ext const ::rtl::OUString& rLocalId = (*pExtInfo)[0]; ResultListEntry aEntry; - aEntry.sId = lcl_compose( sContentIdentifier, Content::escapeIdentifier( rLocalId ) ); + aEntry.sId = lcl_compose( sContentIdentifier, Content::encodeIdentifier( rLocalId ) ); m_pImpl->m_aResults.push_back( aEntry ); } } @@ -327,7 +327,7 @@ namespace ucb { namespace ucp { namespace ext case E_ROOT: { const ::rtl::OUString& rId( m_pImpl->m_aResults[ i_nIndex ].sId ); - const ::rtl::OUString sTitle = Content::deescapeIdentifier( rId.copy( rId.indexOf( '/' ) + 1 ) ); + const ::rtl::OUString sTitle = Content::decodeIdentifier( rId.copy( rId.indexOf( '/' ) + 1 ) ); xRow = Content::getArtificialNodePropertyValues( m_pImpl->m_xSMgr, getResultSet()->getProperties(), sTitle ); } break; -- cgit From dc5d25031d075a39c5b90c76619a8a12601082f4 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 25 Mar 2010 14:10:15 +0100 Subject: slidecopy: adjusted the Ext-UCP URL scheme so that the ExtensionID is the URL's authority --- ucb/source/ucp/ext/ucpext_content.cxx | 90 +++++++++++++++++++++++------- ucb/source/ucp/ext/ucpext_content.hxx | 4 -- ucb/source/ucp/ext/ucpext_datasupplier.cxx | 7 ++- ucb/source/ucp/ext/ucpext_provider.cxx | 61 ++++++++++++++++++-- 4 files changed, 130 insertions(+), 32 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index d8076db33ae2..88afe370908b 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -149,23 +149,29 @@ namespace ucb { namespace ucp { namespace ext ,m_sExtensionId() ,m_sPathIntoExtension() { - if ( denotesRootContent( getIdentifier() ) ) + const ::rtl::OUString sURL( getIdentifier()->getContentIdentifier() ); + if ( denotesRootContent( sURL ) ) { m_eExtContentType = E_ROOT; } - else if ( denotesRootContent( getParentURL() ) ) - { - m_eExtContentType = E_EXTENSION_ROOT; - } else { - m_eExtContentType = E_EXTENSION_CONTENT; + const ::rtl::OUString sRelativeURL( sURL.copy( ContentProvider::getRootURL().getLength() ) ); + const sal_Int32 nSepPos = sRelativeURL.indexOf( '/' ); + if ( ( nSepPos == -1 ) || ( nSepPos == sRelativeURL.getLength() - 1 ) ) + { + m_eExtContentType = E_EXTENSION_ROOT; + } + else + { + m_eExtContentType = E_EXTENSION_CONTENT; + } } if ( m_eExtContentType != E_ROOT ) { const ::rtl::OUString sRootURL = ContentProvider::getRootURL(); - m_sExtensionId = getIdentifier()->getContentIdentifier().copy( sRootURL.getLength() ); + m_sExtensionId = sURL.copy( sRootURL.getLength() ); const sal_Int32 nNextSep = m_sExtensionId.indexOf( '/' ); if ( nNextSep > -1 ) @@ -322,26 +328,70 @@ namespace ucb { namespace ucp { namespace ext //------------------------------------------------------------------------------------------------------------------ bool Content::denotesRootContent( const ::rtl::OUString& i_rContentIdentifier ) { - const sal_Char* pScheme = "vnd.sun.star.extension"; - const sal_Int32 nSchemeLength = sizeof( "vnd.sun.star.extension" ) - 1; - ENSURE_OR_RETURN_FALSE( i_rContentIdentifier.matchAsciiL( pScheme, nSchemeLength ), "illegal content URL" ); - return i_rContentIdentifier.copy( nSchemeLength ).equalsAsciiL( ":/", 2 ); + const ::rtl::OUString sRootURL( ContentProvider::getRootURL() ); + if ( i_rContentIdentifier == sRootURL ) + return true; + + // the root URL contains only two trailing /, but we also recognize 3 of them as denoting the root URL + if ( i_rContentIdentifier.match( sRootURL ) + && ( i_rContentIdentifier.getLength() == sRootURL.getLength() + 1 ) + && ( i_rContentIdentifier[ i_rContentIdentifier.getLength() - 1 ] == '/' ) + ) + return true; + + return false; } //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString Content::getParentURL() { - const ::rtl::OUString sURL = m_xIdentifier->getContentIdentifier(); - ENSURE_OR_RETURN( sURL.getLength(), "unexpected content URL", ::rtl::OUString() ); - sal_Int32 nCopyUpTo = sURL.lastIndexOf( '/' ) + 1; - if ( ( nCopyUpTo == sURL.getLength() ) && ( nCopyUpTo > 1 ) ) + const ::rtl::OUString sRootURL( ContentProvider::getRootURL() ); + + switch ( m_eExtContentType ) { - nCopyUpTo = sURL.lastIndexOf( '/', nCopyUpTo - 2 ) + 1; - if ( nCopyUpTo == 0 ) - nCopyUpTo = sURL.getLength(); + case E_ROOT: + // don't have a parent + return sRootURL; + + case E_EXTENSION_ROOT: + // our parent is the root itself + return sRootURL; + + case E_EXTENSION_CONTENT: + { + const ::rtl::OUString sURL = m_xIdentifier->getContentIdentifier(); + + // cut the root URL + ENSURE_OR_BREAK( sURL.match( sRootURL, 0 ), "illegal URL structure - no root" ); + ::rtl::OUString sRelativeURL( sURL.copy( sRootURL.getLength() ) ); + + // cut the extension ID + const ::rtl::OUString sSeparatedExtensionId( encodeIdentifier( m_sExtensionId ) + ::rtl::OUString( sal_Unicode( '/' ) ) ); + ENSURE_OR_BREAK( sRelativeURL.match( sSeparatedExtensionId ), "illegal URL structure - no extension ID" ); + sRelativeURL = sRelativeURL.copy( sSeparatedExtensionId.getLength() ); + + // cut the final slash (if any) + ENSURE_OR_BREAK( sRelativeURL.getLength(), "illegal URL structure - ExtensionContent should have a level below the extension ID" ); + if ( sRelativeURL.getStr()[ sRelativeURL.getLength() - 1 ] == '/' ) + sRelativeURL = sRelativeURL.copy( 0, sRelativeURL.getLength() - 1 ); + + // remove the last segment + const sal_Int32 nLastSep = sRelativeURL.lastIndexOf( '/' ); + sRelativeURL = sRelativeURL.copy( 0, nLastSep != -1 ? nLastSep : 0 ); + + ::rtl::OUStringBuffer aComposer; + aComposer.append( sRootURL ); + aComposer.append( sSeparatedExtensionId ); + aComposer.append( sRelativeURL ); + return aComposer.makeStringAndClear(); + } + break; + + default: + OSL_ENSURE( false, "Content::getParentURL: unhandled case!" ); + break; } - const ::rtl::OUString sParentURL( sURL.copy( 0, nCopyUpTo ) ); - return sParentURL; + return ::rtl::OUString(); } //------------------------------------------------------------------------------------------------------------------ diff --git a/ucb/source/ucp/ext/ucpext_content.hxx b/ucb/source/ucp/ext/ucpext_content.hxx index a9ee22ca8078..36380d8a7d68 100644 --- a/ucb/source/ucp/ext/ucpext_content.hxx +++ b/ucb/source/ucp/ext/ucpext_content.hxx @@ -135,10 +135,6 @@ namespace ucb { namespace ucp { namespace ext ); static bool denotesRootContent( const ::rtl::OUString& i_rContentIdentifier ); - static bool denotesRootContent( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& i_rIdentifier ) - { - return denotesRootContent( i_rIdentifier->getContentIdentifier() ); - } bool impl_isFolder(); void impl_determineContentType(); diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx b/ucb/source/ucp/ext/ucpext_datasupplier.cxx index dcc1c117befa..dfdd1df82fd6 100644 --- a/ucb/source/ucp/ext/ucpext_datasupplier.cxx +++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx @@ -167,7 +167,7 @@ namespace ucb { namespace ucp { namespace ext const ::rtl::OUString& rLocalId = (*pExtInfo)[0]; ResultListEntry aEntry; - aEntry.sId = lcl_compose( sContentIdentifier, Content::encodeIdentifier( rLocalId ) ); + aEntry.sId = ContentProvider::getRootURL() + Content::encodeIdentifier( rLocalId ) + ::rtl::OUString( sal_Unicode( '/' ) ); m_pImpl->m_aResults.push_back( aEntry ); } } @@ -327,7 +327,10 @@ namespace ucb { namespace ucp { namespace ext case E_ROOT: { const ::rtl::OUString& rId( m_pImpl->m_aResults[ i_nIndex ].sId ); - const ::rtl::OUString sTitle = Content::decodeIdentifier( rId.copy( rId.indexOf( '/' ) + 1 ) ); + const ::rtl::OUString sRootURL( ContentProvider::getRootURL() ); + ::rtl::OUString sTitle = Content::decodeIdentifier( rId.copy( sRootURL.getLength() ) ); + if ( ( sTitle.getLength() > 0 ) && ( sTitle[ sTitle.getLength() - 1 ] == '/' ) ) + sTitle = sTitle.copy( 0, sTitle.getLength() - 1 ); xRow = Content::getArtificialNodePropertyValues( m_pImpl->m_xSMgr, getResultSet()->getProperties(), sTitle ); } break; diff --git a/ucb/source/ucp/ext/ucpext_provider.cxx b/ucb/source/ucp/ext/ucpext_provider.cxx index b626999b66b5..0fbad1d8cf17 100644 --- a/ucb/source/ucp/ext/ucpext_provider.cxx +++ b/ucb/source/ucp/ext/ucpext_provider.cxx @@ -113,7 +113,7 @@ namespace ucb { namespace ucp { namespace ext //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString ContentProvider::getRootURL() { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.extension:/" ) ); + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.extension://" ) ); } //------------------------------------------------------------------------------------------------------------------ @@ -122,20 +122,69 @@ namespace ucb { namespace ucp { namespace ext return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.extension-content" ) ); } + //------------------------------------------------------------------------------------------------------------------ + namespace + { + void lcl_ensureAndTransfer( ::rtl::OUString& io_rIdentifierFragment, ::rtl::OUStringBuffer& o_rNormalization, const sal_Unicode i_nLeadingChar ) + { + if ( ( io_rIdentifierFragment.getLength() == 0 ) || ( io_rIdentifierFragment[0] != i_nLeadingChar ) ) + throw IllegalIdentifierException(); + io_rIdentifierFragment = io_rIdentifierFragment.copy( 1 ); + o_rNormalization.append( i_nLeadingChar ); + } + } + //------------------------------------------------------------------------------------------------------------------ Reference< XContent > SAL_CALL ContentProvider::queryContent( const Reference< XContentIdentifier >& i_rIdentifier ) throw( IllegalIdentifierException, RuntimeException ) { // Check URL scheme... - const ::rtl::OUString aScheme( rtl::OUString::createFromAscii( "vnd.sun.star.extension" ) ); - if ( !i_rIdentifier->getContentProviderScheme().equalsIgnoreAsciiCase( aScheme ) ) + const ::rtl::OUString sScheme( rtl::OUString::createFromAscii( "vnd.sun.star.extension" ) ); + if ( !i_rIdentifier->getContentProviderScheme().equalsIgnoreAsciiCase( sScheme ) ) throw IllegalIdentifierException(); - // normalize the scheme + // normalize the identifier const ::rtl::OUString sIdentifier( i_rIdentifier->getContentIdentifier() ); + + // the scheme needs to be lower-case ::rtl::OUStringBuffer aComposer; - aComposer.append( sIdentifier.copy( 0, aScheme.getLength() ).toAsciiLowerCase() ); - aComposer.append( sIdentifier.copy( aScheme.getLength() ) ); + aComposer.append( sIdentifier.copy( 0, sScheme.getLength() ).toAsciiLowerCase() ); + + // one : is required after the scheme + ::rtl::OUString sRemaining( sIdentifier.copy( sScheme.getLength() ) ); + lcl_ensureAndTransfer( sRemaining, aComposer, ':' ); + + // and at least one / + lcl_ensureAndTransfer( sRemaining, aComposer, '/' ); + + // the normalized form requires one additional /, but we also accept identifiers which don't have it + if ( sRemaining.getLength() == 0 ) + { + // the root content is a special case, it requires /// + aComposer.appendAscii( "//" ); + } + else + { + if ( sRemaining[0] != '/' ) + { + aComposer.append( sal_Unicode( '/' ) ); + aComposer.append( sRemaining ); + } + else + { + lcl_ensureAndTransfer( sRemaining, aComposer, '/' ); + // by now, we moved "vnd.sun.star.extension://" from the URL to aComposer + if ( sRemaining.getLength() == 0 ) + { + // again, it's the root content, but one / is missing + aComposer.append( sal_Unicode( '/' ) ); + } + else + { + aComposer.append( sRemaining ); + } + } + } const Reference< XContentIdentifier > xNormalizedIdentifier( new ::ucbhelper::ContentIdentifier( m_xSMgr, aComposer.makeStringAndClear() ) ); ::osl::MutexGuard aGuard( m_aMutex ); -- cgit From bf9edb43e0ae0caba3a706cf55e53a84071df139 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 25 Mar 2010 14:11:02 +0100 Subject: slidecopy: module ucb now depends on module tools (need tools/diagnose_ex.h) --- ucb/prj/build.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ucb') diff --git a/ucb/prj/build.lst b/ucb/prj/build.lst index f97493acb0e8..1af0a84dc8cd 100644 --- a/ucb/prj/build.lst +++ b/ucb/prj/build.lst @@ -1,4 +1,4 @@ -uc ucb : cppuhelper CURL:curl OPENSSL:openssl NEON:neon LIBXML2:libxml2 offapi sal salhelper ucbhelper udkapi comphelper NULL +uc ucb : cppuhelper CURL:curl OPENSSL:openssl NEON:neon LIBXML2:libxml2 offapi sal salhelper ucbhelper udkapi comphelper tools NULL uc ucb usr1 - all uc_mkout NULL uc ucb\inc nmake - all uc_inc NULL uc ucb\source\regexp nmake - all uc_regexp uc_inc NULL -- cgit From eb910a227e2d48d53ce0624e1455ea1ed99d412d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 25 Mar 2010 14:53:42 +0100 Subject: slidecopy: fixed shadow variable --- ucb/source/ucp/ext/ucpext_datasupplier.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ucb') diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx b/ucb/source/ucp/ext/ucpext_datasupplier.cxx index dfdd1df82fd6..a3a9cc6876ff 100644 --- a/ucb/source/ucp/ext/ucpext_datasupplier.cxx +++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx @@ -264,7 +264,7 @@ namespace ucb { namespace ucp { namespace ext try { Reference< XContent > xContent( m_pImpl->m_xContent->getProvider()->queryContent( xId ) ); - ::rtl::Reference< Content > pContent( dynamic_cast< Content* >( xContent.get() ) ); + pContent.set( dynamic_cast< Content* >( xContent.get() ) ); OSL_ENSURE( pContent.is() || !xContent.is(), "DataSupplier::queryContent: invalid content implementation!" ); m_pImpl->m_aResults[ i_nIndex ].pContent = pContent; return pContent.get(); -- cgit From 33358686ef1c499b1da6bf480b0b5f2fea9d8f82 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 7 Apr 2010 22:36:26 +0200 Subject: slidecopy: fixed encoding/decoding of extension identifiers as part of an URL (thanks SB) --- ucb/source/ucp/ext/ucpext_content.cxx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 88afe370908b..70fcc8d1312f 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -60,7 +60,7 @@ #include #include #include -#include +#include #include @@ -311,18 +311,14 @@ namespace ucb { namespace ucp { namespace ext //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString Content::encodeIdentifier( const ::rtl::OUString& i_rIdentifier ) { - ::rtl::OUString sEncoded; - rtl_uriEncode( i_rIdentifier.pData, rtl_getUriCharClass( rtl_UriCharClassUricNoSlash ), - rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8, &sEncoded.pData ); - return sEncoded; + return ::rtl::Uri::encode( i_rIdentifier, rtl_UriCharClassRegName, rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ); } //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString Content::decodeIdentifier( const ::rtl::OUString& i_rIdentifier ) { - ::rtl::OUString sDecoded; - rtl_uriDecode( i_rIdentifier.pData, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8, &sDecoded.pData ); - return sDecoded; + return ::rtl::Uri::decode( i_rIdentifier, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); } //------------------------------------------------------------------------------------------------------------------ -- cgit From 5ac4e06ca3302ea505949d6bd5df1e2b0ad50a61 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 28 Apr 2010 09:41:55 +0200 Subject: slidecopy: make compile on unxsol[i|s]4.pro and unxmacxi[.pro] --- ucb/source/ucp/ext/ucpext_content.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 70fcc8d1312f..7b7ada742840 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -381,7 +381,6 @@ namespace ucb { namespace ucp { namespace ext aComposer.append( sRelativeURL ); return aComposer.makeStringAndClear(); } - break; default: OSL_ENSURE( false, "Content::getParentURL: unhandled case!" ); @@ -511,9 +510,10 @@ namespace ucb { namespace ucp { namespace ext } return xValueRow.get(); } - break; + default: OSL_ENSURE( false, "Content::getPropertyValues: unhandled case!" ); + break; } OSL_ENSURE( false, "Content::getPropertyValues: unreachable!" ); -- cgit From e4307a4d3fc43914c8d28157c0e71633843fa045 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Thu, 6 May 2010 14:23:16 +0200 Subject: #i110213# - setup master password container on demand. --- ucb/source/ucp/webdav/DAVAuthListener.hxx | 3 --- ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx | 1 - ucb/source/ucp/webdav/DAVResourceAccess.cxx | 4 ++-- ucb/source/ucp/webdav/NeonSession.cxx | 21 --------------------- 4 files changed, 2 insertions(+), 27 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/webdav/DAVAuthListener.hxx b/ucb/source/ucp/webdav/DAVAuthListener.hxx index c092f9fd311f..71bed1c0a14d 100644 --- a/ucb/source/ucp/webdav/DAVAuthListener.hxx +++ b/ucb/source/ucp/webdav/DAVAuthListener.hxx @@ -30,9 +30,7 @@ #include #include -#ifndef _COM_SUN_STAR_UCB_XREFERENCE_HPP_ #include -#endif #include namespace webdav_ucp @@ -46,7 +44,6 @@ class DAVAuthListener : public salhelper::SimpleReferenceObject const ::rtl::OUString & inHostName, ::rtl::OUString & inoutUserName, ::rtl::OUString & outPassWord, - sal_Bool bAllowPersistentStoring, sal_Bool bCanUseSystemCredentials ) = 0; }; diff --git a/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx b/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx index 3d03cc63952b..c0c9968613af 100644 --- a/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx +++ b/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx @@ -61,7 +61,6 @@ namespace webdav_ucp const ::rtl::OUString & inHostName, ::rtl::OUString & inoutUserName, ::rtl::OUString & outPassWord, - sal_Bool bAllowPersistentStoring, sal_Bool bCanUseSystemCredentials ); private: diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx index 4ffc8dd88cf5..872d45405735 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx @@ -57,7 +57,6 @@ int DAVAuthListener_Impl::authenticate( const ::rtl::OUString & inHostName, ::rtl::OUString & inoutUserName, ::rtl::OUString & outPassWord, - sal_Bool bAllowPersistentStoring, sal_Bool bCanUseSystemCredentials ) { if ( m_xEnv.is() ) @@ -79,7 +78,8 @@ int DAVAuthListener_Impl::authenticate( = new ucbhelper::SimpleAuthenticationRequest( m_aURL, inHostName, inRealm, inoutUserName, outPassWord, ::rtl::OUString(), - bAllowPersistentStoring, bCanUseSystemCredentials ); + true /*bAllowPersistentStoring*/, + bCanUseSystemCredentials ); xIH->handle( xRequest.get() ); rtl::Reference< ucbhelper::InteractionContinuation > xSelection diff --git a/ucb/source/ucp/webdav/NeonSession.cxx b/ucb/source/ucp/webdav/NeonSession.cxx index 8fc1730ba018..254fae546940 100644 --- a/ucb/source/ucp/webdav/NeonSession.cxx +++ b/ucb/source/ucp/webdav/NeonSession.cxx @@ -60,7 +60,6 @@ #include #include #include -#include #include #include @@ -330,31 +329,11 @@ extern "C" int NeonSession_NeonAuth( void * inUserData, ( ne_strcasecmp( inAuthProtocol, "Negotiate" ) == 0 ) ); #endif - // #i97003# (tkr): Ask XMasterPasswordHandling if we should store the - // credentials persistently and give this information to the auth listener - uno::Reference< task::XMasterPasswordHandling > xMasterPasswordHandling; - try - { - xMasterPasswordHandling = - uno::Reference< task::XMasterPasswordHandling >( - theSession->getMSF()->createInstance( - rtl::OUString::createFromAscii( - "com.sun.star.task.PasswordContainer" ) ), - uno::UNO_QUERY ); - } - catch ( uno::Exception const & ) - { - } - int theRetVal = pListener->authenticate( rtl::OUString::createFromAscii( inRealm ), theSession->getHostName(), theUserName, thePassWord, - xMasterPasswordHandling.is() - ? xMasterPasswordHandling-> - isPersistentStoringAllowed() - : sal_False, bCanUseSystemCreds); rtl::OString aUser( -- cgit